centos 7 nfs 固定端口安装
一 、nfs 固定端口安装
理论原文链接: https://baijiahao.baidu.com/s?id=1740646335629018982&wfr=spider&for=pc&searchword=nfs%20
安装原文链接:https://blog.csdn.net/weixin_45551608/article/details/125034146
1、安装nfs工具
yum install -y rpcbind nfs-utils
2、创建共享目录
mkdir /data/hos
chmod 777 /data/hos/
vim /etc/exports 添加内容如下:
/data/hos 192.103.100.0/24(rw,sync,no_root_squash)
客户机地址可以是主机名、IP地址、网段地址,允许使用“*”、“?”通配符;
① “rw”表示允许读写,“ro”表示为只读;
② “sync”:表示同步写入到内存与硬盘中;
③ “no_root_squash”:表示当客户机以root身份访问时赋予本地root权限(默认是root_squash);
④ “root_squash”:表示客户机用root用户访问改共享目录时,将root用户映射成匿名用户;
3、修改nfs配置文件,指定固定的端口
vim /etc/sysconfig/nfs
RQUOTAD_PORT=30001
LOCKD_TCPPORT=30002
LOCKD_UDPPORT=30002
MOUNTD_PORT=30003
STATD_PORT=30004
vim /etc/modprobe.d/lockd.conf
options lockd nlm_tcpport=30002
options lockd nlm_udpport=30002
4 、重启(注意一定要先重启rpcbind服务)
systemctl restart rpcbind
systemctl restart nfs
5 、验证端口是否修改成功
rpcinfo -p
二、客户端安装
1、 安装
yum install -y rpcbind nfs-utils
2、 挂载
showmount -e IP --查看可以挂载的目录
mount -t nfs IP:/mnt/gfaShare /bmp2/filesync
3、 设置开机自启
systemctl enable nfs.service
systemctl enable rpcbind.service
4 、设置开机挂载目录
vim /etc/fstab
IP:/mnt/gfaShare /bmp2/filesync nfs defaults,_rnetdev 1 1
服务端ip:服务端共享目录 挂载目录
备注:第 1 个 1 表示备份文件系统,第 2 个 1 表示从 / 分区的顺序开始 fsck 磁盘检测,0 表示不检测。
_rnetdev 表示主机无法挂载直接跳过,避免无法挂载主机无法启动