alert! replicate_do_db pit!

EDITORIAL:
I use the traditional way to build a home from the environment, the main library update records, the library can not synchronize data from the past, from the same replication status, Read_Master_Log_Pos and Exec_Master_Log_Pos viewing from the main library, I / O, SQL threads are normal , from the delay occurs no master, no artificial delay set update parameters, and the main library binlog relay log from the library has a corresponding record update, without copying any information related to the error from the error log repository. If you and I are the same situation, and I, like you might encounter a copy of filtering rules "pit"

environment:
MySQL5.6 (MySQL5.7, MySQL8 not personally measured before)

scene reproduction:

Master Configuration:
[mysqld ]
DATADIR = / Home / Data / mysql3306 /
Port = 3306
the server_id =. 1
binlog_format = Row
log_bin = / Home / Data / mysql3306 / the binlog

SLAVE configuration:
[mysqld]
DATADIR = / Home / Data / mysql3306 /
Port = 3306
binlog_format = Row
= 2 the server_id
relay_log = / Home / Data / mysql3306 / relaylog
replicate_do_db = edusoho_e, statis

Master connected users authorized to copy:
mysql> grant replication slave on *.*to repliter@'192.168.32.2' identified by PASSWORD ' *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9';
Query OK, 0 rows affected (0.01 sec)


mysql> flush logs;
Query OK, 0 rows affected (0.03 sec)

mysql> show master status;
+---------------+----------+--------------+------------------+-------------------+
| File          | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+---------------+----------+--------------+------------------+-------------------+
| binlog.000004 |      120 |              |                  |                   |
+---------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)

Slave开启数据复制:
CHANGE MASTER TO MASTER_HOST='192.168.32.3',MASTER_USER='repliter',MASTER_PASSWORD='123456',MASTER_PORT=3306,MASTER_LOG_FILE='binlog.000004',MASTER_LOG_POS=120;
Query OK, 0 rows affected, 2 warnings (0.05 sec)

mysql> start slave;
Query OK, 0 rows affected (0.03 sec)

mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: edusoho_e,statis

主从复制状态正常!

Master变更了数据:
mysql> create database edusoho_e;
Query OK, 1 row affected (0.00 sec)

mysql> use edusoho_e;
Database changed

CREATE TABLE `t1` (
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`xname` VARCHAR(20) NOT NULL DEFAULT '',
`address` CHAR(20) NOT NULL DEFAULT '',
`sex` TINYINT(1) NOT NULL DEFAULT '1',
`hobby` VARCHAR(30) NOT NULL DEFAULT '',
`age` TINYINT(2) DEFAULT '18',
PRIMARY KEY (`id`),
KEY `idx_name` (`xname`)
) ENGINE=INNODB DEFAULT CHARSET=utf8;

mysql> INSERT INTO `edusoho_e`.`t1` (`xname`, `address`, `hobby`) VALUES ('edusoho_e', 'ldl', 'dba');
Query OK, 1 row affected (0.01 sec)

mysql> show master status;
+---------------+----------+--------------+------------------+-------------------+
| File          | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+---------------+----------+--------------+------------------+-------------------+
| binlog.000004 |      882 |              |                  |                   |
+ ---------- + -------------- + --------------- + ------- + ------------------- + -----------
1 Row in the SET (0.00 sec)

binlog log Master is normal

but you Slave host can not see the new table and its data
Slave:
MySQL> Show Databases;
+ -------------------- +
| Database |
+ ----- + ---------------
| information_schema |
| MySQL |
| performance_schema |
| the Test |
+ -------------------- +
4 rows in set (0.00 sec)

to view the status of the master copy from:
MySQL> Show Slave status \ G;
***************************. 1 . Row ***************************
Slave_IO_State: Waiting for Master to the send Event
MASTER_HOST: 192.168.32.3
MASTER_USER: repliter
MASTER_PORT: 3306
Connect_Retry: 60
Master_Log_File: binlog.000004
Read_Master_Log_Pos: 882
Relay_Log_File: relaylog.000002
RELAY_LOG_POS: 1042
Relay_Master_Log_File: binlog.000004
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: edusoho_e, statis
Exec_Master_Log_Pos: 882
Seconds_Behind_Master: 0
SQL_Delay: 0

You will find I / O, SQL thread is normal; and Exec_Master_Log_Pos Read_Master_Log_Pos same value; the Seconds_Behind_Master 0 if no master from the delay occurred; SQL_Delay 0 if no delay is inserted subjective disposed; although filtering rules provided from the master, but only replicate the library, is it the Slave relay log out of the question, there is no record Master of logs?

