服务端搭建
yum -y intall nfs-utils
netstat -lntp|grep rpcbind 如果没有启动,就执行 systemctl start rpcbind
mkdir /u01/nfs-data
chown -R nfsnobody.nfsnobody /u01/nfs-data
vi /etc/exports 添加 /u01/nfs-data 10.10.0.0/21(rw,async)
systemctl start nfs
rpcinfo -p 10.10.2.129
showmount -e localhost
touch /u01/nfs-data/1.txt
echo “hello nfs” >> /u01/nfs-data/1.txt
systemctl enable nfs.service
firewall-cmd --add-port=111/tcp --add-port=2049/tcp --permanent
exports配置文件说明
rw---设置共享目录读写模式。
ro---设置共享目录只读模式。
sync---采用同步方式存储数据,存储数据到硬盘中。
async---采用异步方式存储数据,存储数据到内存中。
no_root_squash---root用户不做映射。
root_squash---root用户做映射。
all_squash---所有用户都做映射。
no_all_squash---所有用户都不做映射。
客户端挂载
yum -y intall nfs-utils
netstat -lntp|grep rpcbind 如果没有启动,就执行 systemctl start rpcbind
mkdir /u01/nfsdata
showmount -e 10.10.2.129
mount -t nfs 10.10.2.129:/u01/nfs-data /u01/nfsdata (挂载需退出/u01/nfsdata当前路径路径)
cd /u01/nfsdata/
cat 1.txt
echo “2222” >> 1.txt
cat 1.txt
服务端 查看 1.txt文件。