標籤:nfs rpc 網路檔案系統 rpcbind配置
一、簡介
NFS(network file system)網路檔案系統。通過網路讓不同的主機系統之間可以實現檔案或目錄共用。分為用戶端和伺服器,NFS網路檔案系統很像windows系統的網際網路共用、安全功能、網路磁碟機和Samba服務類似。
二、安裝及其配置
伺服器端配置如下:
1)安裝nfs-utils和rpcbind兩包
yum -y install nfs-utils rpcbind
2)啟動服務
service nfs start或/etc/init.d/nfs start /etc/init.d/rpcbind start
3)檢查服務是否開啟
netstat -tnl|grep 111 netstat -tnl|grep 2049
[[email protected] ~]# netstat -tnl|grep 111tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTENtcp 0 0 :::111 :::* LISTEN[[email protected] ~]# netstat -tnl|grep 2049tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTENtcp 0 0 :::2049 :::* LISTEN[[email protected] ~]# lsof -i :111COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMErpcbind 1708 rpc 6u IPv4 13514 0t0 UDP *:sunrpcrpcbind 1708 rpc 8u IPv4 13517 0t0 TCP *:sunrpc (LISTEN)rpcbind 1708 rpc 9u IPv6 13519 0t0 UDP *:sunrpcrpcbind 1708 rpc 11u IPv6 13522 0t0 TCP *:sunrpc (LISTEN)[[email protected] ~]#
4)建立共用目錄並寫入設定檔
vi /etc/exports
/data 10.1.0.0/16(rw,sync,no_root_squash)
5)測試是否成功
showmount -e localhost
客服端配置如下:
1)安裝nfs-utils和rpcbind兩包
yum -y install nfs-utils rpcbind
2)啟動服務,只開啟rpcbind即可
/etc/init.d/rpcbind start
3)檢查服務是否開啟
netstat -tnl|grep 111
4)測試是否生效
showmount -e 10.1.2.2
5)建立掛載點及掛載
mkdir /mnt/data
mount 10.1.2.2:/data /mnt/data
三、綜合測試
分別在伺服器端及其客服端的/data目錄進行建立目錄或檔案查看是否同步生效即可。
四、命令總結及設定檔說明
showmount命令:
-e: 在nfs用戶端執行,探查某主機所匯出的nfs檔案系統;使用格式“showmount -e Server_IP”;
-d: 在nfs伺服器端執行,顯示哪個匯出的檔案系統已經被至少一個客戶掛載使用了;
-a: 在nfs伺服器端顯示所有的掛載會話;
exportfs命令:
-a: 操作所有檔案系統
-ra: 重新匯出所有檔案系統
-ua: 取消匯入的所有檔案系統
-v: 顯示詳細資料
設定檔/etc/exports參數說明:
設定檔格式:
檔案系統 用戶端1(檔案系統匯出屬性) 用戶端2(檔案系統匯出屬性)
檔案系統
用戶端:IP: 172.16.100.8 Hostname: *.magedu.com Network:
檔案系統匯出屬性:
rw,ro:讀寫、唯讀
sync:同步
async:非同步
roo_squash:壓縮用root使用者為匿名使用者,即為nfsnobody使用者
no_root_squash:不壓縮使用者
all_squash:壓縮所有使用者
anonuid, anongid: 指定匿名使用者映射為的UID和GID;
本文出自 “小耳朵” 部落格,請務必保留此出處http://purify.blog.51cto.com/10572011/1852842
名字就叫"nfs"-(network file system)