转自:http://blog.51cto.com/loose/1224564
1 、出现错误提示
Slave I/O: error connecting to master ‘[email protected]:3306’ -retry-time: 60 retries: 86400,Error_code: 1045
2 、出现错误提示
Error reading packet from server: File ‘/home/mysql/mysqlLog/log.000001’ not found (Errcode: 2) (server_errno=29)
3 、错误提示如下
Slave SQL: Error ‘Table ‘xxxx’ doesn’t exist’ on query. Default database: ‘t591’. Query: ‘INSERT INTO xxxx
(type,post_id,browsenum) SELECT type,post_id,browsenum FROM xxxx WHERE hitdate=‘20090209’’, Error_code: 1146
4 、错误提示如下
Error ‘Duplicate entry ‘1’ for key 1’ on query. Default database: ‘movivi1’. Query: ‘INSERT INTO v1vid0_user_samename
VALUES(null,1,‘123’,‘11’,‘4545’,‘123’)’
Error ‘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 ‘’ at line 1’ on query. Default database: ‘club’. Query: ‘INSERT INTO club.point_process (GIVEID, GETID, POINT, CREATETIME, DEMO) VALUES (0, 4971112, 5, ‘2010-12-19 16:29:28’,’
1 row in set (0.00 sec)
5 、错误提示如下
Master_Log_File: mysql-bin.000029
Read_Master_Log_Pos: 3154083
Relay_Log_File: c7-relay-bin.000178
Relay_Log_Pos: 633
Relay_Master_Log_File: mysql-bin.000025
Slave_IO_Running: Yes
Slave_SQL_Running: No
Replicate_Do_DB: club
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 1594
Last_Error: Relay log read failure: Could not parse relay log event entry. The possible reasons are: the master’s binary log is corrupted (you can check this by running ‘mysqlbinlog’ on the binary log), the slave’s relay log is corrupted (you can check this by running ‘mysqlbinlog’ on the relay log), a network problem, or a bug in the master’s or slave’s MySQL code. If you want to check the master’s binary log or slave’s relay log, you will be able to know their names by issuing ‘SHOW SLAVE STATUS’ on this slave.
Skip_Counter: 0
Exec_Master_Log_Pos: 1010663436
这个问题原因是,主数据库突然停止或问题终止,更改了mysql-bin.xxx日志,slave服务器找不到这个文件,需要找到同步的点和日志文件,然后chage master即可。
解决方法:
6 、错误提示如下
Error ‘Unknown column ‘qdir’ in ‘field list’’ on query. Default database: ‘club’. Query: ‘insert into club. question_del (id, pid, ques_name, givepoint, title, subject, subject_pid, createtime, approve, did, status, intime, order_d, endtime,banzhu_uid,banzhu_uname,del_cause,qdir) select id, pid, ques_name, givepoint, title, subject, subject_pid, createtime, approve, did, status, intime, order_d, endtime,‘1521859’,‘admin0523’,’ 无意义回复 ‘,qdir from club.question where id=7330212’
1 row in set (0.00 sec)
7 、错误提示如下
Slave_IO_Running: NO
这个错误就是IO进程没连接上,想办法连接上把与主的POS号和文件一定要对,然后重新加载下数据。
具体步骤:
slave stop;
change master to
master_host=‘IP地址’,
master_user=‘backup’,
master_password=‘123456’,master_log_file=‘mysqld-bin.000008’,MASTER_LOG_POS=396;
注:master_log_file=‘mysqld-bin.000008’,MASTER_LOG_POS=396;是从主的上面查出来的:show master status\G;
8、错误提示如下
使用mysqlbinlog进行分析日志 包以下错误:
ERROR: Error in Log_event::read_log_event(): ‘Found invalid event in binary log’, data_len: 66, event_type: 19
这个错误是使用的mysqlbinlog的版本不正确
mysqlbinlog: /usr/bin/mysqlbinlog
/usr/bin/mysqlbinlog Ver 3.2 for redhat-linux-gnu at x86_64
/usr/local/mysql/bin/mysqlbinlog Ver 3.3 for unknown-linux-gnu at x86_64
通过查询果然发现在默认情况下调用的是系统默认安装的mysql中的mysqlbinlog,因为这个mysqlbinlog的版本和当前的bin_log的版本不能对应起来,所以不能处理,使用对应的mysqlbinlog工作正常
/!40019 SET @@session.max_insert_delayed_threads=0/;
/!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0/;
DELIMITER /!/;
#120228 23:05:14 server id 1 end_log_pos 106 Start: binlog v 4, server v 5.1.41-log created 120228 23:05:14
BINLOG ’
Ku1MTw8BAAAAZgAAAGoAAAAAAAQANS4xLjQxLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC
'/!/;
#120228 23:05:14 server id 1 end_log_pos 181 Query thread_id=175240 exec_time=0 error_code=0
9、解决ERROR 1146 (42S02): Table ‘mysql.servers’ doesn’t exist问题
10、由于主服务器异外重启, 导致从报错, 错误如下:
show slave status错误:
mysql> show slave status\G
Master_Log_File: mysql-bin.000288
Read_Master_Log_Pos: 627806304
Relay_Log_File: mysql-relay-bin.000990
Relay_Log_Pos: 627806457
Relay_Master_Log_File: mysql-bin.000288
Slave_IO_Running: No
Slave_SQL_Running: Yes
Exec_Master_Log_Pos: 627806304
Relay_Log_Space: 627806663
…
Last_IO_Error:
Got fatal error 1236 from master when reading
data from binary log:
‘Client requested master to start
replication from impossible position’
mysql错误日志:
tail /data/mysql/mysql-error.log
111010 17:35:49 [ERROR] Error reading packet from server: Client requested master
to start replication from impossible position ( server_errno=1236)
111010 17:35:49 [ERROR]
Slave I/O: Got fatal error 1236 from master when reading data
from
binary log: ‘Client requested master to start replication from impossible
position’, Error_code: 1236
111010 17:35:49 [Note] Slave I/O thread exiting, read up to log ‘mysql-bin.000288’,
position 627806304
按照习惯, 先尝试必改position位置.
mysql> stop slave;mysql> change master to master_log_file=‘mysql-bin.000288’,master_log_pos=627625751;mysql> start slave;
错误依旧, 接下来登陆到主服务器查看binlog日志.
先按照错误点的标记去主服务器日志中查找:
[root@db1 ~]# mysqlbinlog --start-position=627655136 /data/mysql/binlog/mysql-bin.000288
/!40019 SET @@session.max_insert_delayed_threads=0/;
/!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0/;
DELIMITER /!/;
#111010 13:31:19 server id 4 end_log_pos 106 Start: binlog v 4, server v 5.1.45-log
created 111010 13:31:19
BINLOG ’
F1aTTg8EAAAAZgAAAGoAAAABAAQANS4xLjQ1LWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC
'/!/;
DELIMITER ;
ROLLBACK /* added by mysqlbinlog /;
/!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
没有看到这个位置.
[root@db1 ~]# mysqlbinlog /data/mysql/binlog/mysql-bin.000288 > test.txt
less text.txt
看最后一部分
#111010 16:35:46 server id 1 end_log_pos 627625631 Query thread_id=45613333
exec_time=32758 error_code=0
SET TIMESTAMP=1318289746/!/;
delete from freeshipping_bef_update where part=‘AR-4006WLM’ and code=’’
/!/;
627625631#111010 16:35:46 server id 1 end_log_pos 627625751
Query thread_id=45613333
exec_time=32758 error_code=0
SET TIMESTAMP=1318289746/!/;
delete from shippingFee_special where part=‘AR-4006WLM’
/!/;
DELIMITER ;
ROLLBACK /* added by mysqlbinlog /;
/!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
找到最接近错误标记627655136的一个position是627625631.
再回到slave机器上change master, 将postion指向这个位置.
mysql> stop slave;
Query OK, 0 rows affected (0.00 sec)
mysql>
change master to master_log_file=‘mysql-bin.000288’,master_log_pos=627625631;
Query OK, 0 rows affected (0.06 sec)
mysql>
start slave;Query OK, 0 rows affected (0.00 sec)
再次查看
11、在做MySQL主从复制时遇到个ERROR 1201 (HY000): Could not initialize master info structure .
出现这个问题的原因是之前曾做过主从复制!
解决方案是:运行命令 stop slave;
成功执行后继续运行 reset slave;
然后进行运行GRANT命令重新设置主从复制。
具体过程如下:
mysql> change master to master_host=‘192.168.0.1’, master_user=‘backup’, master_pass
word=‘123456’, master_log_file=‘mysql-bin-000002’, master_log_pos=553;
ERROR 1201 (HY000): Could not initialize master info structure; more error messages can be found in the MySQL error log
mysql> stop slave;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> reset slave;
Query OK, 0 rows affected (0.00 sec)
12、在没有解锁的情况下停止slave进程:
> stop slave;
ERROR 1192 (HY000): Can’t execute the given command because you have active locked tables or an active transaction
13、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
14、在没有停止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
15、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;
6)change master之后,查看slave的状态,发现slave_IO_running 为NO
需要注意的是,做完上述操作之后最后重启mysql进程