syslog-ng 3.0.1, open source edition, fails write to MySQL DB
I have installed syslog-ng 3.0.1, open source edition, binary package in RHEL 5.3 system. I'm having trouble to have it writing to MySQL DB using native driver. The current configuration file looks like: # Write the logs to MySQL DB destination dd_mysql { sql(type(mysql) host("localhost") username("syslogadmin") password("syslogadmin") database("syslog") table("logs") columns("host", "facility", "priority", "level", "tag", "datetime", "program", "msg", "seq") values("$HOST", "$FACILITY", "$PRIORITY", "$LEVEL", "$TAG", "$YEAR-$MONTH-$DAY $HOUR:$MIN:$SEC", "$PROGRAM", "$MSG", "$SEQ") indexes("seq")); # program("/usr/bin/mysql -usyslogadmin -psyslogadmin syslog" # template("INSERT INTO logs (host, facility, priority, level, tag, datetime, program, msg, seq) # VALUES ( '$HOST', '$FACILITY', '$PRIORITY', '$LEVEL', '$TAG', '$YEAR-$MONTH-$DAY $HOUR:$MIN:$SEC', '$PROGRAM', '$MSG', '$SEQ' );\n") # template-escape(yes)); }; It works if I use the program driver, as currently commented out. The table is configured as following, using the schema defined by php-syslog-ng 2.9.8m. +----------+---------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------+---------------------+------+-----+---------+----------------+ | id | bigint(20) unsigned | NO | PRI | NULL | auto_increment | | host | varchar(128) | YES | MUL | NULL | | | facility | varchar(10) | YES | MUL | NULL | | | priority | varchar(10) | YES | MUL | NULL | | | level | varchar(10) | YES | | NULL | | | tag | varchar(10) | YES | | NULL | | | datetime | datetime | YES | MUL | NULL | | | program | varchar(15) | YES | MUL | NULL | | | msg | text | YES | | NULL | | | seq | bigint(20) unsigned | NO | MUL | 0 | | | counter | int(11) | NO | | 1 | | | fo | datetime | YES | | NULL | | | lo | datetime | YES | | NULL | | +----------+---------------------+------+-----+---------+---------------- What is the problem? Thanks in advance for the help.
After I posted to the list, first I did when I run into this problem, I enabled the debug and noticed the following error: Apr 23 15:58:15 alfnetengi01 syslog-ng[7826]: Error establishing SQL connection; type='mysql', host='localhost', port='', username='syslogadmin', database='syslog', error='2002: Can\'t connect to local MySQL server through socket \'/var/run/mysqld/mysqld.sock \' (2)' It appears to me it try to connect to MySQL using sock instead of TCP, as I original assumed. Is there a way to use TCP connection? I will play around as well. Thanks. -----Original Message----- From: Arnold Wang <arnold.wang@inovis.com> To: syslog-ng@lists.balabit.hu Subject: syslog-ng 3.0.1, open source edition, fails write to MySQL DB Date: Thu, 23 Apr 2009 12:35:07 -0700 I have installed syslog-ng 3.0.1, open source edition, binary package in RHEL 5.3 system. I'm having trouble to have it writing to MySQL DB using native driver. The current configuration file looks like: # Write the logs to MySQL DB destination dd_mysql { sql(type(mysql) host("localhost") username("syslogadmin") password("syslogadmin") database("syslog") table("logs") columns("host", "facility", "priority", "level", "tag", "datetime", "program", "msg", "seq") values("$HOST", "$FACILITY", "$PRIORITY", "$LEVEL", "$TAG", "$YEAR-$MONTH-$DAY $HOUR:$MIN:$SEC", "$PROGRAM", "$MSG", "$SEQ") indexes("seq")); # program("/usr/bin/mysql -usyslogadmin -psyslogadmin syslog" # template("INSERT INTO logs (host, facility, priority, level, tag, datetime, program, msg, seq) # VALUES ( '$HOST', '$FACILITY', '$PRIORITY', '$LEVEL', '$TAG', '$YEAR-$MONTH-$DAY $HOUR:$MIN:$SEC', '$PROGRAM', '$MSG', '$SEQ' );\n") # template-escape(yes)); }; It works if I use the program driver, as currently commented out. The table is configured as following, using the schema defined by php-syslog-ng 2.9.8m. +----------+---------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------+---------------------+------+-----+---------+----------------+ | id | bigint(20) unsigned | NO | PRI | NULL | auto_increment | | host | varchar(128) | YES | MUL | NULL | | | facility | varchar(10) | YES | MUL | NULL | | | priority | varchar(10) | YES | MUL | NULL | | | level | varchar(10) | YES | | NULL | | | tag | varchar(10) | YES | | NULL | | | datetime | datetime | YES | MUL | NULL | | | program | varchar(15) | YES | MUL | NULL | | | msg | text | YES | | NULL | | | seq | bigint(20) unsigned | NO | MUL | 0 | | | counter | int(11) | NO | | 1 | | | fo | datetime | YES | | NULL | | | lo | datetime | YES | | NULL | | +----------+---------------------+------+-----+---------+---------------- What is the problem? Thanks in advance for the help.
I figured out the problem. I have to use "host="127.0.0.1" to force it using TCP connection. I have tried "(host="localhost", port=("3306")" and it didn't work neither. I guess it is hard coded to use socket for localhost which seems reasonable. There is a related question on this. If I want to use socket connection, how can I specify the socket file? It is by default using "/var/run/mysqld/mysqld.sock" which is different than the one in RHEL. -----Original Message----- From: Arnold Wang <arnold.wang@inovis.com> To: syslog-ng@lists.balabit.hu Subject: Re: syslog-ng 3.0.1, open source edition, fails write to MySQL DB Date: Thu, 23 Apr 2009 13:06:55 -0700 After I posted to the list, first I did when I run into this problem, I enabled the debug and noticed the following error: Apr 23 15:58:15 alfnetengi01 syslog-ng[7826]: Error establishing SQL connection; type='mysql', host='localhost', port='', username='syslogadmin', database='syslog', error='2002: Can\'t connect to local MySQL server through socket \'/var/run/mysqld/mysqld.sock \' (2)' It appears to me it try to connect to MySQL using sock instead of TCP, as I original assumed. Is there a way to use TCP connection? I will play around as well. Thanks. -----Original Message----- From: Arnold Wang <arnold.wang@inovis.com> To: syslog-ng@lists.balabit.hu Subject: syslog-ng 3.0.1, open source edition, fails write to MySQL DB Date: Thu, 23 Apr 2009 12:35:07 -0700 I have installed syslog-ng 3.0.1, open source edition, binary package in RHEL 5.3 system. I'm having trouble to have it writing to MySQL DB using native driver. The current configuration file looks like: # Write the logs to MySQL DB destination dd_mysql { sql(type(mysql) host("localhost") username("syslogadmin") password("syslogadmin") database("syslog") table("logs") columns("host", "facility", "priority", "level", "tag", "datetime", "program", "msg", "seq") values("$HOST", "$FACILITY", "$PRIORITY", "$LEVEL", "$TAG", "$YEAR-$MONTH-$DAY $HOUR:$MIN:$SEC", "$PROGRAM", "$MSG", "$SEQ") indexes("seq")); # program("/usr/bin/mysql -usyslogadmin -psyslogadmin syslog" # template("INSERT INTO logs (host, facility, priority, level, tag, datetime, program, msg, seq) # VALUES ( '$HOST', '$FACILITY', '$PRIORITY', '$LEVEL', '$TAG', '$YEAR-$MONTH-$DAY $HOUR:$MIN:$SEC', '$PROGRAM', '$MSG', '$SEQ' );\n") # template-escape(yes)); }; It works if I use the program driver, as currently commented out. The table is configured as following, using the schema defined by php-syslog-ng 2.9.8m. +----------+---------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------+---------------------+------+-----+---------+----------------+ | id | bigint(20) unsigned | NO | PRI | NULL | auto_increment | | host | varchar(128) | YES | MUL | NULL | | | facility | varchar(10) | YES | MUL | NULL | | | priority | varchar(10) | YES | MUL | NULL | | | level | varchar(10) | YES | | NULL | | | tag | varchar(10) | YES | | NULL | | | datetime | datetime | YES | MUL | NULL | | | program | varchar(15) | YES | MUL | NULL | | | msg | text | YES | | NULL | | | seq | bigint(20) unsigned | NO | MUL | 0 | | | counter | int(11) | NO | | 1 | | | fo | datetime | YES | | NULL | | | lo | datetime | YES | | NULL | | +----------+---------------------+------+-----+---------+---------------- What is the problem? Thanks in advance for the help.
On Thu, 2009-04-23 at 21:01 +0000, Arnold Wang wrote:
I figured out the problem. I have to use "host="127.0.0.1" to force it using TCP connection. I have tried "(host="localhost", port=("3306")" and it didn't work neither. I guess it is hard coded to use socket for localhost which seems reasonable. There is a related question on this. If I want to use socket connection, how can I specify the socket file? It is by default using "/var/run/mysqld/mysqld.sock" which is different than the one in RHEL.
The binaries we supply use the libmysqlclient binaries copied from Debian, thus it uses the default UNIX domain socket from Debian, that might differ from RHEL. However you can override the path to the UNIX domain socket by setting the MYSQL_UNIX_PORT environment variable before starting syslog-ng. -- Bazsi
participants (3)
-
Arnold Wang
-
Balazs Scheidler
-
okapareeya@hotmail.com