服务端的安装
YUM源新建
# cat >> /etc/yum.repos.d/sohu.repo <<EOF
[sohu]
name=sohu's mirrors
baseurl=http://mirrors.sohu.com/centos/5/os/x86_64/
enabled=1
gpgcheck=0
EOF
安装LAMP环境及rsyslog,如果有LAMP,只需要安装rsyslog rsyslog-mysql即可
yum install rsyslog rsyslog-mysql mysql mysql-devel mysql-server php php-mysql php-pdo php-common php-gd httpd
导入rsyslog数据库
mysql -u root -p < $(rpm -ql rsyslog-mysql | grep sql$)
创建数据库用户
mysql -u root -p
mysql> grant all privileges on Syslog.* to logger@localhost identified by 'logger';
mysql> flush privileges;
mysql> exit;
修改rsyslog的配置文件
# vi /etc/rsyslog.conf //修改一下即可
# Use traditional timestamp format
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
# Provides kernel logging support (previously done by rklogd)
# Provides support for local system logging (e.g. via logger command)
$ModLoad immark
$ModLoad imuxsock
$ModLoad imklog
$ModLoad ommysql
*.* :ommysql:127.0.0.1,Syslog,logger,logger
$ModLoad imudp.so
$UDPServerRun 514
# 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 /var/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 stuff
cron.* /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.log
local7.* /var/log/boot.log
红色部分是添加的,其它的对比一下,有的就略过,没的就添加一下吧。
安装LogAnalyzer
# wget http://download.adiscon.com/loganalyzer/loganalyzer-3.6.3.tar.gz
# tar xf loganalyzer-3.6.3.tar.gz
# mkdir /var/www/html/loganalyzer
# mv loganalyzer-3.6.3/src/* /var/www/html/loganalyze
# touch /var/www/html/loganalyzer/config.php
# chmod 666 /var/www/html/loganalyzer/config.php
通过浏览器安装即可
http://ip地址/loganalyzer/install.php
具体按步骤一步一步点下去,基本就安装完了
这里说2个注意点,在这里我可是耗了好长时间:
在按步骤一步步点下去的时候,一定要主要Syslog数据库的表名称为:SystemEvents,在这里我刚开始没注意到,所以走了很多弯路。
登陆查看
http://ip地址/loganalyzer
linux客户端部署:
vim /etc/syslog.conf
在最后面添加:user.* @192.168.2.39
保存退出,重启syslog服务
service syslog restart
测试命令:logger "test" "123"
在日志服务器上的配置文件里可把user的日志指定保存位置.
Windows客户端安装
下载evtsys http://code.google.com/p/eventlog-to-syslog/
解压缩放到 C:\Windows\System32
evtsys -i -s 10 -h log-server-ip -p 514
net start evtsys
在安装的时候,会报一个错误,是配置文件的问题,可以忽略不用管,只要看到最后的安装成功即可。