CHANGE MASTER TO MASTER_HOST='10.10.30.34', MASTER_PORT=3306, MASTER_USER='slave', MASTER_PASSWORD='slave', MASTER_LOG_FILE='mysql-bin.000148', MASTER_LOG_POS=154; 从数据库变为主库 stop slave; reset slave; reset master; 从库变为刚才的主库(由从库变为主库的数据库) vim /etc/my.cnf log-bin=mysql-bin #并重启数据库,主库开启binlog日志 主库操作:show master status 主库操作:scp -r /var/lib/mysql/* 10.10.50.34:/var/lib/mysql/ 从库:chown -R mysql.mysql /var/lib/mysql/ 从库:systemctl restart mysqld CHANGE MASTER TO MASTER_HOST='172.16.1.51', MASTER_PORT=3306, MASTER_USER='rep', MASTER_PASSWORD='123456', MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=335; 进入数据:start slave; 中间报错: 1.IO进程一直处于connnecting中 slave 用户的密码写错 2.show slave status;报错 Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'Could not find first log file name in binary log index file' 解决办法: 主库:flush logs; 从库: stop slave; CHANGE MASTER TO MASTER_LOG_FILE='mysqld-bin.000011',MASTER_LOG_POS=106; start slave;
转载于:https://blog.51cto.com/wsxxsl/2045620