The following functions, which are available from MySQL 8.0.22 for standard source to replica replication and from MySQL 8.0.23 for Group Replication, enable you to add and remove replication source servers from the source list for a replication channel. 以下功能可用于MySQL 8.0.22中的标准源到副本复制,以及MySQL 8.0.23中的组复制,使您能够从复制通道的源列表中添加和删除复制源服务器。The asynchronous connection failover mechanism automatically establishes an asynchronous (source to replica) replication connection to a new source from the appropriate list after the existing connection from the replica to its source fails. 异步连接故障切换机制会在副本与其源之间的现有连接失败后,自动从相应列表中建立到新源的异步(源到副本)复制连接。From MySQL 8.0.23, the connection is also changed if the currently connected source does not have the highest weighted priority in the group. 从MySQL 8.0.23开始,如果当前连接的源在组中没有最高的加权优先级,则连接也会更改。For Group Replication source servers that are defined as part of a managed group, the connection is also failed over to another group member if the currently connected source leaves the group or is no longer in the majority. 对于定义为受管组一部分的组复制源服务器,如果当前连接的源离开组或不再占多数,则连接也会故障转移到另一个组成员。For more information on the mechanism, see Section 17.4.9, “Switching Sources with Asynchronous Connection Failover”.有关该机制的更多信息,请参阅第17.4.9节,“使用异步连接故障切换切换源”。
The source lists are stored in the 源列表存储在mysql.replication_asynchronous_connection_failover
and mysql.replication_asynchronous_connection_failover_managed
tables, and can be viewed in the Performance Schema table replication_asynchronous_connection_failover
.mysql.replication_asynchronous_connection_failover
和mysql.replication_asynchronous_connection_failover_managed
表中,可以在性能模式表replication_asynchronous_connection_failover
中查看。
asynchronous_connection_failover_add_source()
Add configuration information for a replication source server to the source list for a replication channel.将复制源服务器的配置信息添加到复制通道的源列表中。
Syntax:语法:
asynchronous_connection_failover_add_source(channel
,host
,port
,network_namespace
,weight
)
Arguments:参数:
channel
: The replication channel for which this replication source server is part of the source list.:此复制源服务器是其源列表一部分的复制通道。
host
: The host name for this replication source server.:此复制源服务器的主机名。
port
: The port number for this replication source server.:此复制源服务器的端口号。
network_namespace
: The network namespace for this replication source server. Specify an empty string, as this parameter is reserved for future use.:此复制源服务器的网络命名空间。指定一个空字符串,因为此参数保留供将来使用。
weight
: The priority of this replication source server in the replication channel's source list. :复制通道的源列表中此复制源服务器的优先级。The priority is from 1 to 100, with 100 being the highest, and 50 being the default. 优先级从1到100,100为最高优先级,50为默认优先级。When the asynchronous connection failover mechanism activates, the source with the highest priority setting among the alternative sources listed in the source list for the channel is chosen for the first connection attempt. 当异步连接故障切换机制激活时,在通道的源列表中列出的备选源中,选择优先级设置最高的源进行第一次连接尝试。If this attempt does not work, the replica tries with all the listed sources in descending order of priority, then starts again from the highest priority source. 如果此尝试不起作用,复制副本将按优先级降序尝试所有列出的源,然后从优先级最高的源重新开始。If multiple sources have the same priority, the replica orders them randomly. 如果多个源具有相同的优先级,则复制副本会随机对其排序。From MySQL 8.0.23, the asynchronous connection failover mechanism activates if the currently connected source is not the highest weighted in the group.从MySQL 8.0.23开始,如果当前连接的源不是组中权重最高的源,异步连接故障切换机制将激活。
Return value:返回值:
A string containing the result of the operation, for example whether it was successful or not.包含操作结果的字符串,例如操作是否成功。
Example:例子:
SELECT asynchronous_connection_failover_add_source('channel2', '127.0.0.1', 3310, '', 80);
+-------------------------------------------------------------------------------------------------+
| asynchronous_connection_failover_add_source('channel2', '127.0.0.1', 3310, '', 80) |
+-------------------------------------------------------------------------------------------------+
| Source configuration details successfully inserted. |
+-------------------------------------------------------------------------------------------------+
For more information, see Section 17.4.9, “Switching Sources with Asynchronous Connection Failover”.有关更多信息,请参阅第17.4.9节,“使用异步连接故障切换切换源”。
asynchronous_connection_failover_delete_source()
Remove configuration information for a replication source server from the source list for a replication channel.从复制通道的源列表中删除复制源服务器的配置信息。
Syntax:语法:
asynchronous_connection_failover_delete_source(channel
,host
,port
,network_namespace
)
Arguments:参数:
channel
: The replication channel for which this replication source server was part of the source list.:此复制源服务器是其源列表一部分的复制通道。
host
: The host name for this replication source server.:此复制源服务器的主机名。
port
: The port number for this replication source server.:此复制源服务器的端口号。
network_namespace
: The network namespace for this replication source server. :此复制源服务器的网络命名空间。Specify an empty string, as this parameter is reserved for future use.指定一个空字符串,因为此参数保留供将来使用。
Return value:返回值:
A string containing the result of the operation, for example whether it was successful or not.包含操作结果的字符串,例如操作是否成功。
Example:例子:
SELECT asynchronous_connection_failover_delete_source('channel2', '127.0.0.1', 3310, '');
+------------------------------------------------------------------------------------------------+
| asynchronous_connection_failover_delete_source('channel2', '127.0.0.1', 3310, '') |
+------------------------------------------------------------------------------------------------+
| Source configuration details successfully deleted. |
+------------------------------------------------------------------------------------------------+
For more information, see Section 17.4.9, “Switching Sources with Asynchronous Connection Failover”.有关更多信息,请参阅第17.4.9节,“使用异步连接故障切换切换源”。
asynchronous_connection_failover_add_managed()
Add configuration information for a replication source server that is part of a managed group (a Group Replication group member) to the source list for a replication channel. 将属于托管组(组复制组成员)的复制源服务器的配置信息添加到复制通道的源列表中。You only need to add one group member. 您只需要添加一个组成员。The replica automatically adds the rest from the current group membership, then keeps the source list updated in line with membership change.复制副本会自动添加当前组成员资格中的其余成员,然后根据成员资格的更改保持源列表的更新。
Syntax:语法:
asynchronous_connection_failover_add_managed(channel
,managed_type
,managed_name
,host
,port
,network_namespace
,primary_weight
,secondary_weight
)
Arguments:参数:
channel
: The replication channel for which this replication source server is part of the source list.:此复制源服务器是其源列表一部分的复制通道。
managed_type
: The type of managed service that the asynchronous connection failover mechanism must provide for this server. :异步连接故障转移机制必须为此服务器提供的托管服务的类型。The only value currently accepted is 当前唯一接受的值是GroupReplication
.GroupReplication
。
managed_name
: The identifier for the managed group that the server is a part of. :服务器所属的托管组的标识符。For the 对于GroupReplication
managed service, the identifier is the value of the group_replication_group_name
system variable.GroupReplication
托管服务,标识符是group_replication_group_name
系统变量的值。
host
: The host name for this replication source server.:此复制源服务器的主机名。
port
: The port number for this replication source server.:此复制源服务器的端口号。
network_namespace
: The network namespace for this replication source server. :此复制源服务器的网络命名空间。Specify an empty string, as this parameter is reserved for future use.指定一个空字符串,因为此参数保留供将来使用。
primary_weight
: The priority of this replication source server in the replication channel's source list when it is acting as the primary for the managed group. :当此复制源服务器充当受管组的主服务器时,它在复制通道的源列表中的优先级。The weight is from 1 to 100, with 100 being the highest. 重量从1到100,其中100是最高的。For the primary, 80 is a suitable weight. 对于小学来说,80是一个合适的体重。The asynchronous connection failover mechanism activates if the currently connected source is not the highest weighted in the group. 如果当前连接的源不是组中权重最高的源,则会激活异步连接故障切换机制。Assuming that you set up the managed group to give a higher weight to a primary and a lower weight to a secondary, when the primary changes, its weight increases, and the replica changes over the connection to it.假设您将受管组设置为为主组赋予更高的权重,次组赋予较低的权重,当主组发生更改时,其权重会增加,并且复制副本会通过与它的连接发生更改。
secondary_weight
: The priority of this replication source server in the replication channel's source list when it is acting as a secondary in the managed group. :此复制源服务器在复制通道的源列表中作为受管组中的辅助服务器时的优先级。The weight is from 1 to 100, with 100 being the highest. 重量从1到100,其中100是最高的。For a secondary, 60 is a suitable weight.对于中学来说,60是一个合适的体重。
Return value:返回值:
A string containing the result of the operation, for example whether it was successful or not.包含操作结果的字符串,例如操作是否成功。
Example:例子:
SELECT asynchronous_connection_failover_add_managed('channel2', 'GroupReplication', 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', '127.0.0.1', 3310, '', 80, 60);
+----------------------------------------------------------------------------------------------------------------------------------------------------+
| asynchronous_connection_failover_add_source('channel2', 'GroupReplication', 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', '127.0.0.1', 3310, '', 80, 60) |
+----------------------------------------------------------------------------------------------------------------------------------------------------+
| Source managed configuration details successfully inserted. |
+----------------------------------------------------------------------------------------------------------------------------------------------------+
For more information, see Section 17.4.9, “Switching Sources with Asynchronous Connection Failover”.有关更多信息,请参阅第17.4.9节,“使用异步连接故障切换切换源”。
asynchronous_connection_failover_delete_managed()
Remove an entire managed group from the source list for a replication channel. 从复制通道的源列表中删除整个受管组。When you use this function, all the replication source servers defined in the managed group are removed from the channel's source list.使用此功能时,将从通道的源列表中删除托管组中定义的所有复制源服务器。
Syntax:语法:
asynchronous_connection_failover_delete_managed(channel
,managed_name
)
Arguments:参数:
channel
: The replication channel for which this replication source server was part of the source list.:此复制源服务器是其源列表一部分的复制通道。
managed_name
: The identifier for the managed group that the server is a part of. :服务器所属的托管组的标识符。For the 对于GroupReplication
managed service, the identifier is the value of the group_replication_group_name
system variable.GroupReplication
托管服务,标识符是group_replication_group_name
系统变量的值。
Return value:返回值:
A string containing the result of the operation, for example whether it was successful or not.包含操作结果的字符串,例如操作是否成功。
Example:例子:
SELECT asynchronous_connection_failover_delete_managed('channel2', 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa');
+-----------------------------------------------------------------------------------------------------+
| asynchronous_connection_failover_delete_managed('channel2', 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa') |
+-----------------------------------------------------------------------------------------------------+
| Source managed configuration details successfully deleted. |
+-----------------------------------------------------------------------------------------------------+
For more information, see Section 17.4.9, “Switching Sources with Asynchronous Connection Failover”.有关更多信息,请参阅第17.4.9节,“使用异步连接故障切换切换源”。