在RHEL6上使用新的rsyslog模板语法时出错

我正在将我们的rsyslogconfiguration从旧服务器迁移到新服务器,并且认为我会利用这个机会来整理我们的configuration。 旧的configuration使用“传统”模板定义,模板上的rsyslog文档build议用新的模板语法replace这些定义,所以这就是我所要做的。

我根本无法得到它的工作,而我试图启动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! 

那么,答案很简单(可能不令人满意)。 这个旧版本不支持新的语法。 您至less需要v6,但要使用v7的所有function是必需的。 到目前为止,Red Hat并没有为RHEL提供这些服务。 作为替代,您可以使用rsyslog rpm软件包: http ://www.rsyslog.com/rhelcentos-rpms/

另请注意, http ://www.rsyslog.com/doc上的文档始终适用于最新版本。 但是,每个版本都有自己的文档集。 引用随版本提供的文档集显然是更好的select。 大多数发行版默认不安装,但通常有一个命名为rsyslog-doc的命令行。

截至2015年9月,RHEL6中提供了rsyslog7软件包。 rsyslog的当前版本是8.11,但是这个至less接近当前版本。

要安装,您首先必须删除您的rsyslog软件包:

 # rpm -e --nodeps rsyslog # yum -y install rsyslog7