5次阅读
没有评论

集群架构

开发维度

顶部左侧展示代码从开发到生产的自动化流转

  • 开发人员提交代码后,经 “预发布环境” 测试验证,再通过 “发布网(代理解析)” 和自动化工具(如 Jenkins),将版本发布到 “生产网集群”。
  • 核心价值:通过标准化、自动化的发布流程,减少人为错误,提升迭代效率(支持快速上线 / 回滚)。

用户角度

  • 用户访问站点域名–>DNS解析->Ip(CDN缓存)
  • 用户请求CDN缓存
    • 缓存存在,直接给用户。
    • 缓存不存在,继续处理
  • 请求经过防火墙
  • 负载均衡(把请求转发给后端节点)
  • 网站服务器(WEB服务器)进行处理
    • 查询/登录连接缓存查询,缓存没有再去数据库查询
    • 注册连接数据库写入用户信息
    • 用户上传图片/视频,
      • 图片视频的文件名写入数据库
      • 图片视频文件本身上传存储服务器

运维维度

  • 运维人员(通过 Linux 终端等)经 “DNS 解析→防火墙(VPN 端口)→VPN / 堡垒机”,安全接入内部系统(堡垒机还能审计操作,保障运维合规);
  • 依托 “自动化运维平台(含 CMDB 等工具)”,实现:
    • 批量管理:同时操作多台服务器(如批量部署、配置修改);
    • 大数据分析:对业务数据、访问日志等进行统计,辅助决策;
    • 安全管控:监测漏洞、权限管理,保障系统安全;
    • SOA 组件:支持服务化架构,让模块间松耦合、易扩展;
    • 监控 / 日志 / 备份:实时监控系统状态、收集日志排查问题、定期备份关键数据。

CDN

  • CDN内容分布网络
  • 环境网站集群的压力
  • CDN分布式缓存
  • 用户访问的时候会就近访问附件的节点(缓存),加速效果
  • CDN好处
    • 缓存网站集群的带宽压力
    • 智能调度系统,可以让用户就近访问,用户根据速度提高了
    • 能防御一些攻击

网站由来

  • 想法/需求—–>开发程序app/网站
  • 网站/app运行环境—>运行在服务器(系统为Linux)

集群

  • 网站集群:多台服务器

网站集群架构服务

开发维度

开发维度 软件服务
发布平台 jenkins,argo

用户维度

用户维度 服务 说明
DNS解析 云解析DNS 在哪里买的域名在哪里进行解析
CDN 云厂商的CDN产品 蓝汛/网宿 理解作用
防火墙 硬件防火墙 firewad/iptables/ufw 云产品防火墙:安全组
负载均衡 硬件负载均衡:F5 开源软件:nginx,lvs,haproxy 云产品
web服务器(中间件) 开源软件:nginx,tomcat,php,apache LNMP(linux系统,nginx,mysql,数据库,php)
数据库缓存 开源软件:redis(首选)/memcached
数据库 数据库: MYSQL,PostgreSQL,MariadDB,Oracle(甲骨文) 国产数据库:高斯(opengaues,华为) ob(oceanbase 阿里),达梦,tidb
存储服务 硬件:各种厂商都有,浪潮,华为 开源软件:NFS,ceph,minio 云产品

运维维度

运维维度 服务 说明
批量管理 Ansible/Terraform
VPN 硬件 开源软件:openvpn 云产品 公司—>服务器(内网)
堡垒机 硬件 开源软件:jumpserver
监控 硬件 开源软件:Zabbix,Grafana,Prometheus(普罗米修斯)
日志 ELK(Elatic Stack)
安全与审计 AWVS,Nessus,扫描
大数据 Hadoop系列
登录 统一登录系统:AD(windows),OpenLDAP(linux)
AI Deepseek(自建,调取api接口),ChatGPT(API),ChatGLM

综合架构模板机环境准备

kylin/rocky

开启虚拟机,进入以下界面

选最小安装,标准,调试工具,开发工具,系统工具,Man手册(省下安装很多软件)

1,2,c,c

ubt

boot 2G swap 2G

模板机优化-kylin

1.关闭防火墙,selinux

 systemctl stop firewalld 
 systemctl disable firewalld

