首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MySQL从复制不写入binlog文件

MySQL从复制不写入binlog文件
EN

Stack Overflow用户
提问于 2022-08-04 03:06:32
回答 1查看 192关注 0票数 2

我已经安装了3台MySQL服务器(8.0.29-0ubuntu0.22.04.2)来创建主从复制,如

主->从->二次从

我的问题是,当我更改主数据库时,它是通过binlog写主在从服务器中复制的,但是在从服务器上所做的更改不会在二级奴隶上被复制

我已经在从服务器中启用了log_slave_updates / log_replica_updates,但是没有任何工作。

代码语言:javascript
复制
[mysqld]

# bind-address          = 127.0.0.1
server-id               = 4
log_bin                 = /var/log/mysql/mysql-bin.log
binlog_expire_logs_seconds      = 2592000
max_binlog_size   = 100M
binlog_do_db            = replication_db_1
binlog_do_db            = replication_db_2
relay-log = /var/lib/mysql/ubuntu-vm8-relay-bin.log

log_slave_updates
log_replica_updates
# binlog_ignore_db      = include_database_name

同样的情况也发生在带有3台服务器的循环主复制中,即创建数据库xxxxx;单独复制所有3个节点,但没有复制多个层次结构的表创建查询。

代码语言:javascript
复制
mysql> show global variables like "%log%";
+------------------------------------------------+-------------------------------------------+
| Variable_name                                  | Value                                     |
+------------------------------------------------+-------------------------------------------+
| activate_all_roles_on_login                    | OFF                                       |
| back_log                                       | 151                                       |
| binlog_cache_size                              | 32768                                     |
| binlog_checksum                                | CRC32                                     |
| binlog_direct_non_transactional_updates        | OFF                                       |
| binlog_encryption                              | OFF                                       |
| binlog_error_action                            | ABORT_SERVER                              |
| binlog_expire_logs_auto_purge                  | ON                                        |
| binlog_expire_logs_seconds                     | 2592000                                   |
| binlog_format                                  | MIXED                                     |
| binlog_group_commit_sync_delay                 | 0                                         |
| binlog_group_commit_sync_no_delay_count        | 0                                         |
| binlog_gtid_simple_recovery                    | ON                                        |
| binlog_max_flush_queue_time                    | 0                                         |
| binlog_order_commits                           | ON                                        |
| binlog_rotate_encryption_master_key_at_startup | OFF                                       |
| binlog_row_event_max_size                      | 8192                                      |
| binlog_row_image                               | FULL                                      |
| binlog_row_metadata                            | MINIMAL                                   |
| binlog_row_value_options                       |                                           |
| binlog_rows_query_log_events                   | OFF                                       |
| binlog_stmt_cache_size                         | 32768                                     |
| binlog_transaction_compression                 | OFF                                       |
| binlog_transaction_compression_level_zstd      | 3                                         |
| binlog_transaction_dependency_history_size     | 25000                                     |
| binlog_transaction_dependency_tracking         | COMMIT_ORDER                              |
| expire_logs_days                               | 0                                         |
| general_log                                    | OFF                                       |
| general_log_file                               | /var/lib/mysql/ubuntu-vm8.log             |
| innodb_api_enable_binlog                       | OFF                                       |
| innodb_flush_log_at_timeout                    | 1                                         |
| innodb_flush_log_at_trx_commit                 | 1                                         |
| innodb_log_buffer_size                         | 16777216                                  |
| innodb_log_checksums                           | ON                                        |
| innodb_log_compressed_pages                    | ON                                        |
| innodb_log_file_size                           | 50331648                                  |
| innodb_log_files_in_group                      | 2                                         |
| innodb_log_group_home_dir                      | ./                                        |
| innodb_log_spin_cpu_abs_lwm                    | 80                                        |
| innodb_log_spin_cpu_pct_hwm                    | 50                                        |
| innodb_log_wait_for_flush_spin_hwm             | 400                                       |
| innodb_log_write_ahead_size                    | 8192                                      |
| innodb_log_writer_threads                      | ON                                        |
| innodb_max_undo_log_size                       | 1073741824                                |
| innodb_online_alter_log_max_size               | 134217728                                 |
| innodb_print_ddl_logs                          | OFF                                       |
| innodb_redo_log_archive_dirs                   |                                           |
| innodb_redo_log_encrypt                        | OFF                                       |
| innodb_undo_log_encrypt                        | OFF                                       |
| innodb_undo_log_truncate                       | ON                                        |
| log_bin                                        | ON                                        |
| log_bin_basename                               | /var/log/mysql/mysql-bin                  |
| log_bin_index                                  | /var/log/mysql/mysql-bin.index            |
| log_bin_trust_function_creators                | OFF                                       |
| log_bin_use_v1_row_events                      | OFF                                       |
| log_error                                      | /var/log/mysql/error.log                  |
| log_error_services                             | log_filter_internal; log_sink_internal    |
| log_error_suppression_list                     |                                           |
| log_error_verbosity                            | 2                                         |
| log_output                                     | FILE                                      |
| log_queries_not_using_indexes                  | ON                                        |
| log_raw                                        | OFF                                       |
| log_replica_updates                            | ON                                        |
| log_slave_updates                              | ON                                        |
| log_slow_admin_statements                      | OFF                                       |
| log_slow_extra                                 | OFF                                       |
| log_slow_replica_statements                    | OFF                                       |
| log_slow_slave_statements                      | OFF                                       |
| log_statements_unsafe_for_binlog               | ON                                        |
| log_throttle_queries_not_using_indexes         | 0                                         |
| log_timestamps                                 | UTC                                       |
| max_binlog_cache_size                          | 18446744073709547520                      |
| max_binlog_size                                | 104857600                                 |
| max_binlog_stmt_cache_size                     | 18446744073709547520                      |
| max_relay_log_size                             | 0                                         |
| relay_log                                      | /var/lib/mysql/ubuntu-vm8-relay-bin.log   |
| relay_log_basename                             | /var/lib/mysql/ubuntu-vm8-relay-bin       |
| relay_log_index                                | /var/lib/mysql/ubuntu-vm8-relay-bin.index |
| relay_log_info_file                            | relay-log.info                            |
| relay_log_info_repository                      | TABLE                                     |
| relay_log_purge                                | ON                                        |
| relay_log_recovery                             | OFF                                       |
| relay_log_space_limit                          | 0                                         |
| slow_query_log                                 | ON                                        |
| slow_query_log_file                            | /var/log/mysql/mysql-slow.log             |
| sql_log_off                                    | OFF                                       |
| sync_binlog                                    | 1                                         |
| sync_relay_log                                 | 10000                                     |
| sync_relay_log_info                            | 10000                                     |
| terminology_use_previous                       | NONE                                      |
+------------------------------------------------+-------------------------------------------+
90 rows in set (0.00 sec)

