1.主服务器vim /etc/my.cnf

server-id=1log_bin=master-binlog_bin_index=master-bin.indexbinlog_do_db=cbs_base
其他属性说明


2.登录mysql mysql -u -p
3.在主服务器上创建从服务器的用户和权限

GRANT REPLICATION test ON *.* TO 'test'@'% ';

GRANT REPLICATION SLAVE ON *.* TO 'test'@'% ';SLAVE SLAVE
show master status;

service mysql restart
4.从服务器vim /etc/my.cnf
server-id=2
relay-log=slave-relay-bin
relay-log-index=slave-relay-bin.index
5.登录从服务器mysql
6. 在从服务器上连接master主服务器
如果已绑定执行以下
停止已经启动的绑定
stop slave;
2、重置绑定
reset master;
change master to master_host='192.168.189.132',master_port=3306,master_user='slave',
master_password='slave',master_log_file='master-bin.000005',master_log_pos=3878;
7. 启动slave同步数据
start slave;
8.查看slave信息
show slave status \G
