阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Rsyslog日志服务器搭建以及Loganalyzer安装使用

469次阅读
没有评论

共计 9400 个字符,预计需要花费 24 分钟才能阅读完成。

公司使用 CactiEz 做为网络监控平台,可以实时监控网络设备及出口流量外加邮件报警,虽然有一个延迟但基本够用。除此之外,还需要一个日志服务器。因为设备比较多,设备如果断电重启,问题排除还需借助日志。

华为交换机端配置如下:

info-center source default channel 2 log level warning #日志级别,设置为 warning 警告最为合适

info-center loghost source Vlanif1101 # 源 vlan

info-center loghost 192.168.2.2 #syslog 服务器地址

CentOS6.8 环境下安装 rsyslog 与 loganalezer 日志分析工具

1、做本地源、yum 安装相应包、关闭防火墙、安装 http

# 做本地 yum 源

[root@localhost yum.repos.d]# mv *.repo back/

vim /etc/yum.repos.d/media.repo

[media]

name=media

baseurl=file:///media

enabled=1

gpgcheck=0

# 更新本地源

yum clean all

yum makecache

yum repolist

# 关闭 Selinux,修改配置文件;关闭 iptables

[root@localhost yum.repos.d]# vim/etc/selinux/config

SELINUX=disabled

[root@localhost yum.repos.d]# getenforce

Enforcing

[root@localhost yum.repos.d]# setenforce 0

[root@localhost yum.repos.d]# getenforce

Permissive

[root@localhost yum.repos.d]#services iptables stop

[root@localhost yum.repos.d]# chkconfig iptables off

# 安装软件包

yum install mysql-server mysql-devel libcurl-devel net-snmp-devel php php-gd php-xml php-mysql httpd –y

# 检查相关包

[root@bogon html]# rpm -qa | grep rsyslog

|rsyslog-gssapi-5.8.10-10.el6_6.x86_64

rsyslog-mysql-5.8.10-10.el6_6.x86_64

rsyslog-relp-5.8.10-10.el6_6.x86_64

rsyslog-pgsql-5.8.10-10.el6_6.x86_64

rsyslog-gnutls-5.8.10-10.el6_6.x86_64

rsyslog-5.8.10-10.el6_6.x86_64

# 启动 http

[root@localhost yum.repos.d]#/etc/init.d/httpd start

[root@localhost yum.repos.d]#chkconfig httpd on

正在启动 httpd:httpd: Could not reliably determine the server’s fully qualifieddomain name, using localhost.localdomain for ServerName

# 测试 http 运行环境

[root@localhost yum.repos.d] cd /var/www/html/

[root@TS html]# cat > index.php <<EOF
> <?php
> phpinfo();
> ?>
> EOF

打开浏览器打开浏览器访问:http://192.168.2.2/index.php

Rsyslog 日志服务器搭建以及 Loganalyzer 安装使用

# 启动数据库

[root@localhost yum.repos.d]#/etc/init.d/mysqld start

[root@localhost yum.repos.d]#chkconfig mysqld on

# 设置 mysql 密码,查看数据库表

[root@bogon html]# cd /usr/share/doc/rsyslog-mysql-5.8.10/

[root@bogon rsyslog-mysql-5.8.10]# mysql -uroot -pqaz,123 < createDB.sql

[root@bogon ~]# mysql -uroot -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 4

Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> show databases;

+——————–+

| Database          |

+——————–+

| information_schema |

| Syslog            |

| mysql              |

| test              |

+——————–+

4 rows in set (0.00 sec)

mysql> use Syslog

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql> show tables;

+————————+

| Tables_in_Syslog      |

+————————+

| SystemEvents          |

| SystemEventsProperties |

+————————+

2 rows in set (0.00 sec)

# 授权 rsyslog 往里读写权限并提交更改

mysql> grant all on Syslog.* to rsyslog@localhost identified by ‘adminqaz’;

Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

mysql> exit

Bye

# 修改 rsyslog 配置文件,开启 UDP 端口;并使用 mysql 与 rsyslog 相关联,

[root@bogon ~]# vim /etc/rsyslog.conf

