1、部署分离的LAMP,部署到二台服务器上,php加载xcache模块
两台主机 172.16.100.46 172.16.100.47
在172.16.100.46上安装
apache+php
[root@localhost ~]# yum -y install php httpd php-mysql
[root@localhost wordpress]# setfacl -Ru:apache:rwx /var/www/html/wordpress
在172.16.100.47
[root@localhost ~]# yum install mariadb-server -y
[root@localhost ~]# systemctl start mariadb
[root@localhost ~]# 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 wpdb;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all on wpdb.* to wpuser@'172.16.100.%' identified by 'centos';
Query OK, 0 rows affected (0.00 sec)
安装加载xcache模块 适用于PHP5
https://github.com/lighttpd/xcache/archive/3.2.0.tar.gz 下载源码包
yum -y install php-devel gcc 配置编译环境
tar xf xcache-3.2.0.tar.gz
[root@localhost xcache-3.2.0]# phpize --clean && phpize 生成编译脚本
[root@localhost xcache-3.2.0]# ./configure --enable-xcache
[root@localhost xcache-3.2.0]# make && make install
[root@localhost xcache-3.2.0]# cp xcache.ini /etc/php.d/
[root@localhost xcache-3.2.0]# systemctl restart httpd.service
对比:
没加载前
[root@localhost ~]#ab -c10 -n 100 http://172.16.100.46/wordpress/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 172.16.100.46 (be patient).....done
Server Software: Apache/2.4.6
Server Hostname: 172.16.100.46
Server Port: 80
Document Path: /wordpress/
Document Length: 11173 bytes
Concurrency Level: 10
Time taken for tests: 14.143 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 1144100 bytes
HTML transferred: 1117300 bytes
Requests per second: 7.07 [#/sec] (mean)
Time per request: 1414.339 [ms] (mean)
Time per request: 141.434 [ms] (mean, across all concurrent requests)
Transfer rate: 79.00 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 1
Processing: 631 1275 223.9 1244 1976
Waiting: 602 1167 223.8 1132 1944
Total: 631 1275 223.8 1244 1976
Percentage of the requests served within a certain time (ms)
50% 1244
66% 1296
75% 1381
80% 1414
90% 1549
95% 1694
98% 1960
99% 1976
100% 1976 (longest request)
加载后
[root@localhost ~]#ab -c10 -n 100 http://172.16.100.46/wordpress/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 172.16.100.46 (be patient).....done
Server Software: Apache/2.4.6
Server Hostname: 172.16.100.46
Server Port: 80
Document Path: /wordpress/
Document Length: 11173 bytes
Concurrency Level: 10
Time taken for tests: 5.331 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 1144100 bytes
HTML transferred: 1117300 bytes
Requests per second: 18.76 [#/sec] (mean)
Time per request: 533.052 [ms] (mean)
Time per request: 53.305 [ms] (mean, across all concurrent requests)
Transfer rate: 209.60 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.2 0 1
Processing: 206 477 90.5 487 672
Waiting: 192 415 81.8 425 588
Total: 206 477 90.4 487 672
Percentage of the requests served within a certain time (ms)
50% 487
66% 510
75% 540
80% 553
90% 579
95% 622
98% 647
99% 672
100% 672 (longest request)
2、部署wordpress论坛,并实现正常访问登录论坛。
两台主机 172.16.100.46 172.16.100.47
在172.16.100.46上安装
apache+php
[root@localhost ~]# yum -y install php httpd php-mysql
wordpress下载 https://cn.wordpress.org/download/releases/
[root@localhost data]# tar xvf wordpress-5.0.3-zh_CN.tar.gz
[root@localhost wordpress]# setfacl -Ru:apache:rwx /var/www/html/wordpress
收回权限:
[root@localhost wordpress]# setfacl -b /var/www/html/wordpress
在172.16.100.47
[root@localhost ~]# yum install mariadb-server -y
[root@localhost ~]# systemctl start mariadb
[root@localhost ~]# 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 wpdb;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all on wpdb.* to wpuser@'172.16.100.%' identified by 'centos';
Query OK, 0 rows affected (0.00 sec)
测试
3、收集apache访问日志,并实现图形化展示。
3台测试机
rsyslog服务器上安装mysql模块相关的程序包
[root@localhost ~]#yum install rsyslog-mysql.x86_64 -y
[root@localhost ~]# rpm -ql rsyslog-mysql
/usr/lib64/rsyslog/ommysql.so
/usr/share/doc/rsyslog-8.24.0/mysql-createDB.sql
[root@localhost ~]# scp /usr/share/doc/rsyslog-8.24.0/mysql-createDB.sql 172.16.100.47:/data
创建数据库和表
[root@localhost ~]# mysql < /data/mysql-createDB.sql
[root@localhost ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 68
Server version: 10.2.23-MariaDB-log 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 |
+--------------------+
| Syslog |
| discuz |
| information_schema |
| mysql |
| performance_schema |
| test |
| wordpress |
+--------------------+
7 rows in set (0.00 sec)
MariaDB [(none)]> use Syslog
Database changed
MariaDB [Syslog]> show tables;
+------------------------+
| Tables_in_Syslog |
+------------------------+
| SystemEvents |
| SystemEventsProperties |
+------------------------+
2 rows in set (0.00 sec)
MariaDB [(none)]> grant all on Syslog.* to loguser@'172.16.100.%' identified by 'centos';
Query OK, 0 rows affected (0.00 sec)
更改rsyslog.conf 配置文件
[root@localhost ~]#vim /etc/rsyslog.conf
$ModLoad ommysql
*.info;mail.none;authpriv.none;cron.none :ommysql:172.16.100.47,Syslog,loguser,centos
[root@localhost ~]#systemctl restart rsyslog
搭建lap
yum install httpd php php-mysql php-gd
安装loganalyzer
[root@localhost logs]# tar xvf loganalyzer-4.1.7.tar.gz
[root@localhost loganalyzer-4.1.7]# ls
ChangeLog contrib COPYING doc INSTALL src
[root@localhost loganalyzer-4.1.7]# mv src /var/www/html/logs
[root@localhost loganalyzer-4.1.7]# cd /var/www/html/logs
[root@localhost logs]# touch config.php
[root@localhost logs]# chmod 666 config.php
[root@localhost logs]# systemctl start httpd
视图化如下