web:192.168.1.10 nfs:192.168.1.11
1 配置nfs服務器
安裝軟件
yum install rpcbind
yum install nfs
創建共享目錄
mkdir /tmp/rw
mkdir /tmp/ro
更改屬豬屬組
chmod -R nfsnobody.nfsnobody rw
chmod -R nfsnobody.nfsnobody ro
vim /etc/exports
/tmp/rw 192.168.1.10/24(rw)
/tmp/ro 192.168.1.10/24(ro)
關閉 selinux iptables
setenforce 0
/etc/init.d/iptables stop
service rpcbind restart (需先重啓)
service nfs restart
showmount -e localhost 查看
2 web客戶端
安裝軟件 重啓服務
mkdir /tmp/rw
mkdir /tmp/ro
showmount -e 192.168.1.11 查看nfs服務器
掛載
mount -t nfs 192.168.1.11:/tmp/rw /tmp/rw
mount -t nfs 192.168.1.11:/tmp/ro /tmp/ro
df -hT 查看本機掛載情況
查看寫入情況
cd /tmp/ro
touch q
cd /tmp/rw
touch q
3 配置開機自動掛載 nfs 和客戶端都要配置
配置開機啓動服務
chkconfig --level 35 rpcbind on
chkconfig --level 35 nfs on
chkconfig --list rpcbind
chkconfig --list nfs
等級0表示:表示關機
等級1表示:單用戶模式
等級2表示:無網絡連接的多用戶命令行模式
等級3表示:有網絡連接的多用戶命令行模式
等級4表示:不可用
等級5表示:帶圖形界面的多用戶模式
等級6表示:重新啓動
開機關閉selinux 和iptables
vim /etc/selinux/config
SELINUX=Permissive
chkconfig iptables off (2 3 4 5 等級關閉)
在web客戶端配置自動掛載
echo "mount -t nfs 192.168.1.11:/tmp/ro /tmp/ro" >> /etc/rc.local
echo "mount -t nfs 192.168.1.11:/tmp/rw /tmp/rw" >> /etc/rc.local
完成 開機時先打開NFS 再打開web
若客戶端不能找到nfs會 開機卡在 nfs掛載項 解決
開機 幾秒內 倒計時
回車
按e
按向下箭頭 指到kernel 按e
在quiet後加 空格 再加1 回車
按b
啓動後 刪除 rc.local 裏的 掛載NFS命令 重啓
Windows掛載的寫入問題
將nfs服務器共享目錄文件權限 改爲777 則可寫入 網上找的其他方法沒有試出來