rsyslogの話題と実験
Created: 24 November 2008
rsyslogの小技 (24 November 2008)
rsyslogのインストール (24 November 2008)
受信プロトコルやホストの指定
"/etc/sysconfig/rsyslog"を以下のように、オプションを追加します。
# Options to syslogd
# -m 0 disables 'MARK' messages.
# -rPortNumber Enables logging from remote machines. The listener will listen to the specified port.
# -x disables DNS lookups on messages recieved with -r
# See syslogd(8) for more details
SYSLOGD_OPTIONS="-m 0 -r -t514 -l targhet.tomo.ac -s tomo.ac"
# Options to klogd
# -2 prints all kernel oops messages twice; once for klogd to decode, and
# once for processing with 'ksymoops'
# -x disables all klogd processing of oops messages entirely
# See klogd(8) for more details
KLOGD_OPTIONS="-x"オプションは、以下の意味です。
-r UDPを使うことを許可 -t514 TCP、ポート514を使うことを許可 -l targhet.tomo.ac 指定されたホストから受信することを指定 -s tomo.ac 指定されたドメインから受信することを指定
CentOS5.2では、yum でインストールできます。
# yum install -y rsyslog rsyslog-mysql
"/etc/rsyslog.conf"の内容確認
"syslog.conf"と"rsyslog.conf"の内容が同じであることを比較して確認して見ます。
"/etc/syslog.conf"は以下です。
# Log all kernel messages to the console.
# Logging much else clutters up the screen.
#kern.* /dev/console
# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
*.info;mail.none;news.none;authpriv.none;cron.none /var/log/messages
# The authpriv file has restricted access.
authpriv.* /var/log/secure
# Log all the mail messages in one place.
mail.* -/var/log/maillog
# Log cron stuff
cron.* /var/log/cron
# Everybody gets emergency messages
*.emerg *
# Save news errors of level crit and higher in a special file.
uucp,news.crit /var/log/spooler
# Save boot messages also to boot.log
local7.* /var/log/boot.log
#
# INN
#
news.=crit /var/log/news/news.crit
news.=err /var/log/news/news.err
news.notice /var/log/news/news.notice
"/etc/rsyslog.conf"は、以下です。
newsは使わないので、問題なしとします。
# Log all kernel messages to the console.
# Logging much else clutters up the screen.
#kern.* /dev/console
# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
*.info;mail.none;authpriv.none;cron.none /var/log/messages
# The authpriv file has restricted access.
authpriv.* /var/log/secure
# Log all the mail messages in one place.
mail.* -/var/log/maillog
# Log cron stuff
cron.* /var/log/cron
# Everybody gets emergency messages
*.emerg *
# Save news errors of level crit and higher in a special file.
uucp,news.crit /var/log/spooler
# Save boot messages also to boot.log
local7.* /var/log/boot.log
サービスを起動する
旧の"syslog"を停止し、"rsyslog"を起動します。
# service syslog stop
カーネルロガーを停止中: [ OK ]
システムロガーを停止中: [ OK ]
# service rsyslog start
システムロガーを起動中: [ OK ]
カーネルロガーを起動中: [ OK ]
#以下の記録があれば起動OKです。
# tail /var/log/messages
:
Nov 24 00:36:44 rsyslog kernel: Kernel logging (proc) stopped.
Nov 24 00:36:44 rsyslog kernel: Kernel log daemon terminating.
Nov 24 00:36:45 rsyslog exiting on signal 15
Nov 24 00:36:52 rsyslog rsyslogd: [origin software="rsyslogd" swVersion="2.0.0" x-pid="16477"][x-configInfo udpReception="No" udpPort="514" tcpReception="No" tcpPort="0"] restart
Nov 24 00:36:52 rsyslog kernel: rklogd 2.0.0, log source = /proc/kmsg started.
#
動作確認します
以下のコマンドを実行します。
# logger aaa 以下の記録があればOKです。
Nov 24 00:52:18 rsyslog root: aaa