10 mysql database replication master-slave
我一直在忠实地按照以下说明设置 MySQL 主复制(在 Debian 6.0.1 上):http : //www.neocodesoftware.com/replication/
我已经到了:
mysql > show master status;
Run Code Online (Sandbox Code Playgroud)
但不幸的是,这会产生以下结果,而不是任何有用的输出:
Empty set (0.00 sec)
Run Code Online (Sandbox Code Playgroud)
错误日志/var/log/mysql.err只是一个空文件,所以没有给我任何线索。
有任何想法吗?
这是我/etc/mysql/my.cnf在一台服务器上放置的内容(针对另一台服务器进行了适当修改):
server-id = 1
replicate-same-server-id = 0
auto-increment-increment = 2
auto-increment-offset = 1
master-host = 10.0.0.3
master-user = <myusername>
master-password = <mypass>
master-connect-retry = 60
replicate-do-db = fruit
log-bin = /var/log/mysql-replication.log
binlog-do-db = fruit
Run Code Online (Sandbox Code Playgroud)
我已经设置了用户,可以使用上面的用户名/密码/IP 地址从服务器 A 上的 MySQL 连接到服务器 B 上的数据库。
有趣的是,我在我的 PC 上运行了 mysql,但未启用二进制日志。我做了以下事情:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 5.5.12 MySQL Community Server (GPL)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show master status;
Empty set (0.00 sec)
mysql> show binary logs;
ERROR 1381 (HY000): You are not using binary logging
mysql>
Run Code Online (Sandbox Code Playgroud)
如图所示,由于 MySQL 为 SHOW MASTER STATUS 显示“Empty Set”;因为未启用二进制日志记录。考虑到我的配置,这很明显。
您应该做的第一件事是确保错误日志具有特定文件夹
[mysqld]
log-error=/var/log/mysql/mysql.err
log-bin = /var/log/mysql/mysql-replication.log
Run Code Online (Sandbox Code Playgroud)
然后运行以下命令:
service mysql stop
mkdir /var/log/mysql
chown -R mysql:mysql /var/log/mysql
service mysql start
Run Code Online (Sandbox Code Playgroud)
然后在 mysql 客户端运行这些 SQL 命令
SHOW MASTER STATUS;
SHOW BINARY LOGS;
Run Code Online (Sandbox Code Playgroud)
如果您得到与我之前相同的输出,则 MySQL 无法将二进制日志写入指定的文件夹。您的困境成为 MySQL 无法写入 /var/log 的原因。
这不是一个完整的答案,但我希望这会有所帮助。
| 归档时间: |
|
| 查看次数: |
43388 次 |
| 最近记录: |