文档章节

数据库mysql实现读写分离应用

问题达人
 问题达人
发布于 2016/03/31 09:15
字数 171
阅读 5
收藏 0

参考:http://www.cnblogs.com/DavidYan/articles/2531181.html

1,创建用户

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

2,定义日志

主服务器“

在[mysqld]下面增加下面几行代码

server-id=1 //给数据库服务的唯一标识,一般为大家设置服务器Ip的末尾号

log-bin=master-bin

log-bin-index=master-bin.index

查看日志

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