本文共 1213 字,大约阅读时间需要 4 分钟。
在CentOS 6.3系统上安装以下软件包:
yum -y install nfs-utils rpcbind
确认安装版本:
rpm -qa | grep nfs-utils
rpm -qa | grep rpcbind
mkdir /var/{web,cloud} 设置权限:
chmod a+w /var/web
在/etc/exports中添加以下内容:
cat /etc/exports
/var/web 172.16.0.20(rw,async,no_root_squash) /var/cloud *(ro,sync)
/etc/init.d/rpcbind restart
/etc/init.d/nfs restart
确保服务在启动时启用:
chkconfig rpcbind on
chkconfig nfs on
mount 172.16.0.254:/var/web /var/web
或者在/etc/fstab中添加自动挂载项:
echo "172.16.0.254:/var/web /var/web nfs defaults 0 0" >> /etc/fstab
mount -a
ls -l /var/web
su - jerry cd /var/web touch root.txt
观察文件权限:
ls -l /var/web/root.txt
对于只读共享目录/var/cloud,执行以下操作:
mkdir /var/cloud useradd -u 1003 jerry
尝试写入文件:
touch /var/cloud/root.txt
结果:
touch: cannot touch 'root.txt': Read-only file system
nfsnobody。sync选项确保数据写入硬盘前返回成功。wdelay优化性能,合并写入请求。systemctl status rpcbind nfs
通过以上步骤,可以实现CentOS 6.3系统中NFS服务器的搭建与配置,确保文件共享的稳定性与安全性。
转载地址:http://iacfk.baihongyu.com/