1、修改master配置并重启
server-id=1 log-bin=/var/log/mysql/mysql-bin innodb_flush_log_at_trx_commit = 1 sync_binlog = 1 binlog-do-db=db1 binlog-do-db=db2 replicate-do-db=db1 replicate-do-db=db2
2、mysql,并在master上新建一下账户给从服务器拉去数据用
CREATE USER 'slavecopy'@'%'; GRANT REPLICATION SLAVE ON *.* TO 'slavecopy'@'%' identified by 'mima';
3、设置slave 并重启
server-id=2 read-only=on #只备份 relay-log=relay-bin
4、查看master状态确定复制起始位置 SHOW MASTER STATUS
5、配置slave
change master to master_host='ip', master_user='root', master_password='mima', master_log_file='master-bin.000003', master_log_pos=466;
6、START SLAVE 和 STOP SLAVE 用以启停主从同步
7、查看slave状态 show slave status\G 主要是slave_io_running 和 slave_sql_running为yes即可