博客
关于我
MQ RabbitMQ 高可用集群(四):Keepalived安装和配置
阅读量:277 次
发布时间:2019-03-01

本文共 2918 字,大约阅读时间需要 9 分钟。

Keepalived ???????????

Keepalived ??

Keepalived ?????????????????????????????????????? Nginx?Haproxy ?????????????Keepalived ???? web ????????????????? VRRP??????????????????????????????????? IP????????????

???????

1. ????

[root@localhost ~]# yum install -y openssl openssl-devel

2. ????

[root@localhost ~]# wget http://www.keepalived.org/software/keepalived-1.2.18.tar.gz[root@localhost ~]# tar -zxvf keepalived-1.2.18.tar.gz -C /usr/local/[root@localhost ~]# cd keepalived-1.2.18/ && ./configure --prefix=/usr/local/[root@localhost ~]# make && make install

3. ??

3.1 ?????

[root@localhost ~]# mkdir /etc/keepalived[root@localhost ~]# cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/[root@localhost ~]# cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/[root@localhost ~]# cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/[root@localhost ~]# ln -s /usr/local/sbin/keepalived /usr/sbin/[root@localhost ~]# rm /sbin/keepalived[root@localhost ~]# ln -s /usr/local/keepalived/sbin/keepalived /sbin/

3.2 ??????

[root@localhost ~]# chkconfig keepalived on

3.3 ????

?? keepalived.conf ?????

[root@localhost ~]# vi /etc/keepalived/keepalived.conf
79 ???Master???
vrrp_script chk_haproxy {    script "/etc/keepalived/haproxy_check.sh"    interval 2    weight -20}vrrp_instance VI_1 {    state MASTER    interface eno16777736    virtual_router_id 74    mcast_src_ip 192.168.11.74    priority 100    nopreempt    advert_int 1    authentication {        auth_type PASS        auth_pass bhz    }    track_script {        chk_haproxy    }    virtual_ipaddress {        192.168.11.70    }}
80 ???backup???
vrrp_script chk_haproxy {    script "/etc/keepalived/haproxy_check.sh"    interval 2    weight -20}vrrp_instance VI_1 {    state BACKUP    interface eno16777736    virtual_router_id 74    mcast_src_ip 192.168.11.75    priority 90    nopreempt    advert_int 1    authentication {        auth_type PASS        auth_pass bhz    }    track_script {        chk_haproxy    }    virtual_ipaddress {        192.168.1.70    }}

?????

1. ????

#!/bin/bashCOUNT=`ps -C haproxy --no-header |wc -l`if [ $COUNT -eq 0 ]; then    /usr/local/haproxy/sbin/haproxy -f /etc/haproxy/haproxy.cfg    sleep 2    if [ `ps -C haproxy --no-header |wc -l` -eq 0 ]; then        killall keepalived    fifi

2. ??

[root@localhost ~]# chmod +x /etc/keepalived/haproxy_check.sh

?????

1. ?? keepalived

[root@localhost ~]# service keepalived start | stop | status | restart

2. ?? Haproxy

[root@localhost ~]# /usr/local/haproxy/sbin/haproxy -f /etc/haproxy/haproxy.cfg

3. ??????

[root@localhost ~]# service keepalived start

4. ??????

[root@localhost ~]# ps -ef | grep haproxy[root@localhost ~]# ps -ef | grep keepalived

?????

  • 27 ????????? 27 ??? keepalived ???
  • 28 ??????? 28 ???????? VIP ??? 28 ????????? Haproxy ? Keepalived ???????

????

  • ??? Keepalived ?????????????????????????
  • ???? Haproxy ????? web ????????

转载地址:http://mnhx.baihongyu.com/

你可能感兴趣的文章
Struts2中使用Session的两种方法
查看>>
order by rand()
查看>>
Orderer节点启动报错解决方案:Not bootstrapping because of 3 existing channels
查看>>
org.apache.axis2.AxisFault: org.apache.axis2.databinding.ADBException: Unexpected subelement profile
查看>>
org.apache.commons.beanutils.BasicDynaBean cannot be cast to ...
查看>>
org.apache.dubbo.common.serialize.SerializationException: com.alibaba.fastjson2.JSONException: not s
查看>>
sqlserver学习笔记(三)—— 为数据库添加新的用户
查看>>
org.apache.ibatis.exceptions.PersistenceException:
查看>>
org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned
查看>>
org.apache.ibatis.type.TypeException: Could not resolve type alias 'xxxx'异常
查看>>
org.apache.poi.hssf.util.Region
查看>>
org.apache.xmlbeans.XmlOptions.setEntityExpansionLimit(I)Lorg/apache/xmlbeans/XmlOptions;
查看>>
org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /
查看>>
org.hibernate.HibernateException: Unable to get the default Bean Validation factory
查看>>
org.hibernate.ObjectNotFoundException: No row with the given identifier exists:
查看>>
SQL-CLR 类型映射 (LINQ to SQL)
查看>>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
查看>>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
查看>>
org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size exceeded
查看>>
org.tinygroup.serviceprocessor-服务处理器
查看>>