CHANGE REPLICATION SOURCE TOoption
[,option
] ... [channel_option
]option
: { SOURCE_BIND = 'interface_name
' | SOURCE_HOST = 'host_name
' | SOURCE_USER = 'user_name
' | SOURCE_PASSWORD = 'password
' | SOURCE_PORT =port_num
| PRIVILEGE_CHECKS_USER = {'account
' | NULL} | REQUIRE_ROW_FORMAT = {0|1} | REQUIRE_TABLE_PRIMARY_KEY_CHECK = {STREAM | ON | OFF} | ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS = {OFF | LOCAL |uuid
} | SOURCE_LOG_FILE = 'source_log_name
' | SOURCE_LOG_POS =source_log_pos
| SOURCE_AUTO_POSITION = {0|1} | RELAY_LOG_FILE = 'relay_log_name
' | RELAY_LOG_POS =relay_log_pos
| SOURCE_HEARTBEAT_PERIOD =interval
| SOURCE_CONNECT_RETRY =interval
| SOURCE_RETRY_COUNT =count
| SOURCE_CONNECTION_AUTO_FAILOVER = {0|1} | SOURCE_DELAY =interval
| SOURCE_COMPRESSION_ALGORITHMS = 'value
' | SOURCE_ZSTD_COMPRESSION_LEVEL =level
| SOURCE_SSL = {0|1} | SOURCE_SSL_CA = 'ca_file_name
' | SOURCE_SSL_CAPATH = 'ca_directory_name
' | SOURCE_SSL_CERT = 'cert_file_name
' | SOURCE_SSL_CRL = 'crl_file_name
' | SOURCE_SSL_CRLPATH = 'crl_directory_name
' | SOURCE_SSL_KEY = 'key_file_name
' | SOURCE_SSL_CIPHER = 'cipher_list
' | SOURCE_SSL_VERIFY_SERVER_CERT = {0|1} | SOURCE_TLS_VERSION = 'protocol_list
' | SOURCE_TLS_CIPHERSUITES = 'ciphersuite_list
' | SOURCE_PUBLIC_KEY_PATH = 'key_file_name
' | GET_SOURCE_PUBLIC_KEY = {0|1} | NETWORK_NAMESPACE = 'namespace
' | IGNORE_SERVER_IDS = (server_id_list
) }channel_option
: FOR CHANNELchannel
server_id_list
: [server_id
[,server_id
] ... ]
CHANGE REPLICATION SOURCE TO
changes the parameters that the replica server uses for connecting to the source and for reading data from the source. CHANGE REPLICATION SOURCE TO
更改副本服务器用于连接到源和从源读取数据的参数。It also updates the contents of the replication metadata repositories (see Section 17.2.4, “Relay Log and Replication Metadata Repositories”). 它还更新复制元数据存储库的内容(请参阅第17.2.4节,“中继日志和复制元数据存储库”)。From MySQL 8.0.23, use 在MySQL 8.0.23中,使用CHANGE REPLICATION SOURCE TO
in place of CHANGE MASTER TO
, which is deprecated from that release. CHANGE REPLICATION SOURCE TO
代替CHANGE MASTER TO
,后者在该版本中已被弃用。In releases before MySQL 8.0.23, use 在MySQL 8.0.23之前的版本中,使用CHANGE MASTER TO
.CHANGE MASTER TO
。
You can issue 根据复制SQL线程和复制I/O线程的状态,您可以在运行的复制副本上发出CHANGE REPLICATION SOURCE TO
statements on a running replica without first stopping it, depending on the states of the replication SQL thread and replication I/O thread. CHANGE REPLICATION SOURCE TO
语句,而无需首先停止它。The rules governing such use are provided later in this section. 本节后面将提供有关此类使用的规则。CHANGE REPLICATION SOURCE TO
requires the REPLICATION_SLAVE_ADMIN
privilege (or the deprecated SUPER
privilege).CHANGE REPLICATION SOURCE TO
需要REPLICATION_SLAVE_ADMIN
权限(或不推荐使用的SUPER
权限)。
When using a multithreaded replica (in other words 当使用多线程复制副本时(换句话说,slave_parallel_workers
is greater than 0), stopping the replica can cause “gaps” in the sequence of transactions that have been executed from the relay log, regardless of whether the replica was stopped intentionally or otherwise. slave_parallel_workers
大于0),停止复制副本可能会导致从中继日志执行的事务序列中出现“间隙”,而不管复制副本是故意停止还是以其他方式停止的。When such gaps exist, issuing 当存在此类间隙时,发出CHANGE REPLICATION SOURCE TO
fails. CHANGE REPLICATION SOURCE TO
失败。The solution in this situation is to issue 这种情况下的解决方案是发出START REPLICA UNTIL SQL_AFTER_MTS_GAPS
which ensures that the gaps are closed.START REPLICA UNTIL SQL_AFTER_MTS_GAPS
,这确保了间隔被关闭。
The optional 可选的FOR CHANNEL
clause enables you to name which replication channel the statement applies to. channel
FOR CHANNEL
子句允许您命名语句应用于哪个复制通道。channel
Providing a 提供FOR CHANNEL
clause applies the channel
CHANGE REPLICATION SOURCE TO
statement to a specific replication channel, and is used to add a new channel or modify an existing channel. FOR CHANNEL
子句将channel
CHANGE REPLICATION SOURCE TO
语句应用于特定复制通道,并用于添加新通道或修改现有通道。For example, to add a new channel called 例如,要添加名为channel2
:channel2
的新通道,请执行以下操作:
CHANGE REPLICATION SOURCE TO SOURCE_HOST=host1, SOURCE_PORT=3002 FOR CHANNEL 'channel2'
If no clause is named and no extra channels exist, the statement applies to the default channel.如果未命名任何子句且不存在额外通道,则该语句将应用于默认通道。
When using multiple replication channels, if a 使用多个复制通道时,如果CHANGE REPLICATION SOURCE TO
statement does not name a channel using a FOR CHANNEL
clause, an error occurs. channel
CHANGE REPLICATION SOURCE TO
语句未使用FOR CHANNEL
子句命名通道,则会发生错误。channel
See Section 17.2.2, “Replication Channels” for more information.有关更多信息,请参阅第17.2.2节,“复制通道”。
Values used for 用于SOURCE_HOST
and other CHANGE REPLICATION SOURCE TO
options are checked for linefeed (\n
or 0x0A
) characters. SOURCE_HOST
和其他CHANGE REPLICATION SOURCE TO
选项的值会被检查换行(\n
或0x0A
)字符。The presence of such characters in these values causes the statement to fail with 这些值中存在这样的字符会导致该语句失败,并产生ER_MASTER_INFO
.ER_MASTER_INFO
错误。
Invoking 调用CHANGE REPLICATION SOURCE TO
causes the previous values for SOURCE_HOST
, SOURCE_PORT
, SOURCE_LOG_FILE
, and SOURCE_LOG_POS
to be written to the error log, along with other information about the replica's state prior to execution.CHANGE REPLICATION SOURCE TO
可导致将SOURCE_HOST
、SOURCE_PORT
、SOURCE_LOG_FILE
和SOURCE_LOG_POS
的先前值以及执行前副本状态的其他信息写入错误日志。
CHANGE REPLICATION SOURCE TO
causes an implicit commit of an ongoing transaction. CHANGE REPLICATION SOURCE TO
导致正在进行的事务的隐式提交。See Section 13.3.3, “Statements That Cause an Implicit Commit”.请参阅第13.3.3节,“导致隐式提交的语句”。
For some of the options of the 对于CHANGE REPLICATION SOURCE TO
statement, you must issue a STOP REPLICA
statement prior to issuing a CHANGE REPLICATION SOURCE TO
statement (and a START REPLICA
statement afterwards). CHANGE REPLICATION SOURCE TO
语句的某些选项,必须在发出CHANGE REPLICATION SOURCE TO
语句之前发出STOP REPLICA
语句(之后发出START REPLICA
语句)。Sometimes, you only need to stop the replication SQL thread or the replication I/O thread, not both:有时,您只需要停止复制SQL线程或复制I/O线程,而不是同时停止这两个线程:
When the SQL thread is stopped, you can execute 当SQL线程停止时,即使复制I/O线程正在运行,也可以使用CHANGE REPLICATION SOURCE TO
using any combination that is otherwise allowed of RELAY_LOG_FILE
, RELAY_LOG_POS
, and SOURCE_DELAY
options, even if the replication I/O thread is running. RELAY_LOG_FILE
、RELAY_LOG_POS
和SOURCE_DELAY
项允许的任何组合执行CHANGE REPLICATION SOURCE TO
。No other options may be used with this statement when the I/O thread is running.当I/O线程正在运行时,此语句不能使用其他选项。
When the I/O thread is stopped, you can execute 当I/O线程停止时,即使SQL线程正在运行,您也可以使用此语句的任何选项(以任何允许的组合)执行CHANGE REPLICATION SOURCE TO
using any of the options for this statement (in any allowed combination) except RELAY_LOG_FILE
, RELAY_LOG_POS
, SOURCE_DELAY
, or SOURCE_AUTO_POSITION = 1
even when the SQL thread is running.CHANGE REPLICATION SOURCE TO
,但RELAY_LOG_FILE
、RELAY_LOG_POS
、SOURCE_DELAY
或SOURCE_AUTO_POSITION=1
除外。
Both the SQL thread and the I/O thread must be stopped before issuing a 必须先停止SQL线程和I/O线程,然后才能发出使用CHANGE REPLICATION SOURCE TO
statement that employs SOURCE_AUTO_POSITION = 1
or ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS
.SOURCE_AUTO_POSITION=1
或ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS
的CHANGE REPLICATION SOURCE TO
语句。
You can check the current state of the replication SQL thread and replication I/O thread using 您可以使用SHOW REPLICA STATUS
. SHOW REPLICA STATUS
查复制SQL线程和复制I/O线程的当前状态。Note that the Group Replication applier channel (请注意,组复制应用程序通道(group_replication_applier
) has no I/O thread, only an SQL thread.group_replication_applier
)没有I/O线程,只有一个SQL线程。
For more information, see Section 17.4.8, “Switching Sources During Failover”.有关更多信息,请参阅第17.4.8节,“故障切换期间切换源”。
If you are using statement-based replication and temporary tables, it is possible for a 如果您使用的是基于语句的复制和临时表,则在CHANGE REPLICATION SOURCE TO
statement following a STOP REPLICA
statement to leave behind temporary tables on the replica. STOP REPLICA
语句之后的CHANGE REPLICATION SOURCE TO
语句可能会在副本上留下临时表。A warning (无论何时发生这种情况,都会发出警告(ER_WARN_OPEN_TEMP_TABLES_MUST_BE_ZERO
) is now issued whenever this occurs. ER_WARN_OPEN_TEMP_TABLES_MUST_BE_ZERO
)。You can avoid this in such cases by making sure that the value of the 在执行这种Slave_open_temp_tables
system status variable is equal to 0 prior to executing such a CHANGE REPLICATION SOURCE TO
statement.CHANGE REPLICATION SOURCE TO
语句之前,可以通过确保系统状态变量Slave_open_temp_tables
的值等于0来避免这种情况。
当您拥有源的快照并记录了与快照时间相对应的源的二进制日志坐标时,CHANGE REPLICATION SOURCE TO
is useful for setting up a replica when you have the snapshot of the source and have recorded the source's binary log coordinates corresponding to the time of the snapshot. CHANGE REPLICATION SOURCE TO
可用于设置复制副本。After loading the snapshot into the replica to synchronize it with the source, you can run 将快照加载到复制副本中以使其与源同步后,可以在复制副本上运行将复制源更改为CHANGE REPLICATION SOURCE TO SOURCE_LOG_FILE='
on the replica to specify the coordinates at which the replica should begin reading the source's binary log.log_name
', SOURCE_LOG_POS=log_pos
CHANGE REPLICATION SOURCE TO SOURCE_LOG_FILE='
,以指定复制副本开始读取源二进制日志的坐标。log_name
', SOURCE_LOG_POS=log_pos
The following example changes the source server the replica uses and establishes the source's binary log coordinates from which the replica begins reading:以下示例更改复制副本使用的源服务器,并建立复制副本开始读取的源二进制日志坐标:
CHANGE REPLICATION SOURCE TO
SOURCE_HOST='source2.example.com',
SOURCE_USER='replication',
SOURCE_PASSWORD='password
',
SOURCE_PORT=3306,
SOURCE_LOG_FILE='source2-bin.001',
SOURCE_LOG_POS=4,
SOURCE_CONNECT_RETRY=10;
The next example shows an operation that is less frequently employed. 下一个示例显示了一个较少使用的操作。It is used when the replica has relay log files that you want it to execute again for some reason. 当复制副本中有中继日志文件,您希望出于某种原因再次执行该文件时,将使用该日志文件。To do this, the source need not be reachable. 为此,不需要访问源。You need only use 您只需使用CHANGE REPLICATION SOURCE TO
and start the SQL thread (START REPLICA SQL_THREAD
):CHANGE REPLICATION SOURCE TO
并启动SQL线程(START REPLICA SQL_THREAD
):
CHANGE REPLICATION SOURCE TO RELAY_LOG_FILE='replica-relay-bin.006', RELAY_LOG_POS=4025;
Options that you do not specify on a 除非在下面的讨论中指出,否则在CHANGE REPLICATION SOURCE TO
statement retain their value, except as indicated in the following discussion. CHANGE REPLICATION SOURCE TO
语句中未指定的选项将保留其值。Thus, in most cases, there is no need to specify options that do not change.因此,在大多数情况下,不需要指定不变的选项。
ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS
Makes the replication channel assign a GTID to replicated transactions that do not have one, enabling replication from a source that does not use GTID-based replication, to a replica that does. 使复制通道将GTID分配给没有GTID的复制事务,从而允许从不使用基于GTID的复制的源复制到使用GTID的复制副本。For a multi-source replica, you can have a mix of channels that use 对于多源复制副本,可以混合使用ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS
, and channels that do not. ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS
和不使用ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS
的通道。The default is 默认值为OFF
, meaning that the feature is not used.OFF
,表示不使用该功能。
LOCAL
assigns a GTID including the replica's own UUID (the server_uuid
setting). LOCAL
分配一个GTID,包括复制副本自己的UUID(服务器UUID设置)。
assigns a GTID including the specified UUID, such as the uuid
server_uuid
setting for the replication source server. uuid
分配一个包含指定uuid的GTID,例如复制源服务器的服务器uuid设置。Using a nonlocal UUID lets you differentiate between transactions that originated on the replica and transactions that originated on the source, and for a multi-source replica, between transactions that originated on different sources. 使用非本地UUID,可以区分源于副本的事务和源上的事务,对于多源副本,可以区分源于不同源上的事务。The UUID you choose only has significance for the replica's own use. 您选择的UUID仅对副本的自身使用具有重要意义。If any of the transactions sent by the source do have a GTID already, that GTID is retained.如果源发送的任何事务已经有GTID,则保留该GTID。
Channels specific to Group Replication cannot use 特定于组复制的通道不能使用ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS
, but an asynchronous replication channel for another source on a server instance that is a Group Replication group member can do so. ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS
,但作为组复制组成员的服务器实例上另一个源的异步复制通道可以这样做。In that case, do not specify the Group Replication group name as the UUID for creating the GTIDs.在这种情况下,不要将组复制组名称指定为用于创建GTID的UUID。
To set 要将ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS
to LOCAL
or
, the replica must have uuid
gtid_mode=ON
set, and this cannot be changed afterwards. ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS
设置为LOCAL
或uuid
,复制副本必须设置gtid_mode=ON
,并且以后不能更改。This option is for use with a source that has binary log file position based replication, so 此选项用于具有基于二进制日志文件位置的复制的源,因此无法为通道设置MASTER_AUTO_POSITION=1
cannot be set for the channel. MASTER_AUTO_POSITION=1
。Both the replication SQL thread and the replication I/O thread must be stopped before setting this option.在设置此选项之前,必须停止复制SQL线程和复制I/O线程。
A replica set up with 在需要故障切换的情况下,在任何通道上使用ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS
on any channel cannot be promoted to replace the replication source server in the event that a failover is required, and a backup taken from the replica cannot be used to restore the replication source server. ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS
设置的复制副本无法升级以替换复制源服务器,并且从复制副本获取的备份不能用于恢复复制源服务器。The same restriction applies to replacing or restoring other replicas that use 同样的限制也适用于替换或恢复在任何通道上使用ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS
on any channel.ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS
的其他副本。
For further restrictions and information, see Section 17.1.3.6, “Replication From a Source Without GTIDs to a Replica With GTIDs”.有关更多限制和信息,请参阅第17.1.3.6节,“从没有GTID的源复制到具有GTID的副本”。
GET_SOURCE_PUBLIC_KEY
Enables RSA key pair-based password exchange by requesting the public key from the source. 通过从源请求公钥,启用基于RSA密钥对的密码交换。This option applies to replicas that authenticate with the 此选项适用于使用caching_sha2_password
authentication plugin. caching_sha2_password
身份验证插件进行身份验证的副本。For connections by accounts that authenticate using this plugin, the source does not send the public key unless requested, so it must be requested or specified in the client. 对于使用此插件进行身份验证的帐户连接,除非请求,否则源不会发送公钥,因此必须在客户端请求或指定公钥。If 如果给定SOURCE_PUBLIC_KEY_PATH
is given and specifies a valid public key file, it takes precedence over GET_SOURCE_PUBLIC_KEY
. SOURCE_PUBLIC_KEY_PATH
并指定了有效的公钥文件,则该路径优先于GET_SOURCE_PUBLIC_KEY
。If you are using a replication user account that authenticates with the 如果您使用的复制用户帐户使用caching_sha2_password
plugin (which is the default from MySQL 8.0), and you are not using a secure connection, you must specify either this option or the SOURCE_PUBLIC_KEY_PATH
option to provide the RSA public key to the replica.caching_sha2_password
插件(MySQL 8.0中的默认插件)进行身份验证,并且您没有使用安全连接,则必须指定此选项或SOURCE_PUBLIC_KEY_PATH
选项以向复制副本提供RSA公钥。
IGNORE_SERVER_IDS
Makes the replica ignore events originating from the specified servers. 使复制副本忽略源自指定服务器的事件。The option takes a comma-separated list of 0 or more server IDs. 该选项采用逗号分隔的0个或多个服务器ID列表。Log rotation and deletion events from the servers are not ignored, and are recorded in the relay log.服务器的日志旋转和删除事件不会被忽略,并记录在中继日志中。
In circular replication, the originating server normally acts as the terminator of its own events, so that they are not applied more than once. 在循环复制中,发起服务器通常充当其自身事件的终止器,因此不会多次应用这些事件。Thus, this option is useful in circular replication when one of the servers in the circle is removed. 因此,当删除循环中的一个服务器时,此选项在循环复制中非常有用。Suppose that you have a circular replication setup with 4 servers, having server IDs 1, 2, 3, and 4, and server 3 fails. 假设您有一个包含4台服务器的循环复制设置,服务器ID为1、2、3和4,而服务器3出现故障。When bridging the gap by starting replication from server 2 to server 4, you can include 当通过启动从服务器2到服务器4的复制来缩小差距时,您可以在服务器4上发出的IGNORE_SERVER_IDS = (3)
in the CHANGE REPLICATION SOURCE TO
statement that you issue on server 4 to tell it to use server 2 as its source instead of server 3. CHANGE REPLICATION SOURCE TO
语句中包含IGNORE_SERVER_IDS = (3)
,以告知它使用服务器2作为其源,而不是服务器3。Doing so causes it to ignore and not to propagate any statements that originated with the server that is no longer in use.这样做会导致它忽略并且不会传播任何源于不再使用的服务器的语句。
If 如果IGNORE_SERVER_IDS
contains the server's own ID and the server was started with the --replicate-same-server-id
option enabled, an error results.IGNORE_SERVER_IDS
包含服务器自己的ID,并且服务器启动时启用了--replicate-same-server-id
选项,则会导致错误。
When global transaction identifiers (GTIDs) are used for replication, transactions that have already been applied are automatically ignored, so the 当全局事务标识符(GTID)用于复制时,已应用的事务将自动忽略,因此不需要使用IGNORE_SERVER_IDS
function is not required and is deprecated. IGNORE_SERVER_IDS
功能,因此不推荐使用该功能。If 如果为服务器设置了gtid_mode=ON
is set for the server, a deprecation warning is issued if you include the IGNORE_SERVER_IDS
option in a CHANGE REPLICATION SOURCE TO
statement.gtid_mode=ON
,则如果在CHANGE REPLICATION SOURCE TO
语句中包含IGNORE_SERVER_IDS
选项,将发出弃用警告。
The source metadata repository and the output of 源元数据存储库和SHOW REPLICA STATUS
provide the list of servers that are currently ignored. SHOW REPLICA STATUS
的输出提供了当前被忽略的服务器的列表。For more information, see Section 17.2.4.2, “Replication Metadata Repositories”, and Section 13.7.7.35, “SHOW REPLICA | SLAVE STATUS Statement”.有关更多信息,请参阅第17.2.4.2节,“复制元数据存储库”和第13.7.7.35节,“SHOW REPLICA | SLAVE STATUS语句”。
If a 如果在没有任何CHANGE REPLICATION SOURCE TO
statement is issued without any IGNORE_SERVER_IDS
option, any existing list is preserved. IGNORE_SERVER_IDS
选项的情况下发出CHANGE REPLICATION SOURCE TO
语句,则会保留任何现有列表。To clear the list of ignored servers, it is necessary to use the option with an empty list:要清除被忽略服务器的列表,必须使用空列表选项:
CHANGE REPLICATION SOURCE TO IGNORE_SERVER_IDS = ();
RESET REPLICA ALL
clears IGNORE_SERVER_IDS
.RESET REPLICA ALL
清除IGNORE_SERVER_IDS
。
A deprecation warning is issued if 如果在任何通道的现有服务器ID设置为SET GTID_MODE=ON
is issued when any channel has existing server IDs set with IGNORE_SERVER_IDS
. IGNORE_SERVER_IDS
时发出SET GTID_MODE=ON
,则会发出弃用警告。Before starting GTID-based replication, check for and clear all ignored server ID lists on the servers involved. 在启动基于GTID的复制之前,请检查并清除相关服务器上所有被忽略的服务器ID列表。The SHOW REPLICA STATUS
statement displays the list of ignored IDs, if there is one. SHOW REPLICA STATUS
语句显示被忽略ID的列表(如果有)。If you do receive the deprecation warning, you can still clear a list after 如果您确实收到了弃用警告,则在设置gtid_mode=ON
is set by issuing a CHANGE REPLICATION SOURCE TO
statement containing the IGNORE_SERVER_IDS
option with an empty list.gtid_mode=ON
后,您仍然可以通过发出包含带有空列表的IGNORE_SERVER_IDS
选项的CHANGE REPLICATION SOURCE TO
语句来清除列表。
NETWORK_NAMESPACE
The network namespace to use for TCP/IP connections to the replication source server. 用于到复制源服务器的TCP/IP连接的网络命名空间。If this option is omitted, connections from the replica use the default (global) namespace. 如果省略此选项,则来自复制副本的连接将使用默认(全局)命名空间。On platforms that do not implement network namespace support, failure occurs when the replica attempts to connect to the source. 在未实现网络命名空间支持的平台上,复制副本尝试连接到源时会发生故障。For information about network namespaces, see Section 5.1.14, “Network Namespace Support”. 有关网络名称空间的信息,请参阅第5.1.14节,“网络名称空间支持”。NETWORK_NAMESPACE
is available as of MySQL 8.0.22.NETWORK_NAMESPACE
从MySQL 8.0.22开始可用。
PRIVILEGE_CHECKS_USER
Names a user account that supplies a security context for the specified channel. 命名为指定通道提供安全上下文的用户帐户。NULL
, which is the default, means no security context is used. NULL
是默认值,表示未使用安全上下文。PRIVILEGE_CHECKS_USER
is available as of MySQL 8.0.18.PRIVILEGE_CHECKS_USER
从MySQL 8.0.18开始可用。
The user name and host name for the user account must follow the syntax described in Section 6.2.4, “Specifying Account Names”, and the user must not be an anonymous user (with a blank user name) or the 用户帐户的用户名和主机名必须遵循第6.2.4节,“指定帐户名”中描述的语法,并且用户不得是匿名用户(用户名为空)或CURRENT_USER
. CURRENT_USER
。The account must have the 该帐户必须具有REPLICATION_APPLIER
privilege, plus the required privileges to execute the transactions replicated on the channel. REPLICATION_APPLIER
(复制应用程序)权限,以及执行在通道上复制的事务所需的权限。For details of the privileges required by the account, see Section 17.3.3, “Replication Privilege Checks”. 有关帐户所需权限的详细信息,请参阅第17.3.3节,“复制权限检查”。When you restart the replication channel, the privilege checks are applied from that point on. If you do not specify a channel and no other channels exist, the statement is applied to the default channel.重新启动复制通道时,将从此点开始应用权限检查。如果未指定通道且不存在其他通道,则该语句将应用于默认通道。
The use of row-based binary logging is strongly recommended when 当设置了PRIVILEGE_CHECKS_USER
is set, and you can set REQUIRE_ROW_FORMAT
to enforce this. PRIVILEGE_CHECKS_USER
时,强烈建议使用基于行的二进制日志记录,您可以设置REQUIRE_ROW_FORMAT
来强制执行此操作。For example, to start privilege checks on the channel 例如,要对正在运行的复制副本上的channel_1
on a running replica, issue the following statements:channel_1
启动权限检查,请发出以下语句:
mysql> STOP REPLICA FOR CHANNEL 'channel_1'; mysql> CHANGE REPLICATION SOURCE TO PRIVILEGE_CHECKS_USER = 'priv_repl
'@'%.example.com
', REQUIRE_ROW_FORMAT = 1, FOR CHANNEL 'channel_1'; mysql> START REPLICA FOR CHANNEL 'channel_1';
RELAY_LOG_FILE
,
RELAY_LOG_POS
The relay log file name, and the location in that file, at which the replication SQL thread begins reading from the replica's relay log the next time the thread starts. 中继日志文件名以及该文件中的位置,在该位置,复制SQL线程在下次线程启动时开始从副本的中继日志中读取数据。RELAY_LOG_FILE
can use either an absolute or relative path, and uses the same base name as SOURCE_LOG_FILE
.RELAY_LOG_FILE
可以使用绝对路径或相对路径,并使用与SOURCE_LOG_FILE
相同的基本名称。
A 当复制SQL线程停止时,可以在正在运行的复制副本上执行使用CHANGE REPLICATION SOURCE TO
statement using RELAY_LOG_FILE
, RELAY_LOG_POS
, or both options can be executed on a running replica when the replication SQL thread is stopped. RELAY_LOG_FILE
选项、RELAY_LOG_POS
选项或同时使用这两个选项的CHANGE REPLICATION SOURCE TO
语句。Relay logs are preserved if at least one of the replication SQL thread and the replication I/O thread is running. 如果至少有一个复制SQL线程和复制I/O线程正在运行,则会保留中继日志。If both threads are stopped, all relay log files are deleted unless at least one of 如果两个线程都停止,则删除所有中继日志文件,除非至少指定了RELAY_LOG_FILE
or RELAY_LOG_POS
is specified. RELAY_LOG_FILE
或RELAY_LOG_POS
中的一个。For the Group Replication applier channel (对于只有一个SQL线程而没有I/O线程的组复制应用程序通道(group_replication_applier
), which only has an SQL thread and no I/O thread, this is the case if the SQL thread is stopped, but with that channel you cannot use the RELAY_LOG_FILE
and RELAY_LOG_POS
options.group_replication_applier
),如果SQL线程停止,则会出现这种情况,但对于该通道,您不能使用RELAY_LOG_FILE
和RELAY_LOG_POS
选项。
REQUIRE_ROW_FORMAT
Permits only row-based replication events to be processed by the replication channel. 仅允许复制通道处理基于行的复制事件。This option prevents the replication applier from taking actions such as creating temporary tables and executing 此选项可防止复制应用程序执行创建临时表和执行LOAD DATA INFILE
requests, which increases the security of the channel. LOAD DATA INFILE
请求等操作,从而提高通道的安全性。Group Replication channels are automatically created with 组复制通道是使用REQUIRE_ROW_FORMAT
set, and you cannot change the option for those channels. REQUIRE_ROW_FORMAT
集自动创建的,您不能更改这些通道的选项。For more information, see Section 17.3.3, “Replication Privilege Checks”. 有关更多信息,请参阅第17.3.3节,“复制权限检查”。REQUIRE_ROW_FORMAT
is available as of MySQL 8.0.19.REQUIRE_ROW_FORMAT
从MySQL 8.0.19开始可用。
REQUIRE_TABLE_PRIMARY_KEY_CHECK
Enables a replica to select its own policy for primary key checks. 使复制副本能够为主键检查选择自己的策略。When the option is set to 当复制通道的选项设置为ON
for a replication channel, the replica always uses the value ON
for the sql_require_primary_key
system variable in replication operations, requiring a primary key. ON
时,复制副本在复制操作中始终使用sql_require_primary_key
系统变量的值ON
,这需要一个主键。When the option is set to 当该选项设置为OFF
, the replica always uses the value OFF
for the sql_require_primary_key
system variable in replication operations, so that a primary key is never required, even if the source required one. OFF
时,复制副本在复制操作中始终使用系统变量sql_require_primary_key
的值OFF
,这样即使源需要主键,也不需要主键。When the 当REQUIRE_TABLE_PRIMARY_KEY_CHECK
option is set to STREAM
, which is the default, the replica uses whatever value is replicated from the source for each transaction. REQUIRE_TABLE_PRIMARY_KEY_CHECK
选项设置为STREAM
(默认设置)时,复制副本将使用从源为每个事务复制的任何值。REQUIRE_TABLE_PRIMARY_KEY_CHECK
is available as of MySQL 8.0.20.REQUIRE_TABLE_PRIMARY_KEY_CHECK
从MySQL 8.0.20开始可用。
For multisource replication, setting 对于多源复制,将REQUIRE_TABLE_PRIMARY_KEY_CHECK
to ON
or OFF
enables a replica to normalize behavior across the replication channels for different sources, and keep a consistent setting for the sql_require_primary_key
system variable. REQUIRE_TABLE_PRIMARY_KEY_CHECK
设置为ON
或OFF
可使复制副本跨复制通道规范化不同源的行为,并保持系统变量sql_require_primary_key
的一致设置。Using 当多个源更新同一组表时,使用ON
safeguards against the accidental loss of primary keys when multiple sources update the same set of tables. ON
保护措施防止主键意外丢失。Using 使用OFF
allows sources that can manipulate primary keys to work alongside sources that cannot.OFF
允许可以操纵主键的源与不能操纵主键的源一起工作。
When 设置PRIVILEGE_CHECKS_USER
is set, setting REQUIRE_TABLE_PRIMARY_KEY_CHECK
to ON
or OFF
means that the user account does not need session administration level privileges to set restricted session variables, which are required to change the value of sql_require_primary_key
to match the source's setting for each transaction. PRIVILEGE_CHECKS_USER
时,将REQUIRE_TABLE_PRIMARY_KEY_CHECK设置为ON或OFF意味着用户帐户不需要会话管理级别的特权来设置受限会话变量,这是更改sql_REQUIRE_PRIMARY_KEY的值以匹配每个事务的源设置所必需的。For more information, see Section 17.3.3, “Replication Privilege Checks”.有关更多信息,请参阅第17.3.3节,“复制权限检查”。
SOURCE_AUTO_POSITION
Makes the replica attempt to connect to the source using the auto-positioning feature of GTID-based replication, rather than a binary log file based position. 使复制副本尝试使用基于GTID的复制的自动定位功能(而不是基于二进制日志文件的位置)连接到源。This option can be used with 仅当复制SQL线程和复制I/O线程都停止时,此选项才能用于CHANGE REPLICATION SOURCE TO
only if both the replication SQL thread and replication I/O thread are stopped.CHANGE REPLICATION SOURCE TO
。
Both the replica and the source must have GTIDs enabled (副本和源都必须启用GTID(副本上的GTID_MODE=ON
, ON_PERMISSIVE,
or OFF_PERMISSIVE
on the replica, and GTID_MODE=ON
on the source). GTID_MODE=ON
、ON_PERMISSIVE
或OFF_PERMISSIVE
,源上的GTID_MODE=ON
)。SOURCE_LOG_FILE
, SOURCE_LOG_POS
, RELAY_LOG_FILE
, and RELAY_LOG_POS
cannot be specified together with SOURCE_AUTO_POSITION = 1
. SOURCE_LOG_FILE
、SOURCE_LOG_POS
、RELAY_LOG_FILE
和RELAY_LOG_POS
不能与SOURCE_AUTO_POSITION = 1
一起指定。If multi-source replication is enabled on the replica, you need to set the 如果在复制副本上启用了多源复制,则需要为每个适用的复制通道设置SOURCE_AUTO_POSITION = 1
option for each applicable replication channel.SOURCE_AUTO_POSITION = 1
选项。
With 当SOURCE_AUTO_POSITION = 1
set, in the initial connection handshake, the replica sends a GTID set containing the transactions that it has already received, committed, or both. SOURCE_AUTO_POSITION = 1
时,在初始连接握手中,复制副本发送一个GTID集,其中包含它已经接收、提交或同时提交的事务。The source responds by sending all transactions recorded in its binary log whose GTID is not included in the GTID set sent by the replica. 源通过发送其二进制日志中记录的所有事务进行响应,这些事务的GTID不包括在副本发送的GTID集中。This exchange ensures that the source only sends the transactions with a GTID that the replica has not already recorded or committed. 此交换确保源仅发送带有GTID的事务,而复制副本尚未记录或提交该GTID。If the replica receives transactions from more than one source, as in the case of a diamond topology, the auto-skip function ensures that the transactions are not applied twice. 如果复制副本从多个源接收事务(如菱形拓扑),则自动跳过功能可确保事务不会应用两次。For details of how the GTID set sent by the replica is computed, see Section 17.1.3.3, “GTID Auto-Positioning”.有关如何计算副本发送的GTID集的详细信息,请参阅第17.1.3.3节,“GTID自动定位”。
If any of the transactions that should be sent by the source have been purged from the source's binary log, or added to the set of GTIDs in the 如果源应发送的任何事务已从源的二进制日志中清除,或通过另一种方法添加到系统变量gtid_purged
system variable by another method, the source sends the error ER_MASTER_HAS_PURGED_REQUIRED_GTIDS to the replica, and replication does not start. gtid_purged
中的GTID集,则源将错误ER_MASTER_HAS_PURGED_REQUIRED_GTIDS
发送到副本,并且复制不会启动。The GTIDs of the missing purged transactions are identified and listed in the source's error log in the warning message ER_FOUND_MISSING_GTIDS. 丢失的已清除事务的GTID被识别并列在警告消息ER_FOUND_MISSING_GTIDS
的源错误日志中。Also, if during the exchange of transactions it is found that the replica has recorded or committed transactions with the source's UUID in the GTID, but the source itself has not committed them, the source sends the error ER_SLAVE_HAS_MORE_GTIDS_THAN_MASTER to the replica and replication does not start. 此外,如果在事务交换期间发现复制副本已在GTID中记录或提交了具有源UUID的事务,但源本身未提交这些事务,则源会向复制副本发送错误ER_SLAVE_HAS_MORE_GTIDS_THAN_MASTER
,而且复制不会启动。For information on how to handle these situations, see Section 17.1.3.3, “GTID Auto-Positioning”.有关如何处理这些情况的信息,请参阅第17.1.3.3节,“GTID自动定位”。
You can see whether replication is running with GTID auto-positioning enabled by checking the Performance Schema 通过检查性能架构replication_connection_status
table or the output of SHOW REPLICA STATUS
. replication_connection_status
表或SHOW REPLICA STATUS
的输出,可以查看复制是否在启用GTID自动定位的情况下运行。Disabling the 再次禁用SOURCE_AUTO_POSITION
option again makes the replica revert to file-based replication.SOURCE_AUTO_POSITION
选项将使复制副本恢复为基于文件的复制。
SOURCE_BIND
Determines which of the replica's network interfaces is chosen for connecting to the source, for use on replicas that have multiple network interfaces. 确定选择哪个复制副本的网络接口连接到源,以便在具有多个网络接口的复制副本上使用。The address configured with this option, if any, can be seen in the 使用此选项配置的地址(如果有)可以在Source_Bind
column of the output from SHOW REPLICA STATUS
. SHOW REPLICA STATUS
输出的Source_Bind
列中看到。In the source metadata repository table 在源元数据存储库表mysql.slave_master_info
, the value can be seen as the Source_bind
column. mysql.slave_master_info
中,该值可视为Source_bind
列。The ability to bind a replica to a specific network interface is also supported by NDB Cluster.NDB群集还支持将副本绑定到特定网络接口的功能。
SOURCE_COMPRESSION_ALGORITHMS
Specifies the permitted compression algorithms for connections to the replication source server. 指定到复制源服务器的连接允许的压缩算法。The available algorithms are the same as for the 可用算法与系统变量protocol_compression_algorithms
system variable. protocol_compression_algorithms
相同。The default value is 默认值为uncompressed
. uncompressed
。SOURCE_COMPRESSION_ALGORITHMS
is available as of MySQL 8.0.18.SOURCE_COMPRESSION_ALGORITHMS
(源代码压缩算法)从MySQL 8.0.18开始可用。
The value of 仅当禁用系统变量SOURCE_COMPRESSION_ALGORITHMS
applies only if the slave_compressed_protocol
system variable is disabled. slave_compressed_protocol
时,SOURCE_COMPRESSION_ALGORITHMS
的值才适用。If 如果启用了slave_compressed_protocol
is enabled, it takes precedence over SOURCE_COMPRESSION_ALGORITHMS
and connections to the source use zlib
compression if both source and replica support that algorithm. slave_compressed_protocol
,则其优先级高于SOURCE_COMPRESSION_ALGORITHMS
,如果源和复制副本都支持该算法,则到源的连接将使用zlib
压缩。For more information, see Section 4.2.8, “Connection Compression Control”.有关更多信息,请参阅第4.2.8节,“连接压缩控制”。
Binary log transaction compression (available as of MySQL 8.0.20), which is activated by the 系统变量binlog_transaction_compression
system variable, can also be used to save bandwidth. binlog_transaction_compression
激活的二进制日志事务压缩(从MySQL 8.0.20开始提供)也可用于节省带宽。If you do this in combination with connection compression, connection compression has less opportunity to act on the data, but can still compress headers and those events and transaction payloads that are uncompressed. 如果将连接压缩与此结合使用,则连接压缩对数据的作用机会较小,但仍可以压缩头以及未压缩的事件和事务有效负载。For more information on binary log transaction compression, see Section 5.4.4.5, “Binary Log Transaction Compression”.有关二进制日志事务压缩的更多信息,请参阅第5.4.4.5节,“二进制日志事务压缩”。
SOURCE_CONNECT_RETRY
Specifies the interval between the reconnection attempts that the replica makes after the connection to the source times out. 指定复制副本在与源的连接超时后进行的重新连接尝试之间的间隔。The attempts are limited by the 尝试受SOURCE_RETRY_COUNT
option. SOURCE_RETRY_COUNT
选项的限制。If both the default settings are used, the replica waits 60 seconds between reconnection attempts (如果使用了这两种默认设置,则复制副本在两次重新连接尝试之间等待60秒(SOURCE_CONNECT_RETRY=60
), and keeps attempting to reconnect at this rate for 60 days (SOURCE_RETRY_COUNT=86400
). SOURCE_CONNECT_RETRY=60
),并在60天内继续尝试以此速率重新连接(SOURCE_RETRY_COUNT=86400
)。These values are recorded in the source metadata repository and shown in the 这些值记录在源元数据存储库中,并显示在replication_connection_configuration
Performance Schema table.replication_connection_configuration
性能架构表中。
SOURCE_CONNECTION_AUTO_FAILOVER
Activates the asynchronous connection failover mechanism for a replication channel if one or more alternative replication source servers are available (so when there are multiple MySQL servers or groups of servers that share the replicated data). 如果有一个或多个备用复制源服务器可用(如果有多个MySQL服务器或共享复制数据的服务器组),则激活复制通道的异步连接故障切换机制。从MySQL 8.0.22开始,就可以使用SOURCE_CONNECTION_AUTO_FAILOVER
is available as of MySQL 8.0.22. SOURCE_CONNECTION_AUTO_FAILOVER
(源连接自动故障转移)。The asynchronous connection failover mechanism takes over after the reconnection attempts controlled by 异步连接故障切换机制在SOURCE_CONNECT_RETRY
and SOURCE_RETRY_COUNT
are exhausted. SOURCE_CONNECT_RETRY
(源连接重试)和SOURCE_RETRY_COUNT
(源重试计数)控制的重新连接尝试用尽后接管。It reconnects the replica to an alternative source chosen from a specified source list, which you manage using the 它将复制副本重新连接到从指定源列表中选择的备用源,您可以使用asynchronous_connection_failover_add_source
and asynchronous_connection_failover_delete_source
functions. asynchronous_connection_failover_add_source
和asynchronous_connection_failover_delete_source
功能对其进行管理。To add and remove managed groups of servers, use the 若要添加和删除托管服务器组,请改用asynchronous_connection_failover_add_managed
and asynchronous_connection_failover_delete_managed
functions instead. asynchronous_connection_failover_add_managed
和asynchronous_connection_failover_delete_managed
功能。For more information, see Section 17.4.9, “Switching Sources with Asynchronous Connection Failover”.有关更多信息,请参阅第17.4.9节,“使用异步连接故障切换切换源”。
You can only set 只有在使用GTID自动定位(SOURCE_CONNECTION_AUTO_FAILOVER = 1
when GTID auto-positioning is in use (SOURCE_AUTO_POSITION = 1
).SOURCE_AUTO_POSITION = 1
)时,才能将SOURCE_CONNECTION_AUTO_FAILOVER = 1
。
When you set 当您设置SOURCE_CONNECTION_AUTO_FAILOVER = 1
, set SOURCE_RETRY_COUNT
and SOURCE_CONNECT_RETRY
to minimal numbers that just allow a few retry attempts with the same source, in case the connection failure is caused by a transient network outage. SOURCE_CONNECTION_AUTO_FAILOVER = 1
时,请将SOURCE_RETRY_COUNT
和SOURCE_CONNECT_RETRY
设置为允许对同一源进行几次重试尝试的最小值,以防连接失败是由暂时性网络中断引起的。Otherwise the asynchronous connection failover mechanism cannot be activated promptly. 否则,异步连接故障切换机制无法立即激活。Suitable values are 合适的值是SOURCE_RETRY_COUNT=3
and SOURCE_CONNECT_RETRY=10
, which make the replica retry the connection 3 times with 10-second intervals between.SOURCE_RETRY_COUNT=3
和SOURCE_CONNECT_RETRY=10
,这使得复制副本以10秒的间隔重试连接3次。
When you set 当您设置SOURCE_CONNECTION_AUTO_FAILOVER = 1
, the replication metadata repositories must contain the credentials for a replication user account that can be used to connect to all the servers on the source list for the replication channel. SOURCE_CONNECTION_AUTO_FAILOVER = 1
时,复制元数据存储库必须包含复制用户帐户的凭据,该帐户可用于连接到复制通道源列表上的所有服务器。The account must also have 该帐户还必须对性能架构表具有SELECT
permissions on the Performance Schema tables. SELECT
权限。These credentials can be set using the 可以使用CHANGE REPLICATION SOURCE TO
statement with the SOURCE_USER
and SOURCE_PASSWORD
options. CHANGE REPLICATION SOURCE TO
语句配合SOURCE_USER
和SOURCE_PASSWORD
选项来设置这些凭据。For more information, see Section 17.4.9, “Switching Sources with Asynchronous Connection Failover”.有关更多信息,请参阅第17.4.9节,“使用异步连接故障切换切换源”。
SOURCE_DELAY
Specifies how many seconds behind the source the replica must lag. 指定复制副本必须落后于源的秒数。An event received from the source is not executed until at least 从源接收的事件在源上执行至少interval
seconds later than its execution on the source. interval
秒后才会执行。The default is 0. 默认值为0。An error occurs if 如果间隔不是0到231-1范围内的非负整数,则会发生错误。interval
is not a nonnegative integer in the range from 0 to 231−1. For more information, see Section 17.4.11, “Delayed Replication”. 有关更多信息,请参阅第17.4.11节,“延迟复制”。A 当复制SQL线程停止时,可以在正在运行的复制副本上执行使用CHANGE REPLICATION SOURCE TO
statement using the SOURCE_DELAY
option can be executed on a running replica when the replication SQL thread is stopped.SOURCE_DELAY
选项的CHANGE REPLICATION SOURCE TO
语句。
SOURCE_HEARTBEAT_PERIOD
Controls the heartbeat interval, which stops the connection timeout occurring in the absence of data if the connection is still good. 控制心跳间隔,如果连接仍然良好,则心跳间隔将停止在缺少数据的情况下发生的连接超时。A heartbeat signal is sent to the replica after that number of seconds, and the waiting period is reset whenever the source's binary log is updated with an event. 在该秒数之后,心跳信号被发送到复制副本,并且每当源的二进制日志被事件更新时,等待时间被重置。Heartbeats are therefore sent by the source only if there are no unsent events in the binary log file for a period longer than this.因此,只有在二进制日志文件中没有超过此时间段的未发送事件时,源才会发送心跳。
The heartbeat interval 心跳间隔interval
is a decimal value having the range 0 to 4294967 seconds and a resolution in milliseconds; the smallest nonzero value is 0.001. interval
是一个十进制值,范围为0到4294967秒,分辨率以毫秒为单位;最小非零值为0.001。Setting 将interval
to 0 disables heartbeats altogether. interval
设置为0将完全禁用心跳。The heartbeat interval defaults to half the value of the 心跳间隔默认为系统变量slave_net_timeout
system variable. slave_net_timeout
值的一半。It is recorded in the source metadata repository and shown in the 它记录在源元数据存储库中,并显示在replication_connection_configuration
Performance Schema table. replication_connection_configuration
性能架构表中。Issuing 发出RESET REPLICA
resets the heartbeat interval to the default value.RESET REPLICA
将心跳间隔重置为默认值。
The slave_net_timeout
system variable specifies the number of seconds that the replica waits for either more data or a heartbeat signal from the source, before the replica considers the connection broken, aborts the read, and tries to reconnect. slave_net_timeout
系统变量指定在副本认为连接已断开、中止读取并尝试重新连接之前,副本等待更多数据或来自源的心跳信号的秒数。The default value is 60 seconds (one minute). 默认值为60秒(一分钟)。Note that a change to the value or default setting of 请注意,对slave_net_timeout
does not automatically change the heartbeat interval, whether that has been set explicitly or is using a previously calculated default. slave_net_timeout
的值或默认设置的更改不会自动更改心跳间隔,无论是显式设置还是使用先前计算的默认值。A warning is issued if you set 如果将@@GLOBAL.slave_net_timeout
to a value less than that of the current heartbeat interval. @GLOBAL.slave_net_timeout
设置为小于当前心跳间隔的值,则会发出警告。If 如果更改了slave_net_timeout
is changed, you must also issue CHANGE REPLICATION SOURCE TO
to adjust the heartbeat interval to an appropriate value so that the heartbeat signal occurs before the connection timeout. slave_net_timeout
,还必须发出CHANGE REPLICATION SOURCE TO
以将心跳间隔调整为适当的值,以便心跳信号在连接超时之前出现。If you do not do this, the heartbeat signal has no effect, and if no data is received from the source, the replica can make repeated reconnection attempts, creating zombie dump threads.如果不这样做,心跳信号将无效,并且如果没有从源接收到任何数据,复制副本可以重复尝试重新连接,从而创建僵尸转储线程。
SOURCE_HOST
The host name or IP address of the replication source server. 复制源服务器的主机名或IP地址。The replica uses this to connect to the source.复制副本使用此连接到源。
If you specify 如果指定SOURCE_HOST
or SOURCE_PORT
, the replica assumes that the source server is different from before (even if the option value is the same as its current value.) SOURCE_HOST
或SOURCE_PORT
,复制副本将假定源服务器与以前不同(即使选项值与其当前值相同)。In this case, the old values for the source's binary log file name and position are considered no longer applicable, so if you do not specify 在这种情况下,源的二进制日志文件名和位置的旧值将被视为不再适用,因此,如果在语句中未指定SOURCE_LOG_FILE
and SOURCE_LOG_POS
in the statement, SOURCE_LOG_FILE=''
and SOURCE_LOG_POS=4
are silently appended to it.SOURCE_LOG_FILE
和SOURCE_LOG_POS
,则SOURCE_LOG_FILE=''
和SOURCE_LOG_POS=4
将以静默方式追加到它。
Setting 设置SOURCE_HOST=''
(that is, setting its value explicitly to an empty string) is not the same as not setting SOURCE_HOST
at all. SOURCE_HOST=''
(即,将其值显式设置为空字符串)与根本不设置SOURCE_HOST
不同。Trying to set 尝试将SOURCE_HOST
to an empty string fails with an error.SOURCE_HOST
设置为空字符串失败,并出现错误。
SOURCE_LOG_FILE
,
SOURCE_LOG_POS
The binary log file name, and the location in that file, at which the replication I/O thread begins reading from the source's binary log the next time the thread starts. 二进制日志文件名以及该文件中的位置,在下次线程启动时复制I/O线程从该位置开始读取源的二进制日志。Specify these options if you are using binary log file position based replication. 如果使用基于二进制日志文件位置的复制,请指定这些选项。SOURCE_LOG_FILE
must include the numeric suffix of a specific binary log file that is available on the source server, for example, SOURCE_LOG_FILE='binlog.000145'
. SOURCE_LOG_FILE
必须包含源服务器上可用的特定二进制日志文件的数字后缀,例如,SOURCE_LOG_FILE='binlog.000145'
。SOURCE_LOG_POS
is the numeric position for the replica to start reading in that file. SOURCE_LOG_POS
是复制副本在该文件中开始读取的数字位置。SOURCE_LOG_POS=4
represents the start of the events in a binary log file.SOURCE_LOG_POS=4
表示二进制日志文件中事件的开始。
If you specify either of 如果指定SOURCE_LOG_FILE
or SOURCE_LOG_POS
, you cannot specify SOURCE_AUTO_POSITION = 1
, which is for GTID-based replication.SOURCE_LOG_FILE
或SOURCE_LOG_POS
,则不能指定SOURCE_AUTO_POSITION = 1
,该位置用于基于GTID的复制。
If neither of 如果未指定SOURCE_LOG_FILE
or SOURCE_LOG_POS
is specified, the replica uses the last coordinates of the replication SQL thread before CHANGE REPLICATION SOURCE TO
was issued. SOURCE_LOG_FILE
或SOURCE_LOG_POS
,则复制副本将使用在发出CHANGE REPLICATION SOURCE TO
之前复制SQL线程的最后一个坐标。This ensures that there is no discontinuity in replication, even if the replication SQL thread was late compared to the replication I/O thread.这确保了复制中没有中断,即使复制SQL线程比复制I/O线程晚。
SOURCE_PASSWORD
The password for the replication user account to use for connecting to the replication source server. 用于连接到复制源服务器的复制用户帐户的密码。If you specify 如果指定SOURCE_PASSWORD
, SOURCE_USER
is also required.SOURCE_PASSWORD
,则还需要SOURCE_USER
。
The password used for a replication user account in a 在CHANGE REPLICATION SOURCE TO
statement is limited to 32 characters in length. CHANGE REPLICATION SOURCE TO
语句中,复制用户帐户使用的密码长度限制为32个字符。Trying to use a password of more than 32 characters causes 尝试使用超过32个字符的密码会导致CHANGE REPLICATION SOURCE TO
to fail.CHANGE REPLICATION SOURCE TO
失败。
SOURCE_PORT
The TCP/IP port number that the replica uses to connect to the replication source server.复制副本用于连接到复制源服务器的TCP/IP端口号。
Replication cannot use Unix socket files. 复制无法使用Unix套接字文件。You must be able to connect to the replication source server using TCP/IP.您必须能够使用TCP/IP连接到复制源服务器。
If you specify 如果指定SOURCE_HOST
or SOURCE_PORT
, the replica assumes that the source server is different from before (even if the option value is the same as its current value.) SOURCE_HOST
或SOURCE_PORT
,复制副本将假定源服务器与以前不同(即使选项值与其当前值相同)。In this case, the old values for the source's binary log file name and position are considered no longer applicable, so if you do not specify 在这种情况下,源的二进制日志文件名和位置的旧值将被视为不再适用,因此,如果在语句中未指定SOURCE_LOG_FILE
and SOURCE_LOG_POS
in the statement, SOURCE_LOG_FILE=''
and SOURCE_LOG_POS=4
are silently appended to it.SOURCE_LOG_FILE
和SOURCE_LOG_POS
,则SOURCE_LOG_FILE=''
和SOURCE_LOG_POS=4
将以静默方式追加到它。
SOURCE_PUBLIC_KEY_PATH
Enables RSA key pair-based password exchange by providing the path name to a file containing a replica-side copy of the public key required by the source. 通过提供包含源所需公钥的副本端副本的文件的路径名,启用基于RSA密钥对的密码交换。The file must be in PEM format. 该文件必须为PEM格式。This option applies to replicas that authenticate with the 此选项适用于使用sha256_password
or caching_sha2_password
authentication plugin. sha256_password
或caching_sha2_password
身份验证插件进行身份验证的副本。(For (对于sha256_password
, SOURCE_PUBLIC_KEY_PATH
can be used only if MySQL was built using OpenSSL.) sha256_password
,只有在MySQL是使用OpenSSL构建的情况下,才能使用SOURCE_PUBLIC_KEY_PATH
。)If you are using a replication user account that authenticates with the 如果您使用的复制用户帐户使用caching_sha2_password
plugin (which is the default from MySQL 8.0), and you are not using a secure connection, you must specify either this option or the GET_SOURCE_PUBLIC_KEY=1
option to provide the RSA public key to the replica.caching_sha2_password
插件(MySQL 8.0中的默认插件)进行身份验证,并且您没有使用安全连接,则必须指定此选项或GET_SOURCE_PUBLIC_KEY=1
选项以向复制副本提供RSA公钥。
SOURCE_RETRY_COUNT
Sets the maximum number of reconnection attempts that the replica makes after the connection to the source times out, as determined by the 设置复制副本在与源的连接超时后进行的最大重新连接尝试次数,由系统变量slave_net_timeout
system variable. slave_net_timeout
确定。If the replica does need to reconnect, the first retry occurs immediately after the timeout.如果复制副本确实需要重新连接,则第一次重试将在超时后立即进行。
The interval between the attempts is specified by the 尝试之间的间隔由SOURCE_CONNECT_RETRY
option. SOURCE_CONNECT_RETRY
选项指定。If both the default settings are used, the replica waits 60 seconds between reconnection attempts (如果使用了这两种默认设置,则复制副本在两次重新连接尝试之间等待60秒(SOURCE_CONNECT_RETRY=60
), and keeps attempting to reconnect at this rate for 60 days (SOURCE_RETRY_COUNT=86400
). SOURCE_CONNECT_RETRY=60
),并在60天内继续尝试以此速率重新连接(SOURCE_RETRY_COUNT=86400
)。A setting of 0 for SOURCE_RETRY_COUNT
means that there is no limit on the number of reconnection attempts, so the replica keeps trying to reconnect indefinitely.SOURCE_RETRY_COUNT
设置为0意味着重新连接尝试次数没有限制,因此复制副本会一直尝试无限期重新连接。
The values for SOURCE_CONNECT_RETRY
and SOURCE_RETRY_COUNT
are recorded in the source metadata repository and shown in the replication_connection_configuration
Performance Schema table. SOURCE_CONNECT_RETRY
和SOURCE_RETRY_COUNT
的值记录在源元数据存储库中,并显示在replication_connection_configuration
性能架构表中。SOURCE_RETRY_COUNT
supersedes the --master-retry-count
server startup option.SOURCE_RETRY_COUNT
取代--master-retry-count
服务器启动选项。
SOURCE_SSL_xxx
,
SOURCE_TLS_xxx
Specify how the replica uses encryption and ciphers to secure the replication connection. 指定复制副本如何使用加密和密码来保护复制连接。These options can be changed even on replicas that are compiled without SSL support. 即使在不支持SSL的情况下编译的复制副本上,也可以更改这些选项。They are saved to the source metadata repository, but are ignored if the replica does not have SSL support enabled. 它们会保存到源元数据存储库中,但如果复制副本未启用SSL支持,则会被忽略。The SOURCE_SSL_
and xxx
SOURCE_TLS_
options perform the same functions as the xxx
--ssl-
and xxx
--tls-
client options described in Command Options for Encrypted Connections. xxx
SOURCE_SSL_
和xxx
SOURCE_TLS_
选项执行与加密连接的命令选项中描述的xxx
--ssl-
和xxx
--tls-
客户端选项相同的功能。xxx
The correspondence between the two sets of options, and the use of the 第17.3.1节,“设置复制以使用加密连接”中解释了两组选项之间的对应关系,以及使用SOURCE_SSL_
and xxx
SOURCE_TLS_
options to set up a secure connection, is explained in Section 17.3.1, “Setting Up Replication to Use Encrypted Connections”.xxx
SOURCE_SSL_
和xxx
SOURCE_TLS_
选项来设置安全连接。xxx
SOURCE_USER
The user name for the replication user account to use for connecting to the replication source server.用于连接复制源服务器的复制用户帐户的用户名。
To connect to the source using a replication user account that authenticates with the 要使用通过caching_sha2_password
plugin, you must either set up a secure connection as described in Section 17.3.1, “Setting Up Replication to Use Encrypted Connections”, or enable the unencrypted connection to support password exchange using an RSA key pair. caching_sha2_password
插件进行身份验证的复制用户帐户连接到源,必须按照第17.3.1节,“设置复制以使用加密连接”中的说明设置安全连接,或者启用未加密连接以支持使用RSA密钥对的密码交换。The caching_sha2_password
authentication plugin is the default for new users created from MySQL 8.0 (for details, see Section 6.4.1.2, “Caching SHA-2 Pluggable Authentication”). caching_sha2_password
身份验证插件是MySQL 8.0创建的新用户的默认插件(有关详细信息,请参阅第6.4.1.2节,“缓存SHA-2可插入身份验证”)。If the user account that you create or use for replication uses this authentication plugin, and you are not using a secure connection, you must enable RSA key pair-based password exchange for a successful connection. 如果您创建或用于复制的用户帐户使用此身份验证插件,并且您没有使用安全连接,则必须启用基于RSA密钥对的密码交换才能成功连接。You can do this using either the 您可以使用此语句的SOURCE_PUBLIC_KEY_PATH
option or the GET_SOURCE_PUBLIC_KEY=1
option for this statement.SOURCE_PUBLIC_KEY_PATH
选项或GET_SOURCE_PUBLIC_KEY=1
选项来执行此操作。
It is possible to set an empty user name by specifying 可以通过指定SOURCE_USER=''
, but the replication channel cannot be started with an empty user name. SOURCE_USER=''
来设置空用户名,但复制通道不能用空用户名启动。In releases before MySQL 8.0.21, only set an empty 在MySQL 8.0.21之前的版本中,仅当出于安全目的需要从复制元数据存储库中清除以前使用的凭据时,才设置空的SOURCE_USER
user name if you need to clear previously used credentials from the replication metadata repositories for security purposes. SOURCE_USER
用户名。Do not use the channel afterwards, due to a bug in these releases that can substitute a default user name if an empty user name is read from the repositories (for example, during an automatic restart of a Group Replication channel). 由于这些版本中存在缺陷,如果从存储库中读取空用户名(例如,在自动重新启动组复制通道期间),则可能会替换默认用户名,因此以后不要使用该通道。From MySQL 8.0.21, it is valid to set an empty 从MySQL 8.0.21开始,如果始终使用启动复制通道的SOURCE_USER
user name and use the channel afterwards if you always provide user credentials using the START REPLICA
statement or START GROUP_REPLICATION
statement that starts the replication channel. START REPLAC
E语句或START GROUP_REPLICATION
语句提供用户凭据,则设置空的SOURCE_USER
用户名并在之后使用通道是有效的。This approach means that the replication channel always needs operator intervention to restart, but the user credentials are not recorded in the replication metadata repositories.这种方法意味着复制通道总是需要操作员干预才能重新启动,但用户凭据不会记录在复制元数据存储库中。
The text of a running 正在运行的CHANGE REPLICATION SOURCE TO
statement, including values for SOURCE_USER
and SOURCE_PASSWORD
, can be seen in the output of a concurrent SHOW PROCESSLIST
statement. CHANGE REPLICATION SOURCE TO
语句的文本,包括SOURCE_USER
和SOURCE_PASSWORD
的值,可以在并发SHOW PROCESSLIST
语句的输出中看到。(The complete text of a (START REPLICA
statement is also visible to SHOW PROCESSLIST
.)START REPLICA
语句的完整文本也在SHOW PROCESSLIST
中可见。)
SOURCE_ZSTD_COMPRESSION_LEVEL
The compression level to use for connections to the replication source server that use the 用于连接到使用zstd
compression algorithm. zstd
压缩算法的复制源服务器的压缩级别。The permitted levels are from 1 to 22, with larger values indicating increasing levels of compression. 允许的水平从1到22,较大的值表示压缩水平增加。The default 默认的zstd
compression level is 3. zstd
压缩级别为3。The compression level setting has no effect on connections that do not use 压缩级别设置对不使用zstd
compression. zstd
压缩的连接没有影响。SOURCE_ZSTD_COMPRESSION_LEVEL
is available as of MySQL 8.0.18. SOURCE_ZSTD_COMPRESSION_LEVEL
从MySQL 8.0.18开始可用。For more information, see Section 4.2.8, “Connection Compression Control”.有关更多信息,请参阅SOURCE_ZSTD_COMPRESSION_LEVEL第4.2.8节,“连接压缩控制”。
The following table shows the maximum permissible length for the string-valued options.下表显示了字符串值选项的最大允许长度。
SOURCE_HOST | 255 |
SOURCE_USER | 96 |
SOURCE_PASSWORD | 32 |
SOURCE_LOG_FILE | 511 |
RELAY_LOG_FILE | 511 |
SOURCE_SSL_CA | 511 |
SOURCE_SSL_CAPATH | 511 |
SOURCE_SSL_CERT | 511 |
SOURCE_SSL_CRL | 511 |
SOURCE_SSL_CRLPATH | 511 |
SOURCE_SSL_KEY | 511 |
SOURCE_SSL_CIPHER | 511 |
SOURCE_TLS_VERSION | 511 |
SOURCE_TLS_CIPHERSUITES | 4000 |
SOURCE_PUBLIC_KEY_PATH | 511 |
SOURCE_COMPRESSION_ALGORITHMS | 99 |
NETWORK_NAMESPACE | 64 |