一、系统
二、安装
三、配置
四、指定nfs端口
五、客户端安装
六、同一级目录下的多目录共享
七、报错处理
八、exportfs参数说明
九、fuser参数说明
一、系统
# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
二、安装


# cat /proc/sys/kernel/watchdog_thresh
# echo 30 > /proc/sys/kernel/watchdog_thresh
# sysctl -w kernel.watchdog_thresh=30
# egrep -v "^$|^#" /etc/sysctl.conf
net.bridge.bridge-nf-call-iptables =1
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables =1
kernel.watchdog_thresh = 30
# sysctl -p
# yum install nfs-utils
# firewall-cmd --permanent --zone=public --add-service=nfs
# firewall-cmd --permanent --zone=public --add-service=rpc-bind
# firewall-cmd --permanent --zone=public --add-service=mountd
# firewall-cmd --reload
三、配置
# cat /etc/exports
/work/logs 192.168.0.0/16(rw,no_root_squash,async,fsid=0)
多磁盘共享配置

# cat /etc/exports <有问题>
/k8s_nfs1 192.168.2.0/24(rw,no_root_squash,async,fsid=0)
/k8s_nfs2 192.168.2.0/24(rw,no_root_squash,async,fsid=0)
## 参数说明
参数 作用
ro 只读
rw 读写
root_squash 当nfs客户端以root管理员访问时,映射为NFS服务器的匿名用户
no_root_squash 当nfs客户端以root管理员访问时,映射为nfs服务器的root管理员
all_squash 无论nfs客户端使用什么账号访问,均映射为nfs服务器的匿名用户
sync 同时将数据写入到内存与硬盘中,保证不丢失数据
async 优先将数据保存到内存,让后写入硬盘;这样效率更高,单可能会丢数据
# chmod 777 /work/logs -R
# systemctl start nfs
# systemctl enable nfs
挂载钱首先检查有权限需要挂载的信息
# showmount -e 10.9.85.202
四、指定nfs端口

防火墙:



联通安全组配置:

五、客户端安装
# yum install nfs-utils
# mkdir /work/logs

六、同一级目录下的多目录共享

# exportfs -ar
客户端挂载:
# mount 10.9.85.202:/work/projects/transportation-isp/transportation_data -t nfs /work/projects/transportation-isp/transportation_data
# mount 10.9.85.202:/work/fileserver -t nfs /work/fileserver/
开机挂载:


七、报错处理

# yum install psmisc
# fuser -km /work/projects/transportation-isp/transportation_data/
# umount /work/projects/transportation-isp/transportation_data/


八、exportfs参数说明
1)、-a:全部挂载/卸载 /etc/exports文件内的设定
2)、-r:重新挂载/etc/exports中的设置,此外同步更新/etc/exports及/var/lib/nfs/xtab中的内容
3)、-u:卸载某一目录
4)、-v:在export时将共享的目录显示在屏幕上
九、fuser参数说明

