centos6.9 安装nfs服务
2019-07-08 本文已影响0人
Daisy小朋友
安装
yum -y install nfs-utils
yum -y install rpcbind
开机启动
chkconfig rpcbind on
chkconfig nfs on
配置端口
nfs除了主程序端口2049和rpcbind的端口111是固定以外,还会使用一些随机端口,以下配置将定义这些端口,以便配置防火墙
# vim /etc/sysconfig/nfs
#追加端口配置
MOUNT_PORT=4001
STATD_PORT=4002
LOCKD_TCPPORT=4003
LOCKD_UDPPORT=4004
RQUOTAD_PORT=4005
配置要共享的目录
# vim /etc/exports #配置访问权限
/var/nfs/simple-nfs 192.168.100.0/24(ro,async,root_squash)
配置防火墙
# vim /etc/sysconfig/iptables
-A INPUT -p tcp -m tcp --dport 111 -j ACCEPT
-A INPUT -p udp -m udp --dport 111 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 2049 -j ACCEPT
-A INPUT -p udp -m udp --dport 2049 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 4001:4005 -j ACCEPT
-A INPUT -p udp -m udp --dport 4001:4005 -j ACCEPT
重启服务和防火墙
service rpcbind start
service nfs start
service iptables restart
Linux客户端挂载
# mount -t nfs 192.168.100.110:/var/nfs/simple-nfs /mnt
mount -t nfs 10.0.0.221:/home/adminis/logs tomcat7_8
也可将挂载配置写入fstab文件中,与普通磁盘挂载一样,挂载时同样可以指定权限,只是类型为nfs
问题
1 报错
[root@VM_0_221_centos logs]# service nfs restart
Shutting down NFS daemon: [FAILED]
Shutting down NFS mountd: [FAILED]
Shutting down NFS quotas: [FAILED]
Shutting down NFS services: [ OK ]
Starting NFS services: [ OK ]
Starting NFS quotas: Cannot register service: RPC: Unable to receive; errno = Connection refused
rpc.rquotad: unable to register (RQUOTAPROG, RQUOTAVERS, udp).
[FAILED]
Starting NFS mountd: [FAILED]
Starting NFS daemon: rpc.nfsd: writing fd to kernel failed: errno 111 (Connection refused)
解决:
解决办法就是重新启动rpcbind服务即可:
service rpcbind restart
service nfs restart
2 安装 rpcbind报错
Transaction Test Succeeded
Running Transaction
groupadd: cannot open /etc/group
error: %pre(rpcbind-0.2.0-16.el6.x86_64) scriptlet failed, exit status 6
Error in PREIN scriptlet in rpm package rpcbind-0.2.0-16.el6.x86_64
error: install: %pre scriptlet failed (2), skipping rpcbind-0.2.0-16.el6
Verifying : rpcbind-0.2.0-16.el6.x86_64 1/1
Failed:
rpcbind.x86_64 0:0.2.0-16.el6
解决:
chattr -i /etc/group /etc/passwd /etc/shadow /etc/gshadow