将rsyslog日志存到mysql数据库中
2024-08-21 / Server / 243 次围观 / 0 次吐槽 /安装mysql模块
yum install rsyslog-mysql
查看包
rpm -ql rsyslog-mysql
查看数据库和表创建脚本,使用脚本在mysql中创建
cat /usr/share/doc/rsyslog/mysql-createDB.sql
配置rsyslog:
vi /etc/rsyslog.conf #在MODULE下面,如果是rocky8 添加 module(load="ommysql") #在MODULE下面,如果是centos7 添加 $ModLoad ommysql #在RULES下面添加 *.info :ommysql:192.168.100.3,DBNAME,DBUSER,PASSWD #重启服务 systemctl restart rsyslog.service
测试
#在服务器上生成日志 logger "this is a test log" #在数据库中查询 select count(*) from SystemEvents;
Powered By Cheug's Blog
Copyright Cheug Rights Reserved.