邯鄲做網(wǎng)站的地方網(wǎng)絡(luò)設(shè)計
nfs-server:10.1.59.237
nfs-web:10..159.218
centos7,服務(wù)端和客戶端都關(guān)閉防火墻和selinux內(nèi)核防火墻,如果公司要求開啟防火墻,那需要放行幾個端口
firewall-cmd --add-port=2049/tcp --permanent
firewall-cmd --add-port=111/tcp --permanent
firewall-cmd --add-port=111/udp --permanent
firewall-cmd --reload
setenforce 0 #臨時關(guān)閉selinux
#永久關(guān)閉selinux
vim /etc/selinux/config
1、nfs-server操作
yum -y install rpcbind #安裝rpc協(xié)議的包
yum -y install nfs-utils @安裝nfs服務(wù),提供文件系統(tǒng)
systemctl start nfs
systemctl start rpcbind
mkdir /nfs-dir #創(chuàng)建共享目錄
vim /etc/exports #編輯共享文件/nfs-dir 192.168.246.0/24(rw,no_root_squash,sync)共享目錄 共享給某個網(wǎng)段(共享出去的文件屬性)*(。。。。)共享給所有機(jī)器
ro:只讀
rw:讀寫
sync:所有數(shù)據(jù)在請求時寫入共享
root_squash:對于使用共享目錄的使用者如果是root用戶,那個這個使用者是權(quán)限將被壓縮成為匿名使用者,只讀權(quán)限。
* :共享給所有網(wǎng)段
no_root_squash:使用共享目錄的使用者,如果是root用戶,那么對于這個分享向目錄來說,它具有root的權(quán)限
systemctl restart nfs-server
systemctl enable nfs-server
exportfs -v #確認(rèn)NFS服務(wù)器啟動
2、web端操作
firewall-cmd --add-port=2049/tcp --permanent
firewall-cmd --add-port=111/tcp --permanent
firewall-cmd --add-port=111/udp --permanent
firewall-cmd --reload
setenforce 0 #臨時關(guān)閉selinux
#永久關(guān)閉selinux
vim /etc/selinux/config
yum -y install rpcbind
yum -y install nfs-utils
mkdir /data #創(chuàng)建掛載點
mount -t nfs 10.1.59.237:/nfs-dir /data #掛載
df -Th #查看是否掛載成功
制作開機(jī)掛載
vim /etc/fstab10.1.59.237:/nfs-dir /data nfs defaults 0 0
mount -a
可以在共享目錄中創(chuàng)建、刪除文件和目錄測試一下