我正在尝试使用this tutorial在本地计算机上设置主从复制。

我快结束了,但是当我尝试使用mysqldump运行--master-data=2时出现错误

mysqldump: Error: Binlogging on server not active

我遇到的所有解决方案都说我已经将log_bin = /var/log/mysql/mysql-bin.log添加到my.cnf中了,但这似乎并不能解决问题。

这是我的my.cnf文件:
[client]
port            = 3306
socket          = /var/run/mysqld/mysqld.sock

[mysqld_safe]
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
nice            = 0

[mysqld_multi]
mysqld      = /usr/bin/mysqld_safe
mysqladmin  = /usr/bin/mysqladmin
user        = multi_admin
password    = multipass

[mysqld2]
user            = mysql
pid-file        = /var/run/mysqld/mysqld_slave.pid
socket          = /var/run/mysqld/mysqld_slave.sock
port            = 3307
basedir         = /usr
datadir         = /var/lib/mysql_slave
tmpdir          = /tmp
lc-messages-dir = /usr/share/mysql
explicit_defaults_for_timestamp
server-id   = 2
relay-log   = /var/log/mysql_slave/relay-bin
relay-log-index = /var/log/mysql_slave/relay-bin.index
master-info-file = /var/log/mysql_slave/master.info
relay-log-info-file = /var/log/mysql_slave/relay-log.info
read_only   = 1

[mysqld1]
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3305
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
lc-messages-dir = /usr/share/mysql
explicit_defaults_for_timestamp
server-id   = 1
log_bin     = /var/log/mysql/mysql-bin.log
innodb_flush_log_at_trx_commit = 1
sync_binlog = 1
binlog-format = ROW

# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 0.0.0.0

log-error       = /var/log/mysql/error.log

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf', otherwise they'll be ignored.

!includedir /etc/mysql/conf.d/

最佳答案

我可以建议您放弃mysql_multi并使用Docker解决方案。这使您可以拥有单独的my.cnf文件,这可能是问题的一部分。

甚至可能已经为Master和Slave设置了一对Docker镜像。我很确定有Galera集群。

我想您是在单个服务器上设置M-S只是为了进行实验?这样做对于生产几乎是没有用的。

关于mysql - 错误: Binlogging on server not active when setting up Master Slave replication on one machine,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45210078/

10-16 07:25