17.1.4 Replication and Binary Logging Options and Variables

17.1.4 Replication and Binary Logging Options and Variables 复制和Binary logging 选择和变量

17.1.4.1 Replication and Binary Logging Option and Variable Reference 复制和Binary Logging 选项和变量引用

17.1.4.2 Replication Master Options and Variables 复制Master选项和变量

17.1.4.3 Replication Slave Options and Variables 复制Slave选项和变量

17.1.4.4 Binary Log Options and Variables Binary Log选项和变量

17.1.4.5 Global Transaction ID Options and Variables

下面的章节包含信息关于mysqld 选项和server 变量,用于复制和配置binary log.

选项和变量用于复制master和复制slave 是单独的,选项和变量和binary logging 相关。

快速参考表提供了基本的信息关于那些选项和变量也包括在内:

特别重要的是–server-id 选项:

Command-Line Format –server-id=#
System Variable Name server_id
Variable Scope Global
Dynamic Variable Yes
Permitted Values Type integer
Default 0
Min Value 0
Max Value 4294967295

此选项是共同的用于master和salve 复制服务器,用于复制过程中启用master和slave servers 来识别它们的唯一标示。

更多的信息,, see Section 17.1.4.2, “Replication Master Options and Variables”, and Section 17.1.4.3,

“Replication Slave Options and Variables”.

在主和每个slave, 你必须使用 –server-id option 来建立一个唯一的复制ID 在1到232-1之间。

唯一,意味着每个ID 必须不同于其他的ID 。

如果你省略了 –server-id,默认是0,会导致master拒绝所有slave的连接, slaves拒绝连到master.

在MySQL 5.6中, 是否server ID 被明确的设置为0 或者默认是允许被使用,

server 设置server_id 变量为1

server_uuid

在5.6开始, sever 生成一个真的UUID 除server-id之外。这个变量是全局的,只读变量

当开始时,MySQL server 自动得到一个UUID如下:

尝试读取和使用UUID 写在文件data_dir/auto.cnf(data_dir 是server的数据目录)

如果data_dir/auto.cnf 没有找到,生成一个新的UUID,保存到这个文件,如果需要创建一个文件。

auto.cnf 文件 有一个类似的格式,和my.cnf或者my.ini文件类似。在MySQL 5.6,

auto.cnf 只有一个单独的[auto]章节 包含一个单独的server_uuid 设置和值,文件的内容出现类似于如下:

[auto]
server_uuid=8a94f357-aab4-11df-86ab-c80aa9429562

重要: auto.cnf 文件是自动生成的,不尝试些或者修改文件:

在MySQL 5.6开始,当使用MySQL 复制的时候,masters和slaves 都知道彼此的UUID,一个slave的uuid 可以在

SHOW SLAVE HOSTS里看到,一旦START SLAVE 已经被执行,master的UUID 的值是可以从SHOW SLAVE STATUS显示

注意:

执行STOP SLAVE或者RESET SLAVE语句不重置master的UUID

在MySQL 5.6.5和以后版本, 一个server的server_uuid 也用于GTIDs 用于事务产生在server上。

更多的信息,see Section 17.1.3, “Replication with Global Transaction Identifiers”.

原文地址:https://www.cnblogs.com/hzcya1995/p/13351322.html