Slave relay log to analyze the log, you will also find a corresponding log of the Master
[root @ slave mysql3306] # mysqlbinlog -v --base64-output = decode relaylog.000002
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#190530  9:32:17 server id 2  end_log_pos 120 CRC32 0x35d47ba3  Start: binlog v 4, server v 5.6.16-log created 190530  9:32:17
# at 120
#700101  8:00:00 server id 1  end_log_pos 0 CRC32 0x0166516e    Rotate to binlog.000004  pos: 120
# at 164
#190530  9:29:02 server id 1  end_log_pos 0 CRC32 0xfea4f75a    Start: binlog v 4, server v 5.6.16-log created 190530  9:29:02
# at 280
#190530  9:35:18 server id 1  end_log_pos 229 CRC32 0x6b0d2047  Query   thread_id=2 exec_time=0 error_code=0
SET TIMESTAMP=1559180118/*!*/;
SET @@session.pseudo_thread_id=2/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
SET @@session.sql_mode=1073741824/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8 *//*!*/;
SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=33/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
create database edusoho_e
/*!*/;
# at 389
#190530  9:35:31 server id 1  end_log_pos 653 CRC32 0x1268f754  Query   thread_id=2 exec_time=0 error_code=0
use `edusoho_e`/*!*/;
SET TIMESTAMP=1559180131/*!*/;
CREATE TABLE `t1` (
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`xname` VARCHAR(20) NOT NULL DEFAULT '',
`address` CHAR(20) NOT NULL DEFAULT '',
`sex` TINYINT(1) NOT NULL DEFAULT '1',
`hobby` VARCHAR(30) NOT NULL DEFAULT '',
`age` TINYINT(2) DEFAULT '18',
PRIMARY KEY (`id`),
KEY `idx_name` (`xname`)
) ENGINE=INNODB DEFAULT CHARSET=utf8

/*!*/;
# at 813
#190530  9:35:41 server id 1  end_log_pos 730 CRC32 0x20610ab1  Query   thread_id=2 exec_time=0 error_code=0
SET TIMESTAMP=1559180141/*!*/;
BEGIN
/*!*/;
# at 890
#190530  9:35:41 server id 1  end_log_pos 791 CRC32 0xc2edbad8  Table_map: `edusoho_e`.`t1` mapped to number 540
# at 951
#190530  9:35:41 server id 1  end_log_pos 851 CRC32 0xaa57d74f  Write_rows: table id 540 flags: STMT_END_F
### INSERT INTO `edusoho_e`.`t1`
### SET
###   @1=1
###   @2='edusoho_e'
###   @3='ldl'
###   @4=1
###   @5='dba'
###   @6=18

# at 1011
#190530  9:35:41 server id 1  end_log_pos 882 CRC32 0x7de64644  Xid = 1350
COMMIT/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;

View Slave error log, I did not see any replication error-related information

so the question is, which may be suffered BUG! I have forgotten, is someone chiefs said in a blog or see in too, if Slave configured replicate_do_db filtering rules, if written in the following form:
replicate_do_db = edusoho_e, statis may experience BUG, need to write separately
= edusoho_e replicate_do_db
replicate_do_db = statis


restart Slave to verify conjecture

Master:
MySQL> the flush logs;
Query the OK, 0 rows affected (0.44 sec)

MySQL> Show Master Status;
+ --------------- + -------------- + ------------------ + ---------- + ---- + ---------------
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+ --------------- + ------ ---- ----------- + -------------- + ------------------ + + --------
| binlog.000005 | 120 | | | |
+---------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)

SET @@session.sql_log_bin=0;

DROP DATABASE `edusoho_e`;

mysql> create database edusoho_e;
Query OK, 1 row affected (0.00 sec)

mysql> use edusoho_e;
Database changed

CREATE TABLE `t1` (
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`xname` VARCHAR(20) NOT NULL DEFAULT '',
`address` CHAR(20) NOT NULL DEFAULT '',
`sex` TINYINT(1) NOT NULL DEFAULT '1',
`hobby` VARCHAR(30) NOT NULL DEFAULT '',
`age` TINYINT(2) DEFAULT '18',
PRIMARY KEY (`id`),
KEY `idx_name` (`xname`)
) ENGINE=INNODB DEFAULT CHARSET=utf8;

mysql> INSERT INTO `edusoho_e`.`t1` (`xname`, `address`, `hobby`) VALUES ('edusoho_e', 'ldl', 'dba');
Query OK, 1 row affected (0.01 sec)

Slave:
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| edusoho_e          |
| mysql              |
| performance_schema |
| test               |
+--------------------+
5 rows in set (0.00 sec)

mysql> select * from edusoho_e.t1;
+----+-----------+---------+-----+-------+------+
| id | xname     | address | sex | hobby | age  |
+----+-----------+---------+-----+-------+------+
| 1 | edusoho_e | LDL | 1 | dba | 18 |
+ ---- + ----- + ----------- + --------- + --- + ------ + ----
1 Row in the SET (0.00 sec)

you will find the new tables and data synchronization are passed, indicating that indeed "pit" replicate_do_db filtering rules

Guess you like

Origin blog.51cto.com/20131104/2402468