yum -y install rpcbind.x86_64 nfs-utils.x86_64
yum -y install nfs-utils
服务器:
vim /etc/exports
/home/nfsdir 172.16.22.0/24(rw,sync,all_squash,anonuid=1000,anongid=1000)
NFS配置选项
[root@JAMF ~]# systemctl start rpcbind
[root@JAMF ~]# systemctl start nfs
[root@JAMF ~]# systemctl enable rpcbind
[root@JAMF ~]# systemctl enable nfs
服务器关闭selinux,防火墙信任客户端源IP
getenforce
Disabled
[root@JAMF ~]# firewall-cmd --permanent --zone=trusted --add-source=172.16.22.233
success
[root@JAMF ~]# firewall-cmd --reload
success
客户端挂载:
[root@zabbix ~]# showmount -e 172.16.22.247
Export list for 172.16.22.247:
/home/nfsdir 172.16.22.0/24
[root@zabbix ~]# mount | grep nfs
nfsd on /proc/fs/nfsd type nfsd (rw,relatime)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)
172.16.22.247:/home/nfsdir on /mnt type nfs4 (rw,relatime,vers=4.1,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=172.16.22.233,local_lock=none,addr=172.16.22.247)
[root@zabbix ~]# df -h | grep nfs
172.16.22.247:/home/nfsdir 76G 24G 53G 31% /mnt
客户端:
[root@JAMF nfsdir]# ll
[root@zabbix ~]# echo -e "testnfs\nmysql\n" > /mnt/testnf.txt
-rw-r--r-- 1 www www 15 Mar 16 01:28 testnf.txt
[root@zabbix ~]# ll /mnt/
total 8
-rw-r--r-- 1 www www 15 Mar 16 2018 testnf.txt
[root@zabbix ~]# id www
uid=1000(www) gid=1000(www) groups=1000(www) //虽然在客户端使用的是root账号创建的文件,但实际上是
[root@zabbix ~]#
服务器:
[root@JAMF mnt]# cd /home/nfsdir/
[root@JAMF nfsdir]# ll
total 4
-rw-r--r-- 1 www www 15 Mar 16 18:00 testnfs.txt
drwxr-xr-x 2 www www 6 Mar 16 01:40 tmp
[root@JAMF nfsdir]# id www
uid=1000(www) gid=1000(www) groups=1000(www)
原文地址:http://blog.51cto.com/m51cto/2087736