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
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指令 重新開機