1.我用Mariadb(Mysql),所以先给rsyslog安装mysql支持。
[root@test ~]# dnf install rsyslog-mysql
2.在mysql里导入rsyslog默认使用的数据库信息(库名是Syslog),并添加rsyslog需要的mysql用户:
[root@test ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3127
Server version: 10.3.11-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)]> source /usr/share/doc/rsyslog/mysql-createDB.sql
MariaDB [(none)]> grant all privileges on Syslog.* to 'sysloguser'@'localhost' identified by '125456';
MariaDB [(none)]> flush privileges;
3.修改/etc/rsyslog.conf文件,在#### MODULES ####的那一段最后添加mysql支持:
# mysql
$ModLoad ommysql
然后在后面添加采集条件,把对应的日志添加到数据库:
#关于条件和输出相关其他设置请参阅rsyslog官方文档,我只说我这里的

最低0.47元/天 解锁文章
2172

被折叠的 条评论
为什么被折叠?



