Recently more and more people want to use syslog-ng with database support enabled on CentOS 5, RHEL5 & Co. The syslog-ng package in EPEL does not support it, as libdbi there is too old. But compiling your own database enabled syslog-ng is not a difficult job. This howto is based on input from the syslog-ng mailing list, but tries to install less additional software to the system.
First install some packages necessary to build syslog-ng. Replace “x86_64” with your own architecture for the devel packages (if in doubt, uname -m will print your architecture):
yum install gcc yum install glib2-devel.x86_64
Add /usr/local/lib to ld.so.conf:
echo /usr/local/lib > /etc/ld.so.conf.d/local.conf
Create a working directory:
mkdir ~/workdir
Download and install eventlog:
cd ~/workdir wget https://www.balabit.com/downloads/files/eventlog/0.2/eventlog_0.2.12.tar.gz tar xzvpf eventlog_0.2.12.tar.gz cd eventlog-0.2.12/ ./configure make make install
Go back to the working directory:
cd ~/workdir
Download libdbi from sourceforge: http://sourceforge.net/projects/libdbi/files/libdbi/libdbi-0.8.4/
Compile and install it:
tar xzvpf libdbi-0.8.4.tar.gz cd libdbi-0.8.4 ./configure --disable-docs make make install
Go back to the working directory:
cd ~/workdir
Download libdbi-drivers from sourceforge: http://sourceforge.net/projects/libdbi-drivers/files/libdbi-drivers/libdbi-drivers-0.8.3-1/
Compile and install it:
tar xzvpf libdbi-drivers-0.8.3-1.tar.gz cd libdbi-drivers-0.8.3-1
Configuring is a bit more tricky, as it needs switches and additional development packages. The following example is for PostgreSQL and MySQL, use ./configure –help to see options for other databases. Beware, that sqlite only works with a CVS snapshot of libdbi. First install the development packages for the database and architecture you use:
yum install postgresql84-devel.x86_64 yum install mysql-devel.x86_64
Then configure, compile and install it:
./configure --with-dbi-incdir=/usr/local/include/dbi --with-dbi-libdir=/usr/local/lib --with-mysql --with-mysql-dir=/usr --with-mysql-libdir=/usr/lib64/mysql --with-mysql-incdir=/usr/include/mysql/ --with-pgsql --with-pgsql-dir=/usr –disable-docs make make install
Using your self compiled database server will need slightly different parameters.
Finally download, configure and install syslog-ng:
cd ~/workdir wget https://www.balabit.com/downloads/files/syslog-ng/sources/3.2.4/source/syslog-ng_3.2.4.tar.gz tar xzvpf syslog-ng_3.2.4.tar.gz cd syslog-ng-3.2.4/ PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/ ./configure make make install ldconfig
The output of syslog-ng -V should have the following line:
Enable-SQL: on
Compiling on RHEL 6 should be very similar, most likely the version number of PostgreSQL will be something different. On the other hand, hopefully there will be a libdbi enabled syslog-ng package in EPEL soon.