# 新增下面两行

$ModLoad ommysql
*.* :ommysql:localhost,Syslog,rsyslog,adminqaz

说明:localhost 表示本地主机,Syslog 为数据库名,rsyslog 为数据库的用户,adminqaz 为该用户密码。

# 开启相关模块

# vi /etc/rsyslog.conf

$ModLoad immark    #immark 是模块名,支持日志标记

$ModLoad imudp    #imupd 是模块名,支持 udp 协议

$UDPServerRun 514    #允许 514 端口日志

# 重启 rsyslog 服务

 /etc/init.d/rsyslog restart

如果正常的话,/var/log/messages 下可以接收服务器、交换机的配置信息。

CentOS 6.7 搭建 Rsyslog 日志服务器 http://www.linuxidc.com/Linux/2016-06/132418.htm

Rsyslog+MySQL+Loganalyzer 搭建日志服务器  http://www.linuxidc.com/Linux/2016-09/134849.htm

Rsyslog+MySQL+Loganalyzer 搭建日志服务器  http://www.linuxidc.com/Linux/2016-09/134849.htm

CentOS 6.5+Rsyslog+LogAnalyzer 搭建中央日志服务器  http://www.linuxidc.com/Linux/2014-06/102867.htm

CentOS 6.5 rsyslog+MySQL+loganalyzer 日志集中分析管理 http://www.linuxidc.com/Linux/2016-11/137656.htm

Rsyslog 的详细介绍 :请点这里
Rsyslog 的下载地址 :请点这里

更多详情见请继续阅读下一页的精彩内容 :http://www.linuxidc.com/Linux/2017-02/140240p2.htm

2、安装 LogAnalyzer

[root@bogon home]# ls

loganalyzer-3.6.5  loganalyzer-3.6.5.tar.gz

[root@bogon home]# tar xzvf loganalyzer-3.6.5.tar.gz 

[root@bogon home]# cd loganalyzer-3.6.5

[root@bogon loganalyzer-3.6.5]#mkdir -p /var/www/html/loganalyzer

[root@bogon loganalyzer-3.6.5]# rsync -a src/* /var/www/html/loganalyzer/

# 打开浏览器 http://192.168.2.2/loganalyzer, 点击 here

 

Rsyslog 日志服务器搭建以及 Loganalyzer 安装使用

# 点击 next

Rsyslog 日志服务器搭建以及 Loganalyzer 安装使用

# 调整权限,recheck 重新配置

# touch /var/www/html/loganalyzer/config.php

# chmod 666 /var/www/html/loganalyzer/config.php

Rsyslog 日志服务器搭建以及 Loganalyzer 安装使用

# 点击 next

Rsyslog 日志服务器搭建以及 Loganalyzer 安装使用

# 配置基本信息

Rsyslog 日志服务器搭建以及 Loganalyzer 安装使用

# 点击 next

Rsyslog 日志服务器搭建以及 Loganalyzer 安装使用# 点击 next

Rsyslog 日志服务器搭建以及 Loganalyzer 安装使用

 

第 6 步:创建用户名密码用于管理 loganalyzer 此处无图

# 选择日志源 sql 表,用于与 syslog 关联

Rsyslog 日志服务器搭建以及 Loganalyzer 安装使用

# 点击 next

Rsyslog 日志服务器搭建以及 Loganalyzer 安装使用

# 重新登陆会看到日志

Rsyslog 日志服务器搭建以及 Loganalyzer 安装使用

 

界面如下:

wKioL1f4tNSRaloHAAFjU4KPMnA655.png

公司使用 CactiEz 做为网络监控平台,可以实时监控网络设备及出口流量外加邮件报警,虽然有一个延迟但基本够用。除此之外,还需要一个日志服务器。因为设备比较多,设备如果断电重启,问题排除还需借助日志。

华为交换机端配置如下:

info-center source default channel 2 log level warning #日志级别,设置为 warning 警告最为合适

info-center loghost source Vlanif1101 # 源 vlan

info-center loghost 192.168.2.2 #syslog 服务器地址

CentOS6.8 环境下安装 rsyslog 与 loganalezer 日志分析工具