rocky系统,关闭selinux

 setenforce  0
 sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
 #selinux检查
 [root@oldboy-muban ~]# grep disabled /etc/selinux/config
 #     disabled - No SELinux policy is loaded.
 SELINUX=disabled
 [root@oldboy-muban ~]# getenforce
 Permissive  #或是是disabled都是关闭

ubt

 sudo su - root
 passwd root
 1
 ​
 ​
 ​
 systemctl disable ufw
 systemctl stop ufw

2.yum源与安装常用工具

kylin系统

 #增加epel源
 curl -o /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
 #安装麒麟常用软件
 yum install -y vim tree wget bash-completion lrzsz net-tools sysstat iotop iftop htop unzip nc nmap telnet bc psmisc httpd-tools bind-utils nethogs expect ntpdate
 ​

centos系统

 #配置base源
 curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
 #增加epel源
 curl -o /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
 #安装常用工具
 yum install -y vim tree wget bash-completion bash-completion-extras lrzsz net-tools sysstat iotop iftop htop unzip nc nmap telnet bc psmisc httpd-tools bind-utils nethogs expect ntpdate
 yum install -y sl cowsay

ubuntu系统

 #方法1
 sed -i_bak "s/cn.archive.ubuntu.com/mirrors.aliyun.com/g" /etc/apt/sources.list
 sed -i 's/security.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list
 #更新索引
 apt update
 ​
 #方法2
 cp /etc/apt/sources.list{,.bak}
 cat >/etc/apt/sources.list<<EOF
 ​
 deb https://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
 deb-src https://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
 ​
 deb https://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
 deb-src https://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
 ​
 deb https://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
 deb-src https://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
 ​
 # deb https://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
 # deb-src https://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
 ​
 deb https://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
 deb-src https://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
 EOF
 #更新索引
 apt update
 ​
 ​
 #安装常用软件
 apt install -y tree vim   telnet lrzsz   nmap ncat ntpdate network-manager

rokcy

 #安装 EPEL 源(额外开源软件)
 yum install -y epel-release
 ​
 # 更新系统(安全补丁和bug修复)
 yum update -y
 ​
 # 编辑 dnf 配置
 vim /etc/dnf/dnf.conf
 # 添加以下行:
 fastestmirror=True  # 选择最快镜像
 max_parallel_downloads=10  # 并行下载数
 keepcache=True  # 保留下载的rpm包(下次安装无需重新下载)
 ​
 # 清理无用缓存
 dnf clean all

3,ssh远程连接加速

关闭ssh远程连接反向解析功能,加速ssh远程连接

 #修改ssh服务端配置文件
 #1.注释掉已有的配置
 sed -i '/^GSSAPIAuthentication/s@^@#@g' /etc/ssh/sshd_config
 #2.关闭对应功能
 cat >>/etc/ssh/sshd_config<<EOF
 UseDNS no
 GSSAPIAuthentication no
 #关闭dns反向解析 ip-->域名
 EOF
 #3.重启sshd
 systemctl restart sshd
 #4.检查
 egrep '^(GSSAPIAuthentication|UseDNS)' /etc/ssh/sshd_config
 ​
 #结果有2个no即可.

ubt

vim  /etc/ssh/sshd_config

找到#PermitRootLogin 去掉注释,
修改为
PermitRootLogin yes

systemctl restart sshd

4.时间同步

#kylin
cat >/var/spool/cron/root<<EOF
#1. sync time by lidao996 at 20230101
*/3 * * * * /sbin/ntpdate ntp.aliyun.com >/dev/null 2>&1
EOF

#rocky
systemctl enable --now chronyd
echo 'server ntp.aliyun.com iburst' >>/etc/chrony.conf
systemctl restart chronyd

#ubuntu
cat >/var/spool/cron/crontabs/root<<EOF
#1. sync time by lidao996 at 20230101
*/3 * * * * /sbin/ntpdate ntp.aliyun.com >/dev/null 2>&1
EOF




#设置时区
timedatectl set-timezone Asia/Shanghai


# 验证时间同步
chronyc sources

5.配置脚本添加命令解释器

vim /etc/vimrc  #kylin|rocky

vim /etc//vim/vimrc #ubuntu
--------------------------------
autocmd BufNewFile *.py,*.cc,*.sh,*.java,*.bash,Dockerfile,docker-compose.yml exec ":call SetTitle()"

