日期:2014-05-16  浏览次数:20824 次

求解,修改完系统时间后,对mysql创建分区partition,则出现此 'MySQL server has gone away'错误信息

求解,修改完系统时间后,对mysql创建分区partition,则出现此 'MySQL server has gone away'错误信息

?

出现此的情况是,我修改了linux下的系统时间,就马上对mysql数据库的某一个表创建分区partition(如果修改完时间成功后,等一小会,出不会出现此错误信息了),产生如下错误。

?

不要告诉我等一会再创建partition,这不是解决问题最好的办法。


说明:?/var/aoc/bin/python -m aoc.bin.createpartition ?这个是我写的一个创建partition的python脚本,就是执行两个sql语句。如下:
1.先判断此partition是否存在
SELECT PARTITION_DESCRIPTION FROM information_schema.PARTITIONS WHERE TABLE_SCHEMA = schema() AND TABLE_NAME='MON_ALERTS' AND PARTITION_DESCRIPTION >= 1391356800000000;
2.如果不存在,则创建新的partition,执行以下语句。
ALTER TABLE %s REORGANIZE PARTITION p INTO (PARTITION p%s VALUES LESS THAN (%s),PARTITION p VALUES LESS THAN(MAXVALUE))

错误信息如下:

[root@localhost ~]# date -s 2014-02-02

Sun Feb ?2 00:00:00 CST 2014

[root@localhost ~]# /var/aoc/bin/python -m aoc.bin.createpartition
SELECT PARTITION_DESCRIPTION FROM information_schema.PARTITIONS WHERE TABLE_SCHEMA = schema() AND TABLE_NAME='MON_ALERTS' AND PARTITION_DESCRIPTION >= 1391356800000000
Create Partition 'MON_ALERTS'.'20140202' failed.
Error: (2006, 'MySQL server has gone away')

当登陆mysql数据库,有如下情况:
mysql> show create table MON_ALERTS;
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql> desc MON_ALERTS;
ERROR 1146 (42S02): Table 'enalyzer_dba_db.MON_ALERTS' doesn't exist

?