因爲開發系統過程當中,先後臺因爲部署在不一樣的機器上,一些文件須要放在同一個地方(好比圖片文件),考慮到目前系統不是很大,因此決定將公共文件集中放在一臺內網機器磁盤上,前臺、後臺服務器經過硬盤映射的方式來訪問文件資源bash
假設公共文件服務器內網IP:192.168.1.1,文件存放目錄爲:/data/images,前臺服務器IP:192.168.1.2服務器
yum install -y nfs-utils portmap
/data/images 192.168.1.*(rw,sync,no_root_squash)
表示開放本機器上面/data/images目錄, 對主機網段192.168.1.* 擁有該目錄rw權限。其餘參數能夠去查看nsf文檔,這裏不解釋
啓動portmap和nfs(需按順序啓動)app
systemctl start rpcbind systemctl start nfs
若是防火牆打開了,須要開發以下服務的端口,(在/etc/services文件中查看服務對應的端口)tcp
sunrpc 111 tcp/udp #portmapper rpcbind nfs 2049 tcp/udp/sctp mountd 2048 tcp/udp
firewall-cmd --add-service=nfs --permanent
firewall-cmd --add-service=mountd --permanentcode
配置過程當中遇到的問題及解決圖片
Transaction check error: file /usr/lib/systemd/system/blk-availability.service from install of device-mapper-7:1.02.107-5.el7_2.1.x86_64 conflicts with file from package lvm2-7:2.02.105-14.el7.x86_64 file /usr/sbin/blkdeactivate from install of device-mapper-7:1.02.107-5.el7_2.1.x86_64 conflicts with file from package lvm2-7:2.02.105-14.el7.x86_64 file /usr/share/man/man8/blkdeactivate.8.gz from install of device-mapper-7:1.02.107-5.el7_2.1.x86_64 conflicts with file from package lvm2-7:2.02.105-14.el7.x86_64
解決方案:先升級lvm2
先執行:yum upgrade lvm2
後執行:yum install nfs-utils資源
mount掛載時若是超時,有多是防火牆的問題,須要關閉防火牆或開放上述服務端口開發