[root@NFS-server ~]# cat /etc/redhat-release #查看系統版本 CentOS release 6.8 (Final) [root@NFS-server ~]# uname -r #查看系統內核版本 2.6.32-642.11.1.el6.x86_64 [root@NFS-server ~]# uname -m #查看系統是否64位 x86_64
[root@NFS-server ~]# rpm -qa nfs-utils rpcbind #檢查安裝的軟件包 rpcbind-0.2.0-12.el6.x86_64 nfs-utils-1.2.3-70.el6_8.2.x86_64
[root@NFS-server ~]# yum install -y nfs-utils rpcbind #安裝上述所需的兩個軟件包
[root@NFS-server ~]# /etc/init.d/rpcbind status #查詢rpcbind服務狀態並啓動 rpcbind (pid 1281) is running... [root@NFS-server ~]# LANG=en
[root@NFS-server ~]# lsof -i :111 #查詢rpcbind監聽狀態 (111是rpcbind的主端口) COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME rpcbind 1281 rpc 6u IPv4 10766 0t0 UDP *:sunrpc rpcbind 1281 rpc 8u IPv4 10769 0t0 TCP *:sunrpc (LISTEN) rpcbind 1281 rpc 9u IPv6 10771 0t0 UDP *:sunrpc rpcbind 1281 rpc 11u IPv6 10774 0t0 TCP *:sunrpc (LISTEN)
[root@NFS-server ~]# netstat -lntup |grep rpcbind #查詢rpcbind服務啓動狀態 (同lsof查詢端口效果一樣) tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1281/rpcbind tcp 0 0 :::111 :::* LISTEN 1281/rpcbind udp 0 0 0.0.0.0:608 0.0.0.0:* 1281/rpcbind udp 0 0 0.0.0.0:111 0.0.0.0:* 1281/rpcbind udp 0 0 :::608 :::* 1281/rpcbind udp 0 0 :::111 :::* 1281/rpcbind
[root@NFS-server ~]# chkconfig --list rpcbind #檢查rpcbind自啓動情況 rpcbind 0:off 1:off 2:on 3:on 4:on 5:on 6:off
1 | root@NFS-server ~]# rpcinfo -p localhost #查看NFS服務項rpc服務器註冊的端口信 |
[root@NFS-server ~]# /etc/init.d/nfs status #查看NFS服務並啓動 rpc.svcgssd is stopped rpc.mountd (pid 1526) is running... nfsd (pid 1542 1541 1540 1539 1538 1537 1536 1535) is running... rpc.rquotad (pid 1521) is running...
[root@NFS-server ~]# netstat -lntup|grep nfs #查看NFS端口啓動(FNS默認端口爲2049) [root@NFS-server ~]# lsof -i :2049 #查看NFS端口啓動(FNS默認端口爲2049) [root@NFS-server ~]# netstat -lntup|grep 2049 #查看NFS端口啓動(FNS默認端口爲2049) tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN - tcp 0 0 :::2049 :::* LISTEN - udp 0 0 0.0.0.0:2049 0.0.0.0:* - udp 0 0 :::2049 :::* -
[root@NFS-server ~]# rpcinfo -p localhost #啓動NFS過後rpcbind服務已經啓用了對FNS的端口映射
[root@NFS-server ~]# chkconfig --list nfs #查看nfs的開機自啓動情況 nfs 0:off 1:off 2:on 3:on 4:on 5:on 6:off [root@NFS-server ~]# chkconfig nfs on #讓FNS開機自啓動
[root@NFS-server ~]# less /etc/init.d/rpcbind #查看rpcbind服務啓動詳情
[root@NFS-server ~]# less /etc/init.d/nfs
[root@NFS-server ~]# vi /etc/rc.local
[root@NFS-server ~]# ps -ef |egrep "rpc|nfs" #查看nfs相進程 rpcuser 1303 1 0 Nov22 ? 00:00:00 rpc.statd #檢查文件一致性 root 1512 2 0 Nov22 ? 00:00:00 [rpciod/0] rpc 2723 1 0 02:43 ? 00:00:00 rpcbind root 2896 1 0 02:56 ? 00:00:00 rpc.rquotad #磁盤配額進程 root 2901 1 0 02:56 ? 00:00:00 rpc.mountd #權限管理驗證等 root 2908 2 0 02:56 ? 00:00:00 [nfsd4] root 2909 2 0 02:56 ? 00:00:00 [nfsd4_callbacks] root 2910 2 0 02:56 ? 00:00:00 [nfsd] root 2911 2 0 02:56 ? 00:00:00 [nfsd] root 2912 2 0 02:56 ? 00:00:00 [nfsd] root 2913 2 0 02:56 ? 00:00:00 [nfsd] #NFS主進程,管理登入,身份判定 root 2914 2 0 02:56 ? 00:00:00 [nfsd] root 2915 2 0 02:56 ? 00:00:00 [nfsd] root 2916 2 0 02:56 ? 00:00:00 [nfsd] root 2917 2 0 02:56 ? 00:00:00 [nfsd] root 2948 1 0 02:56 ? 00:00:00 rpc.idmapd #名稱映射
<如果對上述進程不明白可以 用man命令查閱幫助信息,如 “man rpc.statd”>
[root@NFS-server ~]# /etc/init.d/nfs reload
[root@NFS-server ~]# exportfs -r
[root@NFS-server ~]# showmount -e 127.0.0.1 #查看本機掛載情況
[root@NFS-server ~]# mount -t nfs 192.168.1.5:/data /mnt #在本機測試掛載
[root@NFS-server ~]# cat /var/lib/nfs/etab #查看一條配置的詳細信息