mysql启动失败,一直crash,报错如下:

2019-03-14T11:15:12.937923Z 0 [Note] InnoDB: Uncompressed page, stored checksum in field1 1118110825, calculated checksums for field1: crc32 2889511119/2044155182, innodb 4005355497, none 3735928559, stored checksum in field2 1244127832, calculated checksums for field2: crc32 2889511119/2044155182, innodb 952099433, none 3735928559, page LSN 4 2819295388, low 4 bytes of LSN at page end 2486405135, page number (if stored to page already) 3971, space id (if created with >= MySQL-4.1.1 and stored already) 1840
InnoDB: Page may be an index page where index id is 6640
2019-03-14T11:15:12.937950Z 0 [Note] InnoDB: Index 6640 is `GEN_CLUST_INDEX` in table `zabbix`.`history_uint`
2019-03-14T11:15:12.937955Z 0 [Note] InnoDB: It is also possible that your operating system has corrupted its own file cache and rebooting your computer removes the error. If the corrupt page is an index page. You can also try to fix the corruption by dumping, dropping, and reimporting the corrupt table. You can use CHECK TABLE to scan your table for corruption. Please refer to http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html for information about forcing recovery.

看起来是文件损坏了,我有备库,所以希望主库尽快恢复,然后再恢复数据,直接移走有问题的frm和ibd,再启动,报错:

2019-03-14T11:23:37.246589Z 0 [ERROR] InnoDB: Tablespace 1840 was not found at ./zabbix/history_uint.ibd.
2019-03-14T11:23:37.246594Z 0 [ERROR] InnoDB: Set innodb_force_recovery=1 to ignore this and to permanently lose all changes to the tablespace.
2019-03-14T11:23:37.247018Z 0 [ERROR] InnoDB: Cannot continue operation.

修改my.cnf

innodb_force_recovery=1

再重启正常,尝试重新新建表,但是各种报错:

