博客
关于我
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/

你可能感兴趣的文章
sql查询中 查询字段数据类型 int 与 String 出现问题
查看>>
org.apache.commons.beanutils.BasicDynaBean cannot be cast to ...
查看>>
org.apache.dubbo.common.serialize.SerializationException: com.alibaba.fastjson2.JSONException: not s
查看>>
sqlserver学习笔记(三)—— 为数据库添加新的用户
查看>>
org.apache.http.conn.HttpHostConnectException: Connection to refused
查看>>
org.apache.ibatis.binding.BindingException: Invalid bound statement错误一例
查看>>
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.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:processDebugManifest'
查看>>
org.hibernate.HibernateException: Unable to get the default Bean Validation factory
查看>>
org.hibernate.ObjectNotFoundException: No row with the given identifier exists:
查看>>
org.springframework.amqp.AmqpConnectException:java.net.ConnectException:Connection timed out:connect
查看>>
org.springframework.beans.factory.BeanDefinitionStoreException
查看>>
org.springframework.boot.context.properties.ConfigurationBeanFactoryMetadata
查看>>
org.springframework.boot:spring boot maven plugin丢失---SpringCloud Alibaba_若依微服务框架改造_--工作笔记012
查看>>
SQL-CLR 类型映射 (LINQ to SQL)
查看>>