过程大致如下:
先连接主库
mysql -uroot -p
use yourdatabase;
stop slave;
reset slave all;
set global bulk_insert_buffer_size=128*1024*1024;
source /bakfile
less /bakfile
找到
-- CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin-190.000640', MASTER_LOG_POS=120;
/*获取时间binlog文件名和pos*/
注意,实际可能并不需要这样,直接在主库执行:
show master status
取得了bin-log和pos后直接修改从库,pos其实可以为0,会自动follow。
CHANGE MASTER TO
MASTER_HOST='10.251.192.18',
MASTER_USER='sync',
MASTER_PASSWORD='DBect98773!_sync',
MASTER_PORT=3306,
MASTER_LOG_FILE='mysql-bin-190.000640',
MASTER_LOG_POS=120;
set global bulk_insert_buffer_size=8*1024*1024;
start slave ;
show slave status \G;
stop slave;
SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1 ;
start slave ;
show slave status \G;