Mysql + keepalive高可用创建
发布时间:2022-06-25 10:20 所属栏目:115 来源:互联网
导读:系统环境:centos6.8 Ip:192.168.137.36 主库 192.168.137.38 从库 主从搭建略 Mysql1 vim /etc/my.cnf binlog-do-db=test log-bin=mysql-bin server-id=1 gtid-mode=ON enforce-gtid-consistency Mysql2 Vim /etc/my.cnf gtid-mode=ON enforce-gtid-consis
系统环境:centos6.8 Ip:192.168.137.36 主库 192.168.137.38 从库 主从搭建略 Mysql1 vim /etc/my.cnf binlog-do-db=test log-bin=mysql-bin server-id=1 gtid-mode=ON enforce-gtid-consistency Mysql2 Vim /etc/my.cnf gtid-mode=ON enforce-gtid-consistency log-bin=mysql-bin log-slave-updates=ON server-id=3 binlog-do-db=test 安装keepalived yum install keepalived 在192.168.137.36主库修改keepalived的配置文件 注意:加颜色部分为修改部分 [root@zabbix ~]# cat /etc/keepalived/keepalived.conf ! Configuration File for keepalived global_defs{ notification_email { root@localhost } smtp_server 127.0.0.1 smtp_connect_timeout 30 router_id LVS_DEVEL } #VIP1 vrrp_instance VI_1 { state BACKUP interface eth0 lvs_sync_daemon_inteface eth0 virtual_router_id 151 priority 100 advert_int 5 nopreempt authentication { auth_type PASS auth_pass 2222 保存退出 在192.168.137.38从库修改keepalived的配置文件 [root@localhost sh]# cat /etc/keepalived/keepalived.conf ! Configuration File for keepalived global_defs{ notification_email { root@localhost } smtp_server 127.0.0.1 smtp_connect_timeout 30 router_id LVS_DEVEL } #VIP1 vrrp_instance VI_1 { state BACKUP interface eth0 lvs_sync_daemon_inteface eth0 virtual_router_id 151 priority 98 advert_int 5 nopreempt authentication { auth_type PASS auth_pass 2222 } virtual_ipaddress { 192.168.137.100 } } virtual_server 192.168.137.100 3306 { delay_loop 6 lb_algo wrr lb_kind DR persistence_timeout 60 protocol TCP real_server 192.168.137.38 3306 { weight 98 notify_down /data/sh/mysql.sh TCP_CHECK { connect_timeout 10 nb_get_retry 3 delay_before_retry 3 connect_port 3306 } } } 保存退出 上面的配置简单说明: state BACKUP 表示为备模式,nopreempt 为不抢占,双方都配为备模式,并且不抢占,可以避免“脑裂”问题,priority 100 为权重,数字越高,权重越高,当双方都配为BACKUP模式,并且配置nopreempt时,keepalived靠这个数字来判断谁是主,谁是备 主从都要创建/data/sh/mysql.sh脚本 real_server 192.168.137.36 改为 real_server 192.168.137.38其他不变。 (编辑:ASP站长网) |
相关内容
网友评论
推荐文章
热点阅读