Keepalive双主搭建配置

Keepalive 双主搭建配置

环境说明:

192.168.1.10  keepalive 主1

192.168.1.20  keepalive 主2

192.168.1.111  keepalive 主1  从2 VIP

192.168.1.222  keepalive 从1  主2 VIP

1 官网下载最新版本

keepalived-1.2.19

2 部署安装:

yum install gcc gcc-c++ make openssl openssl-devel

tar zxvf keepalived-1.2.19.tar.gz

cd keepalived-1.2.19

./configure --sysconf=/etc/ --with-kernel-dir=/usr/src/linux --prefix=/usr/local/keepalived

make ; make install

cp /usr/local/keepalive/sbin/keepalived /usr/bin/

cp /usr/local/keepalived/sbin/keepalived /usr/bin/

cp /usr/local/keepalived/etc/sysconfig/keepalived  /etc/sysconfig/

cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/

chkconfig keepalived on

3 建立配置文件:

vim /etc/keepalived/keepalived.conf

global_defs {

   notification_email {

     [email protected]

   }

   notification_email_from [email protected]

   smtp_server 127.0.0.1

   smtp_connect_timeout 30    

   router_id Mariadb_keepalive1

}

vrrp_script notification {

   script "/data/ops/script/mail.sh"

   interval 1

   weight 2

   }

vrrp_script check_alive {

   script "/data/ops/script/mysql_check.sh"

   interval 1

   weight 2

   }

vrrp_instance Mariadb_keepalive_channel1 {

    state MASTER

    interface eth0

    virtual_router_id 100

    priority 200

    advert_int 1

    authentication {

     auth_type PASS

     auth_pass 1111

    }

    virtual_ipaddress {

        192.168.1.111

    }

    track_script {

check_alive

    }

}

vrrp_instance Mariadb_keepalive_channel2 {

    state BACKUP

    interface eth0

    virtual_router_id 101

    priority 100

    advert_int 1

    authentication {

        auth_type PASS

        auth_pass 1111

    }

    virtual_ipaddress {

        192.168.1.222

    }

    track_script {

check_alive

    }

}

4  然后启动即可

/etc/init.d/keepalived start

5  Keepalive 另一主服务器除配置文件不一样,其他配置步骤如上,配置文件如下:

vim /etc/keepalived/keepalived.conf

global_defs {

   notification_email {

     [email protected]

   }

   notification_email_from [email protected]

   smtp_server 127.0.0.1

   smtp_connect_timeout 30    

   router_id Mariadb_keepalive

}

vrrp_script notification {

   script "/data/ops/script/mail.sh"

   interval 1

   weight 2

}

vrrp_script check_alive {

   script "/data/ops/script/mysql_check.sh"

   interval 1

   weight 2

}

vrrp_instance Mariadb_keepalive_channel1 {

    state BACKUP

    interface eth0

    virtual_router_id 100

    priority 100

    advert_int 1

    authentication {

     auth_type PASS

     auth_pass 1111

    }

    virtual_ipaddress {

        192.168.1.111

    }

    track_script {

check_alive

    }

}

vrrp_instance Mariadb_keepalive_channel2 {

    state MASTER

    interface eth0

    virtual_router_id 101

    priority 200

    advert_int 1

    authentication {

        auth_type PASS

        auth_pass 1111

    }

    virtual_ipaddress {

        192.168.1.222

    }

    track_script {

check_alive

    }

}

6  效果图:

两台同时运行:

192.168.1.10:

192.168.1.20

192.168.1.10 keepalive 关闭后:

时间: 2024-10-13 01:26:40

Keepalive双主搭建配置的相关文章

mysql 主从,双主简单配置

##创建两台版本相同的mysql 1.主节点修改配置文件 /etc/mysql/my.cf log-bin=master-bin                  #启用二进制日志 默认可以不改 # binary logging format - mixed recommended binlog_format=mixed # required unique id between 1 and 2^32 - 1 # defaults to 1 if master-host is not set #

Keepalived单双主模型配置

