我正在将我们的 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!