監視ポイント
このページは例として監視ポイントについて記述します。
プロセス
romaプロセスがaliveかそうでないかを調べる。
$ ps -eaf | grep romad
roma 1373 1 0 06:24 ? 00:00:00 ruby bin/romad 192.168.33.12 -p 10001 -d --config /home/roma/config.rb
roma 1385 1 0 06:24 ? 00:00:00 ruby bin/romad 192.168.33.12 -p 10002 -d --config /home/roma/config.rb
roma 2192 1283 0 06:26 pts/0 00:00:00 grep romad
チェックポイント!
- プロセスの数が正しい
-
"--enabled_repeathost" および "--replication_in_host" オプションは使われません。
(これらのオプションは単なる開発環境では除外されます。)
状態
"stats"コマンドを使って状態をチェックする。
> stat node
stats.run_receive_a_vnode {}
routing.nodes.length 4
routing.nodes ["192.168.33.12_10001", "192.168.33.12_10002", "192.168.33.13_10001", "192.168.33.13_10002"]
routing.vnodes.length 512
routing.short_vnodes 0
routing.lost_vnodes 0
routing.version_of_nodes {"192.168.33.12_10001"=>65536, "192.168.33.12_10002"=>65536, "192.168.33.13_10001"=>65536, "192.168.33.13_10002"=>65536}
END
チェックポイント!
- routing.nodes は全てのインスタンスを含めなければなりません。
- routing.short_vnodes は通常の場合 0 でなければなりません。
- routing.lost_vnodes は通常の場合 0 でなければなりません。
- routing.version_of_nodes は全てのインスタンスを含まなければなりません。
ルーティング
romaプロセスがaliveかそうでないかを調べる。
$ ls -l #{routing directory}
total 160
-rw-rw-r-- 1 roma roma 39841 Oct 15 06:24 192.168.33.12_10001.route
-rw-rw-r-- 1 roma roma 0 Oct 15 06:24 192.168.33.12_10001.route.1
-rw-rw-r-- 1 roma roma 39841 Oct 15 06:24 192.168.33.12_10002.route
-rw-rw-r-- 1 roma roma 0 Oct 15 06:24 192.168.33.12_10002.route.1
チェックポイント!
- 最初に、全てのROMAのルーティングファイルは同じ内容を持っています。ですので各サーバでmkrouteコマンドを実行しなかったことを確認してください。
- 変則的な変更が起きたかどうかをチェックします。
-
("192.168.33.12_10001.route.1"のような)番号の付いたファイルはルーティングの変更履歴を保持するファイルです。
=> ファイルサイズが 0 であるのが正常です。
=> もしこのファイルサイズが0より大きければ、それはROMAルーティング情報が変更されたことを意味します。
> enabled_repetition_in_routing?
false
チェックポイント!
- false が正常です。
-
trueの場合は、ルーティングを"--replication_in_host" オプションを使って生成しています。
(このオプションは開発環境では含まれません。ですので再びルーてイングファイルを再生成してください。)
サーバ
サーバ状況をチェックします。
$ uptime
12:13:15 up 5 days, 48 min, 1 user, load average: 0.00, 0.01, 0.00
チェックポイント!
- 時々、ROMAの問題に関係しないサーバダウンの問題に遭遇します。
-
サーバのシステムログをチェックします。
例) sys.log, kern.log, など...
ログ
romaのログのチェックをします。
チェックポイント!- エラーおよび警告ログ。
- 接続カウント。
-
高レンテンシーのエラーメッセージ。
例)"#{cmd} has incompleted, passage of #{ps} seconds"
データ
ROMAのロックファイルをチェックします。
$ ls -l #{data directory}
total 204880
-rw-r--r-- 1 roma roma 20975936 Jun 23 15:34 0.tc
-rw-r--r-- 1 roma roma 20975936 Jun 23 15:34 1.tc
-rw-r--r-- 1 roma roma 20975936 Jun 23 15:34 2.tc
-rw-r--r-- 1 roma roma 20975936 Jun 23 15:34 3.tc
-rw-r--r-- 1 roma roma 20975936 Jun 23 15:34 4.tc
-rw-r--r-- 1 roma roma 20975936 Jun 23 15:34 5.tc
-rw-r--r-- 1 roma roma 20975936 Jun 23 15:34 6.tc
-rw-r--r-- 1 roma roma 20975936 Jun 23 15:34 7.tc
-rw-r--r-- 1 roma roma 20975936 Jun 23 15:34 8.tc
-rw-r--r-- 1 roma roma 20975936 Jun 23 15:34 9.tc
-rw-rw-r-- 1 roma roma 0 Jun 23 15:34 lock <===lock file!!
-rw-rw-r-- 1 roma roma 0 Jun 23 15:34 status.log.1
チェックポイント!
- ROMAを起動できない場合は、ほとんどの場合ロックファイルが原因です。
- ロックファイルはROMAが起動中のデータの一貫性を維持します。
- ロックファイルは起動時に生成され、ROMAが正常に終了した時に削除されます。
- しかし、突然インスタンスがダウンするか何かのエラーの場合、ロックファイルはそのままでしょう。
- ROMAを起動できない場合は、ロックファイルをチェックしそれを削除してください。
tokyo cabinetのファイル状態をチェックする。
$ ./tchmgr inform /usr/local/src/20140124/3.tc
path: /usr/local/src/20140124/3.tc
database type: hash
additional flags: fatal <== Check Point!!
bucket number: 3145721
alignment: 16
free block pool: 1024
inode number: 40648
modified time: 2014-01-24T18:35:00+09:00
options: deflate
record number: 87901
file size: 976008944
チェックポイント!
- Tokyo Cabinetファイルの状態をチェックする