简体   繁体   English

Innodb和MyISAM表问题

[英]Innodb and MyISAM tables issue

I had a hard drive crash that led to some issues on an SQL database. 我发生了硬盘崩溃,导致SQL数据库出现一些问题。 Since then, I have rebuilt from a backup, but an issue keeps coming up that makes no sense to me. 从那时起,我就从备份中重建了,但是不断出现的问题对我来说毫无意义。 Hopefully it will to someone here. 希望它会在这里的人。 I am really just looking for help on where to find the source of the issue. 我真的只是在寻找有关问题来源的帮助。 I can fix from there. 我可以在那里修复。 I have read hundreds of posts and searched the web endlessly on this one. 我已经阅读了数百篇文章,并在此上无休止地在网上搜索。 Of course, someone might post a link that has the answer that I missed. 当然,有人可能会发布一个链接,其中包含我错过的答案。

Server is old, running CentOS 5 and MySQL 5.0.77. 服务器较旧,正在运行CentOS 5和MySQL 5.0.77。 I intend to upgrade after fixing this issue. 我打算在解决此问题后进行升级。

The database has both MyISAM and InnoDB tables. 该数据库同时具有MyISAM和InnoDB表。 Through phpmyadmin, I see that InnoDB is not running. 通过phpmyadmin,我看到InnoDB没有运行。 I checked my.cnf and there are no indications there that it is not running, unless I am missing something. 我检查了my.cnf,没有迹象表明它没有运行,除非我丢失了什么。

    [mysqld]
innodb_file_per_table = 1
log-bin=/var/lib/mysql/

binlog-ignore-db=supp
server-id=5
#master-host=
#master-user=
#master-password=
#master-connect-retry=60
port            = 3306
socket          = /var/lib/mysql/mysql.sock
skip-locking
skip-name-resolve
relay-log=/data1/mysqld/mysqld-relay-bin
skip-slave
#set-variable    = join_buffer_size=60M
set-variable    = key_buffer=128M
set-variable    = max_allowed_packet=30M
set-variable    = table_cache=64
set-variable    = sort_buffer=8M
set-variable    = record_buffer=2M
set-variable    = myisam_sort_buffer_size=8M
set-variable    = thread_cache=4
set-variable    = thread_concurrency=2
set-variable    = max_connections=500
set-variable    = wait_timeout=3600

#


# Uncomment the following if you are using BDB tables
#set-variable   = bdb_cache_size=64M

# Point the following paths to different dedicated disks
tmpdir          = /var/tmp/
#log-update     = /path-to-dedicated-directory/hostname

innodb_data_home_dir=
innodb_data_file_path = /data1/ibdata/ibdata1:5000M;/data1/ibdata/ibdata2:5000M;/data1/ibdata/ibdata3:5000M;/data1/ibdata/ibdata4:5000M:autoextend
set-variable = innodb_buffer_pool_size=1G
set-variable = innodb_additional_mem_pool_size=5M
innodb_log_group_home_dir= /data1/iblogs
innodb_log_arch_dir = /data1/iblogs
set-variable = innodb_log_files_in_group=3
##
set-variable = innodb_log_file_size=100M
set-variable = innodb_log_buffer_size=16M
set-variable = innodb_file_io_threads=8
set-variable = innodb_lock_wait_timeout=100
set-variable = innodb_autoextend_increment=200
#
innodb_flush_log_at_trx_commit=0
innodb_log_archive=0

set-variable = innodb_lock_wait_timeout=100
#innodb_flush_method = O_DSYNC

[mysqldump]
quick
set-variable    = max_allowed_packet=16M

[mysql]
no-auto-rehash
#safe-updates   # Remove the comment character if you are not familiar with SQL

[isamchk]
set-variable    = key_buffer=2M
set-variable    = sort_buffer=1M
set-variable    = read_buffer=1M
set-variable    = write_buffer=1M

[myisamchk]
set-variable    = key_buffer=20M
set-variable    = sort_buffer=20M
set-variable    = read_buffer=2M
set-variable    = write_buffer=2M

In phpmyadmin, all InnoDB tables show as 'In Use' and report a 1033 error. 在phpmyadmin中,所有InnoDB表均显示为“正在使用”并报告1033错误。 When I create a new database and copy the tables over, the same thing happens. 当我创建一个新数据库并复制表时,会发生同样的事情。 The only thing that worked was to create the database from an sql dump file, but this created old data, as the backup is a bit old. 唯一有效的方法是从sql转储文件创建数据库,但这会创建旧数据,因为备份有点旧。 The new database had all MyISAM tables and they work, minus some syntax errors from CGI files seeking data from them. 新的数据库具有所有MyISAM表,并且它们起作用,减去了从CGI文件中寻求数据的语法错误。 I can work around that for now. 我现在可以解决这个问题。

I didn't create this server and never managed one before. 我没有创建此服务器,也从未管理过该服务器。 I have fixed a host of problems and am working on getting someone to help out, but it's been difficult. 我已经解决了许多问题,正在努力寻求帮助,但这很难。 I only ask that someone point me in the right direction. 我只要求有人指出我正确的方向。

What would cause only the InnoDB tables to have a problem with incorrect information? 是什么会导致仅InnoDB表出现信息不正确的问题? I have searched the error logs and they report much the same, a slew of 'Incorrect information in table.frm' errors. 我搜索了错误日志,并报告了几乎相同的内容,其中包含“ table.frm中的错误信息”错误。

