--主库slave用户
create user 'slaveuser'@'%' identified BY 'password';
grant replication slave on *.* to 'slaveuser'@'%';
--备份复制数据库
mysqldump -u root -p --all-databases > /usr/local/mariadb/backup/20230729alldb.sql
--排除系统库
mysql -e "show databases;" -uroot -p| grep -Ev "Database|information_schema|mysql|performance_schema|sys" | xargs mysqldump -u root -p --databases --single-transaction> /usr/local/mariadb/backup/20240913alldb.sql;
还原数据库
mariadb -u root -p im_inv< /usr/local/mariadb/backup/iminv20241024.sql
启动主从复制
change master to master_host='10.0.1.188',master_user='slaveuser',master_port=3306,master_password='password',master_log_file='mysql-bin.000025',master_log_pos=2952914 FOR CHANNEL 'wms'
10.1版本
CHANGE MASTER 'master-203' TO MASTER_HOST='192.168.0.203', MASTER_USER='rep', MASTER_PORT=3306, MASTER_PASSWORD='pass', MASTER_LOG_FILE='mysql-bin.000003', MASTER_LOG_POS=107;
多源复制跳过错误
STOP SLAVE 'wms';
SET @@default_master_connection = 'wms'; #指定要操作的通道名称
SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;
START SLAVE 'wms';
SET @@default_master_connection = '';
SHOW SLAVE 'wms' STATUS ;
错误处理
https://www.modb.pro/db/554625
未经允许不得转载:lxfamn » mysql mariadb 多源 主从复制 错误处理 跳过 slave