免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3745 | 回复: 5
打印 上一主题 下一主题

[其他] linux服务器日志实时数据同步的两个情况,rsyslog+mysql谁帮我分析下优劣 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2017-08-03 10:38 |只看该作者 |倒序浏览
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机器资源大?
以及他们之间谁数据传输快,谁数据传输慢?

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



论坛徽章:
33
荣誉会员
日期:2011-11-23 16:44:17天秤座
日期:2014-08-26 16:18:20天秤座
日期:2014-08-29 10:12:18丑牛
日期:2014-08-29 16:06:45丑牛
日期:2014-09-03 10:28:58射手座
日期:2014-09-03 16:01:17寅虎
日期:2014-09-11 14:24:21天蝎座
日期:2014-09-17 08:33:55IT运维版块每日发帖之星
日期:2016-04-17 06:23:27操作系统版块每日发帖之星
日期:2016-04-18 06:20:00IT运维版块每日发帖之星
日期:2016-04-24 06:20:0015-16赛季CBA联赛之天津
日期:2016-05-06 12:46:59
2 [报告]
发表于 2017-08-03 16:13 |只看该作者
回复 1# smoker87

syslog 同步好些.

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

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

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

论坛徽章:
0
3 [报告]
发表于 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服务端口号,肯定会根据具体的需求改变端口号的

论坛徽章:
33
荣誉会员
日期:2011-11-23 16:44:17天秤座
日期:2014-08-26 16:18:20天秤座
日期:2014-08-29 10:12:18丑牛
日期:2014-08-29 16:06:45丑牛
日期:2014-09-03 10:28:58射手座
日期:2014-09-03 16:01:17寅虎
日期:2014-09-11 14:24:21天蝎座
日期:2014-09-17 08:33:55IT运维版块每日发帖之星
日期:2016-04-17 06:23:27操作系统版块每日发帖之星
日期:2016-04-18 06:20:00IT运维版块每日发帖之星
日期:2016-04-24 06:20:0015-16赛季CBA联赛之天津
日期:2016-05-06 12:46:59
4 [报告]
发表于 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 需要单独的一个配置项. 要不你试试 ?

论坛徽章:
0
5 [报告]
发表于 2017-08-08 16:09 |只看该作者
回复 4# q1208c

嗯,行了,多谢你

论坛徽章:
33
荣誉会员
日期:2011-11-23 16:44:17天秤座
日期:2014-08-26 16:18:20天秤座
日期:2014-08-29 10:12:18丑牛
日期:2014-08-29 16:06:45丑牛
日期:2014-09-03 10:28:58射手座
日期:2014-09-03 16:01:17寅虎
日期:2014-09-11 14:24:21天蝎座
日期:2014-09-17 08:33:55IT运维版块每日发帖之星
日期:2016-04-17 06:23:27操作系统版块每日发帖之星
日期:2016-04-18 06:20:00IT运维版块每日发帖之星
日期:2016-04-24 06:20:0015-16赛季CBA联赛之天津
日期:2016-05-06 12:46:59
6 [报告]
发表于 2017-08-10 17:10 |只看该作者
回复 5# smoker87

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP