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/test nfs

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

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值