操作系統(tǒng)版本: [root@localhost /]# cat /etc/redhat-release 1、檢查portmap服務(wù)運行狀態(tài)(因為NFS及其輔助程序都是基于RPC的,所以我們要確保系統(tǒng)中首先運行portmap服務(wù)) [root@localhost /]# id uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel) context=root:system_r:unconfined_t [root@localhost /]# service portmap status portmap is stopped 結(jié)果顯示portmap服務(wù)是停止的,可以通過以下命令啟動該服務(wù): [root@localhost /]# service portmap start Starting portmap: [ OK ] [root@localhost /]# service portmap status portmap (pid 11085) is running... 結(jié)果顯示portmap服務(wù)已處于“running”狀態(tài)。 2、檢查nfs服務(wù)運行狀態(tài) [root@localhost /]# service nfs status Shutting down NFS mountd: rpc.mountd is stopped nfsd is stopped rpc.rquotad is stopped 結(jié)果顯示nfs服務(wù)是停止的,可以通過以下命令啟動該服務(wù): [root@localhost /]# service nfs start Starting NFS services: [ OK ] Starting NFS quotas: [ OK ] Starting NFS daemon: [ OK ] Starting NFS mountd: [ OK ] 此時來檢查一下nfs服務(wù)運行狀態(tài),由下可知,nfs服務(wù)已啟用。 [root@localhost /]# service nfs status Shutting down NFS mountd: rpc.mountd (pid 11155) is running... nfsd (pid 11151 11148 11147 11146 11145 11144 11143 11142) is running... rpc.rquotad (pid 11138) is running... 3、設(shè)置nfs服務(wù)在系統(tǒng)重啟后自動運行 [root@localhost /]# chkconfig --list nfs nfs 0:off 1:off 2:off 3:off 4:off 5:off 6:off [root@localhost /]# chkconfig nfs on [root@localhost /]# chkconfig --list nfs nfs 0:off 1:off 2:on 3:on 4:on 5:on 6:off 4、/etc/exports文件設(shè)置 /etc/exports文件格式: 共享的目錄 主機名稱1或IP1(參數(shù)1,參數(shù)2) 共享的目錄 主機名稱2或IP2(參數(shù)3,參數(shù)4) 如果使用主機名稱,則必須預(yù)先在/etc/hosts文件中定義。 exports主要參數(shù): rw:可讀寫權(quán)限 ro:只讀權(quán)限 no_root_squash: 對于登陸NFS主機的共享目錄用戶如果是root的話則對該目錄具有root權(quán)限。 這樣做極不安全,建議不用為好! root_squash: 對于登陸NFS主機的共享目錄用戶使用者如果是root則它的權(quán)限將被壓縮成匿名使用者, 同時它的UID和GID都會變成nobody那個系統(tǒng)賬號的身份。 all_squash: 不管登陸NFS主機用戶身份如何,它的身份都會被壓縮成匿名使用者,通常就是nobody anonuid:anonuid=xxx, 制定NFS服務(wù)器/etc/passwd中匿名用戶的UID anongid:anonuid=xxx, 制定NFS服務(wù)器/etc/passwd中匿名用戶的GID sync: 數(shù)據(jù)在請求時寫入共享 async: NFS在寫入數(shù)據(jù)前可響應(yīng)請求 secure: NFS通過1024以下的安全端口發(fā)送 insecure: NFS通過1024以上端口發(fā)送 hide: 不共享NFS目錄的子目錄 no_hide: 共享NFS目錄的子目錄 例如在/etc/exports文件中添加以下內(nèi)容(紅色部分): [root@localhost /]# cat /etc/exports /study 10.10.10.12(rw,sync,no_root_squash) 5、輸出共享目錄 [root@localhost /]# exportfs -a 查看是否成功輸出共享目錄: [root@localhost /]# cat /etc/exports /study 10.10.10.12(rw,sync,no_root_squash) 九、NFS客戶端相關(guān)的查詢與設(shè)置操作設(shè)置(NFS客戶端IP:10.10.10.12/25) [root@REDHATAS5 /]# cat /etc/redhat-release Red Hat Enterprise Linux Server release 5 (Tikanga) 1、檢查portmap運行狀態(tài)(因為NFS及其輔助程序都是基于RPC的,所以我們要確保系統(tǒng)中首先運行portmap服務(wù)) [root@REDHATAS5 /]# service portmap status portmap (pid 22742) is running... 如果portmap服務(wù)未啟,則在mount時會報錯: [root@REDHATAS5 /]# mount -t nfs 10.10.10.10:/study /nfstest mount.nfs: Input/output error 2、查看NFS服務(wù)端共享目錄 [root@REDHATAS5 /]# showmount -e 10.10.10.10 Export list for 10.10.10.10: /study 10.10.10.12 3、掛載共享目錄 [root@REDHATAS5 /]# mount -t nfs 10.10.10.10:/study /nfstest 4、查看成功掛載的nfs目錄 [root@REDHATAS5 /]# df -h | grep /nfstest 10.10.10.10:/study 7.8G 6.8G 695M 91% /nfstest 5、測試共享目錄是否可讀寫 [root@REDHATAS5 nfstest]# ls -l total 8 -rw-r--r-- 1 root root 21 Jun 24 13:13 nfs-server.txt [root@REDHATAS5 nfstest]# touch nfs-client.txt [root@REDHATAS5 nfstest]# ls -l total 12 -rw-r--r-- 1 root root 0 Jun 24 13:13 nfs-client.txt -rw-r--r-- 1 root root 21 Jun 24 13:13 nfs-server.txt 由上可知,表明可讀寫。 |
|