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


8

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

Answers:


8

好吧,答案很简单(并且可能不令人满意)。此旧版本不支持新语法。您至少需要v6,但要使用v7的所有功能,则是必需的。到目前为止,Red Hat尚未将这些用于RHEL。或者,您可以使用rsyslog rpm软件包:http ://www.rsyslog.com/rhelcentos-rpms/

另请注意,http : //www.rsyslog.com/doc上的文档始终是MOST CURRENT版本的文档。但是,每个版本都有其自己的文档集。显然,最好参考版本随附的文档集。大多数发行版默认都不安装它,但是通常有一个名为rsyslog-doc的软件包。


7

截至2015年9月,RHEL6中提供了rsyslog7软件包。rsyslog的当前版本为8.11,但此版本至少与当前版本更接近。

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

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

0

您可以添加rsyslog yum存储库,然后直接更新rsyslog,因此不必卸载它。

cd /etc/yum.repos.d/
wget http://rpms.adiscon.com/v8-stable/rsyslog.repo
yum update rsyslog

...

Updating:
rsyslog                                    x86_64                               8.35.0-2.el6   

回购文件供参考:

cat rsyslog.repo 
[rsyslog_v8]
name=Adiscon CentOS-$releasever - local packages for $basearch
baseurl=http://rpms.adiscon.com/v8-stable/epel-$releasever/$basearch
enabled=1
gpgcheck=0
gpgkey=http://rpms.adiscon.com/RPM-GPG-KEY-Adiscon
protect=1

学分:

http://osengineer.blogspot.com/2014/01/install-rsyslog7-to-centos6.html https://www.rsyslog.com/rhelcentos-rpms/

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.