Monit 無法偵測到 MySQL

Monit 無法偵測到 MySQL

Monit webinterfcae 顯示:執行失敗 |不存在

netstat 給我:

sudo netstat -lnp | grep mysql
tcp        0      0 127.0.0.1:33060         0.0.0.0:*               LISTEN      4643/mysqld
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      4643/mysqld
unix  2      [ ACC ]     STREAM     LISTENING     90220    4643/mysqld          /var/run/mysqld/mysqlx.sock
unix  2      [ ACC ]     STREAM     LISTENING     90222    4643/mysqld          /var/run/mysqld/mysqld.sock

和 monit -v (如果這有幫助的話):

Process Name          = mysqld
 Group                = mysql, database
 Pid file             = /var/run/mysqld/mysqld.pid
 Monitoring mode      = active
 On reboot            = start
 Start program        = '/etc/init.d/mysql start' timeout 30 s
 Stop program         = '/etc/init.d/mysql stop' timeout 30 s
 Existence            = if does not exist then restart
 Depends on Service   = mysql_rc
 Depends on Service   = mysql_bin
 Port                 = if failed [localhost]:3306 type TCP/IP protocol MYSQL with timeout 15 s for 3 times within 4 cycles then restart
 Unix Socket          = if failed /var/run/mysqld/mysqld.sock type TCP protocol MYSQL with timeout 5 s for 3 times within 4 cycles then restart
 Timeout              = If restarted 5 times within 5 cycle(s) then unmonitor

File Name             = mysql_bin
 Group                = mysql
 Path                 = /usr/sbin/mysqld
 Monitoring mode      = active
 On reboot            = start
 Existence            = if does not exist then restart
 Checksum             = if failed defc97a98deb37905c97d9b5a09f9f13(MD5) then unmonitor
 Permission           = if failed 0755 then unmonitor
 UID                  = if failed 0 then unmonitor
 GID                  = if failed 0 then unmonitor

File Name             = mysql_rc
 Group                = mysql
 Path                 = /etc/init.d/mysql
 Monitoring mode      = active
 On reboot            = start
 Existence            = if does not exist then restart
 Checksum             = if failed 89a1a5b6ad710389112802fc3fbb81e1(MD5) then unmonitor
 Permission           = if failed 0755 then unmonitor
 UID                  = if failed 0 then unmonitor
 GID                  = if failed 0 then unmonitor

所以即使 mysql 正在運行並且 active Monit 也無法偵測到它。我設定符號連結:

sudo ln -s /etc/monit/conf-available/mysql /etc/monit/conf-enabled/

使用Ubuntu 20.04

編輯 :

監控狀態:

Process 'mysqld'
  status                       Not monitored
  monitoring status            Not monitored
  monitoring mode              active
  on reboot                    start
  data collected               Sun, 20 Dec 2020 00:00:29

File 'mysql_bin'
  status                       OK
  monitoring status            Monitored
  monitoring mode              active
  on reboot                    start
  permission                   755
  uid                          0
  gid                          0
  size                         63.7 MB
  access timestamp             Mon, 21 Dec 2020 11:53:36
  change timestamp             Thu, 17 Dec 2020 11:52:00
  modify timestamp             Thu, 26 Nov 2020 12:03:42
  checksum                     defc97a98deb37905c97d9b5a09f9f13 (MD5)
  data collected               Mon, 21 Dec 2020 16:32:35

File 'mysql_rc'
  status                       OK
  monitoring status            Monitored
  monitoring mode              active
  on reboot                    start
  permission                   755
  uid                          0
  gid                          0
  size                         5.5 kB
  access timestamp             Mon, 21 Dec 2020 11:53:37
  change timestamp             Thu, 17 Dec 2020 11:52:05
  modify timestamp             Wed, 06 Nov 2019 18:34:43
  checksum                     89a1a5b6ad710389112802fc3fbb81e1 (MD5)
  data collected               Mon, 21 Dec 2020 16:32:35

監控日誌顯示如下,對我來說沒有任何異常。忽略郵件錯誤:

