nfs 是一種網絡文件系統,需要依賴rpc進行過程調度
注意nfs只驗證id,驗證用戶名,並且只能在類unix os上進行文件共享服務,由於它的脆弱的驗證機制,所以不適宜在internet上工作,在內網使用是非常可行的。
nfs服務端需要確定這兩個包正確安裝 nfs-utils rpcbind
若是ubuntu服務器,則是nfs-common,nfs-kernel-server兩個包,rpcbind是默認安裝的。
yum -y install nfs-utils rpcbind
編輯共享目錄配置文件 /etc/exports
/var/www/html 192.168.10.0/24(rw,async,no_root_squash) 192.168.20.0/24(ro) #多個網段或主機之間用空格分開 /var/www 192.168.10.0/24(ro,sync,root_squash)
參數:ro表示只讀,rw表示可讀寫,sync同步寫*即同時寫入內存和硬盤,async異步*暫存於內存,no_root_squash表示如果客戶端連接過來的用戶是root,則對服務端的目錄同樣是root權限****請不要開啟,好危險的,root_squash表示客戶端是root則將其轉為匿名用戶的權限***建議開啟。
http://cloud.yesky.com/info/332/1460300332.shtml
http://www.pcpop.com/article/6054830.shtml
啟動nfs服務,並設為開機自啟動
service rpcbind start #或則 systemctl start rpcbind service nfs start #或則 systemctl start nfs ######ubuntu服務器則是 service startnfs-kernel-server start chkconfig rpcbind on #或則 systemctl enable rpcbind chkconfig nfs on #或則 systemctl enable nfs
配置防火牆,放行響應端口或服務
firewall-cmd --permanent --add-service=nfs firewall-cmd --permanent --add-service=rpc-bind firewall-cmd --permanent --add-service=mountd firewall-cmd --reload firewall-cmd --list-all #查看firewalld方向的資源
客戶端掛載
showmount -e nfs_server_ip: 查看nfs服務端的可用掛載點
客戶端掛載操作
mount -t nfs nfs_server:/var/www/html /bendikongmulu 或者 mount -t nfs nfs_server:/var/www/html /bendikongmulu -o proto=tcp
無報錯便成功,當然客戶端可以使用 df -h 來查看是否掛載過來了;這里客戶端切換到本地掛載點便可以看見服務端的文件了(注意若,服務端共享的目錄為空,客戶端是無法查看的)