Server installation
sudo yum install -y nfs-utils
sudo systemctl enable rpcbind
sudo systemctl start rpcbind
sudo systemctl enable nfs
sudo systemctl start nfs
Configure shared directory
mkdir /data/nfs
Configuration / etc / exports, add the following
/data/nfs *(rw,sync,no_root_squash,no_all_squash)
/data/nfs: 共享目录位置。
*: 客户端 IP(18.8.1.0/30) 范围,* 代表所有,即没有限制。
rw: 权限设置,可读可写。
sync: 同步共享目录。
no_root_squash: 可以使用 root 授权。
no_all_squash: 可以使用普通用户授权。
Nfs restart service. Check the local share directory
showmount -e localhost
Client Installation
sudo yum install -y nfs-utils
sudo systemctl enable rpcbind
sudo systemctl start rpcbind
Create a shared directory
mkdir /data/nfs
Mount directory
sudo mount -t nfs 18.8.1.1:/data/nfs /data/nfs
Add automatically mount
sudo vi /etc/fstab
Add a row
18.8.1.1:/data/nfs /data/nfs nfs defaults 0 0