【发布时间】:2018-05-13 07:39:22
【问题描述】:
我一直在 Master-Master-Replication 中设置两个基于 Debian Stretch 的 MariaDB-Server。
Slave 的复制配置部分是:
server-id = 2226
auto_increment_increment = 1
auto_increment_offset = 1
log_bin = /var/tmp/mysql_binlog/mysql-bin.log
log_bin_index = /var/tmp/mysql_binlog/mysql-bin.log.index
expire_logs_days = 3
max_binlog_size = 100M
relay_log = /var/tmp/mysql_binlog/slave-relay.log
relay_log_index = /var/tmp/mysql_binlog/slave-relay.log.index
log_slave_updates = 1
replicate_annotate_row_events = 0
log_bin_trust_function_creators = 1
我遇到以下错误:
show slave status\G;
Relay_Log_File: slave-relay.032025
Relay_Log_Pos: 14887746
Relay_Master_Log_File: mysql-bin.001119
Slave_IO_Running: Yes
Last_Errno: 1062
Last_Error: Error 'Duplicate entry '71899-single' for key 'PRIMARY'' on query. Default database: 'mydb'. Query: 'INSERT INTO document_reference
(document_reference_document_id, document_reference_type, document_reference_value)
VALUES (71899, "single", 0)'
但是:
MariaDB [(none)]> select * from mydb.document_reference WHERE document_reference_document_id=71899;
Empty set (0.00 sec)
我查看了中继日志文件 - 只有一个插入语句。
有人知道是什么导致从属设备出现重复输入错误吗?
补充资料:
主设置:
auto_increment_increment | 1
auto_increment_offset | 1
binlog_format | MIXED
表定义:
CREATE TABLE "document_reference" (
"document_reference_document_id" int(10) unsigned NOT NULL,
"document_reference_type" enum('single,'multi') COLLATE utf8_unicode_ci
NOT NULL DEFAULT 'single',
"document_reference_value" int(11) NOT NULL,
PRIMARY KEY ("document_reference_document_id","document_reference_type"))
【问题讨论】:
-
从站上是否有已经一行,PK 为 71899,'single'? Masters 上
auto_increment_increment的值是多少?是RBR还是SBR?告诉我们SHOW CREATE TABLE document_reference -
嗨@RickJames!我刚刚添加了信息。