[root@zylclient ~]# rpm -aq nfs-utils portmap rpcbind
rpcbind-0.2.0-11.el6.x86_64
nfs-utils-1.2.3-39.el6.x86_64
[root@zylclient ~]# chkconfig --list nfs
nfs 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@zylclient ~]# /etc/init.d/rpcbind start
[root@zylclient ~]# /etc/init.d/rpcbind status
rpcbind (pid 1143) is running...
[root@zylclient ~]# chkconfig rpcbind on
[root@zylclient ~]# chkconfig --list rpcbind
rpcbind 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@zylclient ~]# showmount -e 192.168.21.128
clnt_create: RPC: Port mapper failure - Unable to receive: errno 113 (No route to host) #####出现这种情况。要关系nfs服务器的防火墙。具体操作如下:
[root@zylserver /]# service iptables stop
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
再在nfs服务端的执行:
[root@zylclient ~]# showmount -e 192.168.21.128(服务端的ip)
Export list for 192.168.21.128:
/data 192.168.0.0/24
[root@zylclient ~]# showmount -e 192.168.21.12 ####测试:将ip输错
clnt_create: RPC: Port mapper failure - Unable to receive: errno 113 (No route to host)
###############################
总结测试找出不通的问题:
[root@zylclient ~]# ping 192.168.21.128 ###1种测试网络
PING 192.168.21.128 (192.168.21.128) 56(84) bytes of data.
64 bytes from 192.168.21.128: icmp_seq=1 ttl=64 time=0.474 ms
64 bytes from 192.168.21.128: icmp_seq=2 ttl=64 time=0.450 ms
也可以用:telnet,如果没有安装的话:
[root@zylclient ~]# yum install -y telnet ####安装telnet服务
然后:[root@zylclient ~]# telnet 192.168.21.128 22
Trying 192.168.21.128...
Connected to 192.168.21.128.
###############################
接下来就是挂载
[root@zylclient /]# mount -t nfs 192.168.21.128:/date /mnt ##-t 指定设备的文件系统类型,这里文件类型是nfs
[root@zylclient /]# mount -t nfs 192.168.21.128:/data /mnt
[root@zylclient /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 8.7G 3.4G 5.0G 41% /
tmpfs 495M 84K 495M 1% /dev/shm
/dev/sda1 194M 30M 155M 16% /boot
192.168.21.128:/data 13G 1.6G 11G 14% /mnt ####表示挂载成功
========================================================
接下来就是分别server和client上测试:
[root@zylclient /]# cd /mnt/
[root@zylclient mnt]# ll
total 16
-rw-r--r--. 1 nfsnobody root 111 Jun 20 06:54 html_2016-06-20.tar.gz
-rw-r--r--. 1 nfsnobody root 156 Jun 24 07:41 www_2016-06-24.tar.ga
-rw-r--r--. 1 nfsnobody root 156 Jun 25 02:00 www_2016-06-25.tar.ga
-rw-r--r--. 1 nfsnobody root 111 Jun 24 07:20 www_bak_5.tar.ga
在nfsserver上删除文件html_2016-06-20.tar.gz
[root@zylclient mnt]# ll
total 12
-rw-r--r--. 1 nfsnobody root 156 Jun 24 07:41 www_2016-06-24.tar.ga
-rw-r--r--. 1 nfsnobody root 156 Jun 25 02:00 www_2016-06-25.tar.ga
-rw-r--r--. 1 nfsnobody root 111 Jun 24 07:20 www_bak_5.tar.ga
[root@zylclient mnt]#
[root@zylclient mnt]# touch ddd
[root@zylclient mnt]# ll
total 12
-rw-r--r--. 1 nfsnobody nfsnobody 0 Jun 26 01:00 ddd
-rw-r--r--. 1 nfsnobody root 156 Jun 24 07:41 www_2016-06-24.tar.ga
-rw-r--r--. 1 nfsnobody root 156 Jun 25 02:00 www_2016-06-25.tar.ga
-rw-r--r--. 1 nfsnobody root 111 Jun 24 07:20 www_bak_5.tar.ga
[root@zylclient mnt]#
==========================
[root@client dev]# cd /test/
-bash: cd: /test/: 权限不够
############
[root@service data]# chmod 747 /data/
[root@service data]# ll -d /data
drwxr--rwx. 4 root root 4096 Aug 1 02:00 /data
######################
[root@client dev]# cd /test/
[root@client test]# ls
r_shared www_2016-07-12.tar.ga www_2017-08-01.tar.ga
w_shared www_2017-07-27.tar.ga zhangyiling.exe
www_2016-07-06.tar.ga www_2017-07-30.tar.ga
www_2016-07-07.tar.ga www_2017-07-31.tar.ga
[root@client test]# touch 111
[root@client test]# ls
111 www_2016-07-06.tar.ga www_2017-07-30.tar.ga
1111 www_2016-07-07.tar.ga www_2017-07-31.tar.ga
r_shared www_2016-07-12.tar.ga www_2017-08-01.tar.ga
w_shared www_2017-07-27.tar.ga zhangyiling.exe
[root@client test]# ls -l
总用量 36
-rw-r--r--. 1 nfsnobody nfsnobody 0 8月 3 2017 111
-rw-r--r--. 1 root root 0 8月 3 2017 1111
================================================
[root@service data]# cat /var/lib/nfs/etab
/data 192.168.21.139/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)
===============================================