Linux——nfs

nfs文件系统

服务端:
yum install nfs-utils -y
systemctl start nfs
systemctl status nfs
firewall-cmd –list-all
firewall-cmd –permanent –add-service=nfs
firewall-cmd –reload
firewall-cmd –permanent –add-service=mountd
firewall-cmd –reload
firewall-cmd –permanent –add-service=rpc-bind
firewall-cmd –reload
Linux——nfs
客户端:
showmount -e 172.25.254.108
Export list for 172.25.254.108: ##内容为空,需自行设定
Linux——nfs
服务端:
vim /etc/exports
/van *(sync,ro) ##同步&只读
Linux——nfs
exportfs -rv ##不需要重启服务,直接更新即可
Linux——nfs
客户端:
mount 172.25.254.108:/van /mnt/
rm -rf file
rm: cannot remove ‘file’: Read-only file system ##不能删除,原因只读
Linux——nfs

服务端:
自动挂载文件系统
yum install autofs -y
systemctl start autofs.service
cd /net/172.25.254.108
cd van/
Linux——nfs
vim /etc/autofs.conf
timeout = 3 ##自动挂载时限改为3秒
Linux——nfs
systemctl restart autofs.service

服务端:
更改挂载位置
mkdir -p /westos/hsh ##建立目录

vim /etc/auto.master
/westos/hsh /etc/auto.nfs ##设置挂载点上级目录并设定子配置文件
Linux——nfs
vim /etc/auto.nfs
share -ro 172.25.254.108:/van ##设定为只读,vers=3设定版本
Linux——nfs
systemctl restart autofs.service

cd /westos/hsh/share
ls
file file1 student student2 van1 van2 yang
Linux——nfs

服务端:
vim /etc/exports
/van 172.25.254.8(sync,rw) 172.25.254.0/24(sync,ro) ##8读写,其他只读
Linux——nfs
exportfs -rv
Linux——nfs
客户端:
fuser -kvm /mnt/
umount /mnt/
mount 172.25.254.108:/van /mnt/
cd /mnt/
touch file3
Linux——nfs
服务端:
vim /etc/exports
/van foundation[8,88].ilt.example.com(sync,rw) 172.25.254.0/24(sync,ro) ##识别方式改为域,不推荐
Linux——nfs
exportfs -rv

vim /etc/exports
/van 172.25.254.8(sync,rw,anonuid=1000,anongid=1000) 172.25.254.0/24(sync,ro) ##文件身份为1000
Linux——nfs
exportfs -rv

服务端:
umount /mnt/
mount 172.25.254.108:/van /mnt/
touch file4
Linux——nfs
客户端:
vim /etc/exports
/van 172.25.254.8(sync,rw,no_root_squash) 172.25.254.0/24(sync,ro) ##root用户身份不加以更改
Linux——nfs
exportfs -rv

服务端:
umount /mnt/
mount 172.25.254.108:/van /mnt/
touch file5
Linux——nfs