syslog-ng msyql 设定

评论关闭

配置文件

source src {unix-dgram(“/dev/log”);internal();};
source net {udp();};
destination d_mysql           { pipe(“/tmp/mysql.pipe”
template(“INSERT INTO logs (host, facility,
priority, level, tag, date, time, program,
msg) VALUES ( ‘$HOST’, ‘$FACILITY’, ‘$PRIORITY’,
‘$LEVEL’, ‘$TAG’, ‘$YEAR-$MONTH-$DAY’,
‘$HOUR:$MIN:$SEC’, ‘$PROGRAM’, ‘$MSG’ );\n”)
template-escape(yes)); };
log {source(net);destination(d_mysql);};
log {source(net); destination(d_local); };

写入数据库的脚本

  1. #
  2. #
  3. #
  4. #!/bin/bash
  5. if [ -e /tmp/mysql.pipe ]
  6. then
  7. while [ -e /tmp/mysql.pipe ]
  8. do
  9. mysql -u root –password=Pingzi01# syslog < /tmp/mysql.pipe
  10. done
  11. else
  12. mkfifo /tmp/mysql.pipe
  13. fi

问题 /usr/bin/ld: cannot find -lmysqlclient

评论关闭

问题

/usr/bin/ld: cannot find -lmysqlclient

collect2: ld returned 1 exit status
make: *** [sqlsyslogd] Error 1
解决办法
find / -name libmysqlclient.so
/usr/lib64/mysql/libmysqlclient.so
ln -s  /usr/lib64/mysql /usr/local/lib/