题目:
1.开放/nfs/share目录,提供给任意用户只读查询
2.开放/nfs/upload目录,提供给172.16.1.0/24网段内的机器上传数据,并且要求限制上传数据映射为nfs-upload用户,uid和gid均为200
3.开放/home/chaoge目录仅共享给172.16.1.41这台机器,且只有chaoge01用户可以完全访问该目录
4.添加10G硬盘,给nfs服务端/nfs-nginx-data目录使用,且仅提供给主机名为web-7的机器使用,并且要求限制上传数据映射为www用户,uid、gid均为11211;并且提供HTML、png资源给nginx用;确保nginx可正确访问该静态数据。
主机列表:
# 外网地址 内网地址 主机名
192.168.122.7 172.16.1.7 web-7
192.168.122.31 172.16.1.31 nfs-31
192.168.122.41 172.16.1.41 rsync-41
192.168.122.110 172.16.1.110 client-110
nfs-31
机器上安装和启动nfs-utils
和rpC++bind
nfs-utils
和rpcbind
[root@nfs-31 ~]# yum install -y nfs-utils rpcbind
已加载插件:fastestmirror
Determining fastest mirrors
base | 3.6 kB 00:00:00
epel | 5.4 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
软件包 1:nfs-utils-1.3.0-0.68.el7.2.aarch64 已安装并且是最新版本
软件包 rpcbind-0.2.0-49.el7.aarch64 已安装并且是最新版本
无须任何处理
rpcbind
服务[root@nfs-31 ~]# systemctl start rpcbind
[root@nfs-31 ~]# netstat -tunlp |grep rpc
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2806/rpcbind
tcp6 0 0 :::111 :::* LISTEN 2806/rpcbind
udp 0 0 0.0.0.0:111 0.0.0.0:* 2806/rpcbind
udp 0 0 0.0.0.0:861 0.0.0.0:* 2806/rpcbind
udp6 0 0 :::111 :::* 2806/rpcbind
udp6 0 0 :::861 :::* 2806/rpcbind
/etc/exports
[root@nfs-31 share]# vim /etc/exports
[root@nfs-31 share]# cat /etc/exports
/nfs/share *(ro)
/nfs/share
,并在此目录中创建一个文件用于测试。[root@nfs-31 ~]# mkdir -p /nfs/share
[root@nfs-31 ~]# ll -d /nfs/share/
drwxr-xr-x 2 root root 6 11月 26 09:40 /nfs/share/
[root@nfs-31 ~]# cd /nfs/share/
[root@nfs-31 share]# echo '这是一个测试文件,你只能读' > testro.txt
[root@nfs-31 share]# ll
总用量 4
-rw-r--r-- 1 root root 40 11月 26 09:42 testro.txt
[root@nfs-31 share]# systemctl start nfs
[root@nfs-31 share]# systemctl status nfs
● nfs-server.service - NFS server and services
Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; enabled; vendor preset: disabled)
Drop-In: /run/systemd/generator/nfs-server.service.d
└─order-with-mounts.conf
Active: active (exited) since 二 2024-11-26 10:09:36 CST; 3s aGo
Process: 2681 ExecStopPost=/usr/sbin/exportfs -f (code=exited, status=0/SUCCESS)
Process: 2678 ExecStopPost=/usr/sbin/exportfs -au (code=exited, status=0/SUCCESS)
Process: 2677 ExecStop=/usr/sbin/rpc.nfsd 0 (code=exited, status=0/SUCCESS)
Process: 7932 ExecStartPost=/bin/sh -c if systemctl -q is-active gssproxy; then systemctl reload gssproxy ; fi (code=exited, status=0/SUCCESS)
Process: 7919 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS (code=exited, status=0/SUCCESS)
Process: 7917 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
Main PID: 7919 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/nfs-server.service
#将服务设置为开机自启
[root@nfs-31 ~]# systemctl enable nfs
[root@nfs-31 ~]# systemctl is-enabled nfs
enabled
[root@nfs-31 ~]# systemctl is-enabled rpcbind
enabled
client-110
进行挂载测试nfs-utils
[root@client-110 ~]# yum install -y nfs-utils
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
...
...
完毕!
[root@client-110 ~]# showmount -e 172.16.1.31
Export list for 172.16.1.31:
/nfs/share *
# 外网地址 内网地址 主机名
192.168.122.7 172.16.1.7 web-7
192.168.122.31 172.16.1.31 nfs-31
192.168.122.41 172.16.1.41 rsync-41
192.168.122.110 172.16.1.110 client-110
0
# 外网地址 内网地址 主机名
192.168.122.7 172.16.1.7 web-7
192.168.122.31 172.16.1.31 nfs-31
192.168.122.41 172.16.1.41 rsync-41
192.168.122.110 172.16.1.110 client-110
1
测试达到题目要求。
/nfs/upload
目录,提供给172.16.1.0/24
网段内的机器上传数据,并且要求限制上传数据映射为nfs-upload
用户,uid
和gid
均为200
nfs-31
机器上配置和重载nfs
nfs-upload
用户,uid
和gid
均为200
# 外网地址 内网地址 主机名
192.168.122.7 172.16.1.7 web-7
192.168.122.31 172.16.1.31 nfs-31
192.168.122.41 172.16.1.41 rsync-41
192.168.122.110 172.16.1.110 client-110
2
/etc/exports
开放/nfs/upload目录,提供给172.16.1.0/24网段内的机器上传数据,并且要求限制上传数据映射为nfs-upload用户
# 外网地址 内网地址 主机名
192.168.122.7 172.16.1.7 web-7
192.168.122.31 172.16.1.31 nfs-31
192.168.122.41 172.16.1.41 rsync-41
192.168.122.110 172.16.1.110 client-110
3
/nfs/upload
,修改其属性。# 外网地址 内网地址 主机名
192.168.122.7 172.16.1.7 web-7
192.168.122.31 172.16.1.31 nfs-31
192.168.122.41 172.16.1.41 rsync-41
192.168.122.110 172.16.1.110 client-110
4
# 外网地址 内网地址 主机名
192.168.122.7 172.16.1.7 web-7
192.168.122.31 172.16.1.31 nfs-31
192.168.122.41 172.16.1.41 rsync-41
192.168.122.110 172.16.1.110 client-110
5
client-110
进行挂载和测试[root@client-110 ~]# showmount -e 172.16.1.31
# 外网地址 内网地址 主机名
192.168.122.7 172.16.1.7 web-7
192.168.122.31 172.16.1.31 nfs-31
192.168.122.41 172.16.1.41 rsync-41
192.168.122.110 172.16.1.110 client-110
6
# 外网地址 内网地址 主机名
192.168.122.7 172.16.1.7 web-7
192.168.122.31 172.16.1.31 nfs-31
192.168.122.41 172.16.1.41 rsync-41
192.168.122.110 172.16.1.110 client-110
7
# 外网地址 内网地址 主机名
192.168.122.7 172.16.1.7 web-7
192.168.122.31 172.16.1.31 nfs-31
192.168.122.41 172.16.1.41 rsync-41
192.168.122.110 172.16.1.110 client-110
8
nfs-31
上进入开放目录查看上传的文件# 外网地址 内网地址 主机名
192.168.122.7 172.16.1.7 web-7
192.168.122.31 172.16.1.31 nfs-31
192.168.122.41 172.16.1.41 rsync-41
192.168.122.110 172.16.1.110 client-110
9
测试达到题目要求。
/home/chaoge
目录仅共享给172.16.1.41
这台机器,且只有chaoge01
用户可以完全访问该目录nfs-31
机器上配置和重载nfs
chaoge01
用户,指定用户主目录为/home/chaoge
[root@nfs-31 ~]# yum install -y nfs-utils rpcbind
已加载插件:fastestmirror
Determining fastest mirrors
base | 3.6 kB 00:00:00
epel | 5.4 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
软件包 1:nfs-utils-1.3.0-0.68.el7.2.aarch64 已安装并且是最新版本
软件包 rpcbind-0.2.0-49.el7.aarch64 已安装并且是最新版本
无须任何处理
0
可以看到,chaoge01
的uid
和gid
都为1001
,且只有chaoge01
用户可以完全访问该目录
/etc/exports
[root@nfs-31 ~]# yum install -y nfs-utils rpcbind
已加载插件:fastestmirror
Determining fastest mirrors
base | 3.6 kB 00:00:00
epel | 5.4 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
软件包 1:nfs-utils-1.3.0-0.68.el7.2.aarch64 已安装并且是最新版本
软件包 rpcbind-0.2.0-49.el7.aarch64 已安装并且是最新版本
无须任何处理
1
[root@nfs-31 ~]# yum install -y nfs-utils rpcbind
已加载插件:fastestmirror
Determining fastest mirrors
base | 3.6 kB 00:00:00
epel | 5.4 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
软件包 1:nfs-utils-1.3.0-0.68.el7.2.aarch64 已安装并且是最新版本
软件包 rpcbind-0.2.0-49.el7.aarch64 已安装并且是最新版本
无须任何处理
2
rsync-41
机器上进行挂载和测试nfs-utils
,并查看nfs-31
上的开放情况[root@nfs-31 ~]# yum install -y nfs-utils rpcbind
已加载插件:fastestmirror
Determining fastest mirrors
base | 3.6 kB 00:00:00
epel | 5.4 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
软件包 1:nfs-utils-1.3.0-0.68.el7.2.aarch64 已安装并且是最新版本
软件包 rpcbind-0.2.0-49.el7.aarch64 已安装并且是最新版本
无须任何处理
3
[root@nfs-31 ~]# yum install -y nfs-utils rpcbind
已加载插件:fastestmirror
Determining fastest mirrors
base | 3.6 kB 00:00:00
epel | 5.4 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
软件包 1:nfs-utils-1.3.0-0.68.el7.2.aarch64 已安装并且是最新版本
软件包 rpcbind-0.2.0-49.el7.aarch64 已安装并且是最新版本
无须任何处理
4
/mnt/nfs/chaoge01
,进行挂载测试[root@nfs-31 ~]# yum install -y nfs-utils rpcbind
已加载插件:fastestmirror
Determining fastest mirrors
base | 3.6 kB 00:00:00
epel | 5.4 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
软件包 1:nfs-utils-1.3.0-0.68.el7.2.aarch64 已安装并且是最新版本
软件包 rpcbind-0.2.0-49.el7.aarch64 已安装并且是最新版本
无须任何处理
5
测试达到题目要求。
10G
硬盘,给nfs
服务端/nfs-nginx-data
目录使用,且仅提供给主机名为web-7
的机器使用,并且要求限制上传数据映射为www
用户,uid
、gid
均为11211
;并且提供HTML、png资源给nginx用;确保nginx可正确访问该静态数据。nfs-31
添加硬盘并按要求进行配置/dev/sdb
,并进行挂载查看磁盘/dev/sdb
[root@nfs-31 ~]# yum install -y nfs-utils rpcbind
已加载插件:fastestmirror
Determining fastest mirrors
base | 3.6 kB 00:00:00
epel | 5.4 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
软件包 1:nfs-utils-1.3.0-0.68.el7.2.aarch64 已安装并且是最新版本
软件包 rpcbind-0.2.0-49.el7.aarch64 已安装并且是最新版本
无须任何处理
6
对磁盘进行分区格式化
[root@nfs-31 ~]# yum install -y nfs-utils rpcbind
已加载插件:fastestmirror
Determining fastest mirrors
base | 3.6 kB 00:00:00
epel | 5.4 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
软件包 1:nfs-utils-1.3.0-0.68.el7.2.aarch64 已安装并且是最新版本
软件包 rpcbind-0.2.0-49.el7.aarch64 已安装并且是最新版本
无须任何处理
7
[root@nfs-31 ~]# yum install -y nfs-utils rpcbind
已加载插件:fastestmirror
Determining fastest mirrors
base | 3.6 kB 00:00:00
epel | 5.4 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
软件包 1:nfs-utils-1.3.0-0.68.el7.2.aarch64 已安装并且是最新版本
软件包 rpcbind-0.2.0-49.el7.aarch64 已安装并且是最新版本
无须任何处理
8
新建挂载点/nfs-nginx-data
,并挂载
[root@nfs-31 ~]# yum install -y nfs-utils rpcbind
已加载插件:fastestmirror
Determining fastest mirrors
base | 3.6 kB 00:00:00
epel | 5.4 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
软件包 1:nfs-utils-1.3.0-0.68.el7.2.aarch64 已安装并且是最新版本
软件包 rpcbind-0.2.0-49.el7.aarch64 已安装并且是最新版本
无须任何处理
9
www
用户,uid
、gid
均为11211
[root@nfs-31 ~]# systemctl start rpcbind
[root@nfs-31 ~]# netstat -tunlp |grep rpc
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2806/rpcbind
tcp6 0 0 :::111 :::* LISTEN 2806/rpcbind
udp 0 0 0.0.0.0:111 0.0.0.0:* 2806/rpcbind
udp 0 0 0.0.0.0:861 0.0.0.0:* 2806/rpcbind
udp6 0 0 :::111 :::* 2806/rpcbind
udp6 0 0 :::861 :::* 2806/rpcbind
0
/etc/exports
,并重载nfs[root@nfs-31 ~]# systemctl start rpcbind
[root@nfs-31 ~]# netstat -tunlp |grep rpc
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2806/rpcbind
tcp6 0 0 :::111 :::* LISTEN 2806/rpcbind
udp 0 0 0.0.0.0:111 0.0.0.0:* 2806/rpcbind
udp 0 0 0.0.0.0:861 0.0.0.0:* 2806/rpcbind
udp6 0 0 :::111 :::* 2806/rpcbind
udp6 0 0 :::861 :::* 2806/rpcbind
1
/nfs-nginx-data
目录,准备好index文件等资源。[root@nfs-31 ~]# systemctl start rpcbind
[root@nfs-31 ~]# netstat -tunlp |grep rpc
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2806/rpcbind
tcp6 0 0 :::111 :::* LISTEN 2806/rpcbind
udp 0 0 0.0.0.0:111 0.0.0.0:* 2806/rpcbind
udp 0 0 0.0.0.0:861 0.0.0.0:* 2806/rpcbind
udp6 0 0 :::111 :::* 2806/rpcbind
udp6 0 0 :::861 :::* 2806/rpcbind
2
/nfs-nginx-data
目录属性[root@nfs-31 ~]# systemctl start rpcbind
[root@nfs-31 ~]# netstat -tunlp |grep rpc
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2806/rpcbind
tcp6 0 0 :::111 :::* LISTEN 2806/rpcbind
udp 0 0 0.0.0.0:111 0.0.0.0:* 2806/rpcbind
udp 0 0 0.0.0.0:861 0.0.0.0:* 2806/rpcbind
udp6 0 0 :::111 :::* 2806/rpcbind
udp6 0 0 :::861 :::* 2806/rpcbind
3
web-7
机器上部署nginx
,并挂载nfs
上的数据。www
用户[root@nfs-31 ~]# systemctl start rpcbind
[root@nfs-31 ~]# netstat -tunlp |grep rpc
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2806/rpcbind
tcp6 0 0 :::111 :::* LISTEN 2806/rpcbind
udp 0 0 0.0.0.0:111 0.0.0.0:* 2806/rpcbind
udp 0 0 0.0.0.0:861 0.0.0.0:* 2806/rpcbind
udp6 0 0 :::111 :::* 2806/rpcbind
udp6 0 0 :::861 :::* 2806/rpcbind
4
[root@nfs-31 ~]# systemctl start rpcbind
[root@nfs-31 ~]# netstat -tunlp |grep rpc
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2806/rpcbind
tcp6 0 0 :::111 :::* LISTEN 2806/rpcbind
udp 0 0 0.0.0.0:111 0.0.0.0:* 2806/rpcbind
udp 0 0 0.0.0.0:861 0.0.0.0:* 2806/rpcbind
udp6 0 0 :::111 :::* 2806/rpcbind
udp6 0 0 :::861 :::* 2806/rpcbind
5
[root@nfs-31 ~]# systemctl start rpcbind
[root@nfs-31 ~]# netstat -tunlp |grep rpc
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2806/rpcbind
tcp6 0 0 :::111 :::* LISTEN 2806/rpcbind
udp 0 0 0.0.0.0:111 0.0.0.0:* 2806/rpcbind
udp 0 0 0.0.0.0:861 0.0.0.0:* 2806/rpcbind
udp6 0 0 :::111 :::* 2806/rpcbind
udp6 0 0 :::861 :::* 2806/rpcbind
6
[root@nfs-31 ~]# systemctl start rpcbind
[root@nfs-31 ~]# netstat -tunlp |grep rpc
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2806/rpcbind
tcp6 0 0 :::111 :::* LISTEN 2806/rpcbind
udp 0 0 0.0.0.0:111 0.0.0.0:* 2806/rpcbind
udp 0 0 0.0.0.0:861 0.0.0.0:* 2806/rpcbind
udp6 0 0 :::111 :::* 2806/rpcbind
udp6 0 0 :::861 :::* 2806/rpcbind
7
测试网页能打开
nfs-utils
,挂载nfs[root@nfs-31 ~]# systemctl start rpcbind
[root@nfs-31 ~]# netstat -tunlp |grep rpc
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2806/rpcbind
tcp6 0 0 :::111 :::* LISTEN 2806/rpcbind
udp 0 0 0.0.0.0:111 0.0.0.0:* 2806/rpcbind
udp 0 0 0.0.0.0:861 0.0.0.0:* 2806/rpcbind
udp6 0 0 :::111 :::* 2806/rpcbind
udp6 0 0 :::861 :::* 2806/rpcbind
8
查看nfs-31
上开放情况
[root@nfs-31 ~]# systemctl start rpcbind
[root@nfs-31 ~]# netstat -tunlp |grep rpc
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2806/rpcbind
tcp6 0 0 :::111 :::* LISTEN 2806/rpcbind
udp 0 0 0.0.0.0:111 0.0.0.0:* 2806/rpcbind
udp 0 0 0.0.0.0:861 0.0.0.0:* 2806/rpcbind
udp6 0 0 :::111 :::* 2806/rpcbind
udp6 0 0 :::861 :::* 2806/rpcbind
9
挂载
[root@nfs-31 share]# vim /etc/exports
[root@nfs-31 share]# cat /etc/exports
/nfs/share *(ro)
0
修改网页再次刷新
[root@nfs-31 share]# vim /etc/exports
[root@nfs-31 share]# cat /etc/exports
/nfs/share *(ro)
1
至此已完成题目。