本文已在本人博客https://www.nsxsg.com/archives/90首发
文章目录
多机部署之NFS的安装与配置
NFS即网络文件系统,说的通俗一点就是网络共享文件。它能够让不同的服务器共享同一个资源,这个在集群部署中普遍运用。
-
安装nfs
yum install -y nfs-utils yum install -y rpcbind #适用centos 6 yum install -y portmap #适用centos 5
-
启动NFS服务,一定要先启动rpcbind,后启动nfs
/etc/init.d/rpcbind start /etc/init.d/nfs start
-
在资源服务器(服务器端)上配置NFS,修改
/etc/exports
/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
查看是否成功
showmount -e 服务器端ip Export list for 服务器端ip /data/httpd/www/public 客户端ip /data/httpd/www/themes 客户端ip /data/httpd/www/wap_themes 客户端ip
-
web服务器(客户端)挂载资源服务器的资源
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
-
防止重启服务器忘记挂载
vi /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