keepalived实现主备切换
1.下载安装keepalived,并且做成linux系统服务wget http://www.keepalived.org/download.htmltar -zxvf keepalived-1.2.18.tar.gz -C /usr/local/yum install -y openssl openssl-develcd keepalived-1.2.18/ && ./configure --
·
1.下载安装keepalived,并且做成linux系统服务
wget http://www.keepalived.org/download.html
tar -zxvf keepalived-1.2.18.tar.gz -C /usr/local/
yum install -y openssl openssl-devel
cd keepalived-1.2.18/ && ./configure --prefix=/usr/local/keepalived
make && make install
将keepalived安装成Linux系统服务
mkdir /etc/keepalived
cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/
cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/
cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
ln -s /usr/local/sbin/keepalived /usr/sbin/
ln -s /usr/local/keepalived/sbin/keepalived /sbin/
可以设置开机启动:
chkconfig keepalived on,
到此我们安装完毕!
2.写一个shell脚本,用于检测nginx是否启动,如果没有启动,尝试重启,如果还是不行,则关闭keepalived
脚本实例:
#!/bin/bash
a=`ps -C nginx --no-header | wc -l`
if [ $a -eq 0 ]
then
/usr/local/nginx/sbin/nginx
b=`ps -C nginx --no-header |wc -l`
if [ $b -eq 0 ]
then
killall keepalived
fi
fi
更多推荐
已为社区贡献2条内容
所有评论(0)