qua*_*nta 5 mysql innodb recovery
由于以下问题:
mysql> desc reportingdb.v3_zone_date_cpm7k;
ERROR 1146 (42S02): Table 'reportingdb.v3_zone_date_cpm7k' doesn't exist
Run Code Online (Sandbox Code Playgroud)
/var/log/mysqld.log
120927 16:57:04 [ERROR] Cannot find or open table reportingdb/v3_zone_date_cpm7k#P#pcurrent_2012926 from
the internal data dictionary of InnoDB though the .frm file for the
table exists. Maybe you have deleted and recreated InnoDB data
files but have forgotten to delete the corresponding .frm files
of InnoDB tables, or you have moved .frm files to another database?
or, the table contains indexes that this version of the engine
doesn't support.
See http://dev.mysql.com/doc/refman/5.5/en/innodb-troubleshooting.html
how you can resolve the problem.
Run Code Online (Sandbox Code Playgroud)
(我还没找到原因)
该表的文件仍然存在于 datadir 中:
-rw-rw---- 1 mysql mysql 8932 Sep 26 16:50 /var/lib/mysql/reportingdb/v3_zone_date_cpm7k.frm
-rw-rw---- 1 mysql mysql 84 Sep 26 16:50 /var/lib/mysql/reportingdb/v3_zone_date_cpm7k.par
-rw-rw---- 1 mysql mysql 9437184 Sep 13 17:56 /var/lib/mysql/reportingdb/v3_zone_date_cpm7k#P#MERGER_2012828.ibd
-rw-rw---- 1 mysql mysql 1048576 Sep 27 15:42 /var/lib/mysql/reportingdb/v3_zone_date_cpm7k#P#MERGER_2012926.ibd
Run Code Online (Sandbox Code Playgroud)
这是一个月前备份的表 DDL(因此分区已更改),但仅供参考:
CREATE TABLE `v3_zone_date_cpm7k` (
`campaignid` mediumint(9) NOT NULL DEFAULT '0' COMMENT 'sub_campaignid',
`zoneid` smallint(6) NOT NULL DEFAULT '0',
`bannerid` mediumint(9) NOT NULL DEFAULT '0',
`totalclick` mediumint(9) unsigned NOT NULL DEFAULT '0',
`realclick` mediumint(9) unsigned NOT NULL DEFAULT '0',
`clickcharge` mediumint(9) NOT NULL DEFAULT '0',
`totalview` mediumint(9) unsigned NOT NULL DEFAULT '0',
`viewcharge` mediumint(9) unsigned NOT NULL DEFAULT '0',
`dt` date NOT NULL DEFAULT '0000-00-00',
`partnerid` smallint(6) unsigned NOT NULL DEFAULT '0',
KEY `ix_zoneid` (`zoneid`,`dt`),
KEY `ix_dt` (`dt`),
KEY `ix_campaignid` (`bannerid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (TO_DAYS(dt))
(PARTITION p00 VALUES LESS THAN (0) ENGINE = InnoDB,
PARTITION p04 VALUES LESS THAN (734965) ENGINE = InnoDB,
PARTITION p05 VALUES LESS THAN (735025) ENGINE = InnoDB,
PARTITION MERGER_2012822 VALUES LESS THAN (735102) ENGINE = InnoDB,
PARTITION pcurrent_2012822 VALUES LESS THAN (735103) ENGINE = InnoDB,
PARTITION pcurrent_2012823 VALUES LESS THAN (735104) ENGINE = InnoDB)*/
Run Code Online (Sandbox Code Playgroud)
我将按照本指南恢复此表。但是在 2c。步骤,我收到以下错误:
mysql> alter table v3_zone_date_cpm7k_restore discard tablespace;
ERROR 1031 (HY000): Table storage engine for 'v3_zone_date_cpm7k_restore' doesn't have this option
Run Code Online (Sandbox Code Playgroud)
http://bugs.mysql.com/bug.php?id=52422
我现在能做什么?
更新
我正在从备份中恢复,摆脱这个问题的正确程序是什么?
我尝试过的(在另一台服务器上):
DROP TABLE --> 仍然得到“不存在”
停止 MySQL
将所有表的文件移动到另一个位置
将备份文件复制到对应的数据库
启动 MySQL:
120927 19:12:07 InnoDB: Error: table 'reportingdb/v3_zone_date_cpm7k#P#MERGER_2012828'
InnoDB: in InnoDB data dictionary has tablespace id 741528,
InnoDB: but tablespace with that id or name does not exist. Have
InnoDB: you deleted or moved .ibd files?
InnoDB: This may also be a table created with CREATE TEMPORARY TABLE
InnoDB: whose .ibd and .frm files MySQL automatically removed, but the
InnoDB: table still exists in the InnoDB internal data dictionary.
InnoDB: Please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.5/en/innodb-troubleshooting-datadict.html
InnoDB: for how to resolve the issue.
InnoDB: We removed now the InnoDB internal data dictionary entry
InnoDB: of table `reportingdb`.`v3_zone_date_cpm7k` /* Partition `MERGER_2012828` */.
120927 19:12:07 InnoDB: error: space object of table 'reportingdb/v3_zone_date_cpm7k#P#MERGER_2012926',
InnoDB: space id 921829 did not exist in memory. Retrying an open.
120927 19:12:07 InnoDB: Error: table `reportingdb`.`v3_zone_date_cpm7k` /* Partition `pcurrent_2012926`
*/ does not exist in
the InnoDB internal
InnoDB: data dictionary though MySQL is trying to drop it.
InnoDB: Have you copied the .frm file of the table to the
InnoDB: MySQL database directory from another database?
InnoDB: You can look for further help from
InnoDB: http://dev.mysql.com/doc/refman/5.5/en/innodb-troubleshooting.html
Run Code Online (Sandbox Code Playgroud)
更新 2012 年 9 月 28 日星期五 08:21:49 ICT
按照你的建议,我有:
导入 .sql 文件并得到错误:
第 25 行的错误 1050 (42S01):表 ' reportingdb
。v3_zone_date_cpm7k
/* 分区p00
*/' 已经存在
错误日志显示:
120928 8:26:42 InnoDB: Warning: trying to init to the tablespace memory cache
InnoDB: a tablespace 932889 of name './reportingdb/v3_zone_date_cpm7k#P#p00.ibd',
InnoDB: but a tablespace 932783 of the same name
InnoDB: already exists in the tablespace memory cache!
InnoDB: We assume that InnoDB did a crash recovery, and you had
InnoDB: an .ibd file for which the table did not exist in the
InnoDB: InnoDB internal data dictionary in the ibdata files.
InnoDB: We assume that you later removed the .ibd and .frm files,
InnoDB: and are now trying to recreate the table. We now remove the
InnoDB: conflicting tablespace object from the memory cache and try
InnoDB: the init again.
Run Code Online (Sandbox Code Playgroud)
并且.idb
文件在重启后自动创建:
# ls -l /var/lib/mysql/reportingdb/v3_zone_date_cpm7k#P#p00.ibd
-rw-rw---- 1 mysql mysql 65536 Sep 28 08:35 /var/lib/mysql/reportingdb/v3_zone_date_cpm7k#P#p00.ibd
Run Code Online (Sandbox Code Playgroud)
通过在提示符下运行以下命令解决了问题mysql>
:
CREATE TABLE `v3_zone_date_cpm7k` (
`campaignid` mediumint(9) NOT NULL DEFAULT '0' COMMENT 'sub_campaignid',
`zoneid` smallint(6) NOT NULL DEFAULT '0',
`bannerid` mediumint(9) NOT NULL DEFAULT '0',
`totalclick` mediumint(9) unsigned NOT NULL DEFAULT '0',
`realclick` mediumint(9) unsigned NOT NULL DEFAULT '0',
`clickcharge` mediumint(9) NOT NULL DEFAULT '0',
`totalview` mediumint(9) unsigned NOT NULL DEFAULT '0',
`viewcharge` mediumint(9) unsigned NOT NULL DEFAULT '0',
`dt` date NOT NULL DEFAULT '0000-00-00',
`partnerid` smallint(6) unsigned NOT NULL DEFAULT '0',
KEY `ix_zoneid` (`zoneid`,`dt`),
KEY `ix_dt` (`dt`),
KEY `ix_campaignid` (`bannerid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Run Code Online (Sandbox Code Playgroud)
然后在文件中注释掉它.sql
:
-- DROP TABLE IF EXISTS `v3_zone_date_cpm7k`;
-- /*!40101 SET @saved_cs_client = @@character_set_client */;
-- /*!40101 SET character_set_client = utf8 */;
-- CREATE TABLE `v3_zone_date_cpm7k` (
-- `campaignid` mediumint(9) NOT NULL DEFAULT '0' COMMENT 'sub_campaignid',
-- `zoneid` smallint(6) NOT NULL DEFAULT '0',
-- `bannerid` mediumint(9) NOT NULL DEFAULT '0',
-- `totalclick` mediumint(9) unsigned NOT NULL DEFAULT '0',
-- `realclick` mediumint(9) unsigned NOT NULL DEFAULT '0',
-- `clickcharge` mediumint(9) NOT NULL DEFAULT '0',
-- `totalview` mediumint(9) unsigned NOT NULL DEFAULT '0',
-- `viewcharge` mediumint(9) unsigned NOT NULL DEFAULT '0',
-- `dt` date NOT NULL DEFAULT '0000-00-00',
-- `partnerid` smallint(6) unsigned NOT NULL DEFAULT '0',
-- KEY `ix_zoneid` (`zoneid`,`dt`),
-- KEY `ix_dt` (`dt`),
-- KEY `ix_campaignid` (`bannerid`)
-- ) ENGINE=InnoDB DEFAULT CHARSET=latin1
-- /*!50100 PARTITION BY RANGE (TO_DAYS(dt))
-- (PARTITION p00 VALUES LESS THAN (0) ENGINE = InnoDB,
-- PARTITION p04 VALUES LESS THAN (734965) ENGINE = InnoDB,
-- PARTITION p05 VALUES LESS THAN (735025) ENGINE = InnoDB,
-- PARTITION MERGER_2012822 VALUES LESS THAN (735102) ENGINE = InnoDB,
-- PARTITION pcurrent_2012822 VALUES LESS THAN (735103) ENGINE = InnoDB,
-- PARTITION pcurrent_2012823 VALUES LESS THAN (735104) ENGINE = InnoDB) */;
-- /*!40101 SET character_set_client = @saved_cs_client */;
Run Code Online (Sandbox Code Playgroud)
并正常导入。