MySQL


MySQL is an open-source relational database management system (RDBMS).

Integration of MySQL on ubuntu with DNIF Adapter

To forward MySQL logs to the DNIF Adapter make the following configuration.

Install syslog package, if you haven’t installed it

apt-get install rsyslog

Checking the rsyslog.conf

Open a rsyslog.conf file located at /etc/rsyslog.conf by following command

vim /etc/rsyslog.conf

At the end of the file check for the following line and uncomment

$IncludeConfig /etc/rsyslog.d/*.conf

# Include all config files in /etc/rsyslog.d/
$IncludeConfig /etc/rsyslog.d/*.conf

Save and Quit the configuration file.

Create log configuration for MySQL with vim /etc/rsyslog.d/mysqllog.conf and paste following lines below

$ModLoad imfile

#For MySQL logs
$InputFileName /var/log/mysql/mysql.log  ##path of log file
$InputFileTag mysql-log:
$InputFileStateFile statefile-mysql-general
$InputFileSeverity info
$InputFileFacility local4
$InputRunFileMonitor

#for error logs
$InputFileName /var/log/mysql/error.log  ##path of log file
$InputFileTag mysql-error:
$InputFileStateFile statefile-mysql-error
$InputFileSeverity info
$InputFileFacility local4
$InputRunFileMonitor

#for slow queries logs
$InputFileName /var/log/mysql/mysql-slow.log  ##path of log file
$InputFileTag mysql-slow-queries:
$InputFileStateFile statefile-mysql-slow
$InputFileSeverity info
$InputFileFacility local4
$InputRunFileMonitor

local4.*    @DNIF-Adapter-IP:514

Save and Quit the configuration file.

Restart rsyslog service

service rsyslog restart

MySQL logs are now being streamed to the DNIF-ADAPTER.

Integration of MySQL on CentOS-RHEL with DNIF Adapter

To forward MySQL logs to the DNIF Adapter make the following configuration.

Install syslog package, if you haven’t installed it

yum -y install rsyslog

Checking the rsyslog.conf

Open a rsyslog.conf file located at /etc/rsyslog.conf by following command

vim /etc/rsyslog.conf

At the end of the file check for the following line and uncomment

$IncludeConfig /etc/rsyslog.d/*.conf

# Include all config files in /etc/rsyslog.d/
$IncludeConfig /etc/rsyslog.d/*.conf

Save and Quit the configuration file.

Create log configuration for MySQL with vim /etc/rsyslog.d/mysqllog.conf and paste following lines below

$ModLoad imfile

#For MySQL logs
$InputFileName /var/log/mysql/mysql.log  ##path of log file
$InputFileTag mysql-log:
$InputFileStateFile statefile-mysql-general
$InputFileSeverity info
$InputFileFacility local4
$InputRunFileMonitor

#for error logs
$InputFileName /var/log/mysql/error.log  ##path of log file
$InputFileTag mysql-error:
$InputFileStateFile statefile-mysql-error
$InputFileSeverity info
$InputFileFacility local4
$InputRunFileMonitor

#for slow queries logs
$InputFileName /var/log/mysql/mysql-slow.log  ##path of log file
$InputFileTag mysql-slow-queries:
$InputFileStateFile statefile-mysql-slow
$InputFileSeverity info
$InputFileFacility local4
$InputRunFileMonitor

$WorkDirectory /var/lib/rsyslog
$ActionQueueFileName fwdRule1 # unique name prefix for spool files
$ActionQueueMaxDiskSpace 1g   # 1gb space limit (use as much as possible)
$ActionQueueSaveOnShutdown on # save messages to disk on shutdown
$ActionQueueType LinkedList   # run asynchronously
$ActionResumeRetryCount -1

local4.*    @DNIF-Adapter-IP:514

Save and Quit the configuration file.

Restart rsyslog service

service rsyslog restart

MySQL logs are now being streamed to the DNIF-ADAPTER.