一、部署日志服务

1、查看自己的系统是否安装(一般默认安装)

[root@localhost ~]# rpm -qa | grep rsyslog
rsyslog-8.37.0-13.el8.x86_64

  如果没安装,使用yum安装:

[root@localhost ~]# yum list rsyslog
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
appstream 3.1 MB/s | 3.2 kB 00:00
baseos 2.7 MB/s | 2.8 kB 00:00
Installed Packages
rsyslog.x86_64
[root@localhost ~]# yum install -y rsyslog
...........

2、编辑/etc/rsyslog.conf配置文件:

  • 编辑配置文件(/etc/rsyslog.conf) , 将下列内容前面的注释去掉,然后重启rsyslog服务即可:

    • #module(load="imudp")
    • #input(type="imudp" port="514")
    • #module(load="imtcp")
    • #input(type="imtcp" port="514")
[root@localhost ~]# vim /etc/rsyslog.conf
...........
# Provides UDP syslog reception
# for parameters see http://www.rsyslog.com/doc/imudp.html
module(load="imudp") # needs to be done just once
input(type="imudp" port="514") # Provides TCP syslog reception
# for parameters see http://www.rsyslog.com/doc/imtcp.html
module(load="imtcp") # needs to be done just once
input(type="imtcp" port="514")
............

3、重启rsyslog服务