1、做本地源、yum 安装相应包、关闭防火墙、安装 http

# 做本地 yum 源

[root@localhost yum.repos.d]# mv *.repo back/

vim /etc/yum.repos.d/media.repo

[media]

name=media

baseurl=file:///media

enabled=1

gpgcheck=0

# 更新本地源

yum clean all

yum makecache

yum repolist

# 关闭 Selinux,修改配置文件;关闭 iptables

[root@localhost yum.repos.d]# vim/etc/selinux/config

SELINUX=disabled

[root@localhost yum.repos.d]# getenforce

Enforcing

[root@localhost yum.repos.d]# setenforce 0

[root@localhost yum.repos.d]# getenforce

Permissive

[root@localhost yum.repos.d]#services iptables stop

[root@localhost yum.repos.d]# chkconfig iptables off

# 安装软件包

yum install mysql-server mysql-devel libcurl-devel net-snmp-devel php php-gd php-xml php-mysql httpd –y

# 检查相关包

[root@bogon html]# rpm -qa | grep rsyslog

|rsyslog-gssapi-5.8.10-10.el6_6.x86_64

rsyslog-mysql-5.8.10-10.el6_6.x86_64

rsyslog-relp-5.8.10-10.el6_6.x86_64

rsyslog-pgsql-5.8.10-10.el6_6.x86_64

rsyslog-gnutls-5.8.10-10.el6_6.x86_64

rsyslog-5.8.10-10.el6_6.x86_64

# 启动 http

[root@localhost yum.repos.d]#/etc/init.d/httpd start

[root@localhost yum.repos.d]#chkconfig httpd on

正在启动 httpd:httpd: Could not reliably determine the server’s fully qualifieddomain name, using localhost.localdomain for ServerName

# 测试 http 运行环境

[root@localhost yum.repos.d] cd /var/www/html/

[root@TS html]# cat > index.php <<EOF
> <?php
> phpinfo();
> ?>
> EOF

打开浏览器打开浏览器访问:http://192.168.2.2/index.php

Rsyslog 日志服务器搭建以及 Loganalyzer 安装使用

# 启动数据库

[root@localhost yum.repos.d]#/etc/init.d/mysqld start

[root@localhost yum.repos.d]#chkconfig mysqld on

# 设置 mysql 密码,查看数据库表

[root@bogon html]# cd /usr/share/doc/rsyslog-mysql-5.8.10/

[root@bogon rsyslog-mysql-5.8.10]# mysql -uroot -pqaz,123 < createDB.sql

[root@bogon ~]# mysql -uroot -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 4

Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> show databases;

+——————–+

| Database          |

+——————–+

| information_schema |

| Syslog            |

| mysql              |

| test              |

+——————–+

4 rows in set (0.00 sec)

mysql> use Syslog

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql> show tables;

+————————+

| Tables_in_Syslog      |

+————————+

| SystemEvents          |

| SystemEventsProperties |

+————————+

2 rows in set (0.00 sec)

# 授权 rsyslog 往里读写权限并提交更改

mysql> grant all on Syslog.* to rsyslog@localhost identified by ‘adminqaz’;

Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

mysql> exit

Bye

# 修改 rsyslog 配置文件,开启 UDP 端口;并使用 mysql 与 rsyslog 相关联,

[root@bogon ~]# vim /etc/rsyslog.conf

# 新增下面两行

$ModLoad ommysql
*.* :ommysql:localhost,Syslog,rsyslog,adminqaz

说明:localhost 表示本地主机,Syslog 为数据库名,rsyslog 为数据库的用户,adminqaz 为该用户密码。

# 开启相关模块

# vi /etc/rsyslog.conf

$ModLoad immark    #immark 是模块名,支持日志标记

$ModLoad imudp    #imupd 是模块名,支持 udp 协议

$UDPServerRun 514    #允许 514 端口日志

# 重启 rsyslog 服务

 /etc/init.d/rsyslog restart

如果正常的话,/var/log/messages 下可以接收服务器、交换机的配置信息。

CentOS 6.7 搭建 Rsyslog 日志服务器 http://www.linuxidc.com/Linux/2016-06/132418.htm

