LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 731|回复: 0

nfs服务器配置(基于RHEL 5)

[复制链接]
发表于 2011-3-17 15:30:22 | 显示全部楼层 |阅读模式
来源:http://www.52ipv6.net/read.php?tid=9
在linux服务器中nfs其实就是一种服务,如果没有安装nfs-utils及portmap软件包,将不起作用。
  说明:nfs-utils-xxx-xxx : nfs服务程序包,提供rpc.nfsd及rpc.montd这两个deamons。
              portmap-xxx-xxx:rpc主程序,记录服务的端口映射信息。
第一步:
               建立共享文件目录 如mkdir -p /nfs/public
第二步:开启nfs服务(chkconfig nfs on ,service nfs start)
第三步:编辑/etc/exports配置文件,加入 /nfs/public  192.168.0.0/24(ro)。说明:192.168.0.0/24为允许访问服务器的IP端,并以只读方式访问。
第四步:配置nfs固定端口(/etc/sysconfig/nfs),将RQUOTAD_PORT,LOCKD_TCPPORT,LOCKD_UDPPORT,MOUNTD_PORT,STATD_PORT前的注释符“#”去掉,或者改为相应未被使用的端口。
第五步:配置iptables策略(前提是使用了iptables防火墙)
iptables -I INPUT -p tcp -m multiport --dport 111,2049 -j ACCEPT
iptables -I INPUT -p udp -m multiport --dport 111,2049 -j ACCEPT
iptables -I INPUT -p tcp -m multiport --dport 875,892,662,32803 -j ACCEPT
iptables -I INPUT -p udp -m multiport --dport 875,892,662,32803 -j ACCEPT
然后 /etc/rc.d/init.d/iptables save 或者 service iptables save
第六步:重启portmap及nfs服务
service portmap restart
service nfs restart
第七步:本机测试
<1>使用rpcinfo命令检测nfs是否使用了固定端口
rpcinfo -p
<2>检测nfs的注册状态
rpcinfo -u 主机名或IP地址  进程
如,rpcinfo -u 192.168.0.206 nfs
<3>查看共享目录的参数设置
cat /var/lib/nfs/etab
<4>检测共享目录的发布及使用情况
showmount -e  IP地址
showmount -d  IP地址
如,showmount -e 192.168.0.206
第八步:TCP vrappers设置
修改/etc/hosts.deny 加入ALL:ALL
修改/etc/hosts.allow 加入
portmap:192.168.0.0
mountd:192.168.0.0
lockd:192.168.0.0
rquatad:192.168.0.0
statd:192.169.0.0
第九步:客户端测试
showmount -e 192.168.0.206
挂载及卸载nfs文件系统
mount -t nfs 192.168.0.206:/nfs/public /mnt/nfs
umount 192.168.0.206:/nfs/public
启动自动挂 载(编缉/etc/fstab)
加入 192.168.0.206:/nfs/public /mnt/nfs nfs defaults 0 0
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表