服务 mysqld 5.6 在 CentOS 6.9 上不断启动和停止

服务 mysqld 5.6 在 CentOS 6.9 上不断启动和停止

在我的 VPS 上,mysqld 启动后,它自动停止,然后又自动启动。

我尝试了sudo service mysqld stop并且成功了。我手动启动后成功了。但它突然停止又开始,并且不断地开始和停止。

每次我得到不同的PID。

我怎样才能解决这个问题?

我手动启动 mysqld 并收到以下错误:

2018-12-30 16:51:00 4535 [Note] Plugin 'FEDERATED' is disabled.
2018-12-30 16:51:00 4535 [Warning] option 'innodb-buffer-pool-size': signed value 65536 adjusted to 5242880
2018-12-30 16:51:00 4535 [Note] InnoDB: Using atomics to ref count buffer pool pages
2018-12-30 16:51:00 4535 [Note] InnoDB: The InnoDB memory heap is disabled
2018-12-30 16:51:00 4535 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-12-30 16:51:00 4535 [Note] InnoDB: Memory barrier is not used
2018-12-30 16:51:00 4535 [Note] InnoDB: Compressed tables use zlib 1.2.11
2018-12-30 16:51:00 4535 [Note] InnoDB: Using Linux native AIO
2018-12-30 16:51:00 4535 [Note] InnoDB: Using CPU crc32 instructions
2018-12-30 16:51:00 4535 [Note] InnoDB: Initializing buffer pool, size = 5.0M
2018-12-30 16:51:00 4535 [Note] InnoDB: Completed initialization of buffer pool
2018-12-30 16:51:00 4535 [Note] InnoDB: Highest supported file format is Barracuda.
2018-12-30 16:51:00 4535 [Note] InnoDB: 128 rollback segment(s) are active.
2018-12-30 16:51:00 4535 [Note] InnoDB: 5.6.42 started; log sequence number 4940394469
2018-12-30 16:51:00 4535 [Note] InnoDB: !!! innodb_force_recovery is set to 3 !!!
2018-12-30 16:51:00 4535 [Note] Server hostname (bind-address): '*'; port: 3306
2018-12-30 16:51:00 4535 [Note] IPv6 is available.
2018-12-30 16:51:00 4535 [Note]   - '::' resolves to '::';
2018-12-30 16:51:00 4535 [Note] Server socket created on IP: '::'.
2018-12-30 16:51:00 4535 [Warning] 'user' entry '[email protected]' ignored in --skip-name-resolve mode.
2018-12-30 16:51:00 4535 [Warning] 'user' entry '@v4452.vir.kagoya.net' ignored in --skip-name-resolve mode.
2018-12-30 16:51:00 4535 [Warning] 'proxies_priv' entry '@ [email protected]' ignored in --skip-name-resolve mode.
2018-12-30 16:51:00 4535 [Note] Event Scheduler: Loaded 0 events
2018-12-30 16:51:00 4535 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.6.42'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server (GPL)
2018-12-30 16:51:15 4535 [ERROR] /usr/sbin/mysqld: Table './mylife/wp_options' is marked as crashed and should be repaired
2018-12-30 16:51:15 4535 [ERROR] /usr/sbin/mysqld: Table './mylife/wp_options' is marked as crashed and should be repaired
2018-12-30 16:51:15 4535 [ERROR] /usr/sbin/mysqld: Table './mylife/wp_options' is marked as crashed and should be repaired
2018-12-30 16:53:56 4535 [ERROR] /usr/sbin/mysqld: Table './mylife/wp_options' is marked as crashed and should be repaired
2018-12-30 16:53:56 4535 [ERROR] /usr/sbin/mysqld: Table './mylife/wp_options' is marked as crashed and should be repaired
2018-12-30 16:53:56 4535 [ERROR] /usr/sbin/mysqld: Table './mylife/wp_options' is marked as crashed and should be repaired
2018-12-30 16:54:16 4535 [ERROR] /usr/sbin/mysqld: Table './mylife/wp_options' is marked as crashed and should be repaired
2018-12-30 16:54:16 4535 [ERROR] /usr/sbin/mysqld: Table './mylife/wp_options' is marked as crashed and should be repaired
2018-12-30 16:54:16 4535 [ERROR] /usr/sbin/mysqld: Table './mylife/wp_options' is marked as crashed and should be repaired
2018-12-30 16:54:32 4535 [ERROR] /usr/sbin/mysqld: Table './mylife/wp_options' is marked as crashed and should be repaired
2018-12-30 16:54:32 4535 [ERROR] /usr/sbin/mysqld: Table './mylife/wp_options' is marked as crashed and should be repaired
2018-12-30 16:54:32 4535 [ERROR] /usr/sbin/mysqld: Table './mylife/wp_options' is marked as crashed and should be repaired
2018-12-30 16:54:33 4535 [ERROR] /usr/sbin/mysqld: Table './mylife/wp_options' is marked as crashed and should be repaired
2018-12-30 16:54:33 4535 [ERROR] /usr/sbin/mysqld: Table './mylife/wp_options' is marked as crashed and should be repaired
2018-12-30 16:54:33 4535 [ERROR] /usr/sbin/mysqld: Table './mylife/wp_options' is marked as crashed and should be repaired
2018-12-30 16:56:18 4535 [ERROR] /usr/sbin/mysqld: Table './mylife/wp_options' is marked as crashed and should be repaired
2018-12-30 16:56:18 4535 [ERROR] /usr/sbin/mysqld: Table './mylife/wp_options' is marked as crashed and should be repaired

