因mysql从库报错Last_IO_Error: Got a packet bigger than 'max_allowed_packet' bytes
mysql>show slave status\G;*************************** 1. row ***************************Slave_IO_State:
Master_Host:192.168.90.190Master_User: rsync
Master_Port:3311Connect_Retry:60Master_Log_File: mysql-bin.001891Read_Master_Log_Pos:897184977Relay_Log_File: mysql-relay-bin.003780Relay_Log_Pos:897185056Relay_Master_Log_File: mysql-bin.001891Slave_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:0Last_Error:
Skip_Counter:0Exec_Master_Log_Pos:897184910Relay_Log_Space:897185322Until_Condition: None
Until_Log_File:
Until_Log_Pos:0Master_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:1153Last_IO_Error: Got a packet bigger than'max_allowed_packet'bytes
Last_SQL_Errno:0Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id:1rowin set (0.00 sec)
第一步:先登录数据库,查看 max_allowed_packet 这个参数值
连接数据库服务器,登录 mysql, 执行命令 : show variables like '%max_allowed_packet%'; 默认是1M
mysql> show variables like '%max_allowed_packet%';+--------------------+---------+
| Variable_name | Value |
+--------------------+---------+
| max_allowed_packet | 1048576 |
+--------------------+---------+
1 row in set (0.00 sec)
第二步:set global max_allowed_packet = 100 *1024*1024;
mysql> set global max_allowed_packet = 100 *1024*1024;
Query OK,0 rows affected (0.00sec)
#接着查看没有变过来,需要退出重新登陆,查看的是原始值(缓存)
mysql> show variables like '%max_allowed_packet%';+--------------------+---------+
| Variable_name | Value |
+--------------------+---------+
| max_allowed_packet | 1048576 |
+--------------------+---------+
1 row in set (0.00 sec)
第三步:重新登陆确认是否生效:
mysql> show variables like '%max_allowed_packet%';+--------------------+-----------+
| Variable_name | Value |
+--------------------+-----------+
| max_allowed_packet | 104857600 |
+--------------------+-----------+
1 row in set (0.00 sec)
第四步:重启slave
mysql>stop slave;
Query OK,0 rows affected (0.02sec)
mysql>start slave;
Query OK,0 rows affected (0.00sec)
mysql>show slave status\G;*************************** 1. row ***************************Slave_IO_State: Waitingformaster to send event
Master_Host:192.168.90.90Master_User: rsync
Master_Port:3311Connect_Retry:60Master_Log_File: mysql-bin.001891Read_Master_Log_Pos:948459439Relay_Log_File: mysql-relay-bin.003780Relay_Log_Pos:897185056Relay_Master_Log_File: mysql-bin.001891Slave_IO_Running: Yes
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:0Last_Error:
Skip_Counter:0Exec_Master_Log_Pos:897184910Relay_Log_Space:948459887Until_Condition: None
Until_Log_File:
Until_Log_Pos:0Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master:1356Master_SSL_Verify_Server_Cert: No
Last_IO_Errno:0Last_IO_Error:
Last_SQL_Errno:0Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id:1
1 row in set (0.00 sec)
第五步:修改配置文件
修改配置文件--Linux在 Linux 中,MySQL 对应的配置文件是 my.cnf , 我们在Linux终端输入如下命令 :
[root@192-168-90-90 ~]# mysql --help | grepmy.cnf
order of preference, my.cnf, $MYSQL_TCP_PORT,/etc/mysql/my.cnf /etc/my.cnf ~/.my.cnf
#如果在启动时没有指定my.cnf 就优先列表,先找到的配置文件生效
[root@192-168-90-90 data3311]# moremy.cnf
[mysqld]
basedir=/usr/local/mysql5.5datadir=/home/mysql5.5/data3311
tmpdir=/home/mysql5.5/data3311/temp
port= 3311server_id= 3311socket=/home/mysql5.5/data3311/mysql3311.sock
character_set_server='utf8'max_allowed_packet=100M