我正在尝试仅使用 SQL 语句在 2 个 MySQL 5.5 服务器上设置主-主复制,但它似乎不起作用。
我在 IP 地址 192.168.0.20(服务器 A)和 192.168.0.5(服务器 B)上有 2 个 MySQL 服务器。
在服务器 A 上,我运行以下 SQL 语句。
CHANGE MASTER TO MASTER_HOST='192.168.0.5',
MASTER_PORT=3306,
MASTER_USER='root',
MASTER_PASSWORD='password-here',
master_connect_retry=6000;
set global sql_log_bin=1;
set global server_id=1;
set auto_increment_increment=2;
set auto_increment_offset=1;
start slave;
服务器 A 上的错误日志显示:
121029 0:36:01 InnoDB: Waiting for the background threads to start
121029 0:36:02 Percona XtraDB (http://www.percona.com) 1.1.8-28.1 started; log sequence number 1624076
121029 0:36:02 [Note] Plugin 'FEEDBACK' is disabled.
121029 0:36:02 [Note] Event Scheduler: Loaded 0 events
121029 0:36:02 [Note] C:\Program Files (x86)\MariaDB 5.5\bin\mysqld.exe: ready for connections. Version: '5.5.27-MariaDB' socket: '' port: 3306 mariadb.org binary distribution
121029 0:39:05 [Warning] Neither --relay-log nor --relay-log-index were used; so replication may break when this MySQL server acts as a slave and has his hostname changed!! Please use '--log-basename=#' or '--relay-log=JoshuaNotebook-relay-bin' to avoid this problem.
121029 0:39:05 [Note] 'CHANGE MASTER TO executed'. Previous state master_host='', master_port='3306', master_log_file='', master_log_pos='4'. New state master_host='192.168.0.5', master_port='3306', master_log_file='', master_log_pos='4'.
121029 0:39:05 [Note] Slave SQL thread initialized, starting replication in log 'FIRST' at position 0, relay log '.\JoshuaNotebook-relay-bin.000001' position: 4
121029 0:39:05 [Note] Slave I/O thread: connected to master 'root@192.168.0.5:3306',replication started in log 'FIRST' at position 4
121029 0:39:05 [ERROR] Error reading packet from server: Binary log is not open ( server_errno=1236)
121029 0:39:05 [ERROR] Slave I/O: Got fatal error 1236 from master when reading data from binary log: 'Binary log is not open', Error_code: 1236
121029 0:39:05 [Note] Slave I/O thread exiting, read up to log 'FIRST', position 4
服务器 B 上的错误日志显示:
121029 0:36:08 InnoDB: Waiting for the background threads to start
121029 0:36:09 Percona XtraDB (http://www.percona.com) 1.1.8-28.1 started; log sequence number 1623052
121029 0:36:09 [Note] Plugin 'FEEDBACK' is disabled.
121029 0:36:09 [Note] Event Scheduler: Loaded 0 events
121029 0:36:09 [Note] C:\Program Files\MariaDB 5.5\bin\mysqld.exe: ready for connections. Version: '5.5.27-MariaDB' socket: '' port: 3306 mariadb.org binary distribution
121029 0:39:05 [Warning] IP address '192.168.0.20' could not be resolved: The requested name is valid and was found in the database, but it does not have the correct associated data being resolved for.