配置Mysql主從服務(wù)實(shí)現(xiàn)實(shí)例
### 配置主數(shù)據(jù)庫(kù) my.cnf
server-id=1 log-bin=master-bin log-bin-index=master-bin.index
### 在主數(shù)據(jù)庫(kù)上創(chuàng)建同步賬號(hào)
create user backup; GRANT REPLICATION SLAVE ON *.* TO 'backup'@'192.168.%.%' IDENTIFIED BY 'mysql';
### 配置從數(shù)據(jù)庫(kù) my.cnf
server-id=2 relay-log-index=slave-relay-bin.index relay- log=slave-relay-bin
### 重啟mysql服務(wù)
service mysqld restart
### 連接Master服務(wù)
change master to master_host='192.168.91.128', master_port=3306,master_user='backup',master_password='mysql', master_log_file='master-bin.000001',master_log_pos=0;
### 啟動(dòng)slave服務(wù)
start slave;
### 查看Master服務(wù)狀態(tài)
SHOW MASTER STATUS;
### 查看Slave服務(wù)狀態(tài)
SHOW slave STATUS \G;
### 檢查server_id是否一樣,需要不一樣
show variables like 'server_id';
常見錯(cuò)誤
錯(cuò)誤: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server UUIDs; these UUIDs must be different for replication to work.
解決方式: 檢查data目錄中的auto.cnf中的server-uuid=******************** 是否一樣的,要改為不一樣
感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com