To keep this as short as possible, I will stop here, but am happy to explain more if necessary. 为了使内容尽可能简短,我将在这里停止,但如有必要,我乐于解释更多。

mysqld log: mysqld日志:

    190122 12:45:02  mysqld started
190122 12:45:02 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
190122 12:45:02 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
InnoDB: No valid checkpoint found.
InnoDB: If this error appears when you are creating an InnoDB database,
InnoDB: the problem may be that during an earlier attempt you managed
InnoDB: to create the InnoDB data files, but log file creation failed.
InnoDB: If that is the case, please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.0/en/error-creating-innodb.html
190122 12:45:03 [Warning] 'user' entry 'root@fmdb2' ignored in --skip-name-resolve mode.
190122 12:45:03 [Warning] 'user' entry 'leadtraffic@www.bravelcon.com' ignored in --skip-name-resolve mode.
190122 12:45:03 [Warning] 'db' entry 'leadtraffic leadtraffic@www.bravelcon.com' ignored in --skip-name-resolve mode.
190122 12:45:03 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.0.77-log'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  Source distribution

Here's a blog that I think is similar to your case: https://eric.lubow.org/2010/mysql-error-1033-incorrect-information-in-file/ 这是我认为与您的情况类似的博客: https : //eric.lubow.org/2010/mysql-error-1033-incorrect-information-in-file/

In that case, the user started MySQL Server, but the InnoDB storage engine couldn't initialize. 在那种情况下,用户启动了MySQL Server,但是InnoDB存储引擎无法初始化。 In old versions of MySQL, if the InnoDB engine can't start, it isn't a fatal error, but as you might guess, you won't be able to read or write InnoDB tables without that engine. 在旧版本的MySQL中,如果无法启动InnoDB引擎,这不是致命错误,但是您可能会猜到,没有该引擎,您将无法读取或写入InnoDB表。 There was an option to force the server to stop if it can't initialize InnoDB, but this option was not enabled by default in those days. 有一个选项可以强制服务器在无法初始化InnoDB时停止,但是默认情况下,该选项在当时没有启用。

As shown in the blog, you can confirm if InnoDB is disabled or not present in the list of engines: 如博客中所示,您可以确认引擎列表中是否禁用了InnoDB:

mysql> SHOW ENGINES;

The .FRM files are metadata files that are present for tables regardless of storage engine, so when you query a table, it first opens the .FRM file to get the table definition. .FRM文件是存在于表中的元数据文件,与存储引擎无关,因此,查询表时,它首先打开.FRM文件以获取表定义。 That's fine, but then if it can't read the table data because the InnoDB engine isn't running, it gets confused. 很好,但是如果由于InnoDB引擎未运行而无法读取表数据 ,则会感到困惑。 " There's table metadata but no table?? " 有表元数据但没有表?

You need to figure out why InnoDB couldn't start, and correct that problem. 您需要弄清楚为什么InnoDB无法启动,然后更正该问题。 The clues will likely be in the MySQL error log. 线索可能在MySQL错误日志中。 See for example the case reported in that blog. 例如,参见该博客中报告的案例。

In the blog, the user found that another mysqld process was already running, and was holding a file lock on the InnoDB tablespace ibdata1 . 在博客中,用户发现另一个mysqld进程已经在运行,并且在InnoDB表空间ibdata1上持有文件锁。 So in the second instance, the startup of MySQL Server couldn't get the lock on that file and gave up. 因此,在第二种情况下,MySQL Server的启动无法获得对该文件的锁定并放弃了。

In your case, as you reported in your question a couple of weeks ago ( ERROR /usr/libexec/mysqld: Incorrect information in file ), there was some sign that you had another instance of mysqld running: 就您的情况而言,正如您在几个星期前在问题中所报告的那样( 错误/ usr / libexec / mysqld:file中的信息不正确 ),有迹象表明您正在运行另一个mysqld实例:

190105 17:11:09 [ERROR] Can't start server: Bind on TCP/IP port: Address already in use
190105 17:11:09 [ERROR] Do you already have another mysqld server running on port: 3306 ?

The error you showed in your error log: 您在错误日志中显示的错误:

InnoDB: No valid checkpoint found.
InnoDB: If this error appears when you are creating an InnoDB database,
InnoDB: the problem may be that during an earlier attempt you managed
InnoDB: to create the InnoDB data files, but log file creation failed.

This indicates something is seriously wrong with the InnoDB log files, ib_logfile0 and ib_logfile1 . 这表明InnoDB日志文件ib_logfile0ib_logfile1严重问题。 They could be corrupt or unusable. 它们可能已损坏或无法使用。 This sometimes happens when you try to move the log files around while the mysqld is running. 当您尝试在mysqld运行时移动日志文件时,有时会发生这种情况。

You've gotten your MySQL instance into a risky state, and you might lose all your data. 您已使MySQL实例处于危险状态,并且可能会丢失所有数据。 I really recommend you get some qualified data recovery specialist. 我真的建议您找一些合格的数据恢复专家。 I made this recommendation in my last answer as well. 我也在最后一个答案中提出了此建议。

The other option is to chalk it up to experience. 另一种选择是根据经验进行选择。 Remove all your InnoDB files, restart the MySQL Server, and let it initialize a new tablespace (which will be empty). 删除所有InnoDB文件,重新启动MySQL Server,并使其初始化一个新表空间(该表空间将为空)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM