首先安装NFS套件,命令如下:
yum
yum
然后安装portmap服务,portmap在centos6中改名为rpcbind
yum
yum
挂载光盘,将文件拷贝到要挂载的目录上
mkdir
mount
cp
配置nfs服务端
vi
添加
/opt/centos6
这一行表明本机的/opt/centos6这个目录为nfs共享目录,可访问的ip地址区间为192.168.0.0-192.168.0.254,权限为只读,当访问者为root用户时方位该目录具有root权限
重启nfs服务
/etc/init.d/rpcbind
/etc/init.d/nfs
将nfs加入开机启动项
chkconfig
客户端配置
查看是否能访问nfs服务
showmount
显示如下:
Export list for 192.168.0.10:
/opt/centos6 192.168.0.11
表示可以访问,如不可访问查看nfs服务端nfs服务是否启用,防火墙是否允许通过。
挂载nfs目录
mkdir
mount
配置开机自动挂载
vi
添加
192.168.0.10:/opt/centos6 /opt/centos6 nfs
RHEL6 NFS 防火墙设置
NFS 用到的服务有 portmapper nfs rquotad nlockmgr mountd
通过命令 rpcinfo -p 可查看nfs使用的端口
[root@bk /]# rpcinfo -p
其中 portmapper nfs 服务端口是固定的分别是 111 2049
另外 rquotad nlockmgr mountd 服务端口是随机的。由于端口是随机的,这导致防火墙无法设置。
这时需要配置/etc/sysconfig/nfs 使 rquotad nlockmgr mountd 的端口固定。
找到以下几项,将前面的#号去掉。
RQUOTAD_PORT=875
LOCKD_TCPPORT=32803
LOCKD_UDPPORT=32769
MOUNTD_PORT=892
service nfs restart
[root@bk /]# rpcinfo -p
设置防火墙
[root@bk /]# iptables -I INPUT -s 192.168.1.102/24 -p tcp --dport 111 -j ACCEPT
[root@bk /]# iptables -I INPUT -s 192.168.1.102/24 -p tcp --dport 875 -j ACCEPT
[root@bk /]# iptables -I INPUT -s 192.168.1.102/24 -p tcp --dport 2049 -j ACCEPT
[root@bk /]# iptables -I INPUT -s 192.168.1.102/24 -p tcp --dport 32769 -j ACCEPT
[root@bk /]# iptables -I INPUT -s 192.168.1.102/24 -p tcp --dport 32803 -j ACCEPT
[root@bk /]# iptables -I INPUT -s 192.168.1.102/24 -p tcp --dport 892 -j ACCEPT
[root@bk /]# iptables -I INPUT -s 192.168.1.102/24 -p udp --dport 111 -j ACCEPT
[root@bk /]# iptables -I INPUT -s 192.168.1.102/24 -p udp --dport 875 -j ACCEPT
[root@bk /]# iptables -I INPUT -s 192.168.1.102/24 -p udp --dport 2049 -j ACCEPT
[root@bk /]# iptables -I INPUT -s 192.168.1.102/24 -p udp --dport 32769 -j ACCEPT
[root@bk /]# iptables -I INPUT -s 192.168.1.102/24 -p udp --dport 32803 -j ACCEPT
[root@bk /]# iptables -I INPUT -s 192.168.1.102/24 -p udp --dport 892 -j ACCEPT
设置完毕!