一、配置NFS 伺服器 1. 下載安裝NFS 如果系統是Centos 5:
yum -y install nfs-utils portmap
如果系統是Cenos 6:
yum -y install nfs-utils rpcbind
192.168.0.103 nfs伺服器 192.168.0.107 用戶端
2.配置NFS 設定檔etc/exports
/root/nfs 192.168.0.107(rw,sync,no_root_squash,no_subtree_check)
mount 的地址可以是一個IP,一個網段,一個網域名稱,網域名稱萬用字元, ep: *.youxia.com. mount地址和許可權之間沒有空格。
以後主要講解參數含義:
rw : read-write 讀寫權限 ro : read-only 唯讀許可權 sync: 檔案寫入記憶體和硬碟 async: 檔案暫存於記憶體,但是不寫入記憶體。 no_root_squash: 如果用戶端以root身份登入,則對共用的伺服器目錄頁有root的使用許可權(不安全)。 root_squash:如果用戶端以root身份登入,則對共用的伺服器目錄以匿名使用者的許可權操作,一般為nobody或者nfsnobody.
3.啟動NFS
如果系統為Centos 5:
service portmap start service nfs start
如果系統為Centos6
service rpcbind start service nfs start
4.用戶端mount nfs 伺服器
mount -t nfs 192.168.0.103:/root/nfs /root/test
/root/nfs 為NFS伺服器共用的目錄,/root/test為用戶端mount點(掛載點)。
pleae see teset below:
在用戶端的root/test下做操作,觀察nfs 伺服器指定目錄情況:
192.168.0.103
[root@localhost nfs]# ls[root@localhost nfs]#
192.168.0.107
[root@kevin test]# ls[root@kevin test]#
在用戶端建立檔案
[root@kevin test]# echo "hello world" >> test.log[root@kevin test]# lstest.log[root@kevin test]#
服務端:
[root@localhost nfs]# lstest.log[root@localhost nfs]# cat test.log hello world[root@localhost nfs]#
在用戶端,另一種方法查詢掛載:
[root@kevin test]# df -hFilesystem Size Used Avail Use% Mounted on/dev/sda2 18G 885M 16G 6% /tmpfs 491M 0 491M 0% /dev/shm192.168.0.103:/root/nfs 7.7G 3.0G 4.4G 41% /root/test