Rsyslog +loganalyzer日志服务器搭建

服务器端的安装:

为了防止安装错误,需先设置环境变量以及安装所需的几个软件包

1.配置环境变量

[root@zhu3 ~]# echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
[root@zhu3 ~]# export PATH=/opt/mysql/bin/:$PATH
[root@zhu3 ~]# echo $PATH
/opt/mysql/bin/:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

2.安装libestr软件包

wget http://libestr.adiscon.com/files/download/libestr-0.1.5.tar.gz
tar zxvf libestr-0.1.5.tar.gz
cd libestr-0.1.5
./configure
make && make install

3.安装json软件包

wget https://github.com/json-c/json-c/archive/json-c-0.11-20130402.tar.gz --no-check-certificate
tar zxvf json-c-0.11-20130402
cd json-c-json-c-0.11-20130402/
./configure
make && make install

4.安装python-docutils软件包

wget https://pypi.python.org/packages/source/d/docutils/docutils-0.11.tar.gz --no-check-certificate
tar zxvf docutils-0.11.tar.gz
cd docutils-0.11
python setup.py install
#安装之发现在/usr/bin目录下仍没有rst2man文件,
[root@zhu2 ~]# ll /usr/bin/ | grep rst
-rwxr-xr-x 1 root root        593 09-10 17:19 rst2html.py
-rwxr-xr-x 1 root root        790 09-10 17:19 rst2latex.py
-rwxr-xr-x 1 root root        599 09-10 17:19 rst2man.py
-rwxr-xr-x 1 root root       1697 09-10 17:19 rst2odt_prepstyles.py
-rwxr-xr-x 1 root root        763 09-10 17:19 rst2odt.py
-rwxr-xr-x 1 root root        600 09-10 17:19 rst2pseudoxml.py
-rwxr-xr-x 1 root root        636 09-10 17:19 rst2s5.py
-rwxr-xr-x 1 root root        785 09-10 17:19 rst2xetex.py
-rwxr-xr-x 1 root root        601 09-10 17:19 rst2xml.py
-rwxr-xr-x 1 root root        669 09-10 17:19 rstpep2html.py

此时需建立个软连接

[root@zhu2 ~]# ln -s /usr/bin/rst2man.py /usr/bin/rst2man
[root@zhu2 ~]# ll /usr/bin/rst2man
lrwxrwxrwx 1 root root 19 09-10 17:21 /usr/bin/rst2man -> /usr/bin/rst2man.py

5.安装uuid有关的软件

yum -y install uuid uuid-devel libuuid libuuid-devel

自此安装rsyslog所需的包已经全部安装完成

6.安装rsyslog软件

[root@zhu2 ~]# wget http://www.rsyslog.com/files/download/rsyslog/rsyslog-7.4.3.tar.gz
[root@zhu2 ~]# tar zxvf rsyslog-7.4.3.tar.gz
[root@zhu2 ~]# cd rsyslog-7.4.3
[root@zhu2 ~]# ./configure --prefix=/opt/rsyslog --enable-mysql PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/

7.导入数据库

[root@zhu2 ~]# cd rsyslog-7.4.3/plugins/ommysql/
[root@zhu2 ommysql]# ll
总计 56
drwxrwxr-x 2 1000 1000  4096 07-18 22:47 contrib
-rw-rw-r-- 1 1000 1000  1046 2012-04-04 createDB.sql
-rw-rw-r-- 1 1000 1000   274 2012-04-04 Makefile.am
-rw-rw-r-- 1 1000 1000 21324 07-18 22:44 Makefile.in
-rw-rw-r-- 1 1000 1000 15563 07-15 15:45 ommysql.c
-rw-rw-r-- 1 1000 1000  1080 2012-04-04 ommysql.h
[root@zhu2 ommysql]# mysql -uroot -p123456 < createDB.sql

8.修改配置文件,使支持mysql数据库

vim /etc/rsyslog.conf  #添加下面两行
$ModLoad ommysql
*.* :ommysql:localhost,Syslog,root,123456
#取消下面几行前面的注释
$ModLoad imuxsock
$ModLoad imklog
$ModLoad immark$ModLoad imudp
$UDPServerRun 514
$ModLoad imtcp
$InputTCPServerRun 514

9.设置rsyslogd启动脚本

cp -rf /etc/init.d/syslog /etc/init.d/rsyslogd
sed -i 's/syslog/rsyslog/g' /etc/init.d/rsyslogd
ln -s /opt/rsyslog/sbin/rsyslogd /sbin/rsyslogd

10.安装loganalyzer-3.6.3.tar.gz

[root@zhu2~]#wgethttp://download.adiscon.com/loganalyzer/loganalyzer-3.6.3.tar.gz

[root@zhu2 ~]# wget http://download.adiscon.com/loganalyzer/loganalyzer-3.6.3.tar.gz
[root@zhu2 ~]# tar zxvf loganalyzer-3.6.3.tar.gz
[root@zhu2 ~]# cd loganalyzer-3.6.3
[root@zhu2 loganalyzer-3.6.3]#
[root@zhu2 loganalyzer-3.6.3]# mkdir /opt/nginx/html/rsyslog
[root@zhu2 loganalyzer-3.6.3]# mv src/* /opt/nginx/html/rsyslog/
[root@zhu2 loganalyzer-3.6.3]# mv contrib/* /opt/nginx/html/rsyslog/
[root@zhu2 loganalyzer-3.6.3]# chmod +x /opt/nginx/html/rsyslog/*.sh
[root@zhu2 loganalyzer-3.6.3]# cd /opt/nginx/html/rsyslog
[root@zhu2 rsyslog]# ./configure.sh
[root@zhu2 rsyslog]# ./secure.sh
[root@zhu2 rsyslog]# chmod 666 config.php
[root@zhu2 rsyslog]# chown -R www.www *

11.

在浏览器输入:http://ip/syslog根据提示安装安装截图如下:

110457522.png

110500371.png

110502742.png

110504599.png

110507793.png

110509619.png

110511872.png

110514713.png

110516973.png

110519713.png

110521269.png

110524279.png

110527853.png

客户端的配置:

直接利用系统自带的syslog软件,修改其配置文件

/etc/syslog.conf

在最后加上

*.*@服务端ip地址

你可能感兴趣的:(mysql,服务器,local,Export,软件包)