[root@bogon ~]# yum install -y nfs-utils rpcbind #安装NFS服务器
[root@bogon ~]# rpm -qa nfs-utils rpcbind #检查安装情况
rpcbind-0.2.0-13.el6_9.1.x86_64
nfs-utils-1.2.3-75.el6.x86_6
[root@bogon ~]# setenforce 0 #关闭selinux
[root@bogon ~]# /etc/init.d/iptables stop #关闭防护墙
[root@bogon ~]# /etc/init.d/rpcbind start #首先开启RPC 服务
[root@bogon ~]# /etc/init.d/nfs start #其次开启NFS 服务
Starting NFS services: [ OK ]
Starting NFS mountd: [ OK ]
Starting NFS daemon: [ OK ]
Starting RPC idmapd: [ OK ]
[root@bogon ~]# vi /etc/exports #配置NFS服务器挂载参数
/data 10.41.1.0/24(rw,sync)
[root@bogon ~]# showmount -e 10.41.1.80
Export list for 10.41.1.80:
[root@bogon ~]# /etc/init.d/nfs reload #重启NFS服务
[root@bogon ~]# showmount -e 10.41.1.80 #查看测试挂载
Export list for 10.41.1.80:
/data 10.41.1.0/24
[root@bogon ~]# 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)
[root@bogon ~]# rpcinfo -p localhost
[root@bogon ~]# mount -t nfs 10.41.1.80:/data /mnt # 本地关注测试
[root@bogon ~]# 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
[root@NFS-client01 data2]# mount -t nfs 10.41.1.80:/data /mnt #客户端挂载
[root@NFS-client01 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
[root@bogon ~]# chown -R nfsnobody.nfsnobody /data/ #权限设置,nfsnobody 配合本地目录权限管理。
原文地址:http://11956937.blog.51cto.com/11946937/1965373