简体   繁体   English

MAMP PRO崩溃; MySQL不会在重启时启动

[英]MAMP PRO crashes; MySQL will not start on reboot

Today at work my computer randomly froze/crashed. 今天上班时我的电脑随机冻结/坠毁。 On reboot MAMP refuses to start mysql and I can't figure out why. 在重新启动时,MAMP拒绝启动mysql,我无法弄清楚原因。 There are definitely no other mysql processes running; 肯定没有其他的mysql进程在运行; I've checked several times. 我已经多次检查过了。 So, the killall -9 mysqld is not the solution. 所以, killall -9 mysqld不是解决方案。 I've actually completely re-installed MAMP, also. 我实际上完全重新安装了MAMP。

This is what seems to be the important part of my MySQL log, but I'm not very seasoned in reading these things, so maybe the answer is right in front of me. 这似乎是我的MySQL日志中的重要部分,但我对阅读这些内容并不是很有经验,所以也许答案就在我面前。

140527 15:06:58 mysqld_safe Starting mysqld daemon with databases from /Library/Application Support/appsolute/MAMP PRO/db/mysql
140527 15:06:58 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
140527 15:06:58 [Warning] Setting lower_case_table_names=2 because file system for /Library/Application Support/appsolute/MAMP PRO/db/mysql/ is case insensitive
140527 15:06:58 [Note] Plugin 'FEDERATED' is disabled.
140527 15:06:58 InnoDB: The InnoDB memory heap is disabled
140527 15:06:58 InnoDB: Mutexes and rw_locks use GCC atomic builtins
140527 15:06:58 InnoDB: Compressed tables use zlib 1.2.3
140527 15:06:58 InnoDB: Initializing buffer pool, size = 128.0M
140527 15:06:58 InnoDB: Completed initialization of buffer pool
140527 15:06:58 InnoDB: highest supported file format is Barracuda.
InnoDB: Log scan progressed past the checkpoint lsn 791075520
140527 15:06:58  InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
InnoDB: Doing recovery: scanned up to log sequence number 791076717
InnoDB: Database page corruption on disk or a failed
InnoDB: file read of page 8402.
InnoDB: You may have to recover from a backup.
140527 15:06:58  InnoDB: Page dump in ascii and hex (16384 bytes):
 len 16384; hex ....
InnoDB: End of page dump
140527 15:06:58  InnoDB: Page checksum 3802906200, prior-to-4.0.14-form checksum 786607151
InnoDB: stored checksum 3802906200, prior-to-4.0.14-form stored checksum 1787456768
InnoDB: Page lsn 0 791046088, low 4 bytes of lsn at page end 790720183
InnoDB: Page number (if stored to page already) 8402,
InnoDB: space id (if created with >= MySQL-4.1.1 and stored already) 0
InnoDB: Page may be an insert undo log page
InnoDB: Database page corruption on disk or a failed
InnoDB: file read of page 8402.
InnoDB: You may have to recover from a backup.
InnoDB: It is also possible that your operating
InnoDB: system has corrupted its own file cache
InnoDB: and rebooting your computer removes the
InnoDB: error.
InnoDB: If the corrupt page is an index page
InnoDB: you can also try to fix the corruption
InnoDB: by dumping, dropping, and reimporting
InnoDB: the corrupt table. You can use CHECK
InnoDB: TABLE to scan your table for corruption.
InnoDB: See also http://dev.mysql.com/doc/refman/5.5/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
InnoDB: Ending processing because of a corrupt database page.
140527 15:06:58  InnoDB: Assertion failure in thread 140735261836048 in file buf0buf.c line 3619
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.5/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
19:06:58 UTC - mysqld got signal 6 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed, 
something is definitely wrong and this may fail.

