在另外一种环境中,让我们假定你已经在机器上安装了一个名为“foobar”的应用程序,它会在/var/log下生成foobar.log日志文件。现在,你想要将它的日志定向到rsyslog服务器,这可以通过像下面这样在rsyslog配置文

件中加载imfile模块来实现。

首先,加载imfile模块,这只需做一次。

module(load="imfile" PollingInterval="5")
然后,指定日志文件的路径以便imfile模块可以检测到: mysql rsyslog配置:
uat-db01:/data01/mysql# cat /etc/rsyslog.conf | grep -v "^#" | grep -v "^$"
$ModLoad imuxsock # provides support for local system logging (e.g. via logger command)
$ModLoad imklog # provides kernel logging support (previously done by rklogd)
module(load="imfile" PollingInterval="5")
$ModLoad imtcp
$InputTCPServerRun 514
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
$IncludeConfig /etc/rsyslog.d/*.conf
*.info;mail.none;authpriv.none;cron.none;local5.none /var/log/messages
authpriv.* /var/log/secure
mail.* -/var/log/maillog
cron.* /var/log/cron
uucp,news.crit /var/log/spooler
local7.* /var/log/boot.log
input(type="imfile"
File="/data01/mysql/uat-db01-slow.log"
Tag="uat-mysql01"
Severity="info"
Facility="local5")
local5.* @@115.236.xx.xx:514 需要升级rsyslog 版本:
rhdpt01:/root# tail -100 /var/log/messages
Aug 7 03:38:01 jrhdpt01 rsyslogd: [origin software="rsyslogd" swVersion="5.8.10" x-pid="951" x-info="http://www.rsyslog.com"] rsyslogd was HUPed
Aug 12 13:43:02 jrhdpt01 kernel: Kernel logging (proc) stopped.
Aug 12 13:43:02 jrhdpt01 rsyslogd: [origin software="rsyslogd" swVersion="5.8.10" x-pid="951" x-info="http://www.rsyslog.com"] exiting on signal 15.
Aug 12 13:43:03 jrhdpt01 kernel: imklog 5.8.10, log source = /proc/kmsg started.
Aug 12 13:43:03 jrhdpt01 rsyslogd: [origin software="rsyslogd" swVersion="5.8.10" x-pid="24817" x-info="http://www.rsyslog.com"] start
Aug 12 13:43:03 jrhdpt01 rsyslogd-3000: unknown priority name "" [try http://www.rsyslog.com/e/3000 ]
Aug 12 13:43:03 jrhdpt01 rsyslogd: the last error occured in /etc/rsyslog.conf, line 11:"module(load="imfile" PollingInterval="5")"
Aug 12 13:43:03 jrhdpt01 rsyslogd: warning: selector line without actions will be discarded
Aug 12 13:43:03 jrhdpt01 rsyslogd-3000: unknown priority name "" [try http://www.rsyslog.com/e/3000 ]
Aug 12 13:43:03 jrhdpt01 rsyslogd: the last error occured in /etc/rsyslog.conf, line 84:"input(type="imfile""
Aug 12 13:43:03 jrhdpt01 rsyslogd: warning: selector line without actions will be discarded
Aug 12 13:43:03 jrhdpt01 rsyslogd-3000: unknown priority name "log"" [try http://www.rsyslog.com/e/3000 ]
Aug 12 13:43:03 jrhdpt01 rsyslogd: the last error occured in /etc/rsyslog.conf, line 85:"File="/data01/mysql/jrhdpt01-slow.log""
Aug 12 13:43:03 jrhdpt01 rsyslogd: warning: selector line without actions will be discarded
Aug 12 13:43:03 jrhdpt01 rsyslogd-3000: unknown priority name "" [try http://www.rsyslog.com/e/3000 ]
Aug 12 13:43:03 jrhdpt01 rsyslogd: the last error occured in /etc/rsyslog.conf, line 86:"Tag="zjzc-mysql01""
Aug 12 13:43:03 jrhdpt01 rsyslogd: warning: selector line without actions will be discarded
Aug 12 13:43:03 jrhdpt01 rsyslogd-3000: unknown priority name "" [try http://www.rsyslog.com/e/3000 ]
Aug 12 13:43:03 jrhdpt01 rsyslogd: the last error occured in /etc/rsyslog.conf, line 87:"Severity="info""
Aug 12 13:43:03 jrhdpt01 rsyslogd: warning: selector line without actions will be discarded
Aug 12 13:43:03 jrhdpt01 rsyslogd-3000: unknown priority name "" [try http://www.rsyslog.com/e/3000 ]
Aug 12 13:43:03 jrhdpt01 rsyslogd: the last error occured in /etc/rsyslog.conf, line 88:"Facility="local5")"
Aug 12 13:43:03 jrhdpt01 rsyslogd: warning: selector line without actions will be discarded
Aug 12 13:43:03 jrhdpt01 rsyslogd-2124: CONFIG ERROR: could not interpret master config file '/etc/rsyslog.conf'. [try http://www.rsyslog.com/e/2124 ] 下载下列软件
json-c-0.12-20140410.tar.gz---------------------https://github.com/json-c/json-c/archive/json-c-0.12-20140410.tar.gz
libestr-0.1.10.tar.gz-------------------http://libestr.adiscon.com/files/download/libestr-0.1.10.tar.gz
liblogging-1.0.5.tar.gz ----------------http://download.rsyslog.com/liblogging/liblogging-1.0.5.tar.gz
librdkafka-0.8.6.tar.gz -----------------------https://github.com/edenhill/librdkafka/archive/0.8.6.tar.gz
libuuid-1.0.3.tar.gz --------------------http://jaist.dl.sourceforge.net/project/libuuid/libuuid-1.0.3.tar.gz
zlib-1.2.8.tar.gz-------------------http://zlib.net/zlib-1.2.8.tar.gz
curl-7.44.0.tar.gz--------------http://curl.haxx.se/download/curl-7.44.0.tar.gz
rsyslog-8.15.0.tar.gz-------------------http://www.rsyslog.com/download/files/download/rsyslog/rsyslog-8.15.0.tar.gz 一:安装rsyslog
(1) json-c 安装
tar -xzvf json-c-0.12-20140410.tar.gz
cd json-c-0.12-20140410
./configure CC="gcc -m64" --prefix=/usr --libdir=/usr/lib64 && make && make install
(2) libestr安装
tar -xzvf libestr-0.1.10.tar.gz
cd libestr-0.1.10
./configure CC="gcc -m64" --prefix=/usr --libdir=/usr/lib64
&& make && make install
(3) libuuid 安装
tar -xzvflibuuid-1.0.3.tar.gz
cdlibuuid-1.0.3
./configure CC="gcc -m64" --prefix=/usr --libdir=/usr/lib64 && make && make install (4)zlib
安装
tar
-xzvf zlib-1.2.8.tar.gz
cdzlib-1.2.8
./configure --prefix=/usr --libdir=/usr/lib64 && make && make install (5)liblogging
安装
tar
-xzvf liblogging-1.0.5.tar.gz
cdliblogging-1.0.5
./configure CC="gcc -m64" --prefix=/usr --libdir=/usr/lib64 --disable-journal && make && make install (6)librdkafka ###可以不安装
安装
tar
-xzvf librdkafka-0.8.6.tar.gz
cd librdkafka-0.8.6
./configure --prefix=/usr --libdir=/usr/lib64 && make && make install (7) 安装rsyslogd checking for library containing sched_get_priority_max... none required
checking for sched_get_priority_max... yes
checking for LIBUUID... yes
checking for CURL... no
configure: error: Package requirements (libcurl) were not met: No package 'libcurl' found Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix. 原因没有安装curl:
uat-db01:/root/curl-7.44.0# ./configure CC="gcc -m64" --prefix=/usr --libdir=/usr/lib64 && make && make install uat-db01:/root/rsyslog-8.15.0# cat make.sh
./configure CC="gcc -m64" PKG_CONFIG_PATH=/usr/lib64/pkgconfig LIBESTR_LIBS=/usr/lib64/libestr.a JSON_C_LIBS=/usr/lib64/libjson-c.a ZLIB_LIBS=/usr/lib64/libz.a LIBUUID_LIBS=/usr/lib64/libuuid.a CURL_LIBS=/usr/lib64/libcurl.a LIBLOGGING_STDLOG_LIBS=/usr/lib64/liblogging-stdlog.a LIBRDKAFKA_CFLAGS=/usr/include LIBRDKAFKA_LIBS=/usr/lib64/librdkafka.a --prefix=/usr --libdir=/usr/lib64 -- enable-static --enable-debug --enable-elasticsearch --enable-elasticsearch-tests --enable-liblogging-stdlog --enable-imfile --enable-imptcp --enable-omstdout --enable-omruleset --enable-omuxsock --disable-libgcrypt make && make install uat-db01:/root/rsyslog-8.15.0/tools# cp rsyslogd /sbin/ uat-db01:/root/rsyslog-8.15.0/tools# service rsyslog start
Starting system logger: usage: rsyslogd [options]
use "man rsyslogd" for details. To run rsyslog interactively, use "rsyslogd -n"to run it in debug mode use "rsyslogd -dn"
For further information see http://www.rsyslog.com/doc
[FAILED] uat-db01:/root/rsyslog-8.15.0/tools# rsyslogd -f /etc/rsyslog.conf
uat-db01:/root/rsyslog-8.15.0/tools# ps -ef | grep rsyslog
root 9244 1 12 14:32 ? 00:00:00 rsyslogd -f /etc/rsyslog.conf
root 9259 26662 0 14:32 pts/0 00:00:00 grep rsyslog
uat-db01:/root/rsyslog-8.15.0/tools# 客户端rsyslog 配置:
uat-db01:/data01/mysql# cat /etc/rsyslog.conf | grep -v "^#" | grep -v "^$"
$ModLoad imuxsock # provides support for local system logging (e.g. via logger command)
$ModLoad imklog # provides kernel logging support (previously done by rklogd)
module(load="imfile" PollingInterval="5")
$ModLoad imtcp
$InputTCPServerRun 514
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
$IncludeConfig /etc/rsyslog.d/*.conf
*.info;mail.none;authpriv.none;cron.none;local5.none /var/log/messages
authpriv.* /var/log/secure
mail.* -/var/log/maillog
cron.* /var/log/cron
uucp,news.crit /var/log/spooler
local7.* /var/log/boot.log
input(type="imfile"
File="/data01/mysql/uat-db01-slow.log"
Tag="uat-mysql01"
Severity="info"
Facility="local5")
local5.* @@115.236.xx.xx:514 服务器rsyslog 配置: $EscapeControlCharactersOnReceive off #关闭rsyslog默认转译ASCII<32的所有怪异字符,包括换行符等
$template nginx-zjzc01,"/rsyslog/data/nginx/zjzc/nginx_access01_log.%$year%-%$month%-%$day%" #定义TC:日志存放路径
$template nginx-zjzc02,"/rsyslog/data/nginx/zjzc/nginx_access02_log.%$year%-%$month%-%$day%" #定义TCBeta:日志存放路径
$template nginx-uat01,"/rsyslog/data/nginx/uat/nginx_access01_log.%$year%-%$month%-%$day%" #定义TCBeta:日志存放路径
$template tocFormat,"'%syslogtag%','%FROMHOST-IP%','%msg%'\n" #定义toc日志format
$template uat-zjzc01,"/rsyslog/data/mysql/uat/mysql01_slow_log.%$year%-%$month%-%$day%" #定义TCBeta:日志存放路径 :rawmsg,contains,"nginx-zjzc01" -?nginx-zjzc01;tocFormat #接受TC:日志,并应用tocFormat格式
:rawmsg,contains,"nginx-zjzc02" -?nginx-zjzc02;tocFormat #接受TCBeta:日志,并应用tocFormat格式
:rawmsg,contains,"uat-nginx" -?nginx-uat01;tocFormat #接受TCBeta:日志,并应用tocFormat格式 :rawmsg,contains,"uat-mysql01" -?uat-zjzc01;tocFormat

rsyslog 传输mysql 日志的更多相关文章

  1. Centos7.6部署rsyslog+loganalyzer+mysql日志管理服务器

    参考来自: the_script :https://yq.aliyun.com/articles/675198 名山.深处:https://www.cnblogs.com/skychenjiajun/ ...

  2. CentOS 6.7下利用Rsyslog+LogAnalyzer+MySQL部署日志服务器

    一.简介 LogAnalyzer 是一款syslog日志和其他网络事件数据的Web前端.它提供了对日志的简单浏览.搜索.基本分析和一些图表报告的功能.数据可以从数据库或一般的syslog文本文件中获取 ...

  3. CentOS 6.5下利用Rsyslog+LogAnalyzer+MySQL部署日志服务器

    一.简介 LogAnalyzer 是一款syslog日志和其他网络事件数据的Web前端.它提供了对日志的简单浏览.搜索.基本分析和一些图表报告的功能.数据可以从数据库或一般的syslog文本文件中获取 ...

  4. CentOS7.3下部署Rsyslog+LogAnalyzer+MySQL中央日志服务器

    一.简介 1.LogAnalyzer 是一款syslog日志和其他网络事件数据的Web前端.它提供了对日志的简单浏览.搜索.基本分析和一些图表报告的功能.数据可以从数据库或一般的syslog文本文件中 ...

  5. 如何提升mysql replication的性能&amp;多线程传输二进制日志

    1,最好使用内网或者专线链路传输binlog数据 (千兆网卡.还不够的话,bounding 技术,扩展带宽) 在my.cnf中强制使用内网ip传输数据bind-address=ip2,将二进制保存在独 ...

  6. rsyslog同步history日志(转载)

    前言 由于公司业务是由公司内部开人员及外包团队共同开发,所以需要使用rsyslog对history日志做收集.审计.虽然搭建及配置非常简单,但是在日常运维工作中很实用,所以记录下,方便日后快速搭建.如 ...

  7. RHEL7通过Rsyslog搭建集中日志服务器

    说明:这里是Linux服务综合搭建文章的一部分,本文可以作为单独搭建rsyslog日志服务器的参考. 注意:这里所有的标题都是根据主要的文章(Linux基础服务搭建综合)的顺序来做的. 如果需要查看相 ...

  8. rsyslog+loganalyzer远程日志系统搭建教程(CentOS6.8)

    一.说明 本文主要是对“CentOS 6.7搭建Rsyslog日志服务器”进行整理,同时在本地进行环境搭建,验证在CentOS6.8上的正确性. 二.安装配置rsyslog 1.清空iptables关 ...

  9. rsyslog与journal日志架构

    系统日志架构概述 在centos7系统中有两个日志服务,分别是传统的rsyslog和新添加的systemd-journal systemd-journal是一个改进型的日志管理服务,可以收集来自内核. ...

随机推荐

  1. jquery easyUI DataGrid 初始化的时候就显示可排序的字段

    在使用easy ui的列表中,想要标记可以排序的字段,使用户一看页面就知道哪些是可以点击排序的. 给可排序的字段添加 图标在列名后面.不可排序的字段还和原来一样. 步骤: 你需要一个图标 , 你需要给 ...

  2. jquery 实现横向滑动自动切换源码(同时显示多张图片)

    html代码: <!doctype html> <html lang="en"> <head> <meta charset="U ...

  3. 一分钟了解PHP

    PHP5编辑 PHP5在长时间的开发及多个预发布版本后,2004年7月13日,PHP5.0发布.该版本以Zend引擎Ⅱ为引擎,并且加入了新功能如PHP Data Objects(PDO).PHP5.0 ...

  4. CloudEra Email Search

    http://blog.cloudera.com/blog/2013/09/email-indexing-using-cloudera-search/ http://blog.cloudera.com ...

  5. Firebug入门指南(转)

    据说,对于网页开发人员来说,Firebug是Firefox浏览器中最好的插件之一. 我最近就在学习怎么使用Firebug,网上找到一篇针对初学者的教程,感觉比较有用,就翻译了出来. 作者:Estell ...

  6. IOS研究院之打开照相机与本地相册选择图片

    如下图所示 在本地相册中选择一张图片后,我们将他拷贝至沙盒当中,在客户端中将它的缩略图放在按钮旁边,这个结构其实和新浪微薄中选择图片后的效果一样.最终点击发送将按钮将图片2进制图片上传服务器. 下面我 ...

  7. oracle 和informix 的基础区别

    1:查看表空间 select b.file_name 物理文件名, b.tablespace_name 表空间, b.bytes/1024/1024 大小M, (b.bytes-sum(nvl(a.b ...

  8. MATLAB介绍

    MATLAB MATLAB[1]  是美国MathWorks公司出品的商业数学软件,用于算法开发.数据可视化.数据分析以及数值计算的高级技术计算语言和交互式环境,主要包括MATLAB和Simulink ...

  9. ByteBuffer用法总结

    转自:http://blog.csdn.net/mars5337/article/details/6576417 在NIO中,数据的读写操作始终是与缓冲区相关联的.读取时信道(SocketChanne ...

  10. ubuntu下perl SVG老是make失败

    解决方法是用libgd-svg-perl软件包代替.