1、关闭防火墙(4步)
root@cq ~]# systemctl stop firewalld
[root@cq ~]# systemctl disable firewalld
[root@cq ~]# vim /etc/selinux/config
[root@cq ~]# setenforce 0
2、安装nfs服务(nfs-utils rpcbind)
[root@cq ~]# yum -y install nfs-utils
[root@cq ~]# yum -y install rpcbind
已加载插件:product-id, search-disabled-repos, subscription-manager
This system is
3、启动nfs服务 和 rpcbind
[root@cq ~]# systemctl start nfs-server
[root@cq ~]# systemctl start rpcbind
4、编辑配置文件的共享目录
5、重启nfs服务
[root@cq ~]# systemctl restart nfs-server rpcbind
6、创建共享目录
[root@cq ~]# mkdir /chenqian
客户端:
1、关闭防火墙(4步
[root@chenqian ~]# systemctl stop firewalld
[root@chenqian ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@chenqian ~]# systemctl disable firewalld
[root@chenqian ~]# vim /etc/selinux/
config final/ semanage.conf targeted/ tmp/
[root@chenqian ~]# vim /etc/selinux/
config final/ semanage.conf targeted/ tmp/
[root@chenqian ~]# vim /etc/selinux/
config final/ semanage.conf targeted/ tmp/
[root@chenqian ~]# vim /etc/selinux/config
2、搭建nfs服务
[root@chenqian ~]# yum -y install nfs-utils rpcbind
已加载插件:product-id, search-disabled-repos, subscription-manager
3、启动nfs服务
[root@chenqian ~]# systemctl start nfs-server rpcbind
4、验证nfs服务端的共享目录
[root@chenqian ~]# showmount -e 172.16.195.128
Export list for 172.16.195.128:
/chenqian 172.16.195.129
5、创建挂载的目录站点
[root@chenqian ~]# mkdir /nfs
6、挂载
[root@chenqian ~]# mount -t nfs 172.16.195.128:/chenqian /nfs
7、然后在服务端为共享目录设置匿名用户和组
[root@cq ~]# chown -R nfsnobody.nfsnobody /chenqian
8、在客户端验证挂载目录站点是否可以创建文件和删除文件
[root@chenqian nfs]# touch 4 5
touch: 无法创建"4": 只读文件系统
touch: 无法创建"5": 只读文件系统
[root@chenqian nfs]# touch 4 5
[root@chenqian nfs]# ls
1 2 3 4 5

作业
1.手动搭建一个nfs服务器

开放/nfs/shared目录,供所有用户查阅资料
开放/nfs/upload目录为172.16.12.0/24网段的数据上传目录,并将所有用户及所属的用户组都映射为nfs-upload,其UID与GID均为300

[root@cq ~]# mkdir -p /nfs/{shared,upload}
[root@cq nfs]# ls
shared upload
[root@cq nfs]# vim /etc/exports
/chenqian 172.16.195.129(rw)
/nfs/shared *(ro)
/nfs/upload 172.16.195.0/24(rw,anonuid=300,anongid=300)

[root@cq nfs]# exportfs -r
chown -R 300.300 /nfs/upload/

[root@chenqian ~]# vim /etc/fstab
172.16.195.128:/nfs /cq nfs defaults,_netdev 0 0
[root@chenqian ~]# mount -a
[root@chenqian upload]# touch 2 3
[root@chenqian upload]# ll
总用量 0
-rw-r--r--. 1 300 300 0 7月 2 18:19 2
-rw-r--r--. 1 300 300 0 7月 2 18:19 3