NFS即网络文件系统,说的通俗一点就是网络共享文件。它能够让不同的服务器共享同一个资源,这个在集群部署中普遍运用。
安装nfs
1
2
3yum install -y nfs-utils
yum install -y rpcbind #适用centos 6
yum install -y portmap #适用centos 5启动NFS服务,一定要先启动rpcbind,后启动nfs
1
2/etc/init.d/rpcbind start
/etc/init.d/nfs start在资源服务器(服务器端)上配置NFS,修改
/etc/exports
1
2
3
4
5
6/data/httpd/www/public 客户端ip(rw,sync,no_root_squash)
/data/httpd/www/themes 客户端ip(rw,sync,no_root_squash)
/data/httpd/www/wap_themes 客户端ip(rw,sync,no_root_squash)
修改好之后执行命令
exportfs -rv查看是否成功
1
2
3
4
5showmount -e 服务器端ip
Export list for 服务器端ip
/data/httpd/www/public 客户端ip
/data/httpd/www/themes 客户端ip
/data/httpd/www/wap_themes 客户端ipweb服务器(客户端)挂载资源服务器的资源
1
2
3mount 服务器端ip:/data/httpd/www/public /data/httpd/www/public
mount 服务器端ip:/data/httpd/www/themes /data/httpd/www/themes
mount 服务器端ip:/data/httpd/www/wap_themes /data/httpd/www/wap_themes防止重启服务器忘记挂载
1
2
3
4vi /etc/rc.local
mount 服务器端ip:/data/httpd/www/public /data/httpd/www/public
mount 服务器端ip:/data/httpd/www/themes /data/httpd/www/themes
mount 服务器端ip:/data/httpd/www/wap_themes /data/httpd/www/wap_themes重启服务
先启动:service rpcbind start 再启动:service nfs start
先关闭:service nfs stop 再关闭:service rpcbind stop