天天看點

17.1.4.2 Replication Master Options and Variables

17.1.4.2 Replication Master Options and Variables 複制Master 選項和變量:

本節描述了server選項和系統變量 ,你可以使用在複制master server上。你可以指定選項在指令行或者選項檔案,

你可以指定系統變量使用SET:

在master和每個slave上, 你必須使用server-id選項來建立一個唯一的複制ID.對于每個server,

你可以選擇一個唯一的正數,每個ID 必須不同于其他ID

下面的系統變量用于控制複制master:

auto_increment_increment

System Variable Name auto_increment_increment

Variable Scope Global, Session

Dynamic Variable Yes

Permitted Values Type integer

Default 1

Min Value 1

Max Value 65535

auto_increment_increment and auto_increment_offset是用于主主複制,可以用于控制AUTO_INCREMENT 的操作。

兩個變量都有global和session 值,每個值可以在1到65535之間,設定它們中的任何一個值為0會導緻

值代替為1.

這兩個變量影響AUTO_INCREMENT 列行為如下:

mysql> SHOW VARIABLES LIKE ‘auto_inc%’;

+————————–+——-+

| Variable_name | Value |

| auto_increment_increment | 1 |

| auto_increment_offset | 1 |

2 rows in set (0.00 sec)

mysql> CREATE TABLE autoinc1

-> (col INT NOT NULL AUTO_INCREMENT PRIMARY KEY);

Query OK, 0 rows affected (0.04 sec)

mysql> SET @@auto_increment_increment=10;

Query OK, 0 rows affected (0.00 sec)

| auto_increment_increment | 10 |

2 rows in set (0.01 sec)

mysql> INSERT INTO autoinc1 VALUES (NULL), (NULL), (NULL), (NULL);

Query OK, 4 rows affected (0.00 sec)

Records: 4 Duplicates: 0 Warnings: 0

mysql> SELECT col FROM autoinc1;

+—–+

| col |

| 1 |

| 11 |

| 21 |

| 31 |

4 rows in set (0.00 sec)

繼續閱讀