數據庫mysql實現讀寫分離應用

參考:http://www.cnblogs.com/DavidYan/articles/2531181.htmlhtml

1,建立用戶mysql

grant replication slave on . to 'rep1'@'192.168.%.%' identified by 'fuhan'sql

2,定義日誌數據庫

主服務器「服務器

在[mysqld]下面增長下面幾行代碼ide

server-id=1 //給數據庫服務的惟一標識,通常爲你們設置服務器Ip的末尾號日誌

log-bin=master-binserver

log-bin-index=master-bin.indexhtm

查看日誌blog

show master status

次服務器:1 [mysqld]

server-id=2

relay-log-index=slave-relay-bin.index

relay-log=slave-relay-bin

change master to master_host='192.168.242.1',

master_user='rep1',

master_password='fuhan',

master_log_file='mysql-bin.000002',

master_log_pos=1168;

單次修改:CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000004',MASTER_LOG_POS=120;

查看配置

show slave status\G

報錯:

Slave can not handle replication events with the checksum that master is configured to log;

解決,主機mysqld裏面設置:

flush logs;

binlog_checksum =none

相關文章
相關標籤/搜索