情况是,我们有 AWS EC2 中型实例,上面有 Linux。
它也有 Drupal。除此之外,我们也很少有文件可以访问 mysql,它们的设置与 Drupal 相同。
问题是 - 在某一时刻 mysql 拒绝连接。
它发生在低负载或大负载(与此无关)时,以及一旦无法访问,mysqld 进程仍在运行,并且不会下降。
重新启动此过程并不能解决问题。重新启动实例 - 修复问题。
当我连接到本地主机时,它给出了这个:
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
虽然 mysql.sock 文件就位并具有正确的权限。
重新启动 mysqld 没有帮助,但重新启动实例 - 解决了问题。
my.cnf 看起来像这样:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
wait_timeout=28800
interactive_timeout = 28800
max_allowed_packet=32M
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
mysqld 运行也没有任何错误,在日志中我们有这个:
120830 9:48:00 [Note] /usr/libexec/mysqld: Shutdown complete
120830 09:48:00 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
120830 09:48:01 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
120830 9:48:01 [Note] Plugin 'FEDERATED' is disabled.
120830 9:48:01 InnoDB: The InnoDB memory heap is disabled
120830 9:48:01 InnoDB: Mutexes and rw_locks use GCC atomic builtins
120830 9:48:01 InnoDB: Compressed tables use zlib 1.2.3
120830 9:48:01 InnoDB: Using Linux native AIO
120830 9:48:01 InnoDB: Initializing buffer pool, size = 128.0M
120830 9:48:01 InnoDB: Completed initialization of buffer pool
120830 9:48:02 InnoDB: highest supported file format is Barracuda.
120830 9:48:02 InnoDB: Waiting for the background threads to start
120830 9:48:03 InnoDB: 1.1.8 started; log sequence number 4191070086
120830 9:48:03 [Note] Event Scheduler: Loaded 0 events
120830 9:48:03 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.5.20' socket: '/var/lib/mysql/mysql.sock -u root' port: 3306 MySQL Community Server (GPL)
当问题再次出现时,我再次记录日志,尝试停止 httpd 然后 mysqld,然后运行 mysqld 然后运行 httpd,日志与正常情况下的日志完全相同,重启顺序相同。
更改 php.ini 并没有挽救这种情况:
mysql.allow_persistent = Off
按此顺序重新启动没有帮助(甚至尝试了不同的顺序):
service httpd stop
service mysqld stop
service mysqld start
service httpd start
我们想找出问题所在以及如何防止它像那样掉下来。