[root@test home]# ps -ef | egrep "rpc|nfs" root 487 2 0 Mar21 ? 00:00:00 [rpciod] rpc 65293 1 0 Mar21 ? 00:00:00 /sbin/rpcbind -w rpcuser 76183 1 0 Mar21 ? 00:00:00 /usr/sbin/rpc.statd --no-notify root 152992 567813 0 18:43 pts/0 00:00:00 grep -E --color=auto rpc|nfs root 757265 1 0 17:08 ? 00:00:00 /usr/sbin/rpc.idmapd root 757267 1 0 17:08 ? 00:00:00 /usr/sbin/rpc.mountd root 757272 2 0 17:08 ? 00:00:00 [nfsd4_callbacks] root 757278 2 0 17:08 ? 00:00:00 [nfsd] root 757279 2 0 17:08 ? 00:00:00 [nfsd] root 757280 2 0 17:08 ? 00:00:00 [nfsd] root 757281 2 0 17:08 ? 00:00:00 [nfsd] root 757282 2 0 17:08 ? 00:00:00 [nfsd] root 757283 2 0 17:08 ? 00:00:00 [nfsd] root 757284 2 0 17:08 ? 00:00:00 [nfsd] root 757285 2 0 17:08 ? 00:00:00 [nfsd]
參數命令
|
參數做用
|
rw
|
可讀寫
|
ro
|
只讀權限
|
sync
|
請求或寫入數據時,數據會同步寫入到服務端硬盤,再返回
|
no_root_squas
|
對於客戶端用戶 root 不壓縮。即客戶端 root 能夠以 root 身份來訪問文件
|
root_squash
|
對客戶端用戶 root 壓縮,將 root 身份壓縮爲 nobody
|
all_squash
|
對客戶端所用用戶壓縮,默認將用戶身份壓縮爲用戶 nobody 和用戶組 nobody。
可指定壓縮用戶的身份,可是須要客戶端和服務端都有該用戶,不然沒法訪問
|
anonuid
|
匿名的 uid,說明客戶端以什麼用戶來訪問服務端文件系統
|
anongid
|
匿名的 gid,說明客戶端以什麼用戶組來訪問服務端文件系統
|
[root@test home]# rpm -qa | egrep "rpc|nfs" libnfsidmap-0.25-15.el7.x86_64 rpcbind-0.2.0-38.el7.x86_64 libtirpc-0.2.4-0.8.el7.x86_64 nfs-utils-1.3.0-0.33.el7.x86_64 xmlrpc-c-1.32.5-1905.svn2451.el7.x86_64 xmlrpc-c-client-1.32.5-1905.svn2451.el7.x86_64
[root@test home]# systemctl start rpcbind [root@test home]# systemctl start nfs [root@test test]# 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 55860 status 100024 1 tcp 49019 status 100005 1 udp 20048 mountd 100005 1 tcp 20048 mountd 100005 2 udp 20048 mountd 100005 2 tcp 20048 mountd 100005 3 udp 20048 mountd 100005 3 tcp 20048 mountd 100003 3 tcp 2049 nfs 100003 4 tcp 2049 nfs 100227 3 tcp 2049 nfs_acl 100003 3 udp 2049 nfs 100003 4 udp 2049 nfs 100227 3 udp 2049 nfs_acl 100021 1 udp 36125 nlockmgr 100021 3 udp 36125 nlockmgr 100021 4 udp 36125 nlockmgr 100021 1 tcp 42363 nlockmgr 100021 3 tcp 42363 nlockmgr 100021 4 tcp 42363 nlockmgr
[root@test test]# cat /etc/passwd | grep 4300 [root@test test]# cat /etc/group | grep 4300 [root@test test]# groupadd -g 4300 lianhuasheng [root@test test]# useradd -u 4300 -g 4300 lianhuasheng [root@test test]# cat /etc/passwd | grep lianhuasheng lianhuasheng:x:4300:4300::/home/lianhuasheng:/bin/bash [root@test home]# cat /etc/exports | grep 4300 /home/test 10.57.0.0/24(rw,sync,all_squash,anonuid=4300,anongid=4300) [root@test home]# systemctl restart nfs
[root@test test]# cat /etc/passwd | grep 4300 [root@test test]# cat /etc/group | grep 4300 [root@test test]# groupadd -g 4300 lianhuasheng [root@test test]# useradd -u 4300 -g 4300 lianhuasheng [root@test test]# cat /etc/passwd | grep lianhuasheng lianhuasheng:x:4300:4300::/home/lianhuasheng:/bin/bash
[root@test test]# systemctl stop iptables
[root@test lianhuasheng]# showmount -e 10.57.0.1 Export list for 10.57.0.1: /home/test 10.57.0.0/24 [root@test test]# mount -t nfs 10.57.0.1:/home/test /home/test/lianhuasheng/ [root@test home]# df -hT | grep lianhuasheng 10.57.0.1:/home/test nfs4 895G 849G 46G 95% /home/test/lianhuasheng
[root@test lianhuasheng]# touch nfs.log [root@test lianhuasheng]# ll total 0 -rw-r--r--. 1 lianhuasheng lianhuasheng 0 Mar 22 17:10 nfs.log
[root@test test]# ll -h total 0 -rw-r--r--. 1 lianhuasheng lianhuasheng 0 Mar 22 17:10 nfs.log
[root@test lianhuasheng]# lsof /home/test/lianhuasheng/ COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME lsof 407987 root cwd DIR 0,549 21 1325440613 /home/test/lianhuasheng (10.57.0.1:/home/test) lsof 407988 root cwd DIR 0,549 21 1325440613 /home/test/lianhuasheng (10.57.0.1:/home/test) bash 682732 root cwd DIR 0,549 21 1325440613 /home/test/lianhuasheng (10.57.0.1:/home/test)