key_buffer_size=16777216
read_buffer_size=262144
max_used_connections=0
max_threads=151
thread_count=0
connection_count=0
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 134084 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0 thread_stack 0x40000
0   mysqld                              0x000000010028081c my_print_stacktrace + 44
1   mysqld                              0x0000000100021624 handle_fatal_signal + 692
2   libsystem_platform.dylib            0x00007fff91e625aa _sigtramp + 26
3   ???                                 0x0000000000000000 0x0 + 0
4   libsystem_c.dylib                   0x00007fff9355bb1a abort + 125
5   mysqld                              0x00000001002b30af buf_page_io_complete + 959
6   mysqld                              0x00000001002b9892 buf_read_page_low + 610
7   mysqld                              0x00000001002b9fa5 buf_read_page + 85
8   mysqld                              0x00000001002b4431 buf_page_get_gen + 673
9   mysqld                              0x000000010034fdd5 trx_undo_lists_init + 373
10  mysqld                              0x0000000100348e2e trx_rseg_mem_create + 334
11  mysqld                              0x0000000100348fed trx_rseg_list_and_array_init + 157
12  mysqld                              0x000000010034a147 trx_sys_init_at_db_start + 215
13  mysqld                              0x000000010033eafd innobase_start_or_create_for_mysql + 5805
14  mysqld                              0x00000001003114c1 _ZL13innobase_initPv + 1473
15  mysqld                              0x0000000100027028 _Z24ha_initialize_handlertonP13st_plugin_int + 104
16  mysqld                              0x000000010017f0f1 _ZL17plugin_initializeP13st_plugin_int + 97
17  mysqld                              0x0000000100181810 _Z11plugin_initPiPPci + 3776
18  mysqld                              0x00000001000ccce5 _Z11mysqld_mainiPPc + 10405
19  mysqld                              0x0000000100001804 start + 52
20  ???                                 0x000000000000000a 0x0 + 10
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.
140527 15:06:58 mysqld_safe mysqld from pid file /Applications/MAMP/tmp/mysql/mysql.pid ended

And when trying to do a db dump I am getting: (EDIT: I got this part of it fixed) 当我尝试进行数据库转储时,我得到:(编辑:我修复了这一部分)

mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) when trying to connect

PREFACE: This sounds bad, but please be sure to read everything in this answer before acting. 前言:这听起来很糟糕,但在演戏前请务必阅读本答案中的所有内容。 You can't break things worse by taking your time. 你不能花时间把事情弄糟。 Read each step & hopefully this will be clear enough for you to follow & get your MySQL database server in MAMP Pro up and running again. 阅读每一步并希望这将足够清楚,您可以关注并使MAMP Pro中的MySQL数据库服务器重新启动并运行。

So, it seems like your InnoDB databases crashed. 所以,看起来你的InnoDB数据库崩溃了。 Not the app itself. 不是应用程序本身。 The key is here in the log: 关键在于日志:

140527 15:06:58 InnoDB: highest supported file format is Barracuda.
InnoDB: Log scan progressed past the checkpoint lsn 791075520
140527 15:06:58  InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
InnoDB: Doing recovery: scanned up to log sequence number 791076717
InnoDB: Database page corruption on disk or a failed
InnoDB: file read of page 8402.
InnoDB: You may have to recover from a backup.

And it looks like you are using MAMP PRO over here: 看起来你在这里使用MAMP PRO:

/Library/Application Support/appsolute/MAMP PRO/db/mysql

So the question is, do you have a backup of the MAMP Pro databases? 所以问题是,你有MAMP Pro数据库的备份吗? Either via mysqldump or something else? 要么通过mysqldump还是其他什么? Do you have other InnoDB databases in your MAMP install? 您的MAMP安装中是否有其他InnoDB数据库?

Also, you say you were able to run mysqldump , but it's really not possible of the database crashed. 另外,你说你能够运行mysqldump ,但实际上数据库崩溃是不可能的。 So I am assuming when you ran mysqldump that was another, separate install of MySQL on your system. 所以我假设当你运行mysqldump ,你的系统上是另一个独立的MySQL安装。 The MySQL binaries such as mysqldump in MAMP or MAMP Pro are not the same as the systemwide mysqldump . MySQL二进制文件(如MAMP中的mysqldump或MAMP Pro)与系统范围的mysqldump They are two 100% different installs. 它们是两个100%不同的安装。 You can check which mysqldump is being used by typing in this command: 您可以通过键入以下命令来检查正在使用的mysqldump

which mysqldump

To see the full path of what you believe you were using. 查看您认为自己使用的完整路径。 The MAMP install of mysqldump —and other related binaries—is located here: mysqldump的MAMP安装 - 以及其他相关的二进制文件 - 位于:

/Applications/MAMP/Library/bin/

And to run it directly without modifying your $PATH value (a whole other thing) is to run it like this: 并且直接运行它而不修改$PATH值(另外一件事)就是像这样运行它:

/Applications/MAMP/Library/bin/mysqldump

PLEASE READ CAREFULLY: Please note the advice I am giving you below is me presenting every way I would deal with a situation like this. 请仔细阅读:请注意我在下面给出的建议是我提出处理这种情况的每一种方式。 If the InnoDB database is not important, just do my first suggestion of trashing the InnoDB specific DB files. 如果InnoDB数据库不重要,那就做我的第一个建议,即废弃InnoDB特定的DB文件。 If you have a mysqldump backup, do the same thing but recover the mysqldump backup. 如果你有一个mysqldump备份,做同样的事情,但恢复mysqldump备份。

