centos7 配置 NFS mount挂载服务器

1. NFS服务端

安装NFS服务

yum install nfs_utils

yum install rpcbind (系统默认已经有了,可查看下)

配置共享文件夹

1.    创建文件夹:

mkdir -p /usr/nfsShare (-p可以自动添加没有的文件夹)  

2.    修改文件夹权限:chmod 755 /usr/nfsShare (755或者777)

3.    配置文件修改:vi /etc/exports

4.    添加:/usr/nfsShare 192.111.134.*(rw,sync,no_root_squash) 【可将IP设置为*】

5.    然后保存

固定nfs服务端口

固定端口nfs 2049、portmapper111 另外3个服务端口可设置为mountd 892、rquotad 875、   nlockmgr 32803、32769

具体配置:

1.    修改/etc/sysconfig/nfs文件,将下列内容的注释去掉,如果没有则添加:

RQUOTAD_PORT=875

LOCKD_TCPPORT=32803

LOCKD_UDPPORT=32769

MOUNTD_PORT=892

设置防火墙

#portmap:111  #nfsd:2049 #rquotad:875   #mountd:892  #lockd:32803/tcp  32769 /udp

firewall-cmd --zone=public--add-port=111/tcp --add-port=111/udp --add-port=2049/tcp --add-port=2049/udp--add-port=875/tcp --add-port=875/udp --add-port=892/tcp --add-port=892/udp--add-port=32803/tcp --add-port=32769 /udp –permanent

移除:

firewall-cmd --zone=public --remove-port=111/tcp--remove-port=111/udp --remove-port=2049/tcp --remove-port=2049/udp --remove-port=875/tcp--remove-port=875/udp --remove-port=892/tcp --remove-port=892/udp --remove-port=32803/tcp--remove-port=32769/udp --permanent

firewall-cmd –reload

启动服务

systemctl start rpcbind 

systemctl start nfs

设置开机启动:

systemctl enable rpcbind

systemctl enable nfs-server.service

查看服务状态:

netstat -lt

  如果出现如下内容则配置成功

tcp       0      0 *:nfs                   *:*                     LISTEN  

2. 客户端

1.    yum install nfs_utils

2.    yum install rpcbind

3.    systemctl start rpcbind  #centos6.5 #service rpcbind start

4.    systemctl start nfs   #centos6.5 #service nfs start

5.    systemctl enable rpcbind  #centos6.5 #chkconfig rpcbind on

6.    systemctl enablenfs-server.service  #centos6.5 #chkconfignfs on    查看#chkconfig --list

7.    mount -t nfs 192.111.134.1:/usr/nfsShare /usr/test

查看客户端/usr/test是否已经挂载成功

8.    设置开机自动挂载

vi /etc/fstab

添加:    192.111.134.1:/usr/nfsShare /usr/test nfs  defaults 0 0

其他:​

关闭挂载:umount /usr/shareNFS nfs

windows挂载: mount  192.111.134.1:/usr/nfsShare X: 

原文地址:https://www.cnblogs.com/fatt/p/6911963.html