nfs+keepalived高可用

1台nfs主被服务器都下载nfs、keepalived

yum install nfs-utils rpcbind keepalived -y

 

2台nfs服务器nfs挂载目录及配置必须相同

3.在主nfs服务期编写一个死循环并后台运行

while true

do

if [ `/etc/init.d/nfs  status|awk 'NR==2{print $NF}'`  = "stopped" ]

  then

    /etc/init.d/keepalived  stop

fi

done 

4.再挂载服务器写一个守护进程并执行守护进程

 

挂载服务器脚本内容:

while true

do

if [ `showmount  -e 172.16.1.31|wc -l` -eq 0 ]

  then

    umount /application/nginx-1.10.3/html/blog/wp-content/uploads

    umount  /application/nginx-1.10.3/html/bbs/data/attachment/image

    umount   /application/nginx-1.10.3/html/www/uploads/allimg

    mount -t nfs 172.16.1.30:/data/blog     /application/nginx-1.10.3/html/blog/wp-content/uploads

    mount -t nfs 172.16.1.30:/data/bbs /application/nginx-1.10.3/html/bbs/data/attachment/image

    mount -t nfs 172.16.1.30:/data/www   /application/nginx-1.10.3/html/www/uploads/allimg

   exit

fi

 

done

 

posted @ 2017-09-18 13:15  巽逸  阅读(495)  评论(0编辑  收藏  举报