Keepalived单双主模型配置 Keepalived单主配置实例: 一.安装keepalived包 [[email protected] ~]# hostnamectl set-hostname keepalived-1 [[email protected] ~]# yum install keepalived.x86_64 主配置文件:/etc/keepalived/keepalived.conf主程序文件:/usr/sbin/keepalived 二.进行配置主配置文件: 主keepal

haproxy+keepalived主备与双主模式配置

Haproxy+Keepalived主备模式 主备节点设置 主备节点上各安装配置haproxy,配置内容且要相同 global log 127.0.0.1 local2 chroot /var/lib/haproxy pidfile /var/run/haproxy.pid maxconn 4000 user haproxy group haproxy daemon defaults #defaults段默认值对frontend和backend和listen段生效 mode http #运行模式

openldap 2.4双主MirrorMode配置

虽然主从配置提供了ldap的高可用性,但是当Master节点挂了的时候,还是需要做一些配置才能让Slave节点接管主节点的工作,但是多主的情况下,就可以直接替换主节点,甚至还可以使用keepalived来实现无缝切换.虽然官方给出的openldap 2.4有好几种replication的配置方法,但是以实际应用而言,还是syncrepl和mirror两种模式使用较多,所以这里来操作一下mirror mode. 环境说明: 直接在上一篇的syncrepl基础上进行,因为上一篇主从配置已经从最简单的

49.RocketMQ 双主搭建(本文非EamonSec原创)

声明:本文非EamonSec原创,copy自网上下载的某个个文件 1.RocketMQ介绍 1.1. 简介 RocketMQ 是一款分布式.队列模型的消息中间件,具有以下特点: 能够保证严格的消息顺序 提供丰富的消息拉取模式 高效的订阅者水平扩展能力 实时的消息订阅机制 亿级消息堆积能力 选用理由: l 强调集群无单点,可扩展,任意一点高可用,水平可扩展. l 海量消息堆积能力,消息堆积后,写入低延迟. l 支持上万个队列 l 消息失败重试机制 l 消息可查询 l 开源社区活跃 l 成熟度(经过

Keepalived 双实例双主模式配置

一.环境 A 业务在 lb01 上是主模式,在 lb02 上是备模式B 业务在 lb01 上是备模式,在 lb02 上是主模式 Hostname IP 说明 lb01 192.168.123.101 VIP :192.168.123.100 ( 用于绑定 A 服务 www.abc.com 域名 ) lb02 192.168.123.102 VIP :192.168.123.200 ( 用于绑定 B 服务 bbs.abc.com 域名) 二.配置 [[email protected]lb01 ~]

MYSQL 双主搭建

参考 mysql搭建安装完mysql后https://blog.51cto.com/popli3/2357211 服务器A 服务器B 192.168.0.104 192.168.0.105 在服务器A(192.168.0.104)上: 打开log-bin和server-id=1选项 [root@minion-2 ~]# vi /etc/my.cnflog-binserver-id=1 授权账户并重启 mysql> grant super,reload,replication slave on *

Keepalived双主模式配置流程

实验说明 1)keepalived 支持配置多个VRRP实例,每个实例对应一个业务 2)本次实验将实现 keepalived 的互为主备: 业务A:keepalived01为Master,keepalived02为Backup 业务B:keepalived01为Backup,keepalived02为Master 环境介绍 1)K1 Hostname:keepalived01.example.com IP:192.168.3.31 OS:Centos 7 2)K2 Hostname:keepal

初识MariaDB之9——keepalive+GTID双主实现高可用

一.背景介绍 传统的主从复制架构下,尽管可以使用半同步的方式进行读写分离,但是主节点仍然存在单点隐患,在规模不大的情况下可以采用keepalive+双主的模式对主节点进行高可用保护,客户端通过VIP访问MySQL服务器 二.实现方式 keepalive是通过vrrp协议实现,之前有过介绍这里不多赘述,要注意的是在云主机是禁用vrrp协议的.本次实验采用CentOS7.4,数据库版本为MariaDB-10.2.14,2台MySQL服务器互为主从,172.16.10.30/24为keepalived