mysql主从同步遇到的问题,线程正常,但是没有同步数据

需求:

将主库的表同步到从库,数据库名不一样,映射关系如下:

(pres_eims,riskdb),(pres_system,pres_system_slave),(pres_business,pre_business_slave),(pres_sp_business,pres_sp_business)

问题描述,两个线程都正常,relay_log中也有日志写入,但是没有写入数据库中

  Slave_IO_Running: Yes
  Slave_SQL_Running: Yes

relay-log中有日志,但是没有写入从库

1、使用mysqlbinlog工具查看二进制日志:


    mysqlbinlog mysql-relay-bin-126.000004  --base64-output=decode-row -vvv  --skip-gtids -vv | grep -B 1 -i 'insert into'

能查到日志。

问题解决:

去掉以下两个配置,

Replicate_Do_DB:

Replicate_Ignore_DB

这两个参数如果设置了,会导致Replicate_Rewrite_DB不生效。

完整的/etc/my.cnf

[mysqld]
character-set-server=utf8
server-id=3
log_bin=mysql-bin
relay_log=mysql-relay-bin
relay-log-index=mysql-relay-bin.index    
log_slave_updates=1
sync_relay_log=1
sync_relay_log_info=1
sync_master_info=1
sync_source_info=1
slave-skip-errors=all
#replicate-do-db=pres_eims,pres_system,pres_business,pres_sp_business,pres_options,test
#replicate-do-db=pres_system
#replicate-do-db=pres_business
#replicate-do-db=pres_sp_business
#replicate-ignore-db=pres_options
#replicate-ignore-db=test
#replicate-ignore-db=mysql
#replicate-ignore-db=trmp_business
#replicate-ignore-db=my_database
#replicate-ignore-db=information_schema
#replicate-ignore-db=pres_iams
replicate-rewrite-db=pres_eims -> riskdb
replicate-rewrite-db=pres_system -> pres_system_slave
replicate-rewrite-db=pres_business -> pre_business_slave
replicate-rewrite-db=pres_sp_business -> pres_sp_business

#replicate-rewrite-db=test -> test
#replicate-wild-do-table=riskdb.test01
#replicate-wild-do-table=riskdb.test02

port = 33066
basedir = /opt/mysql-8
datadir = /storage/mysql-8/data
#socket = /var/run/mysql/mysql.sock
#socket = /tmp/mysql/mysql.sock

character-set-server = utf8
#collation-server = unf8mb4_unicode_ci
max_connections = 1000
max_allowed_packet = 4000M
default_authentication_plugin = mysql_native_password
secure_file_priv = ''

[client]
port = 33066
#socket = /var/run/mysql/mysql.sock
#socket = /tmp/mysql/mysql.sock

附排查过程中使用的mysql语句:

how master status;

show slave hosts;

show variables like 'binlog_format';

show variables like '%binlog_format';

show variables;

set @@log_slave_updates=true

show variables like 'log-slave-updates';

 show variables like '%server%id%';
 
 
 show slave status;
 
 show processlist;
 
 flush table with read lock;
 
 UNLOCK tables;
 
 show tables ;
 
 show VARIABLES like 'CHARACTER_set_%'
 
  show VARIABLES like 'COLLATION_%'
 
    
    
    show variables like 'character_set_server'
    
    show VARIABLES like 'init_connect'
    
    
    show variables like '%relay%'
    
    show variables like '%version%'
    
    select @@binlog_format;

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值