LoginSignup
1

More than 5 years have passed since last update.

MySQL サービスがダウンしても自動的に復旧できるよう簡易監視&サービス再起動ツール Monit を導入する。

Last updated at Posted at 2018-10-14

要旨

MySQL サービスがダウンしても自動的に復旧できるよう監視&サービス再起動ツール Monit を導入する。

インストールする

$ sudo yum install monit -y

設定ファイルを作成する

$ sudo vim /etc/monit.d/mysqld.conf
check process mysqld
    with pidfile "/var/run/mysqld/mysqld.pid"
    start program "/etc/init.d/mysqld start"
    stop program "/etc/init.d/mysqld stop"
    if failed unixsocket /var/lib/mysql/mysql.sock then restart
    if 5 restarts within 5 cycles then timeout

monitサービスを起動する

$ sudo service monit start

自動起動に設定する

$ sudo chkconfig monit on

単体テスト

手動で mysqld を落とし、2分で自動的に復旧するか確認する。

以上。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1