2020-09-22 第十七周

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)

测试


image.png

image.png

image.png

image.png

image.png

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

视图化如下

image.png

image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 200,841评论 5 472
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 84,415评论 2 377
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 147,904评论 0 333
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,051评论 1 272
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,055评论 5 363
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,255评论 1 278
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,729评论 3 393
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,377评论 0 255
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,517评论 1 294
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,420评论 2 317
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,467评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,144评论 3 317
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,735评论 3 303
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,812评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,029评论 1 256
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,528评论 2 346
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,126评论 2 341