Chinaunix

标题: linux服务器日志实时数据同步的两个情况,rsyslog+mysql谁帮我分析下优劣 [打印本页]

作者: smoker87    时间: 2017-08-03 10:38
标题: linux服务器日志实时数据同步的两个情况,rsyslog+mysql谁帮我分析下优劣
centos linux

使用rsyslog系统日志服务+mysql使用


两台机器A,B。目的将A的系统日志发送给B,需要将日志内容存储到mysql

这些日志主要是访问和流经A机器上通信数据包,数据信息的日志。流量比较大。

两种同步数据方法

一:A机器有rsyslog服务,设置好远程传输日志的,使用514端口传送到B机器,B机器的sysylog接收,并且安装有syslog-mysql功能,转储到mysql。
二:A机器有rsyslog服务,安装有syslog-mysql功能,转储到mysql,之后是A机器的mysql与B机器mysql数据同步。


一个是rsyslog之间的数据同步,之后存储到mysql
一个是rsyslog存储到mysql,mysql之间的数据同步



优劣性是哪个好,
mysql之间数据备份占A机器系统资源大
还是rsyslog服务之间数据传送占A机器资源大?
以及他们之间谁数据传输快,谁数据传输慢?

望请各位大牛指导指导我!




作者: q1208c    时间: 2017-08-03 16:13
回复 1# smoker87

syslog 同步好些.

UDP的协议会占用很少的资源.
当然, 风险也不是没有, 在很特别的情况会, 会丢数据.

其实, 更好的办法是 A 上的 syslog 写 B 上的数据库.

这样, 你就有了两份数据, 一份在 syslog, 一份在mysql, 而且, 还是分布在两台机器上.


作者: smoker87    时间: 2017-08-04 16:02
本帖最后由 smoker87 于 2017-08-04 16:08 编辑

回复 2# q1208c

嗯,我也想到了说A 上的 syslog 写 B 上的数据库.

但有个问题A为44 B为56
A机器44:/etc/rsyslog.conf
$Modload ommysql
*.*  :ommysql:10.8.0.56,Syslog,loguser,logpass      #56号机,Syslog数据库,用户名是loguser密码是logpass。这个:ommysql的:o会被转义成笑脸,汗,我用中文的:号表示
在B机器56上面,确实是mysql看到了数据

但是,加了个端口号3306,这个是mysql默认的那个端口号3306
$Modload ommysql
*.*  :ommysql:10.8.0.56:3306,Syslog,loguser,logpass


却不能接收到数据,这里写法是怎么样的?
mysql服务端口号,肯定会根据具体的需求改变端口号的

作者: q1208c    时间: 2017-08-04 17:59
smoker87 发表于 2017-08-04 16:02
回复 2# q1208c

嗯,我也想到了说A 上的 syslog 写 B 上的数据库.
  1.    ommysql mostly uses the "old style" configuration, with almost everything on the action line itself. A few newer features are being migrated to the new style-config directive configuration system.
  2.      * $ActionOmmysqlServerPort <port>
  3.        Permits to select a non-standard port for the MySQL server. The default is 0, which means the system default port is used. There is no need to specify this directive unless you know the server is running on a non-standard listen port.
  4.      * $OmMySQLConfigFile <file name>
  5.        Permits the selection of an optional MySQL Client Library configuration file (my.cnf) for extended configuration functionality. The use of this configuration directive is necessary only if you have a non-standard environment or if fine-grained control over the database
  6.        connection is desired.
  7.      * $OmMySQLConfigSection <string>
  8.        Permits the selection of the section within the configuration file specified by the $OmMySQLConfigFile directive.
  9.        This will likely only be used where the database administrator provides a single configuration file with multiple profiles.
  10.        This configuration directive is ignored unless $OmMySQLConfigFile is also used in the rsyslog configration file.
  11.        If omitted, the MySQL Client Library default of "client" will be used.
  12.      * Action parameters:
  13.        :ommysql:database-server,database-name,database-userid,database-password
  14.        All parameters should be filled in for a successful connect.
复制代码
随机文档上说明, 好象 port 需要单独的一个配置项. 要不你试试 ?


作者: smoker87    时间: 2017-08-08 16:09
回复 4# q1208c

嗯,行了,多谢你
作者: q1208c    时间: 2017-08-10 17:10
回复 5# smoker87






欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2