CentOS 7.x 编译 Rsyslog 8.19

日期 2019-08-05 rsyslog 作者 aoe 共0评论

最近查日志的时候发现偶尔某个时间点的日志会丢失,遂登陆日志中心服务器查看日志,发现

Aug  1 21:06:39 it-logelk systemd[1]: rsyslog.service: main process exited, code=killed, status=6/ABRT
Aug  1 21:06:39 it-logelk systemd[1]: Unit rsyslog.service entered failed state.
Aug  1 21:06:39 it-logelk systemd[1]: rsyslog.service failed.
Aug  1 21:06:39 it-logelk systemd[1]: rsyslog.service holdoff time over, scheduling restart.
Aug  1 21:06:39 it-logelk systemd[1]: Stopped System Logging Service.
Aug  1 21:06:39 it-logelk systemd[1]: Starting System Logging Service...
Aug  1 21:06:39 it-logelk rsyslogd[21922]: imuxsock: Acquired UNIX socket '/run/systemd/journal/syslog' (fd 3) from systemd.  [v8.1903.0]
Aug  1 21:06:39 it-logelk rsyslogd[21922]: [origin software="rsyslogd" swVersion="8.1903.0" x-pid="21922" x-info="https://www.rsyslog.com"] start
Aug  1 21:06:39 it-logelk systemd[1]: Started System Logging Service.

于是面向google搜索,发现gayhub上有类似的issue,作者表示貌似是8.1901.0以后才开始的,会有一定几率crash,遂直接考虑升级到最新版8.1907.0(截止发稿日)
https://github.com/rsyslog/rsyslog/issues/3537

安装编译所需要的环境:

yum install libtool libestr libestr-devel libuuid libuuid-devel  libgcrypt libgcrypt-devel byacc pkgconfig zlib-devel  autoconf automake

因为我需要rsyslog写入redis作为队列,所以需要编译redis的支持:

  git clone https://github.com/redis/hiredis.git 
  cd hiredis
  make && make install
  ln -s  /usr/local/lib/libhiredis.so.0.13  /lib64/libhiredis.so.0.13

编译需要libfastjson版本大于等于0.99.8,但是yum安装的版本较低,所以编译安装:

wget http://download.rsyslog.com/libfastjson/libfastjson-0.99.8.tar.gz
tar xzvf libfastjson-0.99.8.tar.gz
cd libfastjson-0.99.8/
./configure --prefix=/usr CC="gcc -m64" PKG_CONFIG_PATH="/usr/lib64/pkgconfig" --libdir=/usr/lib64
make
make install

对日志格式化解析成json的一个库liblognorm:

  wget http://www.liblognorm.com/files/download/liblognorm-2.0.4.tar.gz
  tar xzf liblognorm-2.0.4.tar.gz
  cd liblognorm-2.0.4 
  ./configure --prefix=/usr CC="gcc -m64" PKG_CONFIG_PATH="/usr/lib64/pkgconfig" --libdir=/usr/lib64
  make && make install

以下是编译特定模块需要安装的依赖,有需要的自行安装

  yum install librdkafka-devel    #kafka       omkafka & imkafka
  yum install libmaxminddb-devel  #geoip       mmdblookup  

至此,编译的所需要的包包已经就绪,下载源码编译,注意编译选项尽量只选择自己需要的module:

wget http://www.rsyslog.com/files/download/rsyslog/rsyslog-8.1907.0.tar.gz
tar xzvf rsyslog-8.1907.0.tar.gz
cd rsyslog-8.1907.0
./configure --prefix=/ --enable-imfile --enable-mmjsonparse --enable-omhiredis --enable-mmdblookup  --disable-liblogging-stdlog PKG_CONFIG_PATH=/usr/lib64/pkgconfig --libdir=/lib64
make && make install
systemctl restart rsyslog

至此,安装完毕.


人生在世,错别字在所难免,无需纠正。