NFS網絡檔案系統,它允許網絡中的計算機之間通過TCP/IP共享資源,本地NFS用戶端可以NFS伺服器上的檔案,就像通路本地檔案一樣
安裝nfs
yum -y install rpcbind nfs-utils
#nfs-utils:nfs服務的主程式
#rpcbind:遠端過程調用,能使用戶端執行其他系統中程式
配置nfs服務:
/etc/exports #主配置檔案,預設為空
配置檔案文法:共享目錄 允許通路ip或網段(權限)
例:
/var/www/html 192.168.0.0/24(rw,sync,no_root_squash)
#共享目錄 允許網段 rw:讀寫 sync:同步讀寫 no_root_squash:允許root使用者通路時保留root權限
chmod 666 /var/www/html #nfs權限是配置檔案和檔案系統權限的交集
啟動服務:
service rpcbind start #必須rpc啟動之後才能啟動nfs服務
service nfs start
netstat -pta | grep rpcbind #檢視服務是否啟動
netstat -pta | grep nfs
用戶端通路:
yum -y install nfs-utils
showmount -e 伺服器位址 #檢視伺服器共享的目錄
mount -t nfs 伺服器位址/共享的目錄 挂載點
nfs配置執行個體:
伺服器配置:
vim /etc/exports #修改配置檔案
/var/www/html 192.168.0.0/24(rw,sync)
chmod 666 /var/www/html/*
service rpcbind restart
service nfs restart
netstat -napt | grep nfs
用戶端配置:
mkdir /nfs
showmount -e 192.168.0.10
mount -t nfs 192.168.0.10:/var/www/html /nfs
本文轉自 紅塵世間 51CTO部落格,原文連結:http://blog.51cto.com/hongchen99/1914996