RSYSLOG is the rocket-fast system for log processing.

About

由于环境基于CentOS 6.7 x64,rsyslog本身就是OS的组件,由于本文使用rsyslog作为统一日志采集器,需要与kafka进行数据交付,而原始支持kafka组件是在v8.7.0以后版本才支持,而系统自带的rsyslog是版本是v5的,因此需要对rsyslog版本进行升级。

有网的方法比较简单,通过yum命令即可,官网参考官网 http://www.rsyslog.com/rhelcentos-rpms/ 即可安装指定版本。

安装说明

由于鉴于内网环境无Internet无法使用yum进行安装,因此选择离线rpm方式升级rsyslog(rpm包下载地址:http://rpms.adiscon.com/ )。

此处有坑:按习惯,一般使用官网提供的最新的稳定版/v8-stable/epel-7,然而由于CentOS 6.7 glibc版本为2.12而epel-7依赖的libgt-0.3.11-1.el7.x86_64、libfastjson-0.99.2-1.el7.x86_64、libestr-0.1.10-1.el7.x86_64几个组件需要 libc.so.6: version `GLIBC_2.14,CentOS 6.7升级后会提示bash版本有问题,因此此处选用/v8-stable/epel-6版本(ps:此坑是个人问题,centos6.x本来就应该使用epel-6,因此此坑可忽略)

需要下载的rpm

可在http://rpms.adiscon.com/v8-stable/epel-6/x86_64/RPMS/ 获取

  • json-c-0.11-4.el6.x86_64.rpm
  • libfastjson-0.99.2-1.el6.x86_64.rpm
  • libgt-0.3.11-1.el6.x86_64.rpm
  • libestr-0.1.10-1.el6.x86_64.rpm
  • liblogging-1.0.5-1.el6.x86_64.rpm
  • librdkafka1-0.8.5-0.x86_64.rpm
  • rsyslog-kafka-8.19.0-1.el6.x86_64.rpm
  • rsyslog-8.19.0-1.el6.x86_64.rpm

rpm安装

执行安装前 先给没个文件加上运行属性 chmod +x

  1. rpm -ivh json-c-0.11-4.el6.x86_64.rpm
  2. rpm -ivh libfastjson-0.99.2-1.el6.x86_64.rpm
  3. rpm -ivh libgt-0.3.11-1.el6.x86_64.rpm
  4. rpm -ivh libestr-0.1.10-1.el6.x86_64.rpm
  5. rpm -ivh liblogging-1.0.5-1.el6.x86_64.rpm
  6. rpm -ivh librdkafka1-0.8.5-0.x86_64.rpm
  7. #这边使用 -U 参数是为了直接升级本地rsyslog
  8. rpm -Uvh rsyslog-8.19.0-1.el6.x86_64.rpm
  9. #rsyslog-kafka组件安装依赖 rsyslog-8.19.0及librdkafka,该命令最后执行
  10. rpm -ivh rsyslog-kafka-8.19.0-1.el6.x86_64.rpm

验证安装

  • 安装完后执行 rsyslogd -v , 验证rsyslog是否升级成功。
  1. # rsyslogd -v
  2. rsyslogd 8.19.0, compiled with:
  3. PLATFORM: x86_64-redhat-linux-gnu
  4. PLATFORM (lsb_release -d):
  5. FEATURE_REGEXP: Yes
  6. GSSAPI Kerberos 5 support: No
  7. FEATURE_DEBUG (debug build, slow code): No
  8. 32bit Atomic operations supported: Yes
  9. 64bit Atomic operations supported: Yes
  10. memory allocator: system default
  11. Runtime Instrumentation (slow code): No
  12. uuid support: Yes
  13. Number of Bits in RainerScript integers: 64
  14. See http://www.rsyslog.com for more information.
  • 查看/lib64/rsyslog/(32位系统为 /lib/rsyslog) 中 是否存在 omkafka.so,验证rsyslog-kafka是否安装成功。

配置说明

rsyslog官网是个大坑,能路过尽量路过。

接下来说明下配置,首先声明下本文使用rsyslog的目的是作为应用的log collector,应用使用log4x(log4net:log4net.Appender.RemoteSyslogAppender, log4j:org.apache.log4j.net.SyslogAppender),通过UDP协议将日志传输到rsyslog。

rsyslo的默认的配置文件 /etc/rsyslog.config

  1. # rsyslog configuration file
  2. # note that most of this config file uses old-style format,
  3. # because it is well-known AND quite suitable for simple cases
  4. # like we have with the default config. For more advanced
  5. # things, RainerScript configuration is suggested.
  6. # For more information see /usr/share/doc/rsyslog-*/rsyslog_conf.html
  7. # If you experience problems, see http://www.rsyslog.com/doc/troubleshoot.html
  8. #### MODULES ####
  9. module(load="imuxsock") # provides support for local system logging (e.g. via logger command)
  10. module(load="imklog") # provides kernel logging support (previously done by rklogd)
  11. #module(load"immark") # provides --MARK-- message capability
  12. # Provides UDP syslog reception
  13. # for parameters see http://www.rsyslog.com/doc/imudp.html
  14. #module(load="imudp") # needs to be done just once
  15. #input(type="imudp" port="514")
  16. # Provides TCP syslog reception
  17. # for parameters see http://www.rsyslog.com/doc/imtcp.html
  18. #module(load="imtcp") # needs to be done just once
  19. #input(type="imtcp" port="514")
  20. #### GLOBAL DIRECTIVES ####
  21. # Use default timestamp format
  22. $ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
  23. # File syncing capability is disabled by default. This feature is usually not required,
  24. # not useful and an extreme performance hit
  25. #$ActionFileEnableSync on
  26. # Include all config files in /etc/rsyslog.d/
  27. $IncludeConfig /etc/rsyslog.d/*.conf
  28. #### RULES ####
  29. # Log all kernel messages to the console.
  30. # Logging much else clutters up the screen.
  31. #kern.* /dev/console
  32. # Log anything (except mail) of level info or higher.
  33. # Don't log private authentication messages!
  34. *.info;mail.none;authpriv.none;cron.none /var/log/messages
  35. # The authpriv file has restricted access.
  36. authpriv.* /var/log/secure
  37. # Log all the mail messages in one place.
  38. mail.* /var/log/maillog
  39. # Log cron stuff
  40. cron.* /var/log/cron
  41. # Everybody gets emergency messages
  42. *.emerg :omusrmsg:*
  43. # Save news errors of level crit and higher in a special file.
  44. uucp,news.crit /var/log/spooler
  45. # Save boot messages also to boot.log
  46. local7.* /var/log/boot.log
  47. # ### begin forwarding rule ###
  48. # The statement between the begin ... end define a SINGLE forwarding
  49. # rule. They belong together, do NOT split them. If you create multiple
  50. # forwarding rules, duplicate the whole block!
  51. # Remote Logging (we use TCP for reliable delivery)
  52. #
  53. # An on-disk queue is created for this action. If the remote host is
  54. # down, messages are spooled to disk and sent when it is up again.
  55. #$WorkDirectory /var/lib/rsyslog # where to place spool files
  56. #$ActionQueueFileName fwdRule1 # unique name prefix for spool files
  57. #$ActionQueueMaxDiskSpace 1g # 1gb space limit (use as much as possible)
  58. #$ActionQueueSaveOnShutdown on # save messages to disk on shutdown
  59. #$ActionQueueType LinkedList # run asynchronously
  60. #$ActionResumeRetryCount -1 # infinite retries if host is down
  61. # remote host is: name/ip:port, e.g. 192.168.0.1:514, port optional
  62. #*.* @@remote-host:514
  63. # ### end of the forwarding rule ###

接下来说明配置修改:

配置 input

  • 开启接收UDP消息
  1. module(load="imudp") # 加载imudp模块
  2. input(type="imudp" port="514") # 配置UDP监听的端口号

配置 output

  • 开启数据转发kafka
  1. module(load="omkafka") # 配置加载omkafka模块
  2. # 转发到kafka消息格式
  3. template(name="rsyslogToKafka" type="list" option.json="on"){
  4. constant(value="{")
  5. #constant(value="\"timestamp\":\"") property(name="timereported" dateFormat="rfc3339")
  6. constant(value="\"message\":\"") property(name="msg" format="json")
  7. constant(value="\",\"host\":\"") property(name="hostname")
  8. constant(value="\",\"severity\":\"") property(name="syslogseverity")
  9. constant(value="\",\"severity-text\":\"") property(name="syslogseverity-text")
  10. constant(value="\",\"facility\":\"") property(name="syslogfacility-text")
  11. constant(value="\",\"syslogtag\":\"") property(name="syslogtag")
  12. constant(value="\",\"type\":\"application\"")
  13. constant(value=",\"recieve-from\":\"") property(name="fromhost-ip")
  14. constant(value="\",\"recieve-at\":\"") property(name="timegenerated" dateFormat="rfc3339")
  15. constant(value="\",\"report-at\":\"") property(name="timereported" dateFormat="rfc3339")
  16. constant(value="\"}")
  17. }
  18. # 配置kafka相关信息及模板
  19. action( type="omkafka"
  20. topic="test"
  21. broker="11.4.74.26:9092"
  22. template="rsyslogToKafka"
  23. )
  • 另外一个坑:关于EscapeControlCharacters转换的问题

rsyslog接收的时候会对一些回车换行等敏感字符进行转换 比如 \r\n 会被转换为#015#012,而通过log4x提交的日志如果包含Exception在kibana显示就不能正常的换行,因此关闭了rsyslog中敏感字的转换

  1. $EscapeControlCharactersOnReceive off

【RSYSLOG】rsyslog作为日志采集器安装配置说明的更多相关文章

  1. Filebeat 日志收集器 安装和配置

    Filebeat的配置文件是/etc/filebeat/filebeat.yml,遵循YAML语法.具体可以配置如下几个项目: Filebeat Output Shipper Logging(可选) ...

  2. Filebeat 5.x 日志收集器 安装和配置

    Filebeat 5.x版本 风来了.fox 1.下载和安装 https://www.elastic.co/downloads/beats/filebeat 这里选择 LINUX 64-BIT 即方式 ...

  3. 日志采集器windows客户端的配置释义

    <Extension json> Module xm_json </Extension> <Extension charconv> Module xm_charco ...

  4. 自建Kubernetes logtail日志采集客户端安装方式

    自建Kubernetes安装方式 前提条件 Kubernetes集群版本1.8及以上. 已经安装Helm命令,版本2.6.4及以上. 安装步骤 在日志服务控制台创建一个Project,Project名 ...

  5. ElasticSearch实战系列九: ELK日志系统介绍和安装

    前言 本文主要介绍的是ELK日志系统入门和使用教程. ELK介绍 ELK是三个开源软件的缩写,分别表示:Elasticsearch , Logstash, Kibana , 它们都是开源软件.新增了一 ...

  6. Filebeat轻量级日志采集工具

    Beats 平台集合了多种单一用途数据采集器.这些采集器安装后可用作轻量型代理,从成百上千或成千上万台机器向 Logstash 或 Elasticsearch 发送数据. 一.架构图 此次试验基于前几 ...

  7. Filebeat+Kafka+Logstash+ElasticSearch+Kibana 日志采集方案

    前言 Elastic Stack 提供 Beats 和 Logstash 套件来采集任何来源.任何格式的数据.其实Beats 和 Logstash的功能差不多,都能够与 Elasticsearch 产 ...

  8. SpringCloud微服务实战——搭建企业级开发框架(三十八):搭建ELK日志采集与分析系统

      一套好的日志分析系统可以详细记录系统的运行情况,方便我们定位分析系统性能瓶颈.查找定位系统问题.上一篇说明了日志的多种业务场景以及日志记录的实现方式,那么日志记录下来,相关人员就需要对日志数据进行 ...

  9. 一篇文章教你搞懂日志采集利器 Filebeat

    关注「开源Linux」,选择"设为星标" 回复「学习」,有我为您特别筛选的学习资料~ 本文使用的Filebeat是7.7.0的版本,文章将从如下几个方面说明: Filebeat是什 ...

随机推荐

  1. JavaScript的函数重载

    java语言中函数的重载和重写可谓是很重要的概念,所以在写js的时候时不时的会想到这种用法,重写先不说,这里只说重载.. <script language="JavaScript&qu ...

  2. Bash Shell read file line by line and substring

    #read one file line by line for line in $(cat test1.txt); do echo $line ; done; #while read split li ...

  3. MSBI BigData demo—sqoop import

    --sp_readerrorlog 读取错误的信息记录 exec sys.sp_readerrorlog 0, 1, 'listening'查看端口号 首先hadoop环境要配置完毕,并检验可以正常启 ...

  4. solr性能调优

    Schema Design Considerations indexed fields indexed fields 的数量将会影响以下的一些性能: 索引时的时候的内存使用量 索引段的合并时间 优化时 ...

  5. ZOJ 3820 Building Fire Stations 求中点+树的直径+BFS

    题意:给一棵树,要求找出两个点,使得所有点到这两个点中距离与自己较近的一个点的距离的最大值(所有点的结果取最大的值,即最远距离)最小. 意思应该都能明白. 解法:考虑将这棵树摆直如下: 那么我们可以把 ...

  6. 配置 AEM CQ6 (author + publish + apache dispatcher + ubuntu )

      AEM CQ系列是Adobe下的企业内容管理系统,现在已知的一些企业比如 Deloitte,Ford Racing,这里就不多做基本的介绍了,明白的看! 今天在Docker配置一下author i ...

  7. QTP基础学习(一)安装目录介绍

    上一篇介绍了QTP 10 安装,安装完成后就可以看到文件的目录了,这里主要介绍以下几个目录及作用. 简单介绍部分目录 1.addins:插件包 2.bin目录:可执行程序,这里存储了很多配置文件.运行 ...

  8. 博友的 编写高质量代码 改善java程序的151个建议

    编写高质量代码 改善java程序的151个建议 http://www.cnblogs.com/selene/category/876189.html

  9. ArcGis 获取地理、平面坐标系

                                         ESRI.ArcGIS.Geometry.ISpatialReference spatialReference = spati ...

  10. 分布式监控系统Zabbix-3.0.3-完整安装记录(6)-微信报警部署

    Zabbix可以通过多种方式把告警信息发送到指定人,常用的有邮件,短信报警方式. 现在由于微信使用的广泛度,越来越多的企业开始使用zabbix结合微信作为主要的告警方式,这样可以及时有效的把告警信息推 ...