Nginx+keepalived主从双机热备自动切换解决方案
测试环境如下:
系统:Ceentos 6.4 64位
主nginx服务器:192.168.122.5
备nginx服务器:192.168.122.6
VIP:192.168.122.15
一、Nginx+keepalived 安装—脚本安装
--------------------- #
## Nginx_install
# -------------------------------------------------------- #
# Nginx installation
#CURRENT_PATH=$(pwd)
for i in $(rpm -q gcc gcc-c++ kernel-devel openssl-devel zlib-devel popt-devel popt-static libnl-devel wget make |grep 'not installed' | awk '{print $2}')
do
yum -y install $i
done
[ -d /root/software ]
[ "$?" != 0 ] && mkdir /root/software
cd /root/software
[ !-e pcre-8.33.tar.gz ] && wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.33.tar.gz
tar -zxvf pcre-8.33.tar.gz
cd pcre-8.33
./configure
make && make install
echo $? || [ $? != 0] || echo" installation pcrefailed"