CentOS 7下NFS v4的安裝和使用

  • 搭建nfs服務器

安裝nfs和rpc服務。

yum install -y nfs-utils
yum install -y rpcbind

啓動並配置自啓動,注意需要先啓動rpcbind。

systemctl start rpcbind
systemctl enable rpcbind
systemctl start nfs
systemctl enable nfs

創建和配置共享文件目錄。

mkdir /data/volumes -p
chmod 777 /data/volumes

vim /etc/exports
/data/volumes                     192.168.1.0/24(sync,rw,no_root_squash)

重新導出文件系統。

exportfs –r

查看導出的文件系統。

showmount -e nfs
Export list for nfs:
/data/volumes    192.168.1.0/24
  • nfs客戶端

安裝nfs客戶端。

yum -y install nfs-utils

配置nfs服務器hosts。

vi /etc/hosts
192.168.1.80 nfs

查看導出的文件系統。

showmount -e nfs
Export list for nfs:
/data/volumes    192.168.1.0/24

將導出的文件系統mount到本地目錄。

mkdir /data/vol -p
mount -t nfs nfs:/data/volumes /data/vol

在本地創建一個文件。

echo "hello nfs" >> /data/vol/hello.txt

到nfs服務器查看該文件是否存在。

ll /data/volumes/
-rw-r--r-- 1 root root 10 11月 30 17:47 hello.txt
cat hello.txt
hello nfs
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章