[root@localhost ~]# systemctl restart rsyslog
[root@localhost ~]# netstat -tunlp | grep rsyslog
tcp 0 0 0.0.0.0:514 0.0.0.0:* LISTEN 1814/rsyslogd
tcp6 0 0 :::514 :::* LISTEN 1814/rsyslogd
udp 0 0 0.0.0.0:514 0.0.0.0:* 1814/rsyslogd
udp6 0 0 :::514 :::* 1814/rsyslogd //查看rsyslog状态
[root@localhost ~]# systemctl status rsyslog
● rsyslog.service - System Logging Service
Loaded: loaded (/usr/lib/systemd/system/rsyslog.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2020-08-23 00:57:37 CST; 31s ago
Docs: man:rsyslogd(8)
http://www.rsyslog.com/doc/
Main PID: 1814 (rsyslogd)
Tasks: 9 (limit: 11340)
Memory: 3.7M
CGroup: /system.slice/rsyslog.service
└─1814 /usr/sbin/rsyslogd -n Aug 23 00:57:37 localhost.localdomain systemd[1]: Stopped System Logging Service.
Aug 23 00:57:37 localhost.localdomain systemd[1]: Starting System Logging Service...
Aug 23 00:57:37 localhost.localdomain rsyslogd[1814]: environment variable TZ is not set, auto correcting this to TZ=/etc/localtime [v8.37.0-13.el8 try http://www.rsyslo>
Aug 23 00:57:37 localhost.localdomain rsyslogd[1814]: [origin software="rsyslogd" swVersion="8.37.0-13.el8" x-pid="1814" x-info="http://www.rsyslog.com"] start
Aug 23 00:57:37 localhost.localdomain systemd[1]: Started System Logging Service.

4、测试

  • 首先进入/var/log/secure下监控日志状态 
[root@localhost ~]# tail -f /var/log/secure
[root@localhost ~]# tail -f /var/log/secure
Aug 22 21:36:16 localhost sshd[1051]: Server listening on :: port 22.
Aug 22 21:36:16 localhost polkitd[1019]: Loading rules from directory /etc/polkit-1/rules.d
Aug 22 21:36:16 localhost polkitd[1019]: Loading rules from directory /usr/share/polkit-1/rules.d
Aug 22 21:36:16 localhost polkitd[1019]: Finished loading, compiling and executing 2 rules
Aug 22 21:36:16 localhost polkitd[1019]: Acquired the name org.freedesktop.PolicyKit1 on the system bus
Aug 22 21:36:37 localhost sshd[1519]: Accepted password for root from 192.168.121.1 port 2335 ssh2
Aug 22 21:36:37 localhost systemd[1522]: pam_unix(systemd-user:session): session opened for user root by (uid=0)
Aug 22 21:36:38 localhost sshd[1519]: pam_unix(sshd:session): session opened for user root by (uid=0)
Aug 23 01:01:41 localhost sshd[1843]: Accepted password for root from 192.168.121.1 port 11157 ssh2
Aug 23 01:01:41 localhost sshd[1843]: pam_unix(sshd:session): session opened for user root by (uid=0) //持续监控
  • 使用远程登陆,故意输入错误的密码,看该文件是否接受到错误的日志消息

  • 查看/var/log/secre文件是否收到错误的日志信息
[root@localhost ~]# tail -f /var/log/secure
Aug 22 21:36:16 localhost polkitd[1019]: Loading rules from directory /usr/share/polkit-1/rules.d
Aug 22 21:36:16 localhost polkitd[1019]: Finished loading, compiling and executing 2 rules
Aug 22 21:36:16 localhost polkitd[1019]: Acquired the name org.freedesktop.PolicyKit1 on the system bus
Aug 22 21:36:37 localhost sshd[1519]: Accepted password for root from 192.168.121.1 port 2335 ssh2
Aug 22 21:36:37 localhost systemd[1522]: pam_unix(systemd-user:session): session opened for user root by (uid=0)
Aug 22 21:36:38 localhost sshd[1519]: pam_unix(sshd:session): session opened for user root by (uid=0)
Aug 23 01:01:41 localhost sshd[1843]: Accepted password for root from 192.168.121.1 port 11157 ssh2
Aug 23 01:01:41 localhost sshd[1843]: pam_unix(sshd:session): session opened for user root by (uid=0)
Aug 23 01:05:56 localhost sshd[1877]: error: Received disconnect from 192.168.121.1 port 11264:0: [preauth]
Aug 23 01:05:56 localhost sshd[1877]: Disconnected from 192.168.121.1 port 11264 [preauth] Aug 23 01:10:17 localhost sshd[1883]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=192.168.121.1 user=root
Aug 23 01:10:18 localhost sshd[1883]: Failed password for root from 192.168.121.1 port 11388 ssh2
Aug 23 01:10:21 localhost sshd[1883]: error: Received disconnect from 192.168.121.1 port 11388:0: [preauth]
Aug 23 01:10:21 localhost sshd[1883]: Disconnected from authenticating user root 192.168.121.1 port 11388 [preauth]
//后面四行是刚刚收到的错误日志信息

Linux_部署日志服务器的更多相关文章

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

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

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

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

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

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

  4. Linux下使用rsyslog部署日志服务器 && 记录history并发送到rsyslog服务器

    一.syslog服务简介 rsyslog 是一个 syslogd 的多线程增强版.rsyslog负责写入日志, logrotate负责备份和删除旧日志, 以及更新日志文件 logger命令 将自定义的 ...

  5. rsyslog+mysql+loganalyzer搭建日志服务器<个人笔记>

    大概思路如下: 使用Linux自带的rsyslog服务来做底层,然后再使用mysql与rsyslog的模板来存储文件,并且以web来进行显示出来.<模板的存储以日期的树形结构来存储,并且以服务器 ...

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

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

  7. 利用Syslog Watcher在windows下部署syslog日志服务器

    1.概述 syslog协议是各种网络设备.服务器支持的网络日志记录标准.Syslog消息提供有关网络事件和错误的信息.系统管理员使用Syslog进行网络管理和安全审核. 通过专用的syslog服务器和 ...

  8. 部署openssh服务器

    1.安装服务器端软件包 先查看是否已经安装openSSH服务器软件包 # rpm -qa|grep openssh openssh-askpass-.3p1-.el6_6..x86_64 openss ...

  9. centos7+rsyslog+loganalyzer+mysql 搭建rsyslog日志服务器

    一.简介 在centos7系统中,默认的日志系统是rsyslog,它是一类unix系统上使用的开源工具,用于在ip网络中转发日志信息,rsyslog采用模块化设计,是syslog的替代品. 1.rsy ...

随机推荐

  1. Compound Words UVA - 10391

      You are to find all the two-word compound words in a dictionary. A two-word compound word is a wor ...

  2. 利用Apache部署静态网站(一)

    Apache是世界使用排名第一的Web服务器软件.它可以运行在几乎所有广泛使用的计算机平台上,由于其跨平台和安全性被广泛使用,是最流行的Web服务器端软件之一.它快速.可靠并且可通过简单的API扩充, ...

  3. SQL Server 审计(Audit)

    审计(Audit)用于追踪和记录SQL Server实例,或者单个数据库中发生的事件(Event),审计运作的机制是通过捕获事件(Event),把事件包含的信息写入到事件日志(Event Log)或审 ...

  4. 数据结构之链表(JavaScript描述)

    链表数据结构   链表存储有序的元素集合,但不同于数组,链表中的元素在内存中并不是连续防止的.每个元素由一个存储元素本身的节点和一个只想下一个元素的引用(也称为指针或链接)组成 类似的例子 创建链表 ...

  5. 功能:@Vaild注解使用及扩展

    @Vaild注解使用及扩展 一.@Vaild注解介绍 使用@Vaild注解可以简化入参的校验,配合统一异常实现简单快捷的入参校验,具体使用参照以下 二.@Vaild具体使用 1.引入jar包 如果你是 ...

  6. laravel 解决mysql插入相同数据的问题

    1.背景: 每天0点定时任务统计数据,实现目标是统计时如果没有今天的统计数据,那就执行insert操作 如果存在那就执行update操作: 代码逻辑 1 if(报表存在){ 2 update(); 3 ...

  7. 【VsCode】常用的快捷键

    查找和替换: 查找:Ctrl +F 查找和替换:Ctrl +H编辑器和窗口管理相关快捷键: 文件之间切换:Ctrl+Tab 关闭当前窗口:Ctrl+W /Ctrl +F4 切出一个新的编辑器窗口(最多 ...

  8. Linux中环境变量的设置

    目录 环境变量 Shell定义的环境变量 查看环境变量 Linux下环境变量的设置 环境变量 在Windows 系统下,很多软件安装都需要配置环境变量,比如 安装 jdk ,如果不配置环境变量,在非软 ...

  9. windows核心编程-第一章 对程序错误的处理

    第一章-对程序错误的处理 在开始介绍Microsoft Windows 的特性之前,必须首先了解 Wi n d o w s的各个函数是如何进行错误处理的. 当调用一个Wi n d o w s函数时,它 ...

  10. 【Git】5. 远程库(GitHub)相关操作

    之前也提到了,在整个协作的过程中,必不可少的就是远程库了.Github作为一个全球最大的同性交友网站,同样也是一个非常强大的远程库. 现在希望将本地的hello.txt文件也推到github上去,那首 ...