安装相关的库文件
yum install -y rsyslog-mysql
安装mariadb
yum install -y mariadb-server mariadb
systemctl start mariadb
netstat -ntlp | grep mysql
mysql_secure_installation
mysql -uroot -p
修改默认端口
vi /etc/my.cnf
[mysqld]
port=3309
关闭selinux
setenforce 0
重新启动
systemctl restart mariadb
配置rsyslog将日志发给mysql数据库
创建Syslog数据库
rpm -ql rsyslog-mysql
mysql -uroot -p</usr/share/doc/rsyslog-8.24.0/mysql-createDB.sql
创建用于rsyslog连接数据库的用户
create user ‘sysloguser’@‘%’ identified by ‘123456’;
grant all on Syslog to ‘sysloguser’@‘%’;
flush privileges;
修改/etc/rsyslog.conf
$ModLoad ommysql
$ActionOmmysqlServerPort 3309
. :ommysql:172.16.0.20,Syslog,sysloguser,123456
重启rsyslog服务
systemctl restart rsyslog
发送日志
logger “abc”
检查数据库内容
select * from Syslog.SystemEvents\G;