2013-09-22 36 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

這樣做會造成潛在的衝突風險。 –