【笔记】Archlinux下配置rsyslog写日志到mysql

  1、archlinux的rsyslog不在官方包里面 需要用yay在社区下载

  2、先配置数据库

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
);

数据库名和下面的配置一致就好 但是表明和表结构是定死的 不能改

  3、创建用户并赋予权限

create user sys_用户名@'localhost' identified by '用户密码';
grant all privileges on Syslog.* to 用户名@'localhost';

  4、编辑/etc/rsyslog.conf 在最上面加上两行

$Modload ommysql
*.* :ommysql:数据库地址,数据库名称,用户名,密码

  5、重启rsyslog服务 查看服务状态 如果报错action 'action-0-ommysql' (module 'ommysql') message lost, could not be processed

    刷新数据库权限 flush privileges

 

posted on 2020-12-28 18:33  绝对密位  阅读(453)  评论(0编辑  收藏  举报

导航