1

I set up MASTER->SLAVE database replication. Looks like everything fine, but when I change the master, the slave database is not updated. Exec_Master_Log_Pos on slave is updated when I update master db. I am enable logging on slave

log_output              = "FILE"
general_log_file        = /var/log/mysql/mysql.log
general_log             = 1

In the slave log only these records appear when I apply any changes to the master database:

220129 23:10:33      5 Query    BEGIN
                     5 Query    COMMIT /* implicit, from Xid_log_event */

master

5.7.36-0ubuntu0.18.04.1-log

slave

10.6.4-MariaDB-1:10.6.4+maria~focal-log

On the master the base is called alpha, on the slave - beta

master my.cfg

server-id = 1
log-bin = /mnt/sdb/var/lib/mysql/mysql-bin
binlog_do_db = alpha

slave my.cfg

server-id = 3
replicate-do-db     = beta

master

mysql> 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)

slave

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)

The binary log on the master is written after each change of the base. The slave also gets change notifications, but why doesn't the slave base get updated? I have tried this scheme on several servers and the result is always the same.

1 Answer 1

2

Your master is only binary logging alpha database changes and your slave is only applying changes to database beta.

Because the binary log is filtered to include only alpha, there won't be any beta changes there for the slave to apply.

Recommending avoiding all replication filtering unless you have a specific need. If you do have a need, recommend binlog_format=ROW to ensure things are always saved. See binlog_do_db reference manual for details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.