我正在尝试设置主-主 MySQL 复制(两个活动服务器)。由于我在 Centos 7 上执行此操作,因此我必须使用 MariaDB 而不是 MySQL,尽管它们看起来非常相似。
因此,在设置复制之前,我尝试设置自动增量以避免主键冲突。我将自动增量设置为 10,并将偏移量设置为 8(暂时随机设置以检查其是否有效),重新启动整个服务器,然后前往 PHPMyAdmin,在其中运行以下 SQL:
INSERT INTO `table`(`rdm`) VALUES ('345');
INSERT INTO `table`(`rdm`) VALUES ('345');
INSERT INTO `table`(`rdm`) VALUES ('345');
INSERT INTO `table`(`rdm`) VALUES ('345');
但是,A_I 键 (id) 仍然只每行增加 1。在 MariaDB 中还有其他方法可以执行 AII 吗?
这是我的my.cnf
文件:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
# bind-address = 127.0.0.1
server-id = 1
# report_host = master1
log_bin = /var/log/mysql/mariadb-bin
log_bin_index = /var/log/mysql/mariadb-bin.index
relay_log = /var/log/mysql/relay-bin
relay_log_index = /var/log/mysql/relay-bin.index
# replicate-do-db = testdb
auto-increment-increment = 10
auto-increment-offset = 8
答案1
好吧,以防有人遇到同样的错误:我通过安装不同的版本修复了它。不太清楚我是怎么做到的,但通过使用不同的 yum repos,我成功安装了一个社区版的 MySQL,它按预期工作