準備環(huán)境:
server 端 192.168.1.235
client 端 192.168.1.236
1.在192.168.1.235上執(zhí)行命令
yum install -y nfs-utils
yum install -y rpcbind
systemctl start rpcbind
systemctl enable rpcbind
systemctl start nfs-server
systemctl enable nfs-server
2.創(chuàng)建共享目錄
mkdir /public
vi /etc/exports
添加的文件內(nèi)容為:(注意括號與24之間不要留空格 會報錯)
/public 192.168.1.0/24(rw)
3.重新加載配置文件:
systemctl reload nfs
4.在192.168.1.236上執(zhí)行命令:
yum install -y showmount
showmount -e 192.168.1.235
如果顯示的是192.168.1.235上配置的信息锌杀,則代表連接成功
5.創(chuàng)建共享目錄并掛在到本機个绍,執(zhí)行命令:
mkdir /public
vim /etc/fstab
添加的文件內(nèi)容為:
192.168.1.235:/public /public nfs defaults 0 0
執(zhí)行掛載命令:
mount -a
6.查看是否共享成功撤蚊,在192.168.1.236上執(zhí)行命令:
df -Th
7.可以在192.168.1.235和192.168.1.236上分別curd文件測試裹驰。值得注意的是192.168.1.235上的文件共享目錄的權限配置绳瘟。默認192.168.1.236上訪問192.168.1.235共享目錄時的用戶是nobody苛茂。我暫時給192.168.1.235上設置的權限是766.