Chinaunix首页 | 论坛 | 博客
  • 博客访问: 723320
  • 博文数量: 225
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 2722
  • 用 户 组: 普通用户
  • 注册时间: 2013-02-03 17:32
文章分类

全部博文(225)

文章存档

2019年(7)

2018年(16)

2017年(1)

2016年(26)

2015年(41)

2014年(15)

2013年(119)

我的朋友

分类: 系统运维

2014-01-14 15:28:10

1.配置环境

server:221.174.24.101,192.168.0.19
client:221.174.24.98,192.168.0.13

服务端配置:

yum install nfs4-acl-tools
yum install rpcbind
vim /etc/exports
输入:/mysql/static 192.168.0.13(rw,async,no_root_squash,anonuid=500,anongid=500)
exportfs -rv //让配置文件生效-r : reexport all directories -v: verbose (输出更细)
service rpcbind start
service nfs start
showmount -e 
service iptables stop

客户端配置:

yum install nfs4-acl-tools
yum install rpcbind
service rpcbind start
service nfs start
mount -t nfs 192.168.0.19:/mysql/static /mnt/imgsvr;//可以放在/etc/rc.local里面让开机自动挂载。
总结:挂载相当于将99的/mysql/static/挂接到98的/mnt/imgsvr,当用户上传图片到/mnt/imgsvr,相当于上传到99的/mysql/static目录下,从而解决静态文件抢占带宽的问题,以及web服务器容量的问题.
tips:挂载时最好保证两台机子的文件权限一致,比如都是deployee用户,这样避免权限带来的麻烦。

NFS防火墙的配合

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

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

其中portmapper,nfs服务端口是固定的分别是111和2049;

另外rquotad,nlockmgr,mountd服务端口是随机的。由于端口是随机的,这导致防火墙无法设置。

2、这时需要配置/etc/sysconfig/nfs使rquotad,nlockmgr,mountd的端口固定。

找到以下几项,将前面的#号去掉。

RQUOTAD_PORT=875
LOCKD_TCPPORT=32803
LOCKD_UDPPORT=32769
MOUNTD_PORT=892
service nfs restart

3.再次


4.设置使rquotad,nlockmgr,mountd的端口固定。


vim /etc/services,在文件的最后一行添加:

这几行内容。保存并退出。


5.重启下nfs服务。

service nfs restart


6.在防火墙中开放这5个端口

编辑iptables配置文件
vim /etc/sysconfig/iptables
添加如下行:
-A INPUT -s 192.168.1.0/24 -m state --state NEW -p tcp --dport 111 -j ACCEPT
-A INPUT -s 192.168.1.0/24 -m state --state NEW -p tcp --dport 875 -j ACCEPT
-A INPUT -s 192.168.1.0/24 -m state --state NEW -p tcp --dport 2049 -j ACCEPT
-A INPUT -s 192.168.1.0/24 -m state --state NEW -p tcp --dport 892 -j ACCEPT
-A INPUT -s 192.168.1.0/24 -m state --state NEW -p tcp --dport 32803 -j ACCEPT
-A INPUT -s 192.168.1.0/24 -m state --state NEW -p udp --dport 111 -j ACCEPT
-A INPUT -s 192.168.1.0/24 -m state --state NEW -p udp --dport 875 -j ACCEPT
-A INPUT -s 192.168.1.0/24 -m state --state NEW -p udp --dport 2049 -j ACCEPT
-A INPUT -s 192.168.1.0/24 -m state --state NEW -p udp --dport 892 -j ACCEPT
-A INPUT -s 192.168.1.0/24 -m state --state NEW -p udp --dport 32769 -j ACCEPT


service iptables restart




阅读(1426) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~