Rsyslog+MySQL+Loganalyzer 搭建日志服务器  http://www.linuxidc.com/Linux/2016-09/134849.htm

Rsyslog+MySQL+Loganalyzer 搭建日志服务器  http://www.linuxidc.com/Linux/2016-09/134849.htm

CentOS 6.5+Rsyslog+LogAnalyzer 搭建中央日志服务器  http://www.linuxidc.com/Linux/2014-06/102867.htm

CentOS 6.5 rsyslog+MySQL+loganalyzer 日志集中分析管理 http://www.linuxidc.com/Linux/2016-11/137656.htm

Rsyslog 的详细介绍 :请点这里
Rsyslog 的下载地址 :请点这里

更多详情见请继续阅读下一页的精彩内容 :http://www.linuxidc.com/Linux/2017-02/140240p2.htm

3、关于日志轮循相关内容,linux 中的日志轮循是使用 logrotate

# 查看 logrotate 相关配置文件

[root@bogon ~]# rpm -ql logrotate

/etc/cron.daily/logrotate

/etc/logrotate.conf

/etc/logrotate.d

/usr/sbin/logrotate

/usr/share/doc/logrotate-3.7.8

/usr/share/doc/logrotate-3.7.8/CHANGES

/usr/share/doc/logrotate-3.7.8/COPYING

/usr/share/man/man5/logrotate.conf.5.gz

/usr/share/man/man8/logrotate.8.gz

/var/lib/logrotate.status

# 编缉 logrotate 配置文件

vim /etc/logrotate.conf

[root@bogon ~]# cat /etc/logrotate.conf

# see “man logrotate” for details

# rotate log files weekly

weekly

# keep 4 weeks worth of backlogs

rotate 4

# create new (empty) log files after rotating old ones

create

# use date as a suffix of the rotated file

dateext

# uncomment this if you want your log files compressed

#compress

# RPM packages drop log rotation information into this directory

include /etc/logrotate.d

# no packages own wtmp and btmp — we’ll rotate them here

/var/log/wtmp {

    monthly

    create 0664 root utmp

minsize 1M

    rotate 1

}

/var/log/btmp {

    missingok

    monthly

    create 0600 root utmp

    rotate 1

}

# 以周为单位轮循,4 次:messages1…..messages4 massages1…..massages4……,往前覆盖

/var/log/messages {

    weekly

    rotate 4

    dateext

    compress

    missingok

    create 644 root root

    postrotate

    /usr/bin/killall -HUP rsyslogd  #平滑重启 rsyslog 或者使用 /var/run/syslogd.pid 更准确

    endscript

}

# system-specific logs may be also be configured here.

# 以时间为结尾,如下:

Rsyslog 日志服务器搭建以及 Loganalyzer 安装使用

本文永久更新链接地址 :http://www.linuxidc.com/Linux/2017-02/140240.htm

正文完
星哥玩云-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-21发表,共计9400字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中

星哥玩云

星哥玩云
星哥玩云
分享互联网知识
用户数
4
文章数
19350
评论数
4
阅读量
7965475
文章搜索
热门文章
星哥带你玩飞牛NAS-6:抖音视频同步工具,视频下载自动下载保存

星哥带你玩飞牛NAS-6:抖音视频同步工具,视频下载自动下载保存

星哥带你玩飞牛 NAS-6:抖音视频同步工具,视频下载自动下载保存 前言 各位玩 NAS 的朋友好,我是星哥!...
星哥带你玩飞牛NAS-3:安装飞牛NAS后的很有必要的操作

星哥带你玩飞牛NAS-3:安装飞牛NAS后的很有必要的操作

星哥带你玩飞牛 NAS-3:安装飞牛 NAS 后的很有必要的操作 前言 如果你已经有了飞牛 NAS 系统,之前...
我把用了20年的360安全卫士卸载了

我把用了20年的360安全卫士卸载了

我把用了 20 年的 360 安全卫士卸载了 是的,正如标题你看到的。 原因 偷摸安装自家的软件 莫名其妙安装...
再见zabbix!轻量级自建服务器监控神器在Linux 的完整部署指南

