码迷,mamicode.com
首页 > 其他好文 > 详细

keepalived主从 keepalived高可用

时间:2018-07-02 11:52:16      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:smt   cat   res   ofo   try   group   lte   col   dma   

keepalived 主 172.16.101.194
keepalived 从 172.16.101.193

keepalived 主

global_defs {
notification_email {br/>guoshaoliang789@163.com
}
notification_email_from guoshaoliang789@163.com
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}

vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 88
priority 100
advert_int 1
# nopreempt #不进行抢占操作
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
172.16.101.201
}

}

virtual_server 172.16.101.201 3306 {
delay_loop 2
# lb_algo/lb_kind 这两项注释掉了,在不注释掉的情况下,通过vip访问数据库,会发现3306端口号状态为filtered,将会导致vip切换之后数据库失联

lb_algo rr

# lb_kind NAT
nat_mask 255.255.255.0
persistence_timeout 60
protocol TCP
real_server 172.16.101.194 3306{
weight 3
# 自检程序,当本服务器mysql进程宕掉之后执行的脚本(keepalived自杀脚本)
notify_down /etc/keepalived/scripts/keepalived_down.sh
TCP_CHECK {
connect_timeout 10
nb_get_retry 3
delay_before_retry 3
connect_port 3306
}
}
}

keepalived 从

global_defs {
notification_email {
br/>guoshaoliang789@163.com
}
notification_email_from guoshaoliang789@163.com
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}

vrrp_sync_group VG_1 {
group {
VI_1
}
notify_master /etc/keepalived/sendmail.pl
}

vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 88
priority 90
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}

virtual_ipaddress {
    172.16.101.201
}

}
virtual_server 172.16.101.201 3306 {
delay_loop 2
# lb_algo/lb_kind 这两项注释掉了,在不注释掉的情况下,通过vip访问数据库,会发现3306端口号状态为filtered,将会导致vip切换之后数据库失联

lb_algo rr

# lb_kind NAT
nat_mask 255.255.255.0
persistence_timeout 60
protocol TCP
real_server 172.16.101.193 3306{
weight 3
# 自检程序,当本服务器mysql进程宕掉之后执行的脚本(keepalived自杀脚本)
notify_down /etc/keepalived/scripts/keepalived_down.sh
TCP_CHECK {
connect_timeout 10
nb_get_retry 3
delay_before_retry 3
connect_port 3306
}

}

keepalived_down.sh脚本

#!/bin/bash
service keepalived stop

keepalived主从 keepalived高可用

标签:smt   cat   res   ofo   try   group   lte   col   dma   

原文地址:http://blog.51cto.com/guoshaoliang789/2134923

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!