0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ChefTips: Chef Server のログについて

Posted at

Chef Server が出力するログについてまとめます。

ログの出力先について

Chef Server を導入後、Chef Serverが出力するログは以下に出力されます。

  • /var/log/opscode
  • /var/opt/opscode

参考/引用: Log Files

Chef Serverログのローテション・クリーンアップについては、導入時自動で 設定してくれているようです。私自身、大規模環境でChef Serverを運用した経験はありませんが、導入時のDefault設定で困ったことは今のところありません。

chef-server.rb について

他のChef Serverの設定項目と同じく、ログローテション、クリーンアップの設定変更については

  • chef-server.rb ファイルに記述
  • chef-server-ctl reconfigure コマンドで反映

という流れで変更します。

・chef-server-ctl reconfigure コマンド の説明
https://docs.chef.io/ctl_chef_server.html#reconfigure

・Chef Server設定ファイル chef-server.rb について
https://docs.chef.io/config_rb_server.html

・chef-server.rb で利用可能な オプション記述について
https://docs.chef.io/config_rb_server_optional_settings.html

もしこのログはDefaultだとログローテション・クリーンアップされないので、設定追加したほうがいいよ!という情報をお持ちの方がいらっしゃいましたら、コメントなどで教えてくださると助かります。

追加される logroted の設定

あまり意識する必要はありませんが、実際のログローテションの設定としては、logrotated と svlogd の仕組みを使って行われているようです。簡単に設定箇所を抜粋します。

$ cat /etc/opscode/logrotate.conf
missingok
compress
notifempty
include /etc/opscode/logrotate.d

$ ls -l /etc/opscode/logrotate.d/
total 12
-rw-r--r--. 1 root root 236 Oct 26  2016 nginx
-rw-r--r--. 1 root root 114 Oct 26  2016 opscode-solr4
-rw-r--r--. 1 root root  92 Oct 26  2016 redis_lb

定期実行は以下のcronが設定されます。

$ cat /etc/cron.hourly/opc_logrotate
# !/bin/sh
PATH=/opt/opscode/embedded/sbin:$PATH
command -v logrotate >/dev/null 2>&1 || exit 0
nice -n 19 ionice -c3 logrotate -s /var/log/opscode/logrotate.status /etc/opscode/logrotate.conf

追加される svlogdの設定


$ ls -l /opt/opscode/service/
total 0
lrwxrwxrwx. 1 root root 25 Oct 26  2016 bookshelf -> /opt/opscode/sv/bookshelf
lrwxrwxrwx. 1 root root 21 Oct 26  2016 nginx -> /opt/opscode/sv/nginx
lrwxrwxrwx. 1 root root 26 Oct 26  2016 oc_bifrost -> /opt/opscode/sv/oc_bifrost
lrwxrwxrwx. 1 root root 21 Oct 26  2016 oc_id -> /opt/opscode/sv/oc_id
lrwxrwxrwx. 1 root root 34 Oct 26  2016 opscode-chef-mover -> /opt/opscode/sv/opscode-chef-mover
lrwxrwxrwx. 1 root root 30 Oct 26  2016 opscode-erchef -> /opt/opscode/sv/opscode-erchef
lrwxrwxrwx. 1 root root 32 Oct 26  2016 opscode-expander -> /opt/opscode/sv/opscode-expander
lrwxrwxrwx. 1 root root 29 Oct 26  2016 opscode-solr4 -> /opt/opscode/sv/opscode-solr4
lrwxrwxrwx. 1 root root 26 Oct 26  2016 postgresql -> /opt/opscode/sv/postgresql
lrwxrwxrwx. 1 root root 24 Oct 26  2016 rabbitmq -> /opt/opscode/sv/rabbitmq
lrwxrwxrwx. 1 root root 24 Oct 26  2016 redis_lb -> /opt/opscode/sv/redis_lb
 
$ ps auxwww | grep svlogd
root     13206  0.0  0.0 112648   976 pts/0    R+   04:27   0:00 grep --color=auto svlogd
opscode  14851  0.0  0.0   4328    88 ?        S     2016   0:00 svlogd -tt /var/log/opscode/rabbitmq
opscode  14943  0.0  0.0   4328     0 ?        S     2016   0:00 svlogd -tt /var/log/opscode/postgresql/9.2
opscode  15001  0.0  0.0   4328    40 ?        S     2016   0:00 svlogd -tt /var/log/opscode/oc_bifrost
root     15025  0.0  0.0   4328    32 ?        S     2016   0:00 svlogd -tt /var/log/opscode/oc_id
opscode  15069  0.0  0.0   4328    24 ?        S     2016   0:00 svlogd -tt /var/log/opscode/opscode-solr4
opscode  15109  0.0  0.0   4328    16 ?        S     2016   0:00 svlogd -tt /var/log/opscode/opscode-expander
opscode  15172  0.0  0.0   4328    48 ?        S     2016   0:00 svlogd -tt /var/log/opscode/bookshelf
opscode  15216  0.0  0.0   4328    88 ?        S     2016   0:00 svlogd -tt /var/log/opscode/opscode-erchef
opscode  15273  0.0  0.0   4328     0 ?        S     2016   0:00 svlogd -tt /var/log/opscode/opscode-chef-mover
opscode  15277  0.0  0.0   4328     0 ?        S     2016   0:00 svlogd -tt /var/log/opscode/redis_lb
opscode  15283  0.0  0.0   4328    80 ?        S     2016   0:00 svlogd -tt /var/log/opscode/nginx
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?