[[email protected] ~]# yum install -y nfs-utils rpcbind #安装NFS服务器
[[email protected] ~]# rpm -qa nfs-utils rpcbind #检查安装情况
rpcbind-0.2.0-13.el6_9.1.x86_64
nfs-utils-1.2.3-75.el6.x86_6
[[email protected] ~]# setenforce 0 #关闭selinux
[[email protected] ~]# /etc/init.d/iptables stop #关闭防护墙
[[email protected] ~]# /etc/init.d/rpcbind start #首先开启RPC 服务
[[email protected] ~]# /etc/init.d/nfs start #其次开启NFS 服务
Starting NFS services: [ OK ]
Starting NFS mountd: [ OK ]
Starting NFS daemon: [ OK ]
Starting RPC idmapd: [ OK ]
[[email protected] ~]# vi /etc/exports #配置NFS服务器挂载参数
/data 10.41.1.0/24(rw,sync)
[[email protected] ~]# showmount -e 10.41.1.80
Export list for 10.41.1.80:
[[email protected] ~]# /etc/init.d/nfs reload #重启NFS服务
[[email protected] ~]# showmount -e 10.41.1.80 #查看测试挂载
Export list for 10.41.1.80:
/data 10.41.1.0/24
[[email protected] ~]# cat /var/lib/nfs/etab #查看挂载权限
/data 10.41.1.0/24(rw,sync,wdelay,hide,nocrossmnt,secure,root_squash,no_all_squash,no_subtree_check,secure_locks,acl,anonuid=65534,anongid=65534,sec=sys,rw,root_squash,no_all_squash)
[[email protected] ~]# rpcinfo -p localhost
[[email protected] ~]# mount -t nfs 10.41.1.80:/data /mnt # 本地关注测试
[[email protected] ~]# df -h #查看挂载情况
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 189G 741M 179G 1% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
/dev/sda1 190M 35M 145M 20% /boot
10.41.1.80:/data 189G 741M 179G 1% /mnt
[[email protected] data2]# mount -t nfs 10.41.1.80:/data /mnt #客户端挂载
[[email protected] data2]# df -h
df: `/data1‘: Stale file handle
df: `/data2‘: Stale file handle
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 189G 741M 179G 1% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
/dev/sda1 190M 35M 145M 20% /boot
10.41.1.80:/data 189G 741M 179G 1% /mnt
[[email protected] ~]# chown -R nfsnobody.nfsnobody /data/ #权限设置,nfsnobody 配合本地目录权限管理。