Mysql-Replication

MariaDB 自增-自增無效

  • December 19, 2018

我正在嘗試設置主-主 MySQL 複製(兩個活動伺服器)。當我在 Centos 7 上執行此操作時,我必須使用 MariaDB 而不是 MySQL,儘管它看起來非常相似。

所以,在我設置複製之前,我試圖設置自動增量以避免主鍵衝突。我將 auto-increment-increment 設置為 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

好吧,萬一有人遇到同樣的錯誤:我通過安裝不同的版本來修復它。不太清楚我是怎麼做到的,但是通過使用不同的 yum 儲存庫,我設法安裝了 MySQL 的社區版本,它可以按預期工作

引用自:https://serverfault.com/questions/710599