func SetTitle()
if expand("%:e") =~ 'sh\|bash'
call setline(1,"#!/bin/bash")
call setline(2, "##############################################################")
call setline(3, "# File Name: ".expand("%"))
call setline(4, "# Version: V1.0")
call setline(5, "# Author: song")
call setline(6, "# Organization: ")
call setline(7, "# Description:")
call setline(8, "##############################################################")
call setline(9, "")
endif
if expand("%") == 'Dockerfile'
call setline(1, "#####################Dockerfile###############################")
call setline(2, "##############################################################")
call setline(3, "# File Name: ".expand("%"))
call setline(4, "# Version: V1.0")
call setline(5, "# Author: song")
call setline(6, "# Organization: ")
call setline(7, "# Description:")
call setline(8, "##############################################################")
call setline(9, "")
call setline(10, "FROM")
call setline(11, "LABEL maintaniner='oldboy lidao@oldboyedu.com' author=lidao996")
call setline(12, "CMD []")
endif
if expand("%") == 'docker-compose.yml'
call setline(1, "#####################docker-compose###########################")
call setline(2, "##############################################################")
call setline(3, "# File Name: ".expand("%"))
call setline(4, "# Version: V1.0")
call setline(5, "# Author: song")
call setline(6, "# Organization:")
call setline(7, "# Description:")
call setline(8, "##############################################################")
call setline(9, "")
call setline(10, "version: '3.3'")
call setline(11, "services:")
call setline(12, "volumes:")
endif
endfunc

ubuntu禁用nono

cat >>~/.bashrc<<EOF
#在文件末尾添加以下内容
export EDITOR=vim
export VISUAL=vim
EOF

source ~/.bashrc

ubuntu禁止自动更新

systemctl stop unattended-upgrades
systemctl e unattended-upgrades

6.配置命令行颜色

#kylin|rocky
#编辑/etc/profile,写入到文件末尾
echo "export PS1='[\[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\]\[\e[31;1m\] \w\[\e[0m\]]\\$ '">> /etc/profile

source /etc/profile

#ubuntu
echo "export PS1='[\[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\]\[\e[31;1m\] \w\[\e[0m\]]\\$ '">> ~/.bashrc

source ~/.bashrc

7.修改主机名和ip

mkdir -p /server/scripts/
vim /server/scripts/change.sh
------------------------------------------
#!/bin/bash
##############################################################
# File Name: change.sh
# Version: V1.0
# Author: song
# Organization:
# Description:
##############################################################
# 颜色输出函数
redecho(){
str=$*
echo -e "\E[1;31m${str}\E[0m"
}
greenecho(){
str=$*
echo -e "\E[1;32m${str}\E[0m"
}
yellowecho(){
str=$*
echo -e "\E[1;33m${str}\E[0m"
}
blueecho(){
str=$*
echo -e "\E[1;34m${str}\E[0m"
}

if [ $# -ne 2 ];then
echo "帮助:主机名 ip"
exit 1
fi

hostnamectl set-hostname $1
echo "已修改主机名为$1"

ip_addr="$2"

package="networkmanager" #软件名称



error_exit(){
redecho "Error: $1"
exit 1
}
check_os(){
[ -f "/etc/os-release" ] || error_exit "不支持的系统(未找到/etc/os-release)"
source /etc/os-release
OS_ID=$ID
OS_VERSION=$VERSION_ID
greenecho "检测到系统: ${OS_ID} ${OS_VERSION}"
}


ip_modify(){
case $ID in
kylin|rocky|centos)
if [ $(rpm -qa | grep -ic ${package}) -gt 0 ];then
greenecho "${package}已安装"
else
yum install -y ${package} >/dev/null 2>&1 || error_exit "${package}安装失败"
fi
local name_eth0=`nmcli connection show | awk 'NR==2{print $1}'`
local name_eth1=`nmcli connection show | awk 'NR==3{print $1}'`
if [[ "${ip_addr}" == 10.0.0.* ]];then
nmcli connection modify ${name_eth0} ipv4.addresses ${ip_addr}/24 || error_exit "修改ip失败"
nmcli connection down ${name_eth0} && nmcli connection up ${name_eth0}
greenecho "修改网卡${name_eth0},ip为${ip_addr}"
elif [[ "${ip_addr}" == 172.16.1.* ]];then
nmcli connection modify ${name_eth1} ipv4.addresses ${ip_addr}/24 || error_exit "修改ip失败"
nmcli connection down ${name_eth1} && nmcli connection up ${name_eth1}
greenecho "修改网卡${name_eth1},ip为${ip_addr}"
else
error_exit "新IP ${ip_addr} 不属于10.0.0.*或172.16.1.*网段"
fi
;;
ubuntu)
local ip_network=`hostname -I | awk '{print $1}'`
local ip_intranet=`hostname -I | awk '{print $2}'`
if [[ "${ip_addr}" == 10.0.0.* ]];then
sed -i "s/${ip_network}/${ip_addr}/g" /etc/netplan/00-installer-config.yaml || error_exit "修改ip失败"
greenecho "已修改外网ip${ip_network}"
elif [[ "${ip_addr}" == 172.16.1.* ]];then
sed -i "s/${ip_intranet}/${ip_addr}/g" /etc/netplan/00-installer-config.yaml || error_exit "修改ip失败"
greenecho "已修改内网ip${ip_intranet}"
else
error_exit "新IP ${ip_addr} 不属于10.0.0.*或172.16.1.*网段"

