使用PolarDB-X作为PolarDB-X的Slave

MySQL主从复制,分为Master和Slave两种角色,PolarDB-X的CDC提供的日志服务使PolarDB-X可以作为Master。同时,PolarDB-X的CDC还具备对标MySQL Replica的能力,使PolarDB-X作为Slave。

说明

  • 操作方式和使用MySQL作为PolarDB-X的Slave基本一致。

  • PolarDB-X提供的Replication SQL高度兼容MySQL,具体可参见Replication语句

  • 受限于网络,在通过控制台购买的PolarDB-X实例上,用户无法创建复制链路,该功能主要面向自建场景。

操作方法

  • 创建主从复制链路

    CHANGE MASTER TO option [, option] ... [ channel_option ]
    
    option: {
        MASTER_HOST = 'host_name'
      | MASTER_USER = 'user_name'
      | MASTER_PASSWORD = 'password'
      | MASTER_PORT = port_num
      | MASTER_LOG_FILE = 'source_log_name'
      | MASTER_LOG_POS = source_log_pos
      | MASTER_LOG_TIME_SECOND = source_log_time
      | ENABLE_SRC_LOGICAL_META_SNAPSHOT = {TRUE|FALSE}
      | SOURCE_HOST_TYPE = {RDS|POLARDBX|MYSQL}
      | STREAM_GROUP = 'stream_group_name'
      | WRITE_SERVER_ID = write_server_id
      | TRIGGER_AUTO_POSITION = {FALSE|TRUE}
      | WRITE_TYPE = {SPLIT|SERIAL|TRANSACTION|MERGE}
      | MODE = {INCREMENTAL|IMAGE}
      | CONFLICT_STRATEGY = {OVERWRITE|INTERRUPT|IGNORE|DIRECT_OVERWRITE}
      | IGNORE_SERVER_IDS = (server_id_list)
    }
    
    channel_option:
        FOR CHANNEL channel
    
    server_id_list:
        [server_id [, server_id] ... ]
  • 修改主从复制链路过滤配置

    CHANGE REPLICATION FILTER option [, option] ... [ channel_option ]
    
    option: {
        REPLICATE_DO_DB = 'do_db_list'
      | REPLICATE_IGNORE_DB = 'ignore_db_list'
      | REPLICATE_DO_TABLE = 'do_table'
      | REPLICATE_IGNORE_TABLE = 'ignore_table_list'
      | REPLICATE_WILD_DO_TABLE = 'wild_do_table_list'
      | REPLICATE_WILD_IGNORE_TABLE = 'wile_ignore_table_list'
      | REPLICATE_SKIP_TSO = 'tso_num'
      | REPLICATE_SKIP_UNTIL_TSO = 'tso_num'
      | REPLICATE_ENABLE_DDL = {TRUE|FALSE}
    }
    
    channel_option:
        FOR CHANNEL channel
  • 启动主从复制链路

    START {SLAVE | REPLICA} [channel_option]
    
    channel_option:
        FOR CHANNEL channel
  • 暂停主从复制链路

    STOP {SLAVE | REPLICA} [channel_option]
    
    channel_option:
        FOR CHANNEL channel
  • 删除主从复制链路(需要先停止数据复制进程)

    RESET {SLAVE | REPLICA} ALL [channel_option]
    
    channel_option:
        FOR CHANNEL channel