Lvs+Keepalived+Mysql
环境
[root@node1 ~]# cat /etc/redhat-release
CentOS Linux release 7.1. (Core)
[root@node1 ~]# uname -a
Linux node1 3.10.-.el7.x86_64 # SMP Fri Mar :: UTC x86_64 x86_64 x86_64 GNU/Linux
主机
IP NAME Describe
10.0.0.10 node1 主负载
10.0.0.11 node2 备负载
10.0.0.12 node3 节点
10.0.0.13 node4 节点
10.0.0.14 node5 节点
10.0.0.20 VIP
安装
[root@node1 ~]# yum install -y ipvsadm keepalived
[root@node2 ~]# yum install -y ipvsadm keepalived
主负载配置
[root@node1 ~]# vim /etc/keepalived/keepalived.conf
修改配置文件
! Configuration File for keepalived global_defs {
notification_email {
acassen@firewall.loc
failover@firewall.loc
sysadmin@firewall.loc
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id LVS_DEVEL
vrrp_skip_check_adv_addr
vrrp_strict
vrrp_garp_interval 0
vrrp_gna_interval 0
} vrrp_instance VI_1 {
state MASTER
interface eno16777736
virtual_router_id 51
priority 150
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.0.0.20/24 dev eno16777736 label eno16777736:0
}
} virtual_server 10.0.0.20 3306 {
delay_loop 6
lb_algo rr
lb_kind DR
persistence_timeout 50
protocol TCP real_server 10.0.0.12 3306 {
weight 1
MISC_CHECK {
misc_path "/etc/keepalived/check.sh 10.0.0.12"
misc_dynamic
}
}
real_server 10.0.0.13 3306 {
weight 1
MISC_CHECK {
misc_path "/etc/keepalived/check.sh 10.0.0.13"
misc_dynamic
}
}
real_server 10.0.0.14 3306 {
weight 1
MISC_CHECK {
misc_path "/etc/keepalived/check.sh 10.0.0.14"
misc_dynamic
}
}
}
备负载配置
[root@node2 ~]# vim /etc/keepalived/keepalived.conf
修改配置文件
! Configuration File for keepalived global_defs {
notification_email {
acassen@firewall.loc
failover@firewall.loc
sysadmin@firewall.loc
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id LVS_DEVEL_BACKUP
vrrp_skip_check_adv_addr
vrrp_strict
vrrp_garp_interval 0
vrrp_gna_interval 0
} vrrp_instance VI_1 {
state BACKUP
interface eno16777736
virtual_router_id 51
priority 50
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.0.0.20/24 dev eno16777736 label eno16777736:0
}
} virtual_server 10.0.0.20 3306 {
delay_loop 6
lb_algo rr
lb_kind DR
persistence_timeout 50
protocol TCP real_server 10.0.0.12 3306 {
weight 1
MISC_CHECK {
misc_path "/etc/keepalived/check.sh 10.0.0.12"
misc_dynamic
}
} real_server 10.0.0.13 3306 {
weight 1
MISC_CHECK {
misc_path "/etc/keepalived/check.sh 10.0.0.13"
misc_dynamic
}
}
real_server 10.0.0.14 3306 {
weight 1
MISC_CHECK {
misc_path "/etc/keepalived/check.sh 10.0.0.14"
misc_dynamic
}
}
}
自定义脚本做健康检查(node1和node2配置)
[root@node1 ~]# vim /etc/keepalived/check.sh
插入以下配置
#!/bin/bash mysql -uwsrep -pnx111111 -h$ -e "select 1;" &>/dev/null
ret=$?
if [ $ret -eq ];then
exit
else
exit
fi
启动服务
[root@node1 ~]# systemctl start keepalived
[root@node2 ~]# systemctl start keepalived
开机启动
[root@node1 ~]#systemctl enable keepalived
测试
关闭主负载keepalived,查看VIP是否漂移到备负载
[root@node1 ~]# systemctl stop keepalived
启动主负载keepalived,查看VIP是否漂移回来
[root@node1 ~]# systemctl start keepalived
Lvs+Keepalived+Mysql的更多相关文章
- Lvs+keepalived+mysql主从热备
p.MsoNormal,li.MsoNormal,div.MsoNormal { margin: 0cm; margin-bottom: .0001pt; text-align: justify; f ...
- LVS+Keepalived+Mysql+主备数据库架构[4台]
这是一个坑...磨了不少时间.见证自己功力有待提升... 架构图 数据库 1.安装数据库 这块不难, 直接引用:mysql安装 2.数据库主备 这块不难, 直接引用: mysql主备 虚拟VIP 重点 ...
- Lvs+keepalived+mysql(主从复制)
1.准备环境 操作系统:centos 6.5 2台机器主机名为node53.node54 Mysql Lvs keepalived node2 Y Y Y node3 Y Y Y ...
- Lvs+Keepalived+MySQL Cluster架设高可用负载均衡Mysql集群
------------------------------------- 一.前言 二.MySQL Cluster基本概念 三.环境 四.配置 1.LB-Master及LB-Backup配置 2.M ...
- LVS+Keepalived+Mysql+主主数据库架构[2台]
架构图 安装步骤省略. 158.140 keepalived.conf ! Configuration File for keepalived global_defs { #全局标识模块 notifi ...
- Mysql双主热备+LVS+Keepalived高可用操作记录
MySQL复制能够保证数据的冗余的同时可以做读写分离来分担系统压力,如果是主主复制还可以很好的避免主节点的单点故障.然而MySQL主主复制存在一些问题无法满足我们的实际需要:未提供统一访问入口来实现负 ...
- Lvs+Keepalived实现MySQL高可用
LVS+Keepalived+MySQL高可用配置 本文所有配置前提是已实现MySQL双主备份(MySQL双主) 安装前的准备: VIP:192.168.0.201 Keepalived: Keepa ...
- MySQL 高可用:mysql+Lvs+Keepalived 负载均衡及故障转移
系统信息: mysql主库 mysql从库 VIP 192.168.1.150 mysql 主主同步都设置 auto-increment-offset,auto-increment-increment ...
- 关于lvs+keepalived只加入一台realserver问题
今天做lvs+keepalived+mysql项目实施方案,在配置lvs+keepalived时都是ok的,但是就只加入第一台realserver.本人也感到很奇怪,lvs+keepalived本人也 ...
随机推荐
- 那些年实用但被我忘掉javascript属性.onresize
//获取屏幕宽度并动态赋值 var winWidth = 0; var winHeight = 0; function findDimensions() //函数:获取尺寸 { //获取窗口宽度 if ...
- AngularJs -- ngMessages(1.3+)
ngMessages(1.3+) 表单和验证是AngularJS中复杂的组件之一.用AngularJS默认的方式来写,不是特别好,不简洁. 在AngualrJS1.3发布前,表单验证必须以这种方式编写 ...
- 【问题收集·中级】关于XMPP使用Base传送图片
[问题收集·中级]关于XMPP使用Base传送图片 下面是我与博友的问答过程:并在最后链接附录了相应的文件: 博友问题: 16:35:38 他跟我说要 内容图片 base64编码 上传..博友问题 ...
- 按esc键 关闭模态框
<!-- help start --> <div class="modal fade" id="myModal" tabindex=" ...
- 第10月第5天 v8
1. brew install v8 http://www.cnblogs.com/tinyjian/archive/2017/01/17/6294352.html http://blog.csdn. ...
- C++ 修饰符类型
C++ 修饰符类型 C++ 允许在 char.int 和 double 数据类型前放置修饰符.修饰符用于改变基本类型的含义,所以它更能满足各种情境的需求. 下面列出了数据类型修饰符: signed u ...
- 八、mini2440裸机程序之UART(2)UART0与PC串口通信【转】
转自:http://blog.csdn.net/shengnan_wu/article/details/8309417 版权声明:本文为博主原创文章,未经博主允许不得转载. 1.相关原理图 2.相关寄 ...
- centos7执行 wget命令: command not found的两种解决方法
1.rpm 安装 下载wget的RPM包: http://mirrors.163.com/centos/6.8/os/x86_64/Packages/wget-1.12-8.el6.x86_64.rp ...
- mysql ON DUPLICATE KEY UPDATE重复插入时更新
mysql当插入重复时更新的方法: 第一种方法: 示例一:插入多条记录 假设有一个主键为 client_id 的 clients 表,可以使用下面的语句: INSERT INTO clients (c ...
- Linux下的snmpd.conf配置说明
SNMP(Simple Network Management Protocol,简单网络管理协议)的前身是简单网关监控协议(SGMP),用来对通信线路进行管理.在RHEL中,SNMP的配置文件地址是/ ...