[root@nfs01~]# rpm -qa nfs-utils rpcbind
[root@nfs01~]# yum install nfs-utils rpcbind -y
[root@nfs01 ~]# uname -n
nfs01
[root@nfs01 ~]# /etc/init.d/rpcbind start
[root@nfs01 ~]# /etc/init.d/nfs start
[root@nfs01 ~]# rpcinfo -p localhost
program vers proto port service
100000 4 tcp 111 portmapper
100000 3 tcp 111 portmapper
100000 2 tcp 111 portmapper
100000 4 udp 111 portmapper
100000 3 udp 111 portmapper
100000 2 udp 111 portmapper
100024 1 udp 49110 status
100024 1 tcp 60601 status
100011 1 udp 875 rquotad
100011 2 udp 875 rquotad
100011 1 tcp 875 rquotad
100011 2 tcp 875 rquotad
100005 1 udp 37441 mountd
100005 1 tcp 49490 mountd
100005 2 udp 45029 mountd
100005 2 tcp 33501 mountd
100005 3 udp 35728 mountd
100005 3 tcp 41397 mountd
100003 2 tcp 2049 nfs
100003 3 tcp 2049 nfs
100003 4 tcp 2049 nfs
100227 2 tcp 2049 nfs_acl
100227 3 tcp 2049 nfs_acl
100003 2 udp 2049 nfs
100003 3 udp 2049 nfs
100003 4 udp 2049 nfs
100227 2 udp 2049 nfs_acl
100227 3 udp 2049 nfs_acl
100021 1 udp 35951 nlockmgr
100021 3 udp 35951 nlockmgr
100021 4 udp 35951 nlockmgr
100021 1 tcp 56162 nlockmgr
100021 3 tcp 56162 nlockmgr
100021 4 tcp 56162 nlockmgr[U1]
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODENAME
rpcbind1326 rpc 6u IPv4 10550 0t0 UDP *:sunrpc
rpcbind1326 rpc 8u IPv4 10553 0t0 TCP *:sunrpc (LISTEN)
rpcbind1326 rpc 9u IPv6 10555 0t0 UDP *:sunrpc
rpcbind1326 rpc 11u IPv6 10558 0t0 TCP *:sunrpc (LISTEN)
[root@nfs01~]#netstat -ltunp|grep 111
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1326/rpcbind
tcp 0 0 :::111 :::* LISTEN 1326/rpcbind
udp 0 0 0.0.0.0:111 0.0.0.0:* 1326/rpcbind
udp 0 0 :::111 :::* 1326/rpcbind[U2]
[root@nfs01 scripts]# ps -ef|egrep"rpc|nfs"
rpc 1326 1 0 May01 ? 00:00:00 rpcbind
rpcuser 1348 1 0 May01 ? 00:00:00 rpc.statd [U3]
root 1397 2 0 May01 ? 00:00:00 [rpciod/0]
root 1407 1 0 May01 ? 00:00:00 rpc.rquotad[U4]
root 1412 1 0 May01 ? 00:00:00 rpc.mountd[U5]
root 1419 2 0 May01 ? 00:00:00 [nfsd4]
root 1420 2 0 May01 ? 00:00:00 [nfsd4_callbacks]
root 1421 2 0 May01 ? 00:00:00 [nfsd]
root 1422 2 0 May01 ? 00:00:00 [nfsd]
root 1423 2 0 May01 ? 00:00:00 [nfsd]
root 1424 2 0 May01 ? 00:00:00 [nfsd]
root 1425 2 0 May01 ? 00:00:00 [nfsd]
root 1426 2 0 May01 ? 00:00:00 [nfsd][U6]
[root@nfs01 ~]# vim /etc/exports
#data gongxiang by xiaofang at 20160425
/data 172.16.1.0/24(rw,sync,all_squash[U7]
[root@nfs01 ~]# mkdir /data/ -p
[root@nfs01 ~]# chown -R nfsnobody.nfsnobody/data/[U8]
[root@nfs01 ~]# ll -d /data/
drwxr-xr-x 2 nfsnobody nfsnobody 4096 Apr 30 18:19/data/
[root@nfs01 ~]# chkconfig nfs on
[root@nfs01~]# chkconfig rpcbind on
[root@nfs01 ~]# chkconfig--list|egrep "nfs\b|rpcbind"|grep on
nfs 0:off 1:off 2:on 3:on 4:on 5:on 6:off
rpcbind 0:off 1:off 2:on 3:on 4:on 5:on 6:off[U9] [U10]
[root@web01 ~]# yum install nfs-utils rpcbind -y
[root@web01 ~]# rpm -qa nfs-utils rpcbind
[root@web01 ~]# /etc/init.d/rpcbind start
[root@web01 ~]# /bin/mount -t nfs172.16.1.31:/data /mnt[U11]
[root@web01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 9.1G 1.5G 7.2G 18% /
tmpfs 112M 0 112M 0% /dev/shm
/dev/sda1 190M 36M 145M 20% /boot
172.16.1.31:/data 9.1G 1.5G 7.2G 17% /mnt
注释:如果服务端指定了用户客户端一定要有和服务端一样的用户和UID
[root@web01 ~]# chkconfig rpcbind on
[root@web01 ~]# echo "/bin/mount -t nfs172.16.1.31:/data /mnt" >>/etc/rc.local
[root@web01 ~]#echo "/etc/init.d/rpcbind start" >>/etc/rc.local
[root@nfs01 data]# ls
[root@nfs01 data]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 9.1G 1.5G 7.2G 17% /
tmpfs 112M 0 112M 0% /dev/shm
/dev/sda1 190M 36M 145M 20% /boot
172.16.1.31:/data 9.1G 1.5G 7.2G 17% /mnt
[root@nfs01 data]# touch 123
[root@nfs01 data]# cd /mnt
[root@nfs01 mnt]# ls
123
服务端:
在/data 下创建文件123
[root@nfs01 data]# touch 123
客户端:
[root@backup ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 9.1G 1.5G 7.2G 18% /
tmpfs 112M 0 112M 0% /dev/shm
/dev/sda1 190M 36M 145M 20% /boot
172.16.1.31:/data 9.1G 1.5G 7.2G 17% /mnt
[root@backup ~]# cd /mnt
[root@backup mnt]# ls
123
注释:客户端一定要挂上才可以看到
检查自己的rpcbind服务是不是比nfs服务后启动
第一步:重启一下rpcbind服务和nfs服务
[root@nfs01 ~]# /etc/init.d/rpcbind start&& /etc/init.d/rpcbind rtstart
[root@nfs01 ~]# /etc/init.d/nfs start &&/etc/init.d/nfs rtstart
第二步:showmount 看下服务端是否有共享目录
[root@nfs01 ~]# showmount -e 172.16.1.31
Export list for 172.16.1.31:
/data 172.16.1.0/24
第三步:telnet 看是否连的上服务端
[root@nfs01 ~]# telnet 172.16.1.31 22
Trying 172.16.1.31...
Connected to 172.16.1.31.
Escape character is ‘^]‘.
SSH-2.0-OpenSSH_5.3
第四步:ping 服务端IP
[root@nfs01 ~]# ping 172.16.1.31 -c2
PING 172.16.1.31 (172.16.1.31) 56(84) bytes ofdata.
64 bytes from 172.16.1.31: icmp_seq=1 ttl=64time=0.063 ms
64 bytes from 172.16.1.31: icmp_seq=2 ttl=64time=0.062 ms
--- 172.16.1.31 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss,time 1012ms
rtt min/avg/max/mdev = 0.062/0.062/0.063/0.007 ms
第五步:检查防火墙是否关闭
[root@nfs01 ~]# /etc/init.d/iptables stop&& /etc/init.d/iptables status
第六步:配置文件/etc/exports是否语法错误
[root@nfs01 ~]# cat /etc/exports
#data gongxiang by xiaofang at 20160425
/data 172.16.1.0/24(rw,sync,all_squash)
第七步:检查是否在设置开机自启动
①[root@nfs01 ~]# cat /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all theother init scripts.
# You can put your own initialization stuff in hereif you don‘t
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
/etc/init.d/rpcbind start
/etc/init.d/nfs start
②[root@nfs01 ~]# chkconfig --list|egrep"rpcbind|nfs\b"
nfs 0:off 1:off 2:on 3:on 4:on 5:on 6:off
nfs-rdma 0:off 1:off 2:off 3:off 4:off 5:off 6:off
rpcbind 0:off 1:off 2:on 3:on 4:on 5:on 6:off
第一步:重启一下rpcbind服务
[root@nfs01 ~]# /etc/init.d/rpcbind start&& /etc/init.d/rpcbind rtstart
第二步:showmount 看下服务端是否有共享目录
[root@nfs01 ~]# showmount -e 172.16.1.31
Export list for 172.16.1.31:
/data 172.16.1.0/24
第三步:telnet 看是否连的上服务端
[root@nfs01~]# telnet 172.16.1.31 22
Trying172.16.1.31...
Connectedto 172.16.1.31.
Escapecharacter is ‘^]‘.
SSH-2.0-OpenSSH_5.3
第四步:ping 服务端IP
[root@nfs01~]# ping 172.16.1.31 -c2
PING172.16.1.31 (172.16.1.31) 56(84) bytes of data.
64 bytesfrom 172.16.1.31: icmp_seq=1 ttl=64 time=0.063 ms
64 bytesfrom 172.16.1.31: icmp_seq=2 ttl=64 time=0.062 ms
---172.16.1.31 ping statistics ---
2 packetstransmitted, 2 received, 0% packet loss, time 1012ms
rttmin/avg/max/mdev = 0.062/0.062/0.063/0.007 ms
第五步:检查防火墙是否关闭
[root@nfs01~]# /etc/init.d/iptables stop && /etc/init.d/iptables status
第六步:检查是否挂载上
[root@backup ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 9.1G 1.5G 7.2G 18% /
tmpfs 112M 0 112M 0% /dev/shm
/dev/sda1 190M 36M 145M 20% /boot
172.16.1.31:/data 9.1G 1.5G 7.2G 17% /mnt
第七步:是否开机自动挂载
①[root@backup~]# cat /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all theother init scripts.
# You can put your own initialization stuff in hereif you don‘t
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
>/etc/udev/rules.d/70-persistent-net.rules
/usr/bin/rsync --daemon
/etc/init.d/rpcbind start
/bin/mount -t nfs 172.16.1.31:/data /mnt
②[root@nfs01~]# chkconfig --list|grep netfs
netfs 0:off 1:off 2:off 3:on 4:off 5:off 6:off
[root@nfs01 ~]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Tue Apr 19 08:55:23 2016
#
# Accessible filesystems, by reference, aremaintained under ‘/dev/disk‘
# See man pages fstab(5), findfs(8), mount(8)and/or blkid(8) for more info
#
UUID=fbdd389c-3946-47e9-8505-e7a9f259a92a / ext4 defaults 1 1
UUID=10b243cd-45d9-4433-8609-bfff4b5536ff/boot ext4 defaults 1 2
UUID=44204c38-06fb-4743-90eb-60fdb9d13cc0 swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
172.16.1.31:/data /mnt 172.16.1.31:data defaults 0 0
注释:
[U1]nfs启动后会发现NFS服务向rcp服务注入的端口信息,NFS服务启动后我们会发现多了很多端口和功能的对应
[U2]111端口是nfs服务对外提供服务的主端口
[U3]#<==检查文件一致性
[U4]#<==磁盘配额进程(remote quta server)
[U5]#<==权限管理验证等(NFS mount daemon)
[U6]NFS主进程,管理登入,ID身份判别等
[U7]设置nfs共享目录及目录的权限属性。
注意该目录一定要存在。sync是写入磁盘。all_spuash是把访问该目录的用户压缩成匿名用户,即下面的nfsnobody用户。
[U8]修改该目录的属主和属组
nfsnobody用户是在安装nfs后自动生成的(Cos6有)。
[U9]客户端安好后把NFS服务和rpcbind服务设置成开机自启动
[U10]可以放在/etc/rc.local里
[root@nfs01 backup]# cat /etc/rc.local
#!/bin/sh
#
# This script will be executed *after*all the other init scripts.
# You can put your own initializationstuff in here if you don‘t
# want to do the full Sys V style initstuff.
touch /var/lock/subsys/local
/etc/init.d/rpcbindstart
/etc/init.d/nfsstart
[U11]挂载点一定要存在
本文出自 “11261116” 博客,谢绝转载!
原文:http://11271116.blog.51cto.com/11261116/1894892