NFS 網絡文件系統(Network File System) 是由Sun公司1984年發佈的分佈式文件系統協議。它允許客戶端上的用戶像訪問本地文件一樣地訪問網絡上的文件。
用途
NFS在日常工作中有很多用途:
- nfs-client可以做日誌查看終端,開發和運維不用逐個登陸服務器查看日誌;
- 通過nfs-client可以讓前端開發自己上傳發布文件,類似FTP一樣;
安裝
客戶端和服務端都只需要安裝nfs-util包。yum安裝即可。
強烈建議在所有節點機上使用如ntp之類的時間同步守護進程以保持客戶端/服務器之間的時間同步,如果各個節點上沒有精確同步的時鐘,NFS可能產生非預期的延遲。建議採用網絡時間協議守護進程並使用互聯網上的高精度 NTP 服務器同步服務端和客戶端的時鐘。
注意:
nfs-utils for Arch Linux ARM starting with update 1.3.2-4 (possibly earlier) has been reported by one user to behave differently from the x86_64 or i686 package. See the discussion page for a recipe for client mounts.
配置
Linux_Server和Linux_Client
用途:看日誌
Linux_Server配置:
- 權限:只讀
- 配置:
[root@pszqtizZ ~]# cat /etc/exports /usr/local/apache-tomcat-qq-nfs/ nfs-client.baidu.com(ro,sync,fsid=0,all_squash) server端共享目錄 允許客戶端地址 其他配置
Linux_Client配置:
- mount掛載即可:
[root@hyk7fj3Z ~]# cat /etc/fstab | grep nfs nfs-qq.baidu.com:/usr/local/apache-tomcat-qq-nfs /data/apache-tomcat-qq-nfs nfs defaults 0 0
Linux_Server和Windows_Client
用途:傳文件
Linux_Server配置:
- 權限:讀寫
- 配置:
[root@pszqtj5Z ~]# cat /etc/exports /usr/share/nginx/wap/ nfs-client2.baidu.com(rw,no_root_squash)
Windows_Client配置:
- mount掛載即可:
cmd > mount web-qq.baidu.com:/usr/local/apache-tomcat-web/webapps/ d:
- windows如果要配置開機啓動自動掛載則可在“資源管理器”中添加 “ 映射網絡驅動器 ” 。
啓動nfs服務
systemctl start rpcbind
systemctl status rpcbind
systemctl start nfs
systemctl status nfs
/etc/exports配置加載
- 如果服務運行時修改了 /etc/exports 文件, 你需要重新加載使其生效。
exportfs -ra