为什么 Monit 不能与我的 MySQL 配置文件一起工作?

为什么 Monit 不能与我的 MySQL 配置文件一起工作?

我在 /etc/mysql/conf.d/myfile.cnf 中使用 mysql 的自定义配置文件

文件内容

[client]
port        = 3306
socket      = /var/run/mysqld/mysqld.sock

[mysqld_safe]
socket      = /var/run/mysqld/mysqld.sock
nice        = 0

[mysqld]
user        = mysql
pid-file    = /var/run/mysqld/mysqld.pid
socket      = /var/run/mysqld/mysqld.sock
port        = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir      = /tmp
language    = /usr/share/mysql/english
skip-external-locking
bind-address        = 127.0.0.1

bulk_insert_buffer_size = 8M
connect_timeout=10
interactive_timeout=50
join_buffer=1M
key_buffer=250M
max_allowed_packet=16M
max_connect_errors=10
max_connections=100
max_heap_table_size = 32M
myisam_sort_buffer_size=96M
query_cache_limit = 4M
query_cache_size = 250M
query_cache_type = 1
query_prealloc_size = 65K
query_alloc_block_size = 128K
read_buffer_size=1M
read_rnd_buffer_size=768K
#record_buffer_size=1M
#safe-show-database
#skip-innodb
#skip-locking
skip-networking
sort_buffer=1M
table_cache=4096
thread_cache_size=1024
thread_concurrency=8
tmp_table_size = 32M
wait_timeout=500
# for slow queries, comment when not used
#log-slow-queries=/var/log/mysql-slow.log
#long_query_time=1
#log-queries-not-using-indexes

[mysqld_safe]
nice = -5
open_files_limit = 8192
pid-file    = /var/run/mysqld/mysqld.pid
socket      = /var/run/mysqld/mysqld.sock



[mysqldump]
quick
max_allowed_packet = 16M
[myisamchk]
key_buffer = 64M
sort_buffer = 64M
read_buffer = 16M
write_buffer = 16M

怎么了?

如果使用mysql的默认配置文件,Monit可以顺利运行

我的系统是 Debian Squeeze 6.0.x 和 Mysql Server 版本:5.1.66-0+squeeze1 (Debian)

错误是 monit 状态:“状态连接失败”和“端口响应时间连接失败至 127.0.0.1:3306 [DEFAULT via TCP]”

我的配置Monit Mysql

...
check process mysql with pidfile /var/run/mysqld/mysqld.pid
  group database
  start program = "/etc/init.d/mysql start"
  stop program = "/etc/init.d/mysql stop"
  if failed host 127.0.0.1 port 3306 then restart
  if 5 restarts within 5 cycles then timeout
...

答案1

在 Ubuntu 20.04 LTS 上,我发现pid-filesocket在中被注释掉了/etc/mysql/mysql.conf.d/mysqld.cnf。我取消注释了这两行,然后使用重新启动了 mysql 并service mysql restart使用 monit service monit restart,monit 成功能够监视该mysqld进程。

答案2

我猜是这条线

if failed host 127.0.0.1 port 3306 then restart

如果主机连续出现 10 次(我认为)不良连接,MySQL 将阻止该主机。我认为它一直正常工作,直到第 10 次检查,然后它开始失败。其余部分没有问题。尝试像这样修复它

if failed host 127.0.0.1 port 3306 protocol mysql then restart

你还应该运行

mysqladmin flush-hosts

这将清除被禁止的主机

相关内容