2012-10-28 31 views
0

我想在2臺MySQL 5.5服務器上只使用SQL語句來設置master-master複製,但它似乎沒有工作。如何僅使用SQL語句設置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 '[email protected]: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. 
+0

你沒有使用MySQL。你正在使用MariaDB,一個分支。應該是相似的,但它可能是重要的信息。 – ceejayoz

+0

噢,我幾乎忘了它,因爲它與MySQL非常相似,並且與爲MySQL設計的應用程序一起工作,這裏有一個快速的區別列表,謝謝 - https://kb.askmonty.org/en/mariadb-versus-mysql-功能/ – Joshua

回答

0

二進制日誌未打開(server_errno = 1236)

看來喲你還沒有開始你的主人的二進制日誌。我建議你停止從站,然後執行slave reset,然後通過將log-bin設置爲要用於二進制日誌的文件來打開主站的二進制日誌。

+0

感謝您的建議,這個工程,但我需要能夠使用SQL語句完成。爲什麼不會「SET GLOBAL sql_log_bin = 1;」照着做?請參閱:http://dev.mysql.com/doc/refman/5.0/en/set-sql-log-bin.html – Joshua

相關問題