[UTC Dec 21 16:37:10] info     : 'apache' monitor on user request
[UTC Dec 21 16:37:10] info     : 'mysqld' monitor on user request
[UTC Dec 21 16:37:10] info     : 'nginx' monitor on user request
[UTC Dec 21 16:37:10] info     : 'inf-education-67' monitor on user request
[UTC Dec 21 16:37:10] info     : 'apache_rc' monitor on user request
[UTC Dec 21 16:37:10] info     : 'apache_bin' monitor on user request
[UTC Dec 21 16:37:10] info     : 'mysql_rc' monitor on user request
[UTC Dec 21 16:37:10] info     : 'mysql_bin' monitor on user request
[UTC Dec 21 16:37:10] info     : 'nginx_rc' monitor on user request
[UTC Dec 21 16:37:10] info     : 'nginx_bin' monitor on user request
[UTC Dec 21 16:37:10] info     : Monit daemon with PID 900 awakened
[UTC Dec 21 16:37:10] info     : Awakened by User defined signal 1
[UTC Dec 21 16:37:10] error    : Mail: Mailserver response error -- 535-5.7.8 Username and Password not accepted. Learn more at
[UTC Dec 21 16:37:10] error    : SMTP: Mailserver response error -- 535 5.7.8  https://support.google.com/mail/?p=BadCredentials f77sm22188901wmf.42 - gsmtp
[UTC Dec 21 16:37:10] error    : Alert handler failed, retry scheduled for next cycle
[UTC Dec 21 16:37:10] info     : 'nginx_bin' monitor action done
[UTC Dec 21 16:37:11] error    : Mail: Mailserver response error -- 535-5.7.8 Username and Password not accepted. Learn more at
[UTC Dec 21 16:37:11] error    : SMTP: Mailserver response error -- 535 5.7.8  https://support.google.com/mail/?p=BadCredentials y63sm24571380wmd.21 - gsmtp
[UTC Dec 21 16:37:11] error    : Event queue is full
[UTC Dec 21 16:37:11] error    : Aborting event - queue over quota
[UTC Dec 21 16:37:11] info     : 'nginx_rc' monitor action done
[UTC Dec 21 16:37:11] error    : Mail: Mailserver response error -- 535-5.7.8 Username and Password not accepted. Learn more at
[UTC Dec 21 16:37:11] error    : SMTP: Mailserver response error -- 535 5.7.8  https://support.google.com/mail/?p=BadCredentials o125sm24541891wmo.30 - gsmtp
[UTC Dec 21 16:37:11] error    : Event queue is full
[UTC Dec 21 16:37:11] error    : Aborting event - queue over quota
[UTC Dec 21 16:37:11] info     : 'mysql_bin' monitor action done
[UTC Dec 21 16:37:11] error    : Mail: Mailserver response error -- 535-5.7.8 Username and Password not accepted. Learn more at
[UTC Dec 21 16:37:11] error    : SMTP: Mailserver response error -- 535 5.7.8  https://support.google.com/mail/?p=BadCredentials m2sm22734832wml.34 - gsmtp
[UTC Dec 21 16:37:11] error    : Event queue is full
[UTC Dec 21 16:37:11] error    : Aborting event - queue over quota
[UTC Dec 21 16:37:11] info     : 'mysql_rc' monitor action done
[UTC Dec 21 16:37:11] error    : Mail: Mailserver response error -- 535-5.7.8 Username and Password not accepted. Learn more at
[UTC Dec 21 16:37:11] error    : SMTP: Mailserver response error -- 535 5.7.8  https://support.google.com/mail/?p=BadCredentials s3sm2848477wmc.44 - gsmtp
[UTC Dec 21 16:37:11] error    : Event queue is full
[UTC Dec 21 16:37:11] error    : Aborting event - queue over quota
[UTC Dec 21 16:37:11] info     : 'apache_bin' monitor action done
[UTC Dec 21 16:37:12] error    : Mail: Mailserver response error -- 535-5.7.8 Username and Password not accepted. Learn more at
[UTC Dec 21 16:37:12] error    : SMTP: Mailserver response error -- 535 5.7.8  https://support.google.com/mail/?p=BadCredentials 125sm22297314wmc.27 - gsmtp
[UTC Dec 21 16:37:12] error    : Event queue is full
[UTC Dec 21 16:37:12] error    : Aborting event - queue over quota
[UTC Dec 21 16:37:12] info     : 'apache_rc' monitor action done
[UTC Dec 21 16:37:12] error    : Mail: Mailserver response error -- 535-5.7.8 Username and Password not accepted. Learn more at
[UTC Dec 21 16:37:12] error    : SMTP: Mailserver response error -- 535 5.7.8  https://support.google.com/mail/?p=BadCredentials o23sm30549332wro.57 - gsmtp
[UTC Dec 21 16:37:12] error    : Event queue is full
[UTC Dec 21 16:37:12] error    : Aborting event - queue over quota
[UTC Dec 21 16:37:12] info     : 'inf-education-67' monitor action done
[UTC Dec 21 16:37:12] error    : Mail: Mailserver response error -- 535-5.7.8 Username and Password not accepted. Learn more at
[UTC Dec 21 16:37:12] error    : SMTP: Mailserver response error -- 535 5.7.8  https://support.google.com/mail/?p=BadCredentials v20sm28999905wra.19 - gsmtp
[UTC Dec 21 16:37:12] error    : Event queue is full
[UTC Dec 21 16:37:12] error    : Aborting event - queue over quota
[UTC Dec 21 16:37:12] info     : 'nginx' monitor action done
[UTC Dec 21 16:37:12] error    : Mail: Mailserver response error -- 535-5.7.8 Username and Password not accepted. Learn more at
[UTC Dec 21 16:37:12] error    : SMTP: Mailserver response error -- 535 5.7.8  https://support.google.com/mail/?p=BadCredentials k1sm27935712wrn.46 - gsmtp
[UTC Dec 21 16:37:12] error    : Event queue is full
[UTC Dec 21 16:37:12] error    : Aborting event - queue over quota
[UTC Dec 21 16:37:12] info     : 'mysqld' monitor action done

答案1

泰勒的答案另一個問題對這個:

在 Ubuntu 20.04 LTS 上,我發現 pid-file 和 socket 在/etc/mysql/mysql.conf.d/mysqld.cnf.我取消註解這兩行,然後用service mysql restartmonit 重新啟動 mysql service monit restart,monit 成功地能夠監視 mysqld 進程。

這對我有用,順便說一句,謝謝你@Tyler(我不能在那裡投票和評論)

相關內容