MariaDB 一主多从配置
波罗科技
2022-12-12
1、要想实现AB复制,那么前提是master上必须要开启二进制日志
vi /etc/my.cnf为各个库设置唯一的SERVER ID
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
server-id=1
log-bin=/var/lib/mysql/mysql-bin
2、在主库创建复制用户
grant replication slave on *.* to 'xbido'@'172.20.28.%' identified by 'Xx123456'; flush privileges;3、在master端查看
show variables like "log_bin"; show master status;+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000001 | 341 | | |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
记下FILE及位置
4、分别开启两台从库
stop slave; change master to master_host='172.20.28.36',master_port=3306,master_user='xbido',master_password='Xx123456', master_log_file='mysql-bin.000001', master_log_pos=341; flush privileges; start slave;
会员留言
注意 不支持HTML代码!