fi
netplan apply >/dev/null 2>&1 || error_exit "修改ip失败"
;;
*)
error_exit "不支持的系统"
;;
esac
}

main(){
check_os
ip_modify
}
main
-------------------------------------------------
chmod +x /server/scripts/change.sh
ln -s /server/scripts/change.sh /sbin/

change.sh 主机名 ip

8.rm的别名


vim /server/scripts/rocyle_rm.sh
------------------------------------
#定义变量
rm_dirfile=$* #要删除的目录/文件
user=$(whoami) #当前用户
recy=/recycle/ #回收站目录
#判断参数是否为0,0是失败
if [ $# -eq 0 ];then
echo "脚本格式不对请重新输入"
exit 1
fi
#判断用户是否为root
if [ $user != root ];then
echo "普通用户无法使用rm,请自己使用mv"
exit 2
fi
#创建目录
mkdir -p $recy
#使用mktemp命令创建临时目录
random_dir=$(mktemp -dp /recycle/)
mv ${rm_dirfile} ${random_dir} #移动目录/文件到回收站
echo "${rm_dirfile}已经移动到${random_dir}"
----------------------------------------
cat >>/etc/profile<<EOF
alias rm='bash /server/scripts/rocyle_rm.sh'
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
EOF
source /etc/profile
#注释掉已有的rm别名
vim .bashrc

#ubt
cat >>~/.bashrc<<EOF
alias rm='bash /server/scripts/rocyle_rm.sh'
EOF
source ~/.bashrc

9.hosts解析

kylin

cat >>/etc/hosts <<EOF
172.16.1.5 lb01
172.16.1.6 lb02
172.16.1.7 web01
172.16.1.8 web02
172.16.1.9 web03
172.16.1.31 nfs01
172.16.1.41 backup
172.16.1.51 db01
172.16.1.61 m01
EOF

ubt

cat >>/etc/hosts <<EOF
172.16.1.105 lb01-ubt
172.16.1.106 lb02-ubt
172.16.1.107 web01-ubt
172.16.1.108 web02-ubt
172.16.1.109 web03-ubt
172.16.1.131 nfs01-ubt
172.16.1.141 backup-ubt
172.16.1.151 db01-ubt
172.16.1.161 m01-ubt
EOF

rocky

cat >>/etc/hosts <<EOF
172.16.1.205 lb01-rocky
172.16.1.206 lb02-rocky
172.16.1.207 web01-rocky
172.16.1.208 web02-rocky
172.16.1.209 web03-rocky
172.16.1.231 nfs01-rocky
172.16.1.241 backup-rocky
172.16.1.251 db01-rocky
172.16.1.261 m01-rocky
EOF

10.释放被占用的内存 kdump

注意:ubuntu默认没有

#1.命令关闭
systemctl disable --now kdump

#2.修改启动配置文件
sed -i 's#crashkernel=1024M,high##g' /boot/grub2/grub.cfg

#3.重启linux系统
free -h

11.处理tmp

systemctl mask tmp.mount
umount /tmp/
重启检查结果
sudo firewall-cmd --add-port=873/tcp --permanent
sudo firewall-cmd --reload
正文完
 0
评论(没有评论)

这是一个shf的网站

近期评论

您尚未收到任何评论。