2015-11-19 74 views
0

我正在測試運行Debian 8.2的VirtualBox的兩臺虛擬機上的MySQL複製。 以下教程,我這是怎麼設定的從屬的/ 等/ mysql /下的my.cnfMySQL複製 - 奴隸不會啓動mysql服務

server-id = 2 
master-host = 192.168.56.101 
master-connect-retry = 60 
master-user = slave 
master-password = 123 
replicate-do-db = base1 
replicate-do-db = base2 

relay-log = /var/lib/mysql/slave-relay.log 
relay-log-index = /var/lib/mysql/slave-relay-log.index 

但是,這樣做也不會讓我啓動mysql。當我運行/etc/init.d/mysql start時,它失敗。這些是出現在日誌中的兩個錯誤:

error: Can't connect to local MySQL server through socket '/var/run/mysql/mysqld.sock' (2) 
Failed to start LSB: Start and stop the mysql server database daemon 

談到了主ZZZ線允許的mysql啓動順利。

虛擬機可以看到對方並ping無損。我嘗試過更改my.cnf的主用戶和密碼,以及在主服務器上創建不同的複製從屬用戶,但無濟於事。我究竟做錯了什麼?

回答

1

那麼,事實證明,我所遵循的教程有點過時了。這些都是的my.cnf文件的最終配置:

#master 
bind-address = 0.0.0.0 
server-id = 1 
log-bin= /var/log/mysql/mysql-bin.log 

#slave 
server-id = 2 

而不是設置奴隸的my.cnf中,我使用MySQL控制檯:

CHANGE MASTER TO master_host='master_ip', master_user='slave', master_password='slavepass'; 

按照本手冊的說明:https://downloads.mysql.com/docs/mysql-replication-excerpt-5.0-en.pdf