gpt4 book ai didi

mysql - Master-Master 复制 auto_increment_offset

转载 作者:行者123 更新时间:2023-11-30 23:49:31 27 4
gpt4 key购买 nike

我设置了 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
...

有可能吗?

最佳答案

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

关于mysql - Master-Master 复制 auto_increment_offset,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18941096/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com