# 下载辅助软件查找[root@rsyslog ~]$yuminstall mlocate
[root@rsyslog ~]$updatedb# 更新数据库信息[root@rsyslog ~]$locate mysql-createDB.sql # 使用locatedb查找脚本文件存放路径
/usr/share/doc/rsyslog-8.24.0/mysql-createDB.sql
[root@rsyslog ~]$cat /usr/share/doc/rsyslog-8.24.0/mysql-createDB.sql # 脚本文件内容
CREATE DATABASE Syslog;
USE Syslog;
CREATE TABLE SystemEvents
(
ID int unsigned not null auto_increment primary key,
CustomerID bigint,
ReceivedAt datetime NULL,
DeviceReportedTime datetime NULL,
Facility smallint NULL,
Priority smallint NULL,
FromHost varchar(60) NULL,
Message text,
NTSeverity int NULL,
Importance int NULL,
EventSource varchar(60),
EventUser varchar(60) NULL,
EventCategory int NULL,
EventID int NULL,
EventBinaryData text NULL,
MaxAvailable int NULL,
CurrUsage int NULL,
MinUsage int NULL,
MaxUsage int NULL,
InfoUnitID int NULL ,
SysLogTag varchar(60),
EventLogType varchar(60),
GenericFileName VarChar(60),
SystemID int NULL
);
CREATE TABLE SystemEventsProperties
(
ID int unsigned not null auto_increment primary key,
SystemEventID int NULL ,
ParamName varchar(255) NULL ,
ParamValue text NULL
);[root@rsyslog ~]$scp /usr/share/doc/rsyslog-8.24.0/mysql-createDB.sql 192.168.39.27:/root # 发送到数据库服务器
The authenticity of host '192.168.39.27 (192.168.39.27)' can't be established.
ECDSA key fingerprint is SHA256:XVNFzEbN3eaCzTwYrlQg2SzHZXHbd0dS0YKLuIOXVr0.
ECDSA key fingerprint is MD5:df:4d:86:ba:0c:e6:c1:a2:6c:45:71:e9:ac:ea:1d:a5.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.39.27' (ECDSA) to the list of known hosts.
root@192.168.39.27's password:
mysql-createDB.sql 100% 1046 588.1KB/s 00:00
修改配置文件启动服务模块并且写如数据库信息(用于给数据库服务器发送日志信息)
# The imjournal module bellow is now used as a message source instead of imuxsock.$ModLoad ommysql # 添加这一行# Don't log private authentication messages!
*.info;mail.none;authpriv.none;cron.none /var/log/messages
*.info;mail.none;authpriv.none;cron.none :ommysql:192.168.39.27,Syslog,syslog,taotaobao
[root@mysql ~]$mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h'for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> grant all on Syslog.* to syslog@'192.168.39.%' identified by 'taotaobao';# 注意这里的数据库名要对应执行的sql脚本里的数据库名。
Query OK, 0 rows affected (0.00 sec)
[root@centos7 ~]$mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h'for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> 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
MariaDB [Syslog]> show tables;
+------------------------+
| Tables_in_Syslog |
+------------------------+
| SystemEvents |# 这个表是作为存储日志信息使用的| SystemEventsProperties |
+------------------------+
2 rows inset(0.00 sec)