我正在将rsyslog配置从旧服务器迁移到新服务器,并认为我会借此机会整理一下我们的配置。旧的配置使用了“旧版”模板定义,并且模板上的rsyslog文档建议用新的模板语法替换这些定义,因此这就是我尝试做的事情。
我根本无法使它正常工作,并且尝试启动rsyslog时遇到的错误没有任何意义。因此,似乎我从根本上误解了rsyslog文档,或者RHEL6中包含的rsyslog软件包有些有趣。
这是我要更新的旧模板:
$template secureTemplate,"INSERT INTO var_log_secure (received_at, source_ip, source_hostname, logged_at, severity, service, message, severity_int, syslogtag) VALUES ('%timegenerated:::date-rfc3339%', '%fromhost-ip%', '%hostname%', '%timereported:::date-rfc3339%', '%syslogseverity-text%', '%programname%', '%msg%', '%syslogseverity%', '%syslogtag%')",STDSQL
这是我阅读rsyslog文档后使用新语法尝试的同一模板:
template(name="secureTemplate" type="string" option.stdsql="on"
string="INSERT INTO var_log_secure (received_at, source_ip, source_hostname, logged_at, severity, service, message, severity_int, syslogtag) values ('%timegenerated:::date-rfc3339%', '%fromhost-ip%', '%hostname%', '%timereported:::date-rfc3339%', '%syslogseverity-text%', '%programname%', '%msg%', '%syslogseverity%', '%syslogtag%')"
)
这些是我在rsyslog启动时遇到的错误:
rsyslogd: [origin software="rsyslogd" swVersion="5.8.10" x-pid="4491" x-info="http://www.rsyslog.com"] start
rsyslogd-3000:unknown priority name "stdsql="on"" [try http://www.rsyslog.com/e/3000 ]
rsyslogd:the last error occured in /etc/rsyslog.conf, line 49:"template(name="secureTemplate" type="string" option.stdsql="on""
rsyslogd:warning: selector line without actions will be discarded
rsyslogd-3000:unknown priority name "" [try http://www.rsyslog.com/e/3000 ]
rsyslogd:the last error occured in /etc/rsyslog.conf, line 50:" string="INSERT INTO var_log_secure (received_at, source_ip, source_hostname, logged_at, severity, service, message, severity_int, syslogtag) values ('%timegenerated:::date-rfc3339%', '%fromhost-ip%', '%hostname%', '%timereported:::date-rfc3339%', '%syslogseverity-text%', '%programname%', '%msg%', '%syslogseverity%', '%syslogtag%')""
rsyslogd:warning: selector line without actions will be discarded
rsyslogd-3000:unknown priority name "" [try http://www.rsyslog.com/e/3000 ]
rsyslogd:the last error occured in /etc/rsyslog.conf, line 51:")"
rsyslogd:warning: selector line without actions will be discarded
rsyslogd-3003: Could not find template 'secureTemplate' - action disabled
[try http://www.rsyslog.com/e/3003 ]
rsyslogd:the last error occured in /etc/rsyslog.conf, line 55:"then :ompgsql:127.0.0.1,rsyslog,rsyslog,+Without-Goodbye-22+;secureTemplate"
rsyslogd:warning: selector line without actions will be discarded
rsyslogd-2124:CONFIG ERROR: could not interpret master config file '/etc/rsyslog.conf'. [try http://www.rsyslog.com/e/2124 ]
rsyslogd:EMERGENCY CONFIGURATION ACTIVATED - fix rsyslog config file!