rsyslog的mysql的helloworld
Mysql  /  houtizong 发布于 3年前   373
mysql-5.1.49.tar.gz../configure \--prefix=/usr/local/mysql \--localstatedir=/data \--sysconfdir=/usr/local/mysql \--with-unix-socket-path=/tmp/mysql.sock \--with-charset=utf8 \--with-collation=utf8_general_ci \--with-extra-charsets=gbk,latin1 \--with-plugins=partition,blackhole,heap,innobase,myisam,ndbcluster,csv,federated \--without-debug \--enable-thread-safe-client \--enable-assembler \--enable-profiling \--with-mysqld-ldflags=-all-static \--with-client-ldflags=-all-static \--with-mysqld-user=mysql \--without-embedded-server \--with-server-suffix=-community \--with-tcp-port=3306 \#--with-named-curses-libs=/usr/lib/libncurses.so.5.5make make installmkdir /usr/local/mysqlmkdir /datauseradd mysql./mysql_install_db --basedir=/mysql --datadir=/data/ --user=mysqlchown -R root:mysql /usr/local/mysqlchown -R mysql:mysql /dataln -sf /mysql/bin/mysqladmin /sbin/mysqladminln -sf /mysql/bin/mysql /sbin/mysqlcp /mysql/share/mysql/my-large.cnf /mysql/my.cnf[mysqld]下面添加datadir=/datalog-error=/data/mysql.errfederatedndbcluster./mysqld_safe --user=mysql &#ln -s /mysql /usr/local/mysql#ln -s /tmp/mysql.sock /mysql/mysql.sockmysql或mysql --sock=/tmp/mysql.sockcp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqldchkconfig --add mysqldchkconfig --level 35 mysqld onchkconfig --list mysqldservice mysqld startservice mysqld stop改密码mysqladmin -uroot password "haoning" --sock=/tmp/mysql.sockroot@red54apple backup]# ps -ef|grep mysqlroot 4079 1 0 16:42 pts/2 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data --pid-file=/data/red54apple.pidmysql 4260 4079 0 16:42 pts/2 00:00:00 /usr/local/mysql/libexec/mysqld --basedir=/usr/local/mysql --datadir=/data --user=mysql --log-error=/data/mysql.err --pid-file=/data/red54apple.pid --socket=/tmp/mysql.sock --port=3306root 4296 16425 0 16:45 pts/2 00:00:00 grep mysql[root@red54apple backup]---------------------------------------http://www.cublog.cn/u2/76419/showart_1783316.html--------------/configure --enable-mysql最好是/configure --prefix=/usr/local/rsyslog --enable-mysqlmakemake installcp rsyslog.conf /etc/打开注释# UDP Syslog Server:#$ModLoad imudp.so # provides UDP syslog reception#$UDPServerRun 514 # start a UDP syslog server at standard port 514mysqlsource /opt/backup/rsyslog-6.1.0/plugins/ommysql/createDB.sql之后加载mysql模块,当然你一定要确认ommysql.so在lib文件夹里存在,如果你之前使用./configure --enable-mysql进行配置则会在/usr/local/lib/rsyslog下存在ommysql.so文件(操作系统不同,目录可能不一样),然后在rsyslog.conf文件中加上:$ModLoad ommysql#local4.* :ommysql:127.0.0.1,yourdb,yourname,yourpass;local4.* :ommysql:127.0.0.1,Syslog,root,haoning;修改etc/init.d/syslog:-----------[root@red54apple ommysql]# cat /etc/init.d/syslog#!/bin/bash## syslog Starts syslogd/klogd.### chkconfig: 2345 12 88# description: Syslog is the facility by which many daemons use to log \# messages to various system log files. It is a good idea to always \# run syslog.### BEGIN INIT INFO# Provides: $syslog### END INIT INFO# Source function library.. /etc/init.d/functions[ -f /usr/local/sbin/rsyslogd ] || exit 0[ -f /sbin/klogd ] || exit 0RETVAL=0start() { echo -n $"Starting rsyslog: " /usr/local/sbin/rsyslogd RETVAL=$? echo echo -n $"Starting kernel logger: " daemon klogd $KLOGD_OPTIONS echo [ $RETVAL -eq 0 ] && touch /var/lock/subsys/rsyslog return $RETVAL}stop() { echo -n $"Shutting down kernel logger: " killproc klogd echo echo -n $"Shutting down system rsyslog: " killproc rsyslogd RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/rsyslog return $RETVAL}rhstatus() { status rsyslogd status klogd}restart() { stop start}case "$1" in start) start ;; stop) stop ;; status) rhstatus ;; restart) restart ;; reload) reload ;; condrestart) [ -f /var/lock/subsys/rsyslog ] && restart || : ;; *) echo $"Usage: $0 {start|stop|status|restart|condrestart}" exit 2esacexit $?---------------------------------------rsyslog.conf:# UDP Syslog Server:$ModLoad imudp.so # provides UDP syslog reception$UDPServerRun 514 # start a UDP syslog server at standard port 514# MySQL log$ModLoad ommysql$template MySQLInsert,"insert into SystemEvents( ReceivedAt,DeviceReportedTime,message,FromHost,syslogtag) values('%timegenerated:::date-mysql%','%timereported:::date-mysql%','%msg%','%fromhost-ip%','%syslogtag%')", SQLlocal4.* :ommysql:127.0.0.1,syslogdatabase,syslogusername,syslogpass;MySQLInsert--------------------------------202----------------------------[@zjm_106_202 ~]# cat /etc/rsyslog.conf$ModLoad imudp.so$ModLoad ommysql.so$UDPServerRun 514:syslogtag, !contains, "#CMS5" /opt/log/all.log:syslogtag, contains, "#CMS5" /opt/log/cms5.log:syslogtag, contains, "#CMS5.CAS" /opt/log/cas.log:syslogtag, contains, "#CMS5.CAS" :ommysql:localhost,CasSyslog,syslog,sysloglocal6.* /opt/log/audit.loglocal6.* :ommysql:localhost,Syslog,syslog,syslog# Log all kernel messages to the console.# Logging much else clutters up the screen.#kern.* /dev/console# Log anything (except mail) of level info or higher.# Don't log private authentication messages!*.info;mail.none;authpriv.none;cron.none /opt/log/messages# The authpriv file has restricted access.authpriv.* /var/log/secure# Log all the mail messages in one place.mail.* -/var/log/maillog# Log cron stuffcron.* /var/log/cron# Everybody gets emergency messages*.emerg *# Save news errors of level crit and higher in a special file.uucp,news.crit /var/log/spooler# Save boot messages also to boot.loglocal7.* /var/log/boot.log[@zjm_106_202 ~]# -------------------------------------------------------/usr/local/sbin/rsyslogd -c5如果报错,看清楚,可能是安装的时候没指定安装路径,直接装到/usr/local/lib下面了,找不到so动态库了可以建立ln -s /usr/local/lib /usr/local/rsyslog/lib解决
import org.slf4j.Logger;import org.slf4j.LoggerFactory;public class TestLog {private static final Logger logger = LoggerFactory.getLogger(TestLog.class);public static void main(String[] args) {logger.info("test haoning");}}
log4j.rootLogger=INFO,CONSOLE,SYSLOG#log4j.rootLogger=INFO,SYSLOG,CONSOLE,DAILY_ROLLING_FILElog4j.addivity.org.apache=truelog4j.debug=false#################### Console Appender###################log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppenderlog4j.appender.CONSOLE.Target=System.outlog4j.appender.CONSOLE.Threshold=DEBUGlog4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayoutlog4j.appender.CONSOLE.layout.ConversionPattern=[%-5p] %d{yyyy-MM-dd HH:mm:ss} %l %m%n######################### RSYSLOG########################app.name=#CMS5.SERVERlog4j.appender.SYSLOG=org.apache.log4j.net.SyslogAppenderlog4j.appender.SYSLOG.SyslogHost= 10.10.10.10log4j.appender.SYSLOG.Facility=local5log4j.appender.SYSLOG.Threshold=INFOlog4j.appender.SYSLOG.layout=org.apache.log4j.PatternLayoutlog4j.appender.SYSLOG.layout.ConversionPattern=${app.name} %d{yyyy-MM-dd HH:mm:ss} %c:%L %m%n
请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!
技术博客集 - 网站简介:
前后端技术:
后端基于Hyperf2.1框架开发,前端使用Bootstrap可视化布局系统生成
网站主要作用:
1.编程技术分享及讨论交流,内置聊天系统;
2.测试交流框架问题,比如:Hyperf、Laravel、TP、beego;
3.本站数据是基于大数据采集等爬虫技术为基础助力分享知识,如有侵权请发邮件到站长邮箱,站长会尽快处理;
4.站长邮箱:[email protected];
文章归档
文章标签
友情链接