CentOS7 最小化安装后,安装配置NFS

来源:互联网 发布:淘宝店需要什么手续 编辑:程序博客网 时间:2024/06/02 02:25

系统环境:CentOS 7

yum -y install nfs-utils rpcbind

NFS 的配置文件 cat /etc/exports

#NFS sharedir/home/ *(rw,no_root_squash,no_all_squash,async)

配置文件说明
*:所有IP,也可以设置为某个网段或者某个具体的地址
rw:read-write,可读写
async:文件暂存于内存,而不是直接写入内存
no_root_squash:NFS客户端连接服务端时如果使用的是root的话,那么对服务端分享的目录来说,也拥有root权限

exportfs -r   #重新加载配置文件systemctl start  rpcbind.service  #启动rpc服务systemctl start  nfs.service    #启动nfs服务systemctl enable nfs    #设置开机启动systemctl enable rpcbind    #设置开机启动

如网络可能不太稳定,NFS默认是用UDP协议,换成TCP协议即可:

mount -t nfs 服务器IP:/home/share-dir /mnt -o proto=tcp -o nolock

在此文件下/etc/sysconfig/nfs指定mountd,statd,lockd,rquotad端口号

RQUOTAD_PORT=10001LOCKD_TCPPORT=10002LOCKD_UDPPORT=10002MOUNTD_PORT=10003STATD_PORT=10004

firewall配置

firewall-cmd --permanent --add-service=nfs  #永久打开nfs服务所使用的端口firewall-cmd --reload   #重新加载firewall配置文件

配置iptables规则

iptables -A INPUT -p tcp --dport 111 -j ACCEPTiptables -A INPUT -p udp --dport 111 -j ACCEPTiptables -A INPUT -p tcp --dport 2049 -j ACCEPTiptables -A INPUT -p udp --dport 2049 -j ACCEPTiptables -A INPUT -p tcp --dport 10001:10004 -j ACCEPTiptables -A INPUT -p udp --dport 10001:10004 -j ACCEPT

NFS挂载命令

mount -t nfs 12.12.1.4:/home/data/ /mnt/               要挂载机器的IP:路径 要挂载到本机的路径
原创粉丝点击