中小型企业网络部署搭建项目(搭建WordPress)

项目需求

【项目名称】
搭建中小型企业网站平台
【项目说明】

设计一个中小型企业网站平台架构,可以满足公司日常一天10-30万PV访问量。项目中要包括安全,备份,监控,shell脚本自动化管理等内容。
【项目考核技能点】

  1. 画好架构图, 不限制用什么工具画图、visio、亿图、xmind、在线画图processon等

  2. LAMP或LNMP架构

  3. 在Web架构上部署网站模版。如:discuz论坛或ecshop商城或wordpress博客等。

  4. 整个方案要包括:安全、监控、备份等相关内容。

  5. 给web平台,起一个名字。比如:某宝,某东。

    参考架构图:
    请添加图片描述

项目分析

PV是page view的简写。PV是指页面的访问次数,每打开或刷新一次页面,就算做一个pv。

每天80%的访问集中在20%的时间里,这20%时间叫做峰值时间。

计算模型:
每台服务器每秒处理请求的数量=((80%总PV量)/(24小时60分60秒20%)) / 服务器数量 。其中关键的参数是80%、20%。

每天30w PV 在单台机器上:

(300000 * 0.8)/ (86400 * 0.2)= 13.888(QPS)

也就是单台机器需要满足 14(QPS)

Apache的最大连接数,默认为256个。可以满足需求

ulimit 命令是 Linux 系统的内建功能,它具有一套参数集,用于控制 shell 进程及其所创进程的资源使用限制。它主要用于设置用户和系统的资源限制,如打开文件的最大数量、内存使用限制等。

默认的ulimit open files(用户可以打开文件的最大数目)默认为1024 。也可满足需求。

留足余量:

但实际情况并不会这么均匀的分布,会有高峰有低谷。为了应对高峰时段,应该留一些余地,最少也要x2倍,x3倍也不为过。

14个请求/秒 * 2倍=28个请求/秒

14个请求/秒 * 3倍=42个请求/秒

结论:

如果服务器一秒能处理42个请求/秒,就可以应对平均30万PV/每天。

结构图
请添加图片描述

规划表

序号 用途 操作系统 IP 主机名
1 apache服务器 rocky-8.8 192.168.137.31 zhyj1
2 mysql-master rocky-8.8 192.168.137.32 zhyj2
3 mysql-slave rocky-8.8 192.168.137.33 zhyj3
4 数据备份(web,mysql) rocky-8.8 192.168.137.34 zhyj4
5 zabbix6监控所有主机 rocky-8.8 192.168.137.35 zhyj5
6 ansible集中管理 rocky-8.8 192.168.137.36 zhyj6

系统基础环境准备

修改ip地址为静态ip地址

编辑网卡配置文件

[root@zhyj1 ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens160

在这里插入图片描述

重启网卡

[root@zhyj1 ~]# nmcli connection down ens160
[root@zhyj1 ~]# nmcli connection up ens160

在这里插入图片描述
其他机器同理(192.168.137. 32 33 34 35 36)

管理员主机(192.168.137.36)安装ansible软件

ansible是是一个"配置管理工具",它是一个"自动化运维工具",是运维人员的瑞士军刀,可以帮助我们完成一些批量工作或者重复性工作。

ansible是在epel扩展源中

**配置管理员主机(192.168.137.36)epel源 **

[root@zhyj6 ~]# dnf install epel-release.noarch -y

在这里插入图片描述

使用dnf安装ansible

[root@zhyj6 ~]# dnf install ansible -y

查看ansible的版本

[root@zhyj6 ~]# ansible --version
ansible [core 2.15.3]

定义主机清单

[root@zhyj6 ~]# vim /etc/ansible/hosts

在这里插入图片描述

生成ssh公钥和私钥,将生成的公钥拷贝到其他机器,免密登录

[root@zhyj6 ~]# ssh-keygen   回车 * 4  ----生成完成
[root@zhyj6 ~]# ssh-copy-id 192.168.137.35

在这里插入图片描述

其他机器同理

使用ping命令检测是否成功连通

[root@zhyj6 ~]# ansible -i /etc/ansible/hosts 'weblist' -m ping

请添加图片描述

使用ansible为所有主机安装epel扩展源

[root@zhyj6 ~]# ansible -i /etc/ansible/hosts 'weblist' -m yum -a  'name=epel-release.noarch state=latest'

在这里插入图片描述

修改epel源为阿里云

[root@zhyj6 yum.repos.d]# ansible 'weblist' -m shell -a " sed -i 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel* && sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel* "

在这里插入图片描述

使用ansible关闭所有主机selinux

[root@zhyj6 ~]# ansible -i /etc/ansible/hosts 'weblist' -m shell -a 'sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config' 

在这里插入图片描述

使用ansible关闭所有主机firewalld

[root@zhyj6 ~]# ansible -i /etc/ansible/hosts 'weblist' -m service -a 'name=firewalld state=stopped enabled=no'

在这里插入图片描述

使用ansible为所有主机修改阿里云源地址

![

[root@zhyj6 ~]# ansible -i /etc/ansible/hosts 'weblist' -m script -a '/root/aliyuan.sh'

在这里插入图片描述

Apache php Mysql环境配置

为192.168.137.31主机安装php环境

[root@zhyj1 ~]# yum install -y httpd php php-fpm php-mysqlnd php-gd php-opcache php-json php-xml

为192.168.137.32 192.168.137.33安装mysql

[root@zhyj2 ~]#dnf module install mysql -y
[root@zhyj3 ~]#dnf module install mysql -y

将相应服务启动并设置开机自启动

[root@zhyj1 ~]# systemctl enable --now httpd
[root@zhyj2 ~]# systemctl enable --now mysqld
[root@zhyj3 ~]# systemctl enable --now mysqld

查看服务运行状态

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

数据库安好后,我们需要运行安全初始化命令提高mysql的安全性。 这里实验环境我的mysql密码就设置为123456了

运行mysql_secure_installation会执行几个设置:(192.168.137.32机器)
a)为root用户设置密码
b)删除匿名账号
c)取消root用户远程登录
d)删除test库和对test库的访问权限
e)刷新授权表使修改生效

[root@zhyj2 ~]# mysql_secure_installation 

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: 
Please set the password for root here.

New password: 

Re-enter new password: 
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.

Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n

 ... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done! 

192.168.137.33机器同理

安装discuz网站

rz上传discuz网站压缩包

在这里插入图片描述

解压到当前目录下

[root@zhyj1 ~]# unzip Discuz_X3.2_SC_UTF8.zip

把upload文件夹里的文件都移动到 /var/www/html/ 文件夹中

[root@zhyj1 ~]#mv /root/upload/* /var/www/html/

给 /var/www 目录及其子目录赋予权限

[root@zhyj1 ~]# chown apache.apache -R /var/www

重启httpd服务

[root@zhyj1 ~]# systemctl restart httpd

浏览器中输入ip地址进行安装

在这里插入图片描述

环境状态都正确 点击下一步进行安装
在这里插入图片描述

这里选择第二个选项

在这里插入图片描述

填写好相关信息

这里我使用的是192.168.32主机为主数据库,192.168.137.33主机为从数据库 稍后将进行配置

在这里插入图片描述

安装报错记录

在这里插入图片描述

在终端中使用mysql命令没有找到

在这里插入图片描述

分析,可能没有安装mysql软件包

使用yum安装msql

在这里插入图片描述

还是存在该问题

在这里插入图片描述

**经过查询得知 root 用户没有远程连接的权限 **

修改 root 用户的连接权限

[root@zhyj2 ~]# mysql -uroot -p123456
mysql> use mysql;
Database changed
mysql>  select host 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值