奴隶1:

代码语言:javascript
复制
mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for source to send event
                  Master_Host: 192.168.203.88
                  Master_User: replicator
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000002
          Read_Master_Log_Pos: 157
               Relay_Log_File: ubuntu-vm8-relay-bin.000006
                Relay_Log_Pos: 373
        Relay_Master_Log_File: mysql-bin.000002
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB: 
          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: 157
              Relay_Log_Space: 635
              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_UUID: 0f426665-12fa-11ed-b411-080027e54a70
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Replica has read all relay log; waiting for more updates
           Master_Retry_Count: 86400
                  Master_Bind: 
      Last_IO_Error_Timestamp: 
     Last_SQL_Error_Timestamp: 
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
           Retrieved_Gtid_Set: 
            Executed_Gtid_Set: 
                Auto_Position: 0
         Replicate_Rewrite_DB: 
                 Channel_Name: 
           Master_TLS_Version: 
       Master_public_key_path: 
        Get_master_public_key: 1
            Network_Namespace: 
1 row in set, 1 warning (0.00 sec)

奴隶2(二级奴隶)

代码语言:javascript
复制
mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for source to send event
                  Master_Host: 192.168.202.120
                  Master_User: replicator
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000002
          Read_Master_Log_Pos: 157
               Relay_Log_File: ubuntu-vm7-relay-bin.000005
                Relay_Log_Pos: 326
        Relay_Master_Log_File: mysql-bin.000002
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB: 
          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: 157
              Relay_Log_Space: 757
              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: 4
                  Master_UUID: d2dc13dc-12f9-11ed-b7d6-080027d93010
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Replica has read all relay log; waiting for more updates
           Master_Retry_Count: 86400
                  Master_Bind: 
      Last_IO_Error_Timestamp: 
     Last_SQL_Error_Timestamp: 
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
           Retrieved_Gtid_Set: 
            Executed_Gtid_Set: 
                Auto_Position: 0
         Replicate_Rewrite_DB: 
                 Channel_Name: 
           Master_TLS_Version: 
       Master_public_key_path: 
        Get_master_public_key: 1
            Network_Namespace: 
1 row in set, 1 warning (0.01 sec)

知道怎么解决这个问题吗?

谢谢!!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-08-26 13:40:29

如果在binlog_do_db中添加mysql.conf,则只有数据库级别的更改(如create database xxxdrop database xxx )仅在所有3台mysql服务器上受影响

只需注释掉binlod_do_db,并重新启动mysql

在复制组的所有3个节点中,所有数据库级别、表级别的更改都会受到影响。

https://dev.mysql.com/doc/refman/5.7/en/replication-options-binary-log.html#option_mysqld_binlog-do-db

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73229933

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档