mysql8 keepalived_MySQL8 Keepalived+双主

1. 配置双主:

双机名

win89.inno.com

win88.inno.com

准备账号

SET SQL_LOG_BIN=0;

set passwordfor ‘root‘@‘localhost‘=‘123456‘;

grant all privileges on*.* to root@‘localhost‘with grant option;

create user‘repl‘@‘win88.inno.com‘ identified WITH mysql_native_password by ‘123456‘PASSWORD EXPIRE NEVER ;

grant replication slave on*.* to ‘repl‘@‘win88.inno.com‘with grant option;

create user‘repl‘@‘win89.inno.com‘ identified WITH mysql_native_password by ‘123456‘PASSWORD EXPIRE NEVER ;

grant replication slave on*.* to ‘repl‘@‘win89.inno.com‘with grant option;

create user‘repl‘@‘192.168.68.88‘ identified WITH mysql_native_password by ‘123456‘PASSWORD EXPIRE NEVER ;

grant replication slave on*.* to ‘repl‘@‘192.168.68.88‘with grant option;

create user‘repl‘@‘192.168.68.89‘ identified WITH mysql_native_password by ‘123456‘PASSWORD EXPIRE NEVER ;

grant replication slave on*.* to ‘repl‘@‘192.168.68.89‘with grant option;

flush privileges;

SET SQL_LOG_BIN=1;

配置主从

设win88.inno.com 的主机

change master to master_host=‘win89.inno.com‘,master_port=3308,master_user=‘repl‘,master_password=‘123456‘,master_auto_position=1;

start slave;

show slave status\G

设win89.inno.com 的主机

change master to master_host=‘win88.inno.com‘,master_port=3308,master_user=‘repl‘,master_password=‘123456‘,master_auto_position=1;

start slave;

show slave status\G

设置mysql 开机自启

cp -p /data/mysql/support-files/mysql.server /etc/init.d/mysqld

chkconfig--add mysqldcp -p /data/3308/my.cnf /etc/my.cnf.d/my.cnf

chkconfig --list

安装keepalive

yum -y install keepalived

win89.inno.com 的keepalived 设定

[root@win89 ~]# cat /etc/keepalived/keepalived.conf! Configuration File forkeepalived

global_defs {

router_id mysql_slave_

vrrp_skip_check_adv_addr

vrrp_script check_run {

script"/data/mysql_check.sh"interval10}

vrrp_garp_interval0vrrp_gna_interval0}

vrrp_instance VI_1 {

state BACKUP

interface ens160

virtual_router_id51priority90advert_int1authentication {

auth_type PASS

auth_pass1111}

virtual_ipaddress {192.168.68.188}

track_script {

check_run

}

}

virtual_server192.168.68.188 3308{

delay_loop6lb_algo wrr

lb_kind DR

nat_mask255.255.255.0persistence_timeout50protocol TCP

real_server192.168.68.89 3308{

weight1TCP_CHECK {

connect_timeout3nb_get_retry3connect_port3308}

}

}

win88.inno.com 的keepalived 设定

[root@win88 ~]# cat /etc/keepalived/keepalived.conf! Configuration File forkeepalived

global_defs {

router_id mysql_master_

vrrp_skip_check_adv_addr

vrrp_script check_run {

script"/data/mysql_check.sh"interval10}

vrrp_garp_interval0vrrp_gna_interval0}

vrrp_instance VI_1 {

state BACKUP

interface ens160

virtual_router_id51priority100advert_int1authentication {

auth_type PASS

auth_pass1111}

virtual_ipaddress {192.168.68.188}

track_script {

check_run

}

}

virtual_server192.168.68.188 3308{

delay_loop6lb_algo wrr

lb_kind DR

nat_mask255.255.255.0persistence_timeout50protocol TCP

real_server192.168.68.88 3308{

weight1TCP_CHECK {

connect_timeout3nb_get_retry3connect_port3308}

}

}

设置keepalived 开机自启

systemctl enable keepalived systemctl start keepalived

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值