我也在 MySQL CLI 中做了:

mysql> use mylife;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    1

mylife DB 有 InnoDB 表。

答案1

你有一个损坏的表;innodb_force_recovery不适合与正常的 MySQL 启动一起使用,并且innodb_force_recovery设置为无效值,因此 MySQL 放弃运行。

从您的 MySQL 日志中:

  • 您的 WordPress 数据库表 /mylife/wp_options 被标记为已损坏;
  • innodb_force_recovery设置为无效值。

设置innodb_force_recovery为1并启动MySQL可能允许您手动修复表;但是MySQL没有正常启动。

从以下命令开始:

/usr/sbin/mysqld --skip-grant-tables --basedir=/ --datadir=/var/lib/mysql --user=mysql --pid-file=/var/lib/mysql/HOSTNAME.pid --skip-external-locking --port=3306 --socket=/var/lib/mysql/mysql.sock

然后做:

# mysql
> use mylife;
> repair table wp_options;
> exit;

现在,消除那个innodb_force_recovery设定。之后您将能够重新启动 MySQL。

作为参考,请参阅mysql Innodb – 表“用户”被标记为崩溃,应该修复

如果 MySQL 无法恢复表(不太可能),或者您尝试手动恢复表文件,则必须在 MySQL 启动之前从数据库转储中恢复表 wp_options。 InnoDB 表并不像 MyISAM 那样作为单独的表文件恢复,这是我看到人们一次又一次犯的一个常见错误。

相关日志:

InnoDB: !!! innodb_force_recovery is set to 3 !!!  
[ERROR] /usr/sbin/mysqld: Table './mylife/wp_options' is marked as crashed and should be repaired

此外,如果您使用该选项--skip-name-resolve,则根据以下日志,您必须通过 IP 地址而不是 DNS 名称进行授权。请注意,这是一个警告,可能是之前设置的残余;然而,由于缺乏对你的问题更好的背景,我们无法确定该说些什么。

[Warning] 'user' entry '[email protected]' ignored in --skip-name-resolve mode.
[Warning] 'user' entry '@v4452.vir.kagoya.net' ignored in --skip-name-resolve mode.
[Warning] 'proxies_priv' entry '@ [email protected]' ignored in --skip-name-resolve mode.

至于获取不同的 PID,如果服务正在死亡/重新启动,则在每次后续运行中获取不同的 PID 是正常行为。

相关内容