2013年9月25日水曜日

Pandora FMSが上手く動かないからログをチェックしたら、mysql.logにエラーが出てたときの対処法

何を隠そう、私は死活監視ソフトとしてPandora FMSというプロダクトを使っている。

ずっとNagios使ってたけど、設定ファイル書くのが(特に記述ミスったときに、ミスった箇所を特定するのが)大変だったし……ってことで、何かいいプロダクトないかなーといつぞやのOSCに行ったときデモみたりとかセミナーとか参加した時に見かけたのがきっかけ。Zabbixとかもあったけど、何となく気に入ったので使い始めて今に至る……というわけ。

それはどうでもいいんだけども、何らかの理由で正常にMySQLがシャットダウンされなかったときにPandora FMSが正常に動作しなくなることがある。例えば、/var/log/mysqld.logには下記のようなエラーが出力されていたり、管理コンソールにログインしたときに「全モニタシステム:停止」になっていたりする。

[ERROR] /usr/libexec/mysqld: Incorrect key file for table './pandora/tserver.MYI'; try to repair it

前述のログに出力されたエラーを見れば分かるとおり、テーブルが壊れてしまっている。どうするか。「try to repair it」なのです。

これは必要な手順なのかはイマイチ不明なんだけど、個人的にはPandora FMS関連のデーモンをいったん止めてから作業するようにしていたりする。……探せば出てくるんだろうけど、結局MySQLのエラーだから自分的お決まりの手順でいいかなーって(*^ー゜)

# /etc/init.d/pandora_server stop
Stopping Pandora FMS Server
# /etc/init.d/pandora_agent_daemon stop
Stopping Pandora Agent.

で、いろいろとやり方はあるんだけども、今回はmysqlcheckコマンドを使ってみる。「-r」オプションね。

# /etc/init.d/pandora_server stop
# mysqlcheck -u root -p -r {{Pandora FMSのDB} FMSのDB}
Enter password:{rootユーザのパスワードを入力}
{Pandora FMSのDB}.taddress
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.taddress_agent
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tagent_access
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tagent_custom_data
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tagent_custom_fields
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tagente
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tagente_datos
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tagente_datos_inc
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tagente_datos_log4x
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tagente_datos_string
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tagente_estado
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tagente_modulo
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.talert_actions
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.talert_commands
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.talert_compound
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.talert_compound_actions
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.talert_compound_elements
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.talert_snmp
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.talert_template_module_actions
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.talert_template_modules
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.talert_templates
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tattachment
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tconfig
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tconfig_os
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tevento
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tgis_data_history
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tgis_data_status
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tgis_map
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tgis_map_connection
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tgis_map_has_tgis_map_connection
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tgis_map_layer
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tgis_map_layer_has_tagente
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tgraph
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tgraph_source
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tgroup_stat
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tgrupo
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tincidencia
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tlanguage
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tlayout
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tlayout_data
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tlink
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tmensajes
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tmodule
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tmodule_group
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tnetwork_component
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tnetwork_component_group
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tnetwork_map
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tnetwork_profile
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tnetwork_profile_component
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tnews
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tnota
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.torigen
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tperfil
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tplanned_downtime
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tplanned_downtime_agents
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tplugin
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.trecon_script
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.trecon_task
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.treport
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.treport_content
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.treport_content_item
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.treport_content_sla_combined
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.treport_custom_sql
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tserver                                    OK
{Pandora FMSのDB}.tserver_export
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tserver_export_data
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tsesion
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tsnmp_filter
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.ttag
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.ttag_event
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.ttag_module
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.ttag_policy_module
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.ttipo_modulo
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.ttrap
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tupdate
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tupdate_journal
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tupdate_package
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tupdate_settings
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tusuario
note     : The storage engine for the table doesn't support repair
{Pandora FMSのDB}.tusuario_perfil
note     : The storage engine for the table doesn't support repair

実際にはMySQLのrootユーザじゃなくても大丈夫かもしれないけど、個人的にはこの手の作業は特権ユーザでやることにしてるので検証はしていない。必要なら各自お試しください。

で、これで修復されているはずなので、再び関連サービスを起動します。

# /etc/init.d/pandora_agent_daemon start
Pandora FMS Agent is now running with PID {デーモンのPID}
# /etc/init.d/pandora_server start

Pandora FMS Server 4.1 Build 130708 Copyright (c) 2004-2011 ArticaST
This program is OpenSource, licensed under the terms of GPL License version 2.
You can download latest versions and documentation at http://www.pandorafms.org

 [*] Pandora FMS Enterprise module not available.
 [*] Backgrounding Pandora FMS Server process.

Pandora Server is now running with PID {デーモンのPID}

これで/var/log/mysqld.logにもエラーは出なくなったし、管理コンソールにログインすればちゃんと監視が再開されているはず。

ちなみにこの手順、Pandora FMSに限らずMyISAMなテーブルが壊れたときの対処法として汎用的に使えるので覚えておくとよさげ。

……と、ここまで書きためておいたんだけど、改めてグーグル先生にお伺いを立ててみたら似たようなことをやってる人がいたのでリンクしておく。私のやり方とはちょっと違う……かな?

お茶屋さん、なう。 - PandoraFMSのtserver.MYIが壊れてた話

0 件のコメント:

コメントを投稿