mysql> CREATE TABLE `history` (
-> `itemid` bigint(20) unsigned NOT NULL,
-> `clock` int(11) NOT NULL DEFAULT '',
-> `value` double(16,4) NOT NULL DEFAULT '0.0000',
-> `ns` int(11) NOT NULL DEFAULT '',
-> KEY `history_1` (`itemid`,`clock`)
-> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
ERROR 1813 (HY000): Tablespace '`zabbix`.`history`' exists.
mysql> alter table history discard tablespace;
ERROR 1146 (42S02): Table 'zabbix.history' doesn't exist
mysql> drop tablespace history;
ERROR 1529 (HY000): Failed to drop TABLESPACE history
mysql> drop table history;
ERROR 1051 (42S02): Unknown table 'zabbix.history'

完全没有办法操作,这时的解决方法是:

  • CREATE TABLE bad_table ENGINE=MyISAM ...
  • rm bad_table.ibd
  • DROP TABLE bad_table
  • CREATE TABLE bad_table ENGINE=INNODB ...

然后再恢复数据

也有可能报错时并没有指出具体出错的文件或者表,类似

2019-11-25T12:54:59.258844Z 0 [ERROR] InnoDB: Database page corruption on disk or a failed file read of page [page id: space=0, page number=593]. You may have to recover from a backup.

这时需要使用mysqlcheck命令来检查某个数据库

# mysqlcheck -uroot -proot $dbname

也可以检查所有的数据库

# echo 'show databases'|mysql -uroot -proot|xargs -i mysqlcheck -uroot -proot {}

输出结果为两列,第二列是status,正常为OK,其他值为异常,找到异常的表,删除或者将数据导出后再导入,则问题修复;

参考:
https://stackoverflow.com/questions/15694168/error-tablespace-for-table-xxx-exists-please-discard-the-tablespace-before-imp

【原创】大叔问题定位分享(32)mysql故障恢复的更多相关文章

  1. 【原创】大叔问题定位分享(28)openssh升级到7.4之后ssh跳转异常

    服务器集群之间忽然ssh跳转不通 # ssh 192.168.0.1The authenticity of host '192.168.0.1 (192.168.0.1)' can't be esta ...

  2. 【原创】大叔问题定位分享(13)HBase Region频繁下线

    问题现象:hive执行sql报错 select count(*) from test_hive_table; 报错 Error: java.io.IOException: org.apache.had ...

  3. 【原创】大叔问题定位分享(6)Dubbo monitor服务iowait高,负载高

    一 问题 Dubbo monitor所在服务器状态异常,iowait一直很高,load也一直很高,监控如下: iowait如图: load如图: 二 分析 通过iotop命令可以查看当前系统中磁盘io ...

  4. 【原创】大叔问题定位分享(5)Kafka客户端报错SocketException: Too many open files 打开的文件过多

    kafka0.8.1 一 问题 10月22号应用系统忽然报错: [2014/12/22 11:52:32.738]java.net.SocketException: 打开的文件过多 [2014/12/ ...

  5. 【原创】大叔问题定位分享(4)Kafka集群broker节点从zookeeper上消失

    kafka_2.8.0-0.8.1 一 现象 生产环境一组kafka集群经常发生问题,现象是kafka在zookeeper上的broker节点消失,此时kafka进程和端口都在,然后每个broker都 ...

  6. 【原创】大叔问题定位分享(3)Kafka集群broker进程逐个报错退出

    kafka0.8.1 一 问题现象 生产环境kafka服务器134.135.136分别在10月11号.10月13号挂掉: 134日志 [2014-10-13 16:45:41,902] FATAL [ ...

  7. 【原创】大叔问题定位分享(31)hive metastore报错

    hive metastore在建表时报错 [pool-5-thread-2]: MetaException(message:Got exception: java.net.ConnectExcepti ...

  8. 【原创】大叔问题定位分享(30)mesos agent启动失败:Failed to perform recovery: Incompatible agent info detected

    mesos agent启动失败,报错如下: Feb 15 22:03:18 server1.bj mesos-slave[1190]: E0215 22:03:18.622994 1192 slave ...

  9. 【原创】大叔问题定位分享(29)datanode启动报错:50020端口被占用

    集群中有一台datanode一直启动报错如下: java.net.BindException: Problem binding to [$server1:50020] java.net.BindExc ...

随机推荐

  1. 055、创建macvlan网络 (2019-03-22 周五)

    参考https://www.cnblogs.com/CloudMan6/p/7364332.html     创建macvlan网络,需要指定使用哪块物理网卡进行通信   -o parent=ens1 ...

  2. Vertica系列:性能优化

    Vertica 性能非常好, 平时基本不会碰到性能问题, 即使碰到, 优化也很容易, 而且效果往往会很好. ======================优化工具==================== ...

  3. MongoDB 更新数组中的元素

    本文记录如何更新MongoDB Collection 中的Array 中的元素.假设Collection中一条记录格式如下: 现要删除scores 数组中,"type" 为 &qu ...

  4. MyBatis简单使用和入门理解

    本文记录第一次使用Mybatis时碰到的一些错误和简单理解,采用的示例是Eclipse中的JAVA工程,采用XML文件定义数据库连接. 可以使用Java JDBC API直接操作数据库,但使用框架会更 ...

  5. Android弹出窗口

    protected void PopUp() { final PopupWindow popup = new PopupWindow(TestActivity.this); View popView ...

  6. VS2017 15.6之后支持直接反编译了

    在 15.6 预览版 2 中,增加了导航到反编译源功能. 启用后,在任何引用的类型或成员上调用转到定义或查看定义时,将显示其通过 ILSpy 反编译使用重新构造方法主体的定义. 要打开此功能,请转到“ ...

  7. constraintLayout的一些高级用法 布局一个16:9的图片 以及GuideLine的使用

    <!-- "W,9:16" 同样的效果 --> <ImageView android:layout_width="0dp" android:l ...

  8. Failed to read artifact descriptor for org.apache.maven.plugins:maven-install-plugin-JavaWeb(四)

    今天使用maven clean, maven install 出现了下图问题,只解决了 maven clean , 还有maven install 今天 使用maven clean 出现以下问题(把下 ...

  9. Microsoft SQL - 查询与更新

    查询与更新(Query & Update) 转义引号 SQL语句中字符串只能使用单引号,如果需要转义,可用单引号转义单引号. 查询(Inquire) 以下公式中的c指代列名. 规则 1.查询语 ...

  10. centOS7 tomcat 开机自启 自启动设置

    1.编写配置文件 // (1)修改tomcat.service vim /lib/systemd/system/tomcat.service // (2)复制以下代码,注意修改tomcat路径 [Un ...