Centos 6.X的NFS配置

centos6以后版本变更了portmap服务为rpcbind ,在使用nfs时这点与centos5不同,下面配置一个nfs系统,用来使局域网内的所有用户均可访问该目录,可将该目录 配置成yum源 ,供内网机器安装软件。


首先安装NFS套件,命令如下:

yum install nfs-utils.x86_6464位系统

yum install nfs-utils(32位系统)

 

然后安装portmap服务,portmapcentos6中改名为rpcbind

yum install rpcbind(centos6.X)

yum install portmap(centos5.X)

 

挂载光盘,将文件拷贝到要挂载的目录上

mkdir /opt/centos6

mount  /dev/cdrom /media -o loop

cp -r /media/* /opt/centos6/

 

配置nfs服务端

vi /etc/exports

添加

/opt/centos6 192.168.0.0/24(ro,no_root_squash)

这一行表明本机的/opt/centos6这个目录为nfs共享目录,可访问的ip地址区间为192.168.0.0-192.168.0.254,权限为只读,当访问者为root用户时方位该目录具有root权限

 

重启nfs服务

/etc/init.d/rpcbind start

/etc/init.d/nfs start

 

nfs加入开机启动项

chkconfig nfs on

 

客户端配置

查看是否能访问nfs服务

showmount -e 192.168.0.10

显示如下:

 

Export list for 192.168.0.10:

/opt/centos6 192.168.0.11

 

表示可以访问,如不可访问查看nfs服务端nfs服务是否启用,防火墙是否允许通过。

 

挂载nfs目录

mkdir /opt/centos6

mount -t nfs 192.168.0.10:/opt/centos6/ /opt/centos6/

 

 

配置开机自动挂载

vi /etc/fstab

添加

192.168.0.10:/opt/centos6 /opt/centos6 nfs  nodev,ro,rsize=32768,wsize=32768    0


RHEL6 NFS 防火墙设置

NFS 用到的服务有 portmapper nfs rquotad nlockmgr mountd

通过命令 rpcinfo -p 可查看nfs使用的端口

[root@bk /]# rpcinfo -p
   program vers proto   port  service
    100000    4   tcp    111  portmapper
    100000    3   tcp    111  portmapper
    100000    2   tcp    111  portmapper
    100000    4   udp    111  portmapper
    100000    3   udp    111  portmapper
    100000    2   udp    111  portmapper
    100024    1   udp  53713  status
    100024    1   tcp  47753  status
    100011    1   udp    875  rquotad
    100011    2   udp    875  rquotad
    100011    1   tcp    875  rquotad
    100011    2   tcp    875  rquotad
    100003    2   tcp   2049  nfs
    100003    3   tcp   2049  nfs
    100003    4   tcp   2049  nfs
    100227    2   tcp   2049  nfs_acl
    100227    3   tcp   2049  nfs_acl
    100003    2   udp   2049  nfs
    100003    3   udp   2049  nfs
    100003    4   udp   2049  nfs
    100227    2   udp   2049  nfs_acl
    100227    3   udp   2049  nfs_acl
    100021    1   udp  40399  nlockmgr
    100021    3   udp  40399  nlockmgr
    100021    4   udp  40399  nlockmgr
    100021    1   tcp  46247  nlockmgr
    100021    3   tcp  46247  nlockmgr
    100021    4   tcp  46247  nlockmgr
    100005    1   udp  60639  mountd
    100005    1   tcp  39962  mountd
    100005    2   udp  51575  mountd
    100005    2   tcp  42414  mountd
    100005    3   udp  38358  mountd
    100005    3   tcp  48741  mountd

其中 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
   program vers proto   port  service
    100000    4   tcp    111  portmapper
    100000    3   tcp    111  portmapper
    100000    2   tcp    111  portmapper
    100000    4   udp    111  portmapper
    100000    3   udp    111  portmapper
    100000    2   udp    111  portmapper
    100024    1   udp  53713  status
    100024    1   tcp  47753  status
    100011    1   udp    875  rquotad
    100011    2   udp    875  rquotad
    100011    1   tcp    875  rquotad
    100011    2   tcp    875  rquotad
    100003    2   tcp   2049  nfs
    100003    3   tcp   2049  nfs
    100003    4   tcp   2049  nfs
    100227    2   tcp   2049  nfs_acl
    100227    3   tcp   2049  nfs_acl
    100003    2   udp   2049  nfs
    100003    3   udp   2049  nfs
    100003    4   udp   2049  nfs
    100227    2   udp   2049  nfs_acl
    100227    3   udp   2049  nfs_acl
    100021    1   udp  32769  nlockmgr
    100021    3   udp  32769  nlockmgr
    100021    4   udp  32769  nlockmgr
    100021    1   tcp  32803  nlockmgr
    100021    3   tcp  32803  nlockmgr
    100021    4   tcp  32803  nlockmgr
    100005    1   udp    892  mountd
    100005    1   tcp    892  mountd
    100005    2   udp    892  mountd
    100005    2   tcp    892  mountd
    100005    3   udp    892  mountd
    100005    3   tcp    892  mountd

设置防火墙

[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

设置完毕!


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值