LogAnalyzer是一款使用率较高的日志服务器,在遇到非法***或故障排查,当然还有责任划分(公司内互扯的事太多了)的时候尤为显得重要,所以公司内部使用一台日志服务器是一件很有必要的事情。
系统环境
CentOS 6.5 x86_64 版本安装
loganalyzer4.1.1搭建过程:
(在安装loganalyzer最新版本第三步空白过不去,日志说是PHP没有调用到某个函数,好像PHP5.5以后支持了,但安装了5.5以后的版本了还是空白过不去,网上百度了很多没有解决这个问题,loganalyzer4.1.1没有这个问题)
一、安装并设置LAMP环境
1、安装LAMP环境
一、MysqL数据库安装
1. 基础软件包安装
- #yuminstallgccmake-y
2. 下载
3. 解压安装
- #useradd-s/sbin/nologin-MMysqL
5. 准备数据目录
6. 初始化数据库
7. 拷贝配置文件
- #/bin/cpsupport-files/my-xxxx.cnf/etc/my.cnf
8. 拷贝启动脚本
9. 修改启动脚本
11. 启动MysqL服务
12. 查看验证MysqL启动进程
13. 配置MysqL环境变量
将 MysqL 客户端命令路径加入 PATH 环境变量中去。
二、Apache服务安装
apache可以通过yum的方式来安装,也可以通过源码编译的方式来安装,这里采用编译源码的方式进行安装。
1. 下载解压apache安装包
- #cd/usr/local/src
- #tar-xfhttpd-2.4.29.tar.bz2
2. 安装必要的库和工具
- #yuminstall-ypcrepcre-develaprapr-develzlib-develgccmake
- #wgethttp://archive.apache.org/dist/apr/apr-1.5.0.tar.gz
- #wgethttp://archive.apache.org/dist/apr/apr-util-1.5.4.tar.gz
- #tar-xfapr-1.5.0.tar.gz
- #tar-xfapr-util-1.5.4.tar.gz
- #cdapr-1.5.0
- #./configure--prefix=/usr/local/apr/
- #make&&makeinstall
- #cd
- #cdapr-util-1.5.4
- #./configure--prefix=/usr/local/apr-util/--with-apr=/usr/local/apr/
- #make&&makeinstall
- #cd
- #wgethttp://jaist.dl.sourceforge.net/project/pcre/pcre/8.39/pcre-8.39.tar.gz
- #tar-xfpcre-8.39.tar.gz
- #cdpcre-8.39
- #yum-yinstallgccgcc-c++cmake
- #./configure--prefix=/usr/local/pcre/
- #make&&makeinstall
3. 配置编译参数
- #cdhttpd-2.4.29
- #./configure--prefix=/usr/local/apache2--with-apr=/usr/local/apr/--with-apr-util=/usr/local/apr-util/--with-pcre=/usr/local/pcre/
4. 编译安装
- #make&&makeinstall
- #echo$?
5. 配置apache环境变量
- #echo'exportPATH=$PATH:/usr/local/apache2/bin'>/etc/profile.d/http.sh
- #source/etc/profile.d/http.sh
6. apache的启动和停止
- apachectl start # 启动
apachectl stop # 停止
apachectl restart # 重启
apachectl -t # 检查语法
apachectl -M # 查看加载模块
7. 将apache加入系统服务
- #添加到系统服务并设置开机启动
- #chkconfig--addhttpd
- #chkconfighttpdon
8. 验证服务是否正常
- #servicehttpdstarthttpd:apr_sockaddr_info_get()Failedforvip
- #出现警告信息
- httpd:Couldnotreliablydeterminetheserver'sfullyqualifieddomainname,using127.0.0.1forServerName
解决警告信息的方法:去掉ServerName www.example.com:80 行的注释#。
三、PHP系统安装
1. 下载解压安装包
- #cd
- #tar-xfPHP-5.6.33.tar.bz2
2. 下载依赖库和工具
- # yum install -y libxml2-devel openssl openssl-devel bzip2 bzip2-devel libjpeg-devel
# yum -y install libpng libpng-devel freetype freetype-devel libmcrypt-devel
# yum install gcc bison bison-devel zlib-devel libmcrypt-devel mcrypt mhash-devel perl
3. 编译配置安装选项
- #cdPHP-5.6.33
- #./configure--prefix=/usr/local/PHP--with-apxs2=/usr/local/apache2/bin/apxs--with-config-file-path=/usr/local/PHP/etc\
- #--with-MysqL=/usr/local/MysqL--with-libxml-dir--with-gd--with-jpeg-dir--with-png-dir--with-freetype-dir--with-iconv-dir--with-zlib-dir\
- #--with-bz2--with-openssl--with-mcrypt--enable-soap--enable-gd-native-ttf--enable-mbstring--enable-sockets--enable-exif--disable-ipv6--enable-fpm
6. 配置PHP环境变量
到此为止,PHP完成基本的编译安装,后续解析PHP还得另外配置。
四、配置支持PHP解析
vi /usr/local/apache2/conf/httpd.conf
- <Directory/>
- OptionsFollowSymLinks
- AllowOverrideNone
- Orderdeny,allow
- Allowfromall#Deny修改为Allow</Directory>
4. 测试配置语法和重启apache服务
- #apachectl-t
- SyntaxOK
- #servicehttpdrestart
5. 测试PHP解析
编写测试文件:/usr/local/apache2/htdocs/index.PHP
命令行curl测试:
解析 PHP 成功!
2、基础装好了下面就是准备数据
检查并安装服务器端软件
1.检查是否安装rsyslog软件
- #rpm-qa|greprsyslog//默认系统都安装了该软件
注: rsyslog-MysqL 为rsyslog 将日志传送到MysqL 数据库的一个模块,这里必须安装
2、配置服务器端
3、查看做了哪些操作
MysqL> use Syslog;
MysqL> show tables;
导入数据库操作创建了Syslog 库并在该库中创建了两张空表SystemEvents 和SystemEventsProperties
2、配置服务端支持rsyslog-MysqL 模块,并开启UDP服务端口获取网内其他LINUX系统日志
注:localhost 表示本地主机,Syslog 为数据库名,rsyslog 为数据库的用户,123456为该用户密码
3、开启相关日志模块
- 重启rsyslog服务
- #servicersyslogrestart
4、配置客户端
- a、检查rsyslog是否安装
- #rpm-qa|greprsyslog
- b、配置rsyslog客户端发送本地日志到服务端
- #vim/etc/rsyslog.conf
- *.*@192.168.131.130
注:行尾新增上面这行内容,即客户端将本地日志发送到服务器
5、测试Rsyslog Server是否可以正常接受Client端日志
Client端测试
Server端侦测
注:说明接收正常,包括你重启机器的一些Log都可以查看到
3、最后安装LogAnalyzer
安装LogAnalyzer
- #yum-yinstallwget
- #wget
- #tarxfloganalyzer-4.1.1.tar.gz
- #cdloganalyzer-4.1.1
- #mkdir/usr/local/apache2/htdocs/loganalyzer
- #cp-rsrc/*/usr/local/apache2/htdocs/loganalyzer/
- #cpcontrib/*/usr/local/apache2/htdocs/loganalyzer/
- #cd/usr/local/apache2/htdocs/loganalyzer/
- #chmod+xconfigure.shsecure.sh
- #./configure.sh
- #./secure.sh
- #chmod666config.PHP
- #cd..
- #chown-Rdaemon:daemonloganalyzer/
- #servicehttpdrestart
- #servicersyslogrestart
2、在浏览器安装向导中安装LogAnalyzer
打开浏览器输入:http://xxxx/loganalyzer/
测试系统环境
点击"next",进入下一步
基础配置
在User Database Options 中,填入上面设置的参数,然后点击 "Next".
创建表
点击 Next 开始创建表
检查sql结果
创建管理用户
创建第一个系统日志source
完成
测试
LogAnalyzer 首页
点击"Statistics"
登录测试
点击"Admin Center"在Admin Center 里可以进行一些系统设置
本文转载参考: