<< IBM IPV6 Can Cause Poor Java Performance - United States | 首页 | keepalived手册中未更新的功能挖掘及使用介绍_李小红_新浪博客 >>

安装配置keepalived 使nginx高可用

wget  ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.35.tar.gz

tar -zxvf pcre-8.35.tar.gz

cd pcre-8.35

./configure

make

make install

 

wget http://zlib.net/zlib-1.2.8.tar.gz

tar -zxvf zlib-1.2.8.tar.gz

cd zlib-1.2.8

./configure

make

make install

 

wget  http://nginx.org/download/nginx-1.7.0.tar.gz

tar -zvxf nginx-1.7.0.tar.gz

 

cd nginx1.7.0

./configure --with-pcre=/root/pcre-8.35 --with-zlib=/root/zlib-1.2.8

make && make install

 

 

 

 

yum install openssl-devel

 

wget  http://www.keepalived.org/software/keepalived-1.2.12.tar.gz

 

vi /etc/keepalived/keepalived.conf

10.124.55.134:

global_defs {

 

  notification_email {

[email protected]

  }

 

  notification_email_from [email protected]

  smtp_server 127.0.0.1

  smtp_connect_timeout 30

  router_id LVS_DEVEL

 

}

 

vrrp_script chk_http_port {

script "/opt/nginx_pid.sh" ############该脚本我们在后面书写

interval 2

weight 2

}

 

vrrp_instance VI_1 {

state MASTER        ############ 辅机为 BACKUP

interface eth0

virtual_router_id 51

mcast_src_ip 10.124.55.134

priority 102                  ########### 权值要比 back 高

advert_int 1

authentication {

auth_type PASS

auth_pass 1111

}

 

track_script { 

chk_http_port ### 执行监控的服务 

}

 

virtual_ipaddress {

 10.124.55.150 ############ 此处的虚拟IP 地址即 我们web所                                                      ####要访问的IP地址  必须在同一网段

}

 

}

10.124.55.135:

global_defs {

 

  notification_email {

[email protected]

  }

 

  notification_email_from [email protected]

  smtp_server 127.0.0.1

  smtp_connect_timeout 30

  router_id LVS_DEVEL

 

}

 

vrrp_script chk_http_port {

script "/opt/nginx_pid.sh" ############该脚本我们在后面书写

interval 2

weight 2

}

 

vrrp_instance VI_1 {

state BACKUP        ############ 辅机为 BACKUP

interface eth0

virtual_router_id 51

mcast_src_ip 10.124.55.135

priority 105                  ########### 权值要比 master 低

advert_int 1

authentication {

auth_type PASS

auth_pass 1111

}

 

track_script { 

chk_http_port ### 执行监控的服务 

}

 

virtual_ipaddress {

 10.124.55.150 ############ 此处的虚拟IP 地址即 我们web所                                                      ####要访问的IP地址  必须在同一网段

}

 

}

 

vi /opt/nginx_pid.sh

 

 

 

输入以下配置

 

nginxpid=`ps -C nginx --no-header | wc -l`

if [ $nginxpid -eq 0 ];then

/usr/local/nginx/sbin/nginx

sleep 5

  if [ `ps -C nginx --no-header | wc -l` -eq 0 ];then

  /etc/init.d/keepalived stop

  fi

fi

 

 

标签 : ,



发表评论 发送引用通报