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
nfs+keepalived高可用