再见zabbix!轻量级自建服务器监控神器在Linux 的完整部署指南

再见 zabbix!轻量级自建服务器监控神器在 Linux 的完整部署指南 在日常运维中,服务器监控是绕不开的...
飞牛NAS中安装Navidrome音乐文件中文标签乱码问题解决、安装FntermX终端

飞牛NAS中安装Navidrome音乐文件中文标签乱码问题解决、安装FntermX终端

飞牛 NAS 中安装 Navidrome 音乐文件中文标签乱码问题解决、安装 FntermX 终端 问题背景 ...
阿里云CDN
阿里云CDN-提高用户访问的响应速度和成功率
随机文章
我把用了20年的360安全卫士卸载了

我把用了20年的360安全卫士卸载了

我把用了 20 年的 360 安全卫士卸载了 是的,正如标题你看到的。 原因 偷摸安装自家的软件 莫名其妙安装...
国产开源公众号AI知识库 Agent:突破未认证号限制,一键搞定自动回复,重构运营效率

国产开源公众号AI知识库 Agent:突破未认证号限制,一键搞定自动回复,重构运营效率

国产开源公众号 AI 知识库 Agent:突破未认证号限制,一键搞定自动回复,重构运营效率 大家好,我是星哥,...
把小米云笔记搬回家:飞牛 NAS 一键部署,小米云笔记自动同步到本地

把小米云笔记搬回家:飞牛 NAS 一键部署,小米云笔记自动同步到本地

把小米云笔记搬回家:飞牛 NAS 一键部署,小米云笔记自动同步到本地 大家好,我是星哥,今天教大家在飞牛 NA...
支付宝、淘宝、闲鱼又双叕崩了,Cloudflare也瘫了连监控都挂,根因藏在哪?

支付宝、淘宝、闲鱼又双叕崩了,Cloudflare也瘫了连监控都挂,根因藏在哪?

支付宝、淘宝、闲鱼又双叕崩了,Cloudflare 也瘫了连监控都挂,根因藏在哪? 最近两天的互联网堪称“故障...
星哥带你玩飞牛NAS-3:安装飞牛NAS后的很有必要的操作

星哥带你玩飞牛NAS-3:安装飞牛NAS后的很有必要的操作

星哥带你玩飞牛 NAS-3:安装飞牛 NAS 后的很有必要的操作 前言 如果你已经有了飞牛 NAS 系统,之前...

免费图片视频管理工具让灵感库告别混乱

一言一句话
-「
手气不错
300元就能买到的”小钢炮”?惠普7L四盘位小主机解析

300元就能买到的”小钢炮”?惠普7L四盘位小主机解析

  300 元就能买到的 ” 小钢炮 ”?惠普 7L 四盘位小主机解析 最近...
小白也能看懂:什么是云服务器?腾讯云 vs 阿里云对比

小白也能看懂:什么是云服务器?腾讯云 vs 阿里云对比

小白也能看懂:什么是云服务器?腾讯云 vs 阿里云对比 星哥玩云,带你从小白到上云高手。今天咱们就来聊聊——什...
你的云服务器到底有多强?宝塔跑分告诉你

你的云服务器到底有多强?宝塔跑分告诉你

你的云服务器到底有多强?宝塔跑分告诉你 为什么要用宝塔跑分? 宝塔跑分其实就是对 CPU、内存、磁盘、IO 做...
浏览器自动化工具!开源 AI 浏览器助手让你效率翻倍

浏览器自动化工具!开源 AI 浏览器助手让你效率翻倍

浏览器自动化工具!开源 AI 浏览器助手让你效率翻倍 前言 在 AI 自动化快速发展的当下,浏览器早已不再只是...
星哥带你玩飞牛 NAS-9:全能网盘搜索工具 13 种云盘一键搞定!

星哥带你玩飞牛 NAS-9:全能网盘搜索工具 13 种云盘一键搞定!

星哥带你玩飞牛 NAS-9:全能网盘搜索工具 13 种云盘一键搞定! 前言 作为 NAS 玩家,你是否总被这些...