1、部署分离的LAMP,部署到二台服务器上,php加载xcache模块
基础知识
什么是LAMP?
即linux操作系统下的apache(httpd)+MySQL或者mariadb并且可以运行php,per,python等代码,我们这里的LAMP指的是linux+apache(httpd)+(Mysql)Mariadb+php;
httpd与php的结合方式
一种方式是:php以模块的形式集成在apache当中,让apache具有了处理php程序的能力;其只需要安装php包即可;
yum install httpd php-mysql php
#生产场景不常用,但是可以实现快速部署
一种方式是:php与apache直接以fastcgi协议进行通信,apache,php,是二个不同的软件来运行,并监听在不同的端口之上;其需要安装php-fpm包;这种结合方式其效率更高,也是生产场景中使用的结合方式;
实现LAMP的方式
快速部署:yum安装的方式,简单快速
编译部署:运行新的php程序代码需要比较新的环境,就需要编译部署
LAMP的分离方式
常用的分离方式:apache--->fascgi--->php做为一台服务器,数据库单独一台服务器部署
当然也可以apache,php,数据库都单独一台服务器部署,这里不常用
关于Xcache?
php的加速器:基于PHP的特殊扩展机制如opcode缓存扩展也可以将opcode缓存于php的共享内存中,从而可以让同一段代码的后续重复执行时跳过编译阶段以提高性能。这些加速器并非真正提高了opcode的运行速度,而仅是通过分析opcode后并将它们重新排列以达到快速执行的目的;
XCache就是其中一中php的缓存加速器,XCache快速而且稳定的PHP opcode缓存,经过严格测试且被大量用于生产环境。项目地址:http://xcache.lighttpd.net/,收录EPEL源 ;其官网的XCache3.2只能支持php5.X,也没有新的更新了,而新的PHP7.X其本身自带加速模块,XCache3.2加速器已经成为历史。
所以下面的部署,以yum安装方式来部署LAMP,并且演示Xcache的加速效果;
部署过程
1. 主机规划
主机IP | 主机用途 |
---|---|
192.168.37.7 | web服务器(apache-->fastcgi-->php) |
192.168.37.17 | 数据库服务器(mariadb)主机规划 |
2. web服务器的安装配置过程
#yum安装所需包组
#php-mysql也是模块,用来连接数据库
[root@37-7-test1 ~]# yum install httpd php-mysql php-fpm -y
Installing:
httpd x86_64 2.4.6-93.el7.centos base 2.7 M
php-fpm x86_64 5.4.16-48.el7 base 1.4 M
php-mysql x86_64 5.4.16-48.el7 base 102 k
Installing for dependencies:
httpd-tools x86_64 2.4.6-93.el7.centos base 92 k
libzip x86_64 0.10.1-8.el7 base 48 k
mailcap noarch 2.1.41-2.el7 base 31 k
php-common x86_64 5.4.16-48.el7 base 565 k
php-pdo x86_64 5.4.16-48.el7 base 99 k
Updating for dependencies:
openssl x86_64 1:1.0.2k-19.el7 base 493 k
openssl-libs x86_64 1:1.0.2k-19.el7 base 1.2 M
Installed:
httpd.x86_64 0:2.4.6-93.el7.centos php-fpm.x86_64 0:5.4.16-48.el7
php-mysql.x86_64 0:5.4.16-48.el7
Dependency Installed:
httpd-tools.x86_64 0:2.4.6-93.el7.centos libzip.x86_64 0:0.10.1-8.el7
mailcap.noarch 0:2.1.41-2.el7 php-common.x86_64 0:5.4.16-48.el7
php-pdo.x86_64 0:5.4.16-48.el7
Dependency Updated:
openssl.x86_64 1:1.0.2k-19.el7 openssl-libs.x86_64 1:1.0.2k-19.el7
Complete!
-----------------------------------------------------
-----------------------------------------------------
#配置httpd的配置文件遇到php结尾的文件,交由php处理
#这种httpd和php-fpm在同一台机器上,也可以使用套接字文件进行通信,就不会开启9000端口
#如果将httpd和php-fpm分别部署在不同机器上,就只能基于这种套接字的通信方式
#通信方式1和通信方式2可以任选一个,这里选通信方式2,因为其都在一台服务器上
#此种方式效率高
-----------------------------------------------------
#通信方式1 socket的配置
[root@37-7-test1 ~]# vim /etc/httpd/conf.d/fcgi.conf
DirectoryIndex index.php
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/var/www/html/$1
------------------------------------------------------------------
#通信方式2 UDS方式即套接字文件
#通信双方在本地打开一个文件,进行通信
vim /etc/httpd/conf.d/uds.conf
ProxyRequests off
ProxyPassMatch "^/(.*\.php)$" "unix:/var/run/php.sock|fcgi://localhost/var/www/html/$1"
#还需修改监听端口变成监听文件
[root@37-7-test1 conf.d]# vim /etc/php-fpm.d/www.conf
; Start a new pool named 'www'.
[www]
; The address on which to accept FastCGI requests.
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses on a
; specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
;listen = 127.0.0.1:9000
#主要修改此将监听在端口上改成一个文件
listen = /var/run/php.sock
-----------------------------------------------------
-----------------------------------------------------
#创建一个php测试网页调用phpinfo()
[root@37-7-test1 ~]# cd /var/www/html/
[root@37-7-test1 html]# ls
[root@37-7-test1 html]# vim index.php
#开启httpd服务,和php-fpm服务
[root@37-7-test1 html]# systemctl start httpd
[root@37-7-test1 html]# systemctl start php-fpm
[root@37-7-test1 html]# ss -tnl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 *:51966 *:*
LISTEN 0 128 *:111 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 128 :::111 :::*
LISTEN 0 128 :::80 :::*
LISTEN 0 128 :::34352 :::*
LISTEN 0 128 :::22 :::*
[root@37-7-test1 html]#
#测试php程序是否可以运行
如上页面打开就说明httpd与php的结合方式已经可以了;下面部署数据库服务器
3. 数据库服务器的安装与配置
[root@37-17-test2 ~]# yum install mariadb-server -y
Loaded plugins: fastestmirror, langpacks
base ..... Installed:
mariadb-server.x86_64 1:5.5.65-1.el7
Dependency Installed:
mariadb.x86_64 1:5.5.65-1.el7
perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7
perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7
perl-DBD-MySQL.x86_64 0:4.023-6.el7
perl-DBI.x86_64 0:1.627-4.el7
perl-IO-Compress.noarch 0:2.061-2.el7
perl-Net-Daemon.noarch 0:0.48-5.el7
perl-PlRPC.noarch 0:0.2020-14.el7
Dependency Updated:
mariadb-libs.x86_64 1:5.5.65-1.el7
Complete!
#启动数据库并创建测试数据库
[root@37-17-test2 ~]# systemctl start mariadb
[root@37-17-test2 ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.65-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
#创建测试数据库
MariaDB [(none)]> create database testdb;
Query OK, 1 row affected (0.00 sec)
#授权用户方便测试
MariaDB [(none)]> grant all privileges on testdb.* to testuser@'192.168.37.%' identified by 'centos';
Query OK, 0 rows affected (0.00 sec)
在web服务器上编写php测试代码,连接192.168.37.17数据库服务器,查看所有环境是否准备好;
[root@37-7-test1 html]# vim test.php
close();
?>
#测试浏览器显示OK即可
4. 部署wordpress个人博客来测试php的性能
1. 数据库创建
#创建wpdb数据库,并授权用户,以便安装wordpress
MariaDB [(none)]> create database wpdb;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> use wpdb;
Database changed
MariaDB [wpdb]> grant all on wpdb.* to wpuser@'192.168.37.%' identified by 'centos';
Query OK, 0 rows affected (0.00 sec)
MariaDB [wpdb]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
#测试与数据库的连接
[root@master-mariadb html]# mysql -uwpuser -pcentos -h192.168.37.17
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.65-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| test |
| wpdb |
+--------------------+
3 rows in set (0.00 sec)
2. 安装wordpress
[root@37-7-test1 data]# rz
rz waiting to receive.
zmodem trl+C ȡ
100% 10838 KB 10838 KB/s 00:00:01 0 Errorsar.gz...
[root@37-7-test1 data]# ls
#以5.0.3wordpress为例
wordpress-5.0.3-zh_CN.tar.gz xcache-3.2.0 xcache-3.2.0.tar.gz
#直接解压至站点wordpress子目录,yum安装默认站点目录是/var/www/html/可以在配置文件中修改
#centos7修改站点目录,还需要配合授权语句授权目录权限
[root@37-7-test1 data]# tar xvf wordpress-5.0.3-zh_CN.tar.gz -C /var/www/html/
wordpress/
wordpress/wp-login.php
wordpress/wp-cron.php
wordpress/xmlrpc.php
wordpress/wp-load.php
wordpress/wp-admin/
wordpress/wp-admin/credits.php
wordpress/wp-admin/admin-functions.php
wordpress/wp-admin/options-reading.php
wordpress/wp-admin/edit-tags.php
wordpress/wp-admin/link-manager.php
wordpress/wp-admin/options-writing.php
wordpress/wp-admin/network.php
#修改wordpress的配置文件,这里可以直接修改配置文件,也可以根据网页提示信息一步一步安装
[root@37-7-test1 wordpress]# cp wp-config-sample.php wp-config.php
[root@37-7-test1 wordpress]# vim wp-config.php
// ** MySQL 设置 - 具体信息来自您正在使用的主机 ** //
/** WordPress数据库的名称 */
define('DB_NAME', 'wpdb');
/** MySQL数据库用户名 */
define('DB_USER', 'wpuser');
/** MySQL数据库密码 */
define('DB_PASSWORD', 'centos');
/** MySQL主机 */
define('DB_HOST', '192.168.37.17');
3. 网页初始化
配置好以后,打开浏览器输入http://192.168.37.7/wordpress,进行初始化即可,即填写一个信息,并自动生成数据库当中的表等内容;
一个个人博客网站就搭建好了,有了它,我们来测试缓存加速器的作用,使用ab工具来测试当前网站的效率。
[root@37-27-test3 ~]# ab -c10 -n 100
Requests per second: 5.24 [#/sec] (mean)
#每秒钟响应5次请求
#可以多测几次取平均值
Requests per second: 5.21 [#/sec] (mean)
Requests per second: 5.23 [#/sec] (mean)
5. 源码安装php-xcache
[root@37-27-test3 ~]# rpm -qi php
Name : php
Version : 5.4.16
#xcache可以对php5.X进行加速,不支持更高版本
[root@37-7-test1 html]# rz
rz waiting to receive.
zmodem trl+C ȡ
100% 169 KB 169 KB/s 00:00:01 0 Errors
[root@37-7-test1 data]# ls
#官网已经不存在了,可以去github下载
xcache-3.2.0.tar.gz
[root@37-7-test1 data]# tar xvf xcache-3.2.0.tar.gz
#解压
xcache-3.2.0/
xcache-3.2.0/AUTHORS
xcache-3.2.0/bin/
xcache-3.2.0/bin/phpdc.phpr
#使用phpize生成configure,需要安装php-devel包
[root@37-7-test1 xcache-3.2.0]# yum install php-devel -y
....
Complete!
[root@37-7-test1 xcache-3.2.0]# phpize --clean && phpize
Cleaning..
Configuring for:
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525
#开启xcache
[root@37-7-test1 xcache-3.2.0]# ./configure --enable-xcache
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
[root@37-7-test1 xcache-3.2.0]# make && make install
Build complete.
Don't forget to run 'make test'.
Installing shared extensions: /usr/lib64/php/modules/
#拷贝配置文件xcache.ini到php-fpm的启动配置端,从其php-fpm
[root@37-7-test1 xcache-3.2.0]# cp xcache.ini /etc/php.d/
[root@37-7-test1 xcache-3.2.0]# cd /etc/php.d/
[root@37-7-test1 php.d]# systemctl restart php-fpm
#测试速度
[root@37-27-test3 data]# ab -c10 -n 100
Requests per second: 12.74 [#/sec] (mean)
#每秒12个处理请求明显提升
#如何关闭加速
#在/etc/php.d/xcache.ini里注释掉;extension = xcache.so然后重启服务
2、部署论坛,并实现正常访问登录论坛。
论坛比较著名的php源码程序,就是discuz,可以去官网下载所需版本;
1. 192.168.37.7的准备
#下载utf8版本,上传至服务器,并解压,拷贝至站点相对应子目录
[root@37-7-test1 html]# rz
rz waiting to receive.
zmodem trl+C ȡ
100% 10666 KB 10666 KB/s 00:00:01 0 Errors...
[root@37-7-test1 html]# unzip Discuz_X3.3_SC_UTF8.zip -d discuz
Archive: Discuz_X3.3_SC_UTF8.zip
creating: discuz/readme/
inflating: discuz/readme/changelog.txt
inflating: discuz/readme/convert.txt
inflating: discuz/readme/license.txt
inflating: discuz/readme/readme.txt
[root@37-7-test1 html]# ls
discuz Discuz_X3.3_SC_UTF8.zip index.php test.php wordpress
[root@37-7-test1 html]# cd discuz/
[root@37-7-test1 discuz]# mv upload/ /var/www/html/forum
[root@37-7-test1 discuz]# ls /var/www/html/forum/
admin.php config data home.php misc.php search.php uc_client
api connect.php favicon.ico index.php plugin.php source uc_server
api.php cp.php forum.php install portal.php static userapp.php
archiver crossdomain.xml group.php member.php robots.txt template
[root@37-7-test1 discuz]# cd ..
[root@37-7-test1 html]# setfacl -Rm u:apache:rwx forum/
2. 192.168.37.27的准备
#192.168.37.17创建所需数据库,授权用户
[root@37-17-test2 ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2184
Server version: 5.5.65-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database forumdb;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all privileges on forumdb.* to forum@'192.168.37.%' identified by 'centos';
Query OK, 0 rows affected (0.00 sec)
3. 初始化网页的过程
浏览器地址栏输入192.168.37.7/forum/进入安装向导
到此一个论坛就搭建成功了
3、收集apache访问日志,并实现图形化展示。
想要图形化展示apache的访问日志,可以通过loganalyzer来实现,loganalyzer依赖LAMP,图形化展示apache的访问日志的方法有二种:
- 直接让访问日志交给loganalyzer并图形化展示
- 将pache访问日志统一管理到一台日志服务器上,然后让loganalyzer去日志服务器取相关数据,出图
1. 直接让访问日志交给loganalyzer并图形化展示
A. 部署loganalyzer
#192.168.37.7下载loganlzer解压到/var/www/html/目录
#这里不需要连接数据库直接,所以安装包有httpd php或httpd php-fpm
#这里以httpd模块的方式演示
[root@37-7-test1 ~]# yum install httpd php
Loaded plugins: fastestmirror, langpacks
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
base | 3.6 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/5): epel/x86_64/group_gz | 95 kB 00:00:00
(2/5): epel/x86_64/updateinfo | 1.0 MB 00:00:00
(3/5): epel/x86_64/primary_db
[root@37-7-test1 html]# rz
rz waiting to receive.
zmodem trl+C ȡ
100% 1022 KB 255 KB/s 00:00:04 0 Errorsgz...
[root@37-7-test1 html]# ls
discuz forum loganalyzer-3.6.4.tar.gz wordpress
Discuz_X3.3_SC_UTF8.zip index.php test.php
[root@37-7-test1 html]# tar xvf loganalyzer-3.6.4.tar.gz -C /var/www/html/
loganalyzer-3.6.4/
loganalyzer-3.6.4/ChangeLog
loganalyzer-3.6.4/INSTALL
loganalyzer-3.6.4/doc/
loganalyzer-3.6.4/doc/free_support.html
loganalyzer-3.6.4/doc/manual.html
loganalyzer-3.6.4/doc/professional_services.html
[root@37-7-test1 html]# cd loganalyzer-3.6.4/
[root@37-7-test1 loganalyzer-3.6.4]# ls
ChangeLog contrib COPYING doc INSTALL src
[root@37-7-test1 loganalyzer-3.6.4]# mv src/ ../logs
[root@37-7-test1 loganalyzer-3.6.4]# cd ..
[root@37-7-test1 html]# ls
discuz forum loganalyzer-3.6.4 logs wordpress
Discuz_X3.3_SC_UTF8.zip index.php loganalyzer-3.6.4.tar.gz test.php
[root@37-7-test1 html]# systemctl restart httpd
B. 网页初始化安装
#可以执行其contrib/configure.sh脚本,也可以自己执行
[root@37-7-test1 html]# cd logs/
[root@37-7-test1 logs]# touch config.php
[root@37-7-test1 logs]# chmod 666 config.php
[root@37-7-test1 logs]# setfacl -R -m u:apache:rwx /var/log/httpd/
图形化展示
2.将apache访问日志保存至一台日志服务器上,然后让loganalyzer去日志服务器取相关数据,出图
主机规划:
主机用途 | IP |
---|---|
apache服务器 | 192.168.37.7 |
mariadb数据库服务器/日志服务器 | 192.168.37.17 |
loganalyzer服务器 | 192.168.37.27 |
说明:
这里的apache服务器生成的日志由rsyslog转发到mariadb数据库服务器,也可以称为专门的日志服务器;
loganalyzer需要lamp环境,然后连接数据库服务器出图;
1. apache服务器快速部署
#192.168.37.7安装这里以fastcgi的方式运行php
[root@37-7-test1 ~]# yum install httpd php-fpm php-mysql
Loaded plugins: fastestmirror, langpacks
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
base | 3.6 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
updates
#配置fcgi.conf
[root@37-7-test1 conf.d]# pwd
/etc/httpd/conf.d
[root@37-7-test1 conf.d]# vim fcgi.conf
DirectoryIndex index.php
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/var/www/html/$1
#启动服务httpd和php-fpm
systemctl start httpd
systemctl start php-fpm
#编写测试代码
[root@37-7-test1 conf.d]# cd /var/www/html/
[root@37-7-test1 html]# ls
index.php
[root@37-7-test1 html]# vim index.php
进入浏览器查看效果
2. 数据库服务器连接配置
#apache服务器上安装rsyslog-mysql模块,可以连接数据库
[root@37-7-test1 html]# yum install rsyslog-mysql
Loaded plugins: fastestmirror, langpacks
base | 3.6 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
Loading mirror speeds from cached hostfile
#上传mysql-createDB.sql给192.168.37.17生成所需数据库
[root@37-7-test1 html]# rpm -ql rsyslog-mysql
/usr/lib64/rsyslog/ommysql.so
/usr/share/doc/rsyslog-8.24.0/mysql-createDB.sql
You have new mail in /var/spool/mail/root
[root@37-7-test1 html]# scp /usr/share/doc/rsyslog-8.24.0/mysql-createDB.sql 192.168.37.17:/data
The authenticity of host '192.168.37.17 (192.168.37.17)' can't be established.
ECDSA key fingerprint is 82:01:ab:34:04:e9:98:28:c2:10:0b:79:9a:60:19:06.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.37.17' (ECDSA) to the list of known hosts.
[email protected]'s password:
mysql-createDB.sql 100% 1046 1.0KB/s 00:00
[root@37-7-test1 html]#
#数据库服务器安装,启动,导入数据
[root@37-17-test2 ~]# yum install mariadb-server -y
[root@37-17-test2 ~]# systemctl start mariadb
[root@37-17-test2 ~]# mysql < /data/mysql-createDB.sql
#授权用户权限
[root@37-17-test2 ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.65-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> use Syslog;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [Syslog]> grant all on Syslog.* to 'loguser'@'192.168.37.%' identified by 'centos';
Query OK, 0 rows affected (0.01 sec)
3. apache服务器配置日志服务将日志发送至数据库服务器
#1. 访问日志改这里就可以了
[root@37-7-test1 html]# vim /etc/httpd/conf/httpd.conf
#access_log由管道交给syslog,facility为自定义的local4
CustomLog "|/usr/bin/logger -p local4.info" combined
#2. 配置rsyslog
[root@37-7-test1 html]# vim /etc/rsyslog.co
#启用数据库模块,将local4所有内容 记录到远程数据库服务器上
#打开udp514端口
$ModLoad imudp
$UDPServerRun 514
$ModLoad ommysql
local4.* :ommysql:192.168.37.17,Syslog,loguser,centos
#重启httpd服务和rsyslog服务,尝试浏览器访问,检查数据库中是否由日志产生
[root@37-7-test1 html]# systemctl restart rsyslog
[root@37-7-test1 html]# systemctl restart httpd
#192.168.37.17开始没有数据,访问过后日志数据来了
MariaDB [Syslog]> select * from SystemEvents\G
Empty set (0.00 sec)
MariaDB [Syslog]> select * from SystemEvents\G
*************************** 1. row ***************************
ID: 1
CustomerID: NULL
ReceivedAt: 2020-09-04 12:00:26
DeviceReportedTime: 2020-09-04 12:00:26
Facility: 20
Priority: 6
FromHost: [localhost]
Message: 192.168.37.1 - - [04/Sep/2020:12:00:26 +0800] "GET / HTTP/1.1" 200 45485 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0"
NTSeverity: NULL
Importance: NULL
EventSource: NULL
EventUser: NULL
EventCategory: NULL
EventID: NULL
EventBinaryData: NULL
MaxAvailable: NULL
CurrUsage: NULL
MinUsage: NULL
MaxUsage: NULL
InfoUnitID: 1
SysLogTag: logger:
EventLogType: NULL
GenericFileName: NULL
SystemID: NULL
......
4. loganalyzer服务器的安装配置
#首先快速部署lamp httpd
[root@37-27-test3 ~]# yum install httpd php php-mysql php-gd -y
#部署loganalyzer
[root@37-27-test3 ~]# rz
rz waiting to receive.
zmodem trl+C ȡ
100% 2802 KB 2802 KB/s 00:00:01 0 Errorsgz...
[root@37-27-test3 ~]# ls
anaconda-ks.cfg initial-setup-ks.cfg loganalyzer-4.1.7.tar.gz
[root@37-27-test3 ~]# tar xvf loganalyzer-4.1.7.tar.gz -C /var/www/html
[root@37-27-test3 ~]# cd /var/www/html/
[root@37-27-test3 html]# cd loganalyzer-4.1.7/
[root@37-27-test3 loganalyzer-4.1.7]# ls
ChangeLog contrib COPYING doc INSTALL src
[root@37-27-test3 loganalyzer-4.1.7]# mv src/ ../logs
[root@37-27-test3 loganalyzer-4.1.7]# cd ..
[root@37-27-test3 html]# cd logs/
[root@37-27-test3 logs]# ls
admin convert.php favicon.ico js search.php
asktheoracle.php cron images lang statistics.php
BitstreamVeraFonts css include login.php templates
chartgenerator.php details.php index.php reportgenerator.php themes
classes export.php install.php reports.php userchange.php
[root@37-27-test3 logs]# touch config.php
[root@37-27-test3 logs]# chmod 666 config.php
#启动httpd服务即可
loganalyzer初始化过程
日志图形展示
错误汇总
#1. logAnalyzer报错如下
Could not find the configured table, maybe misspelled or the tablenames are case sensitive
#提示找不到表,修改,解决方法修改配置tablename的名字一定要对应正确的数据库里的表名,区分大小写
[root@37-27-test3 logs]# vim config.php
#将小写的sysemevents改成SystemEvents后重启服务
$CFG['Sources']['Source1']['DBTableName'] = 'SystemEvents';
[root@37-27-test3 logs]# systemctl restart httpd
#2. 不出图
#安装php-gd
yum install php-gd -y