MySQL primary/secondary replication requires a primary database and a secondary database. The binary logging feature based on the Change Data Capture (CDC) feature of PolarDB-X allows you to configure a PolarDB-X database as the primary database. The CDC feature of PolarDB-X has the capabilities of the replication feature of MySQL. This allows you to configure a PolarDB-X database as the secondary database.
Usage notes
The configuration method of data replication from PolarDB-X to PolarDB-X is almost the same as that of data replication from PolarDB-X to MySQL. For more information, see Replicate data from PolarDB-X to MySQL.
The SQL statements for data replication provided by PolarDB-X are highly compatible with MySQL. For more information, see Replication.
Users cannot create replication links for PolarDB-X instances that are purchased in the PolarDB-X console due to network limits. In this case, the replication links mainly apply to self-managed databases.
Procedure
Execute the following statement to create a replication link.
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] ... ]
Execute the following statement to modify the filtering configurations of a replication link.
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
Execute the following statement to start data replication.
START {SLAVE | REPLICA} [channel_option] channel_option: FOR CHANNEL channel
Execute the following statement to stop data replication.
STOP {SLAVE | REPLICA} [channel_option] channel_option: FOR CHANNEL channel
Execute the following statement to reset data replication. Take note that you must stop your data replication task before you execute the following statement.
RESET {SLAVE | REPLICA} ALL [channel_option] channel_option: FOR CHANNEL channel