NFS局域网目录共享

NFS局域网目录共享
  1. 安装配置nfs服务
#服务端配置
yum install rpcbind nfs-utils -y
vim /etc/exports
--------------/etc/exports-----------------
/data 172.16.1.0/24(rw,sync,all_squash)
--------------/etc/exports 结束-------------
mkdir /data
chown -R nfsnobody.nfsnobody /data/	#改变共享目录的权限
systemctl enable nfs	#开机启动
systemctl start nfs		#启动服务

#客户端配置
yum install nfs-utils -y
showmount -e 172.16.1.31	#检查31服务端的共享目录详情
mount -t nfs 172.16.1.31:/data /mnt	#挂载到本地
df -h 	#查看是否挂载
nfs参数作用
rw读写权限
ro只读权限
sync同时将数据写入内存与硬盘种,保证不丢失数据
async优先将数据保存到内存,然后写入硬盘,效率提高但易丢失数据
root_squash当NFS客户端以root访问时,映射为NFS服务器的匿名用户(不常用)
no_root_squash当客户端以root身份访问时,映射为NFS的root管理员(不常用)
no_all_squash无论NFS客户端使用什么身份访问,都不进行压缩(kvm热迁移)
all_squash不论客户端以什么身份访问,都映射为NFS的匿名用户
anonuid配置all_squash使用,指定NFS的用户UID,必须存在于系统
anongid配置all_squash使用,指定NFS的用户GID,必须存在于系统
  1. 验证ro权限
#服务端配置
vim /etc/exports
-------------/etc/exports----------------
/data1 172.16.1.0/24(ro,sync,all_squash)
-------------/etc/exports结束-------------
mkdir /data1
chown nfsnobody.nfsnobody /data1/
systemctl restart nfs

#客户端配置
mount -t nfs 172.16.1.31:/data1 /mnt
echo "123" >> /mnt/test
-bash: /mnt/test: 只读文件系统
  1. 验证all_squash、anonuid、anongid权限
#服务端配置
vim /etc/exports
--------------/etc/exports-------------
/data 172.16.1.0/24(rw,sync,all_squash,anonuid=666,anongid=666)
--------------/etc/exports结束----------
mkdir -p /data
chown -R www.www /data
systemctl restart nfs
groupadd -g 666 www
useradd -u 666 -g666 www

#客户端配置
mount -t nfs 172.16.1.31:/data /mnt
echo "132" >> /mnt/test
ll /mnt/	#检查客户端
-rw-r--r-- 1 666 666 4 Apr 16 11:11 test
#为了避免程序在操作NFS时。权限会出现错误,我们将进程运行的用户,与nfs存储压缩的用户保持一致
groupadd -g 666 www
useradd -u 666 -g666 www
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值