Also, InnoDB is not a default storage engine. 此外,InnoDB 不是默认的存储引擎。 You have to go out of your way to set that. 你必须尽力设置。 The default is MyISAM. 默认为MyISAM。 Any new DB created in MySQL will be MyISAM. 在MySQL中创建的任何新数据库都将是MyISAM。 So this will help you. 所以这会对你有所帮助。 You need to put on your thinking cap an figure out which databases have InnoDB storage engines set. 你需要在思考上面弄清楚哪些数据库设置了InnoDB存储引擎。 If you say you have 25 but only 1 has InnoDB, easy solution. 如果你说你有25个,但只有1个有InnoDB,那么简单的解决方案。 But also if you have 25 databases, you should get into the habit of making regular mysqldump backups. 但是如果你有25个数据库,你应该养成定期进行mysqldump备份的习惯。 If you had backups, this would be a headache but a straight forward thing to solve. 如果你有备份,这将是一个令人头痛的问题,但需要解决。

ONE OPTION: Delete the corrupted InnoDB stuff & recover from a mysqldump backup. 一个选项:删除损坏的InnoDB内容并从mysqldump备份中恢复。

The first thing I would do if I were you is backup the mysql directory in /Library/Application Support/appsolute/MAMP PRO/db/ so you can at least have a backup of the corrupted files just in case. 如果我是你,我会做的第一件事就是备份/Library/Application Support/appsolute/MAMP PRO/db/mysql目录,这样你至少可以备份已损坏的文件以防万一。

Then I would delete the following files: 然后我会删除以下文件:

/Library/Application Support/appsolute/MAMP PRO/db/mysql/ib_logfile0
/Library/Application Support/appsolute/MAMP PRO/db/mysql/ib_logfile1
/Library/Application Support/appsolute/MAMP PRO/db/mysql/ibdata1

Those are InnoDB specific files. 这些是InnoDB特定文件。 Delete them and then attempt to start MAMP again. 删除它们然后再次尝试启动MAMP。 It should come up. 它应该出现。 But any InnoDB database in MAMP will be in some “zombie” state. 但是MAMP中的任何InnoDB数据库都处于某种“僵尸”状态。 You should delete those databases & recreate from backup. 您应该删除这些数据库并从备份重新创建。 Or from scratch if you can. 或者从头开始,如果可以的话。

ANOTHER OPTION: Try to get the MySQL server up & running again with innodb_force_recovery . 另一个选项:尝试使用innodb_force_recovery重新启动并运行MySQL服务器。

Now on the offhand chance you need to recover that DB, you can run attempt to set a innodb_force_recovery as described here. 现在,您需要恢复该数据库,您可以尝试设置innodb_force_recovery ,如此处所述。

For MAMP Pro it seems you can edit your MySQL configuration file as per these instructions: 对于MAMP Pro,您似乎可以按照以下说明编辑MySQL配置文件:

  1. Start MAMP Pro. 启动MAMP Pro。
  2. Stop the MAMP Pro server if it is running. 如果正在运行,请停止MAMP Pro服务器。
  3. Select File -> Edit Template -> MySQL my.cnf 选择文件 - >编辑模板 - > MySQL my.cnf
  4. An editor window appears. 出现编辑器窗口。
  5. If a warning message appears confirm with OK. 如果出现警告消息,请单击“确定”。
  6. Find the section "[mysqld]" 找到“[mysqld]”部分
  7. Beneath the last line of this section add this line: innodb_force_recovery = 1 在本节的最后一行下面添加以下行: innodb_force_recovery = 1

And as the MySQL documentation explains , this is strictly to get the database up and running so you can make a backup via mysqldump : 正如MySQL文档所解释的那样 ,这完全是为了让数据库启动并运行,以便您可以通过mysqldump进行备份:

In such cases, use the innodb_force_recovery option to force the InnoDB storage engine to start up while preventing background operations from running, so that you can dump your tables. 在这种情况下,使用innodb_force_recovery选项强制InnoDB存储引擎启动,同时防止后台操作运行,以便您可以转储表。

Now there are about 6 different values for innodb_force_recovery but you should really only attempt with 1 for now. 现在innodb_force_recovery有大约6个不同的值,但你现在应该只尝试1 If you want to attempt each of the 6, here is a breakdown: 如果你想尝试6中的每一个,这里是一个细分:

1 (SRV_FORCE_IGNORE_CORRUPT) 1(SRV_FORCE_IGNORE_CORRUPT)

Lets the server run even if it detects a corrupt page. 即使检测到损坏的页面,也允许服务器运行。 Tries to make SELECT * FROM tbl_name jump over corrupt index records and pages, which helps in dumping tables. 尝试使SELECT * FROM tbl_name跳过损坏的索引记录和页面,这有助于转储表。

