我设置了主->从数据库复制.看起来一切都很好,但是当我更改主程序时,没有更新从数据库。当我更新主数据库时,会更新从服务器上的Exec_Master_Log_Pos。我正在启用从服务器登录。
log_output = "FILE"
general_log_file = /var/log/mysql/mysql.log
general_log = 1在从日志中,当我将任何更改应用到主数据库时,只会显示这些记录:
220129 23:10:33 5 Query BEGIN
5 Query COMMIT /* implicit, from Xid_log_event */5.7.36-0ubuntu0.18.04.1-log
10.6.4-MariaDB-1:10.6.4+maria~焦点日志
在主程序上,基名为alpha,在从测试版上。
server-id = 1
log-bin = /mnt/sdb/var/lib/mysql/mysql-bin
binlog_do_db = alphaserver-id = 3
replicate-do-db = betamysql> SHOW MASTER STATUS\G
*************************** 1. row ***************************
File: mysql-bin.000006
Position: 24181
Binlog_Do_DB: alpha
Binlog_Ignore_DB:
Executed_Gtid_Set:
1 row in set (0.00 sec)MariaDB [(none)]> SHOW SLAVE STATUS\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 144.217.157.211
Master_User: beta_user
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000006
Read_Master_Log_Pos: 24181
Relay_Log_File: mysqld-relay-bin.000010
Relay_Log_Pos: 5097
Relay_Master_Log_File: mysql-bin.000006
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: beta
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 24181
Relay_Log_Space: 5407
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 1
Master_SSL_Crl:
Master_SSL_Crlpath:
Using_Gtid: No
Gtid_IO_Pos:
Replicate_Do_Domain_Ids:
Replicate_Ignore_Domain_Ids:
Parallel_Mode: optimistic
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
Slave_DDL_Groups: 0
Slave_Non_Transactional_Groups: 0
Slave_Transactional_Groups: 0
1 row in set (0.001 sec)主站上的二进制日志是在基座每次更改后写入的。从服务器也会收到更改通知,但是为什么没有更新从基呢?我在几个服务器上尝试过这个方案,结果总是一样的。
发布于 2022-01-30 22:07:01
您的主程序只是二进制日志记录alpha数据库更改,而您的从服务器只将更改应用到数据库beta。
因为二进制日志被过滤为只包含alpha,所以在那里不会对从属程序进行任何beta更改。
建议避免所有复制筛选,除非您有特定的需要。如果您确实有需要,请推荐binlog_format=ROW,以确保总是保存东西。详情请参见联木_做_db参考手册。
https://dba.stackexchange.com/questions/306769
复制相似问题