mysql5.6设置主从报错1236,Increase max_allowed_packet on master,原因却是Binlog偏移量不对

时间:2024-07-05 16:34:32
在试Mysql5.6,搭了个主从:
CHANGE MASTER TO
MASTER_HOST='1.2.3.4',
master_user='slave',
master_password='xxxqqq',
master_port=,
MASTER_LOG_FILE='binlog.000001',
MASTER_LOG_POS=;
一切正常。然后在主上建个表,在从上一看没有。再看看状态:
mysql> show slave status\G;
*************************** . row ***************************
Slave_IO_State:
Master_Host: 1.2.3.4
Master_User: slave
Master_Port:
Connect_Retry:
Master_Log_File: binlog.
Read_Master_Log_Pos:
Relay_Log_File: relaylog.
Relay_Log_Pos:
Relay_Master_Log_File: binlog.
Slave_IO_Running: No
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno:
Last_Error:
Skip_Counter:
Exec_Master_Log_Pos:
Relay_Log_Space:
Until_Condition: None
Until_Log_File:
Until_Log_Pos:
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno:
Last_IO_Error: Got fatal error from master when reading data from binary log: 'log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master; the first event 'binlog.' at 107, the last event read from '/mnt/disk1/mysql_5615_binlog/binlog.' at 107, the last byte read from '/mnt/disk1/mysql_5615_binlog/binlog.' at 126.'
Last_SQL_Errno:
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id:
Master_UUID: aa8bc3d4-81aa-11e3--001517a25b3a
Master_Info_File: /mnt/disk1/mysql_5615/master.info
SQL_Delay:
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
Master_Retry_Count:
Master_Bind:
Last_IO_Error_Timestamp: ::
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position:
row in set (0.00 sec) ERROR:
No query specified
确认了我的max_allowed_packet 是32M,太够了啊。搞了半天无果,后来搜了搜,发现了这个贴子(http://blog.chinaunix.net/uid-451-id-3087001.html),说是根本原因是偏移量不对。于是去主上看看:
mysqlbinlog binlog.
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at
# :: server id end_log_pos CRC32 0xf881fb00 Start: binlog v , server v 5.6.-debug-log created :: at startup
ROLLBACK/*!*/;
BINLOG '
KcPdUg9ZAgAAdAAAAHgAAAAAAAQANS42LjE1LWRlYnVnLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAApw91SEzgNAAgAEgAEBAQEEgAAXAAEGggAAAAICAgCAAAACgoKGRkAAQD7
gfg=
'/*!*/;
# at
# :: server id end_log_pos CRC32 0x4763204a Query thread_id= exec_time= error_code=
于是在从上重新change master to,把偏移量设成120,就一切正常了。
我之前搞Mysql5.5时一直是偏移量107的,到了现在5.6了变成了120,有趣。
另外也是头脑反应慢了些,其实在主上看状态时也应该能反应到的:
mysql> show binary logs;
+---------------+-----------+
| Log_name | File_size |
+---------------+-----------+
| binlog. | |
| binlog. | |
| binlog. | |
+---------------+-----------+
rows in set (0.03 sec)