安裝NFS:
yum install nfs-utils
建立分享的目錄:
mkdir /mnt/nfsshare
chmod -R 777 /mnt/nfsshare/
建立exports檔案:
vi /etc/exports
內容:
/mnt/nfsshare 192.168.1.0/24(rw,sync,no_root_squash,no_all_squash)
設定開機啟動服務:
systemctl enable rpcbind
systemctl enable nfs-server
Created symlink from /etc/systemd/system/multi-user.target.wants/nfs-server.service to /usr/lib/systemd/system/nfs-server.service.
systemctl enable nfs-lock
systemctl enable nfs-idmap
現在啟動服務:
systemctl restart rpcbind
systemctl start nfs-server
systemctl start nfs-lock
systemctl start nfs-idmap
設定防火牆:
firewall-cmd --permanent --zone=public --add-service=nfs
firewall-cmd --reload
查看NFS是否有啟動:
showmount -e
連接mount:
mount -t nfs 192.168.1.100:/mnt/nfsshare/ /mnt/nfsshare/
開機自動連接:
vi /etc/fstab
192.168.1.100:/mnt/nfsshare/ /mnt/nfsshare/ nfs rw,sync,hard,intr 0 0