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 ~]# cat /etc/keepalived/keepalived.conf
! Configuration File for keepalived    

global_defs {
   notification_email {
     [email protected]
   }
   notification_email_from [email protected]
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id lb01
}

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 55
    priority 150
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.123.100/24 dev eth0 label eth0:1
    }
}

vrrp_instance VI_2 {
    state BACKUP
    interface eth0
    virtual_router_id 56
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.123.200/24 dev eth0 label eth0:2
    }
}
[[email protected]lb02 ~]# cat /etc/keepalived/keepalived.conf
! Configuration File for keepalived    

global_defs {
   notification_email {
     [email protected]
   }
   notification_email_from [email protected]
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id lb02
}

vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    virtual_router_id 55
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.123.100/24 dev eth0 label eth0:1
    }
}

vrrp_instance VI_2 {
    state MASTER
    interface eth0
    virtual_router_id 56
    priority 150
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.123.200/24 dev eth0 label eth0:2
    }
}
[[email protected] ~]# /etc/init.d/keepalived restart    # 查看 lb01 上的主服务器[[email protected] ~]# ip addr | egrep "192.168.123.100|192.168.123.200"    inet 192.168.123.100/24 scope global secondary eth0:1
[[email protected] ~]# /etc/init.d/keepalived restart    # 查看 lb02 上的主服务器
[[email protected] ~]# ip addr | egrep "192.168.123.100|192.168.123.200"
    inet 192.168.123.200/24 scope global secondary eth0:2
[[email protected] ~]# /etc/init.d/keepalived stop       # 停掉 lb01 看会不会切换到 lb02[[email protected] ~]# ip addr | egrep "192.168.123.100|192.168.123.200"    inet 192.168.123.200/24 scope global secondary eth0:2    inet 192.168.123.100/24 scope global secondary eth0:1
[[email protected] ~]# /etc/init.d/keepalived start      # 再次启动看会不会切换回来
[[email protected] ~]# ip addr | egrep "192.168.123.100|192.168.123.200"
    inet 192.168.123.100/24 scope global secondary eth0:1
时间: 2024-10-13 12:02:14

Keepalived 双实例双主模式配置的相关文章

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 #运行模式

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

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 #

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 # but will not f

keepalived双实例配置

一.keepalived双实例 keepalived在master/backup工作模式下,会有一个主机处于闲置,所以keepalived可以使用vrrp的特性配置双master模式,使资源最大化.     1.承接上文配置 --->  keepalived基础配置     2.双主配置 第一个节点: [[email protected] keepalived]# grep -Ev '#|^$' keepalived.conf ! Configuration File for keepalive

KeepAlived双主模式高可用集群

一.keepalived简介 keepalived是vrrp协议的实现,原生设计目的是为了高可用ipvs服务,keepalived能够配置文件中的定义生成ipvs规则,并能够对各RS的健康状态进行检测:通过共用的虚拟IP地址对外提供服务:每个热备组内同一时刻只有一台主服务器提供服务,其他服务器处于冗余状态,若当前在线的服务器宕机,其虚拟IP地址将会被其他服务器接替(优先级决定接替顺序),实现高可用为后端主机提供服务.   二.keepalived组件 Keepalived组件介绍 core:ke

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

nginx+keepalived高可用及双主模式

高可用有2中方式. 1.Nginx+keepalived 主从配置 这种方案,使用一个vip地址,前端使用2台机器,一台做主,一台做备,但同时只有一台机器工作,另一台备份机器在主机器不出现故障的时候,永远处于浪费状态,对于服务器不多的网站,该方案不经济实惠. 2.Nginx+keepalived 双主配置 这种方案,使用两个vip地址,前端使用2台机器,互为主备,同时有两台机器工作,当其中一台机器出现故障,两台机器的请求转移到一台机器负担,非常适合于当前架构环境. 1.Nginx+keepali

keepalived主从及双主配置

原文链接:https://www.cnblogs.com/mmdln/p/8988951.html 高可用有2中方式. 1.Nginx+keepalived 主从配置 这种方案,使用一个vip地址,前端使用2台机器,一台做主,一台做备,但同时只有一台机器工作,另一台备份机器在主机器不出现故障的时候,永远处于浪费状态,对于服务器不多的网站,该方案不经济实惠. 2.Nginx+keepalived 双主配置 这种方案,使用两个vip地址,前端使用2台机器,互为主备,同时有两台机器工作,当其中一台机器