0
0

More than 3 years have passed since last update.

kahadbのログファイルを強制的にフラッシュする方法

Last updated at Posted at 2020-10-26

サーバのディスク容量アラートの原因を探ったら
activemqのkahadbのフォルダが100G近くあって、ディスクを圧迫していた

フォルダ内を見ると
db-xxxxxx.log
というファイルが無数に作成されており、これが積み重なって100Gになっているようだった

[user01 srv01 /usr/apache-activemq/data/kahadb]
$ ls -lh
合計 101G
略
-rw-r--r--  1 root root  33M 11月 12 17:24 2018 db-47599.log
-rw-r--r--  1 root root  33M 11月 12 17:42 2018 db-47600.log
-rw-r--r--  1 root root  33M 11月 12 18:02 2018 db-47601.log
-rw-r--r--  1 root root  33M  3月  5 17:22 2019 db-54390.log
-rw-r--r--  1 root root  33M  3月  5 18:46 2019 db-54391.log
-rw-r--r--  1 root root  32M 10月 26 20:47 2020 db-63532.log
-rw-r--r--. 1 root root  88M 10月 26 20:47 2020 db.data
-rw-r--r--. 1 root root 3.2M 10月 26 20:47 2020 db.redo
-rw-r--r--. 1 root root    0  5月  9 18:26 2014 lock

db-xxxxxx.logは何のファイル?

公式のドキュメントを見るとdb-xxxxxx.logというファイルは拡張子の通りkahadbのログファイルだった
https://activemq.apache.org/why-do-kahadb-log-files-remain-after-cleanup

本来は30秒毎に更新されるのだが
何らか理由でkahadbが掴んでいる状態だとログファイルが削除されず残り
db-1.log
db-2.log
db-3.log
....
と溜まり続けるようだ

削除方法

本来は、なぜログファイルが掴まれ続けているのかを調査した上で個別の解決方法を取るのが正しいのだが
自分のケースでは、ログや未送信のキューを失っても良かったので全データをリセットする方法を取った

方法は
deleteAllMessagesOnStartup="true"
という属性をactivemq.xmlのbroker要素に追加してactivemqを再起動するだけ

例

# activemq.xml修正
vim /usr/apache-activemq/conf/activemq.xml

#以下のようにbroker要素のdeleteAllMessagesOnStartupを追加
  <broker deleteAllMessagesOnStartup="true" xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.base}/data" destroyApplicationContextOnStop="true" schedulerSupport="true" persistent="true">

# activemq再起動 (cent6環境)
sudo /etc/init.d/activemq stop
sudo /etc/init.d/activemq start

activemq.xmlのリファレンス
https://activemq.apache.org/xml-reference

0
0
0

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
0
0