标签:mysql5.7
安装忽略,参考我前面的博客。从库克隆主库,克隆主数据库后,需要修改 server-id 和 /data/mysql/auto.cnf 中的UUID, 修改pid文件名字修改my.cnf
master: 只发送 binlog-do-db=autoops slave: 只接受 replicate-do-db=autoops
主库设置:
配置文件开启 log-bin=mysql-bin 从库一般开启
mysql> show variables like 'log_bin%'; +---------------------------------+-------+ | Variable_name | Value | +---------------------------------+-------+ | log_bin | ON | mysql> grant replication slave on *.* to 'rep'@'192.168.10.%' identified by '123456'; mysql> flush privileges;
主库:
mysqldump -uroot -p -B autoops --events --master-data=2 --single-transaction > rep.sql
查看req.sql 记录 MASTER_LOG_FILE 和 MASTER_LOG_POS
22 -- CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000009', MASTER_LOG_POS=1564447;
注意:innodb用 –single-transaction, myisam需要用 –lock-all-tables。
scp rep.sql root@192.168.10.36:/root
从库:
mysql -uroot -p123456 < /opt/rep.sql
CHANGE MASTER TO MASTER_HOST='192.168.10.29', MASTER_PORT=3306, MASTER_USER='rep', MASTER_PASSWORD='123456', MASTER_LOG_FILE='mysql-bin.000009', MASTER_LOG_POS=1486295;
/data/master.info //生成的文件
mysql> start slave;
mysql> show slave status\G;
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
relay-bin.index
/data/3307/relay-bin.000001
/data/3307/relay-bin.000002
relay-log.info /中继日志
427
mysql-bin.000005
591
标签:mysql5.7
原文地址:http://blog.51cto.com/hequan/2045634