您的位置:首页 > 数据库 > MySQL

mysql 互为主从复制常见问题

2014-09-19 11:14 585 查看
报错: 1) change master导致的: Last_IO_Error: error connecting to master - retry-time: 60 retries 2) 在没有解锁的情况下停止slave进程: stop slave; ERROR 1192 (HY000): Cant execute the given command because you have active locked tables
报错:

1)
change master导致的:
Last_IO_Error: error connecting to master - retry-time: 60 retries2)
在没有解锁的情况下停止slave进程:
> stop slave;
ERROR 1192 (HY000): Can't execute the given command because you have active locked tables or an active transaction3)
change master语法错误,落下逗号
mysql> change master to
-> master_host='IP'
-> master_user='USER',
-> master_password='PASSWD',
-> master_log_file='mysql-bin.000002',
-> master_log_pos=106;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'master_user='USER',
master_password='PASSWD',
master_log_file='mysql-bin.000002' at line 3 4)
在没有停止slave进程的情况下change master
mysql> change master to master_host=‘IP', master_user='USER', master_password='PASSWD', master_log_file='mysql-bin.000001',master_log_pos=106;
ERROR 1198 (HY000): This operation cannot be performed with a running slave; run STOP SLAVE first 5)用change master语句指定同步位置出错,修改master_log_file和master_log_pos参数:
Slave I/O: Got fatal error 1236 from master when reading data from binary log: 'bogus data in log event', Error_code: 1236
6 )A B的server-id相同:
Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids;
these ids must be different for replication to work (or the --replicate-same-server-id option must be used on
slave but this does not always make sense; please check the manual before using it).
查看server-id
mysql> show variables like 'server_id';
手动修改server-id
mysql> set global server_id=2; #此处的数值和my.cnf里设置的一样就行
mysql> slave start;

7)change master之后: Could not initialize master info structure, more error messages can be found in the MySQL error log 1.mysql> reset slave; # 重点就是这行
2.mysql> CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=107; # 请依照自行环境设定
3.mysql> start slave; # 就正常了重新设置 slave, MASTER_LOG_FILE 和 MASTER_LOG_POS 会被清空, 所以需要重新设置:
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: