[toc]

架构专业名词

  1. 项目:类似手机app,一个app就是一个项目
  2. 架构:用多个服务器取搭建出一个项目
  3. 集群:为了解决某个特定问题,用多态计算机服务器来形成某套系统
  4. 高可用:当一台机器噶了,会有另一台机器顶上去,保证服务不down机
  5. 单点故障: 没有备机只有一台,一旦服务down机,服务就无法运行
  6. 负载均衡:让用户的请求平均分摊到多个服务器上,保证服务器的稳定性
  7. 静态页面:前端写的,不用调取数据库的数据
  8. 动态页面:要调取数据库的数据

架构流程图

image-20221128211838899

环境准备

外网IP 内网IP 主机名
10.0.0.5 172.16.1.5 lb01
10.0.0.6 172.16.1.6 lb02
10.0.0.7 172.16.1.7 web01
10.0.0.8 172.16.1.8 web02
10.0.0.9 172.16.1.9 web03
10.0.0.31 172.16.1.31 nfs
10.0.0.41 172.16.1.41 backup
10.0.0.51 172.16.1.51 db01
10.0.0.61 172.16.1.61 m01
10.0.0.71 172.16.1.71 zabbix

虚拟机准备

image-20221128172425675

image-20221128172514906

image-20221128172523719

image-20221128172546360

image-20221128172557874

image-20221128172602738

image-20221128172605550

image-20221128172610034

image-20221128172613651

虚拟机优化

优化网卡信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# eth0
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="none"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
NAME="eth0"
DEVICE="eth0"
ONBOOT="yes"
IPADDR="10.0.0.100"
PREFIX="24"
GATEWAY="10.0.0.2"
DNS1="223.5.5.5"

# eth1
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
NAME=eth1
DEVICE=eth1
ONBOOT=yes
IPADDR=172.16.1.100
NETMASK=255.255.255.0

优化下载源

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Base源配置的两种方法:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# epel源配置的两种方法
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

## 查看源是否下载完成
ll
total 8
-rw-r--r--. 1 root root 2523 Nov 28 11:49 CentOS-Base.repo
-rw-r--r--. 1 root root 664 Nov 28 11:49 epel.repo

# 检查可用源
yum repolist

关闭防火墙并取消开机自启

1
2
3
4
5
6
7
# 关闭防火墙
[root@localhost yum.repos.d]# systemctl stop firewalld

# 取消开机自启防火墙
[root@localhost yum.repos.d]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

关闭selinux并取消开机自启

1
2
3
4
5
6
# 关闭selinux
getenforce 0 # 关闭selinux(临时关闭)

# 关闭开机自启selinux
vim /etc/sysconfig/selinux
SELINUX=disabled

image-20221128174457215

优化文件描述符

1
echo '* - nofile 65535' >> /etc/security/limits.conf

优化安装包

1
2
3
yum install net-tools vim tree htop iftop gcc gcc-c++ glibc iotop lrzsz sl wget unzip
telnet nmap nc psmisc dos2unix bash-completion bash-completion-extra sysstat rsync
nfs-utils httpd-tools ntpdate -y

时间同步

1
2
# update time by aliyun
* * * * * /usr/sbin/ntpdate time1.aliyun.com

克隆优化后的虚拟机

更改网卡配置信息

1
2
vim /etc/sysconfig/network-scripts/ifcfg-eth0
vim /etc/sysconfig/network-scripts/ifcfg-eth1

更改主机名

1
hostnamectl set-hostname

保存快照

1
已优化纯净状态