nfs共享(centos7)

服務端:

[root@nfs_server ~]# yum -y install nfs-utils rpcbind
[root@nfs_server ~]# systemctl enable rpcbind
[root@nfs_server ~]# 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.
[root@nfs_server ~]# systemctl enable nfs-lock
[root@nfs_server ~]# systemctl enable nfs-idmap

[root@nfs_server ~]# systemctl start rpcbind
[root@nfs_server ~]# systemctl start nfs-server
[root@nfs_server ~]# systemctl start nfs-lock
[root@nfs_server ~]# systemctl start nfs-idmap

[root@nfs_server ~]# mkdir -p /application/share                    -p 級聯創建
[root@nfs_server ~]# chmod -R 777 /application/share       更改share文件夾及其子文件夾權限爲777

[root@nfs_server ~]# echo "/application/share 192.168.0.*(rw,sync,no_root_squash)" >> /etc/exports
[root@nfs_server ~]# exportfs -a          使exports的修改生效

[root@nfs_server /]# showmount -e
Export list for nfs_server:
/application/share 192.168.0.*

[root@nfs_server ~]# firewall-cmd --add-service=nfs --permanent --zone=public
success
[root@nfs_server ~]# firewall-cmd --add-service=mountd --permanent --zone=public
success
[root@nfs_server ~]# firewall-cmd --add-service=rpc-bind --permanent --zone=public
success
[root@nfs_server ~]# firewall-cmd --reload   重新載入配置,使其生效
success

客戶端:

[root@nfs_client ~]# yum -y install nfs-utils

[root@nfs_client ~]# mkdir -p /application/localshare
[root@nfs_client ~]# mount -t nfs 192.168.0.240:/application/share /application/localshare

解釋一下:
mount :掛載命令
nfs :使用的協議
nolock :不阻塞
vers : 使用的NFS版本號
IP : NFS服務器的IP(NFS服務器運行在哪個系統上,就是哪個系統的IP)
/work/nfs: 要掛載的目錄(Ubuntu的目錄)
/mnt : 要掛載到的目錄(開發板上的目錄,注意掛載成功後,/mnt下原有數據將會被隱藏,無法找到)

配置客戶端開機自動掛載nfs共享目錄

vi /etc/fstab

添加 192.168.0.240:/application/share /application/share nfs defaults 0 0

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章