2013-09-22 37 views
1

我已经设置了2个MySQL服务器:主 - 主复制auto_increment_offset

my.cnf文件服务器1:

auto_increment_increment = 2 
auto_increment_offset = 1 

my.cnf文件服务器2:

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

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

+2

这样做会造成潜在的冲突风险。 –