2 (SRV_FORCE_NO_BACKGROUND) 2(SRV_FORCE_NO_BACKGROUND)

Prevents the master thread and any purge threads from running. 防止主线程和任何清除线程运行。 If a crash would occur during the purge operation, this recovery value prevents it. 如果在清除操作期间发生崩溃,则此恢复值会阻止它。

3 (SRV_FORCE_NO_TRX_UNDO) 3(SRV_FORCE_NO_TRX_UNDO)

Does not run transaction rollbacks after crash recovery. 崩溃恢复后不运行事务回滚。

4 (SRV_FORCE_NO_IBUF_MERGE) 4(SRV_FORCE_NO_IBUF_MERGE)

Prevents insert buffer merge operations. 阻止插入缓冲区合并操作。 If they would cause a crash, does not do them. 如果它们会导致崩溃,则不会这样做。 Does not calculate table statistics. 不计算表统计信息。

5 (SRV_FORCE_NO_UNDO_LOG_SCAN) 5(SRV_FORCE_NO_UNDO_LOG_SCAN)

Does not look at undo logs when starting the database: InnoDB treats even incomplete transactions as committed. 启动数据库时不查看撤消日志:InnoDB甚至将未完成的事务视为已提交。

6 (SRV_FORCE_NO_LOG_REDO) 6(SRV_FORCE_NO_LOG_REDO)

Does not do the redo log roll-forward in connection with recovery. 不执行与恢复相关的重做日志前滚。

With this value, you might not be able to do queries other than a basic SELECT * FROM t , with no WHERE , ORDER BY , or other clauses. 使用此值,您可能无法执行基本SELECT * FROM t以外的查询,没有WHEREORDER BY或其他子句。 More complex queries could encounter corrupted data structures and fail. 更复杂的查询可能会遇到损坏的数据结构并失败。

If corruption within the table data prevents you from dumping the entire table contents, a query with an ORDER BY primary_key DESC clause might be able to dump the portion of the table after the corrupted part. 如果表数据中的损坏阻止您转储整个表内容,则具有ORDER BY primary_key DESC子句的查询可能能够在损坏的部分之后转储表的一部分。

If you happen to get the database up and running and then can do a mysqldump then congratulations! 如果您碰巧启动并运行数据库,然后可以执行mysqldump那么恭喜! You are in the clear! 你很清楚! The best next steps is to 最好的后续步骤是

  1. Stop the MySQL database server 停止MySQL数据库服务器
  2. Remove the innodb_force_recovery option from the MySQL config so the database server can operate normally. 从MySQL配置中删除innodb_force_recovery选项,以便数据库服务器可以正常运行。
  3. Restart the MySQL database server. 重启MySQL数据库服务器。
  4. Delete the corrupted MySQL database from the server (Don't delete the dump file! That is your backup!) 从服务器删除损坏的MySQL数据库(不要删除转储文件!这是你的备份!)
  5. Create a new database you want to recover. 创建要恢复的新数据库。
  6. Import the mysqldump backup into the new database. mysqldump备份导入新数据库。

And you should be done. 你应该完成。

One of the pages in your ibdata1 file failed a checksum test as it was being read from disk, which causes MySQL to crash itself by design. 你的ibdata1文件中的一个页面因为从磁盘读取而无法进行校验和测试,这导致MySQL在设计时自行崩溃。 They wouldn't want you to accidentally read data that was known to be corrupt, nor risk modifying any other data in an instance that's liable to corrupt it. 他们不希望您意外地读取已知已损坏的数据,也不会冒险修改可能破坏它的实例中的任何其他数据。

You can read tips on recovering the remaining data here: Recovering Innodb table Corruption . 您可以在此处阅读有关恢复剩余数据的提示: 恢复Innodb表损坏

The innodb_force_recovery might or might not be able to help. innodb_force_recovery可能会也可能无法提供帮助。 Any read of the corrupt page will cause the server to crash again. 任何读取损坏的页面都会导致服务器再次崩溃。 The errors suggest the corrupt page is in the change buffer, which is processed by a background thread immediately upon startup. 错误表明损坏的页面位于更改缓冲区中,后台在启动时立即由后台线程处理。 innodb_force_recovery=4 or higher will prevent the change buffer from being read. innodb_force_recovery=4或更高将阻止更改缓冲区被读取。

It would probably be simpler, provided you have a backup of the database, to delete the ibdata1 file the ib_log* files, and other .ibd files, and then restore the backup. 它可能会更简单,只要你有数据库的备份,删除ibdata1文件的ib_log*文件和其他.ibd文件,然后还原备份。 You can also replay binary logs for point-in-time recovery . 您还可以重播二进制日志以进行时间点恢复

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

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