Master-Master复制auto_increment_offset

时间:2013-09-22 06:37:26

标签: mysql replication multi-master-replication

我已经设置了2台MYSQL服务器:

my.cnf server1:

auto_increment_increment = 2
auto_increment_offset = 1 

my.cnf server2:

auto_increment_increment = 2
auto_increment_offset = 2 

但是当我从不同的服务器逐个插入记录10次时:

INSERT INTO `table1` (`id`, `text`) VALUES (NULL, '22222');

结果:

id  text
1   22222
2   22222
5   22222
6   22222
9   22222
...

但我想:

id  text
1   22222
2   22222
3   22222
4   22222
5   22222
...

有可能吗?

1 个答案:

答案 0 :(得分:-1)

部分原因可能是因为插入是从单独的会话中调用的。使用auto_increment_increment = 2,我的猜测是你可能无法得到你想要的结果。您是否尝试将auto_increment_increment和auto_increment_offset都设置为1?