文章目录
- [1. 网站集群架构](#1. 网站集群架构)
-
- [1.1 开发维度](#1.1 开发维度)
- [1.2 用户维度](#1.2 用户维度)
- [1.3 运维维度](#1.3 运维维度)
- [2. 模板机](#2. 模板机)
-
- [2.1 系统准备-kylin v10](#2.1 系统准备-kylin v10)
- [2.2 系统优化](#2.2 系统优化)
-
- [2.2.1 关闭**防火墙和selinux**](#2.2.1 关闭防火墙和selinux)
- [2.2.2 配置**yum源与安装常用工具**](#2.2.2 配置yum源与安装常用工具)
- [2.2.3 **ssh远程连接加速**](#2.2.3 ssh远程连接加速)
- [2.2.4 时间同步](#2.2.4 时间同步)
- [2.2.5 **配置命令行颜色**](#2.2.5 配置命令行颜色)
- [2.2.6 **配置rm的别名**](#2.2.6 配置rm的别名)
- [2.2.7 **修改ip和主机名的脚本**](#2.2.7 修改ip和主机名的脚本)
- [2.2.8 配置**hosts解析**](#2.2.8 配置hosts解析)
- [2.2.9 配置vimrc](#2.2.9 配置vimrc)
- [2.2.10 释放被占用的内存 kdump](#2.2.10 释放被占用的内存 kdump)
- [2.2.11 **处理tmp**](#2.2.11 处理tmp)
- [2.2.12 根据hosts文件克隆虚拟机,修改ip和hostname](#2.2.12 根据hosts文件克隆虚拟机,修改ip和hostname)
1. 网站集群架构
1.1 开发维度
开发维度 |
软件服务 |
发布平台 |
Jenkins、argo |
1.2 用户维度
用户维度 |
服务 |
说明 |
DNS解析 |
云解析DNS |
在哪里买的域名,在哪里解析即可 |
CDN |
云厂商的CDN产品 蓝汛/网宿 |
Content Delivery Network,内容分发网络,通过将静态资源 (如图片、视频、CSS/JS 文件等)缓存在全球分布的 边缘节点(Edge Servers),使用户可以从最近的服务器获取内容, 从而提升访问速度、降低源站负载。 |
防火墙 |
硬件防火墙 firewalld/iptables/ufw 云产品防火墙:安全组 |
|
负载均衡 |
硬件负载均衡:F5 开源软件: nginx、lvs、haproxy 云产品 |
|
web服务器(中间件) |
开源软件: nginx、tomcat、php、apache |
LNMP(Linux系统、nginx、mysql数据库、php) |
数据库缓存 |
开源软件:redis |
|
数据库 |
mysql、mariadb、oracle(甲骨文)、 国产数据库:高斯(opengause 华为)、 ob(oceanbase 阿里)、tidb |
|
存储服务 |
硬件:各种厂商都有,浪潮、华为 开源软件:NFS、ceph、minio 云产品 |
|
1.3 运维维度
运维维度 |
服务 |
说明 |
VPN |
硬件 开源软件:openvpn 云产品 |
公司--->内网服务器 |
堡垒机 |
硬件 开源软件:jumpserver 云产品 |
|
监控 |
硬件 开源软件:zabbix、Grafana、 Prometheus(普罗米修斯) 云产品 |
|
日志 |
ELK(Elatic Stack) |
|
安全 |
AWNS、nessus扫描 |
|
大数据 |
hadoop系列 |
|
登录 |
统一登录系统:AD(windoes)、openLDAP(linux) |
|
AI |
DeepSeek(自建、调取API接口)、ChatGPT(api)、ChatGLM |
|
2. 模板机
2.1 系统准备-kylin v10
- cpu:2核
- memory:2G
- 2块网卡
- 100G磁盘,手动分区
2.2 系统优化
2.2.1 关闭防火墙和selinux
shell
复制代码
systemctl stop firewalld
systemctl disable firewalld
- selinux默认是关闭的,可用
getenforce
2.2.2 配置yum源与安装常用工具
shell
复制代码
#增加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
2.2.3 ssh远程连接加速
- 关闭ssh远程连接反向解析功能,加速ssh远程连接.
shell
复制代码
修改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即可.
2.2.4 时间同步
shell
复制代码
cat >/var/spool/cron/root<<EOF
#1. sync time by lidao996 at 20230101
*/3 * * * * /sbin/ntpdate ntp.aliyun.com >/dev/null 2>&1
EOF
2.2.5 配置命令行颜色
shell
复制代码
# 编辑/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
2.2.6 配置rm的别名
shell
复制代码
cat recyle-rm.sh
#!/bin/bash
##############################################################
# File Name:07.recyle-rm.sh
# Version:V1.0
# Author:oldboy lidao996
# Organization:www.oldboyedu.com
# Desc:
##############################################################
#1.vars
files="$@"
dir=/recyle/
#2.判断
if [ $# -eq 0 ];then
echo "Help: $0 file dir ...."
exit
fi
#3.创建临时目录
#后期可以加入判断 目录不存在则创建
mkdir -p $dir
tmp_dir=`mktemp -d -p ${dir}`
#4.把文件,目录...移动到临时目录
#这里未来可以加入更多的判断.
mv -t ${tmp_dir} ${files}
#5.文件,目录已经移动到回收站
echo "文件,目录已经移动到回收站:${tmp_dir}"
echo "alias rm='bash /server/scripts/recyle-rm.sh' " >>/etc/profile
- 注释已有的rm命令
shell
复制代码
# 注释掉已有的rm别名
sed -i '/rm/s@^@#@g' ~/.bashrc
sed -i 's@alias.*rm@#&@g' ~/.bashrc
cat >>/etc/profile<<EOF
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
EOF
source /etc/profile
2.2.7 修改ip和主机名的脚本
- cat /server/scripts/change.sh
shell
复制代码
#!/bin/bash
#author: lidao996
#desc: change ip and hostname
#version: v7.0 fina
#sh 脚本 主机名 ip地址(新的ip)
eth0_name=ens33
eth1_name=ens34
eth0=/etc/sysconfig/network-scripts/ifcfg-$eth0_name
eth1=/etc/sysconfig/network-scripts/ifcfg-$eth1_name
#1.脚本参数个数
if [ $# -ne 2 ] ;then
echo "请输入2个参数"
exit 1
fi
#2.模板机ip地址(最后1位)
ip=`hostname -I |awk '{print $1}'|sed 's#.*\.##g'`
#3.新的ip
ip_new=`echo $2 |sed 's#^.*\.##g'`
#4.新的主机名
hostname=$1
#5.修改ip
if [ -f $eth0 ];then
sed -i "s#10.0.0.$ip#10.0.0.$ip_new#g" $eth0
else
echo "eth0网卡不存在,修改失败"
fi
if [ -f $eth1 ];then
sed -i "s#172.16.1.$ip#172.16.1.$ip_new#g" $eth1
else
echo "eth1网卡不存在,修改失败"
fi
ifdown $eth0_name && ifup $eth0_name
ifdown $eth1_name && ifup $eth1_name
#6.修改主机名
hostnamectl set-hostname $hostname
- chmod +x /server/scripts/change.sh
- ln -s /server/scripts/change.sh /bin/
- 重启系统:reboot
2.2.8 配置hosts解析
shell
复制代码
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
2.2.9 配置vimrc
shell
复制代码
# vim /etc/vimrc 追加
set ignorecase
autocmd BufNewFile *.py,*.cc,*.sh,*.java,*.bash 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:SunKexu")
call setline(6, "# Organization:www.oldboyedu.com")
call setline(7, "# Desc:")
call setline(8,"##############################################################")
endif
endfunc
2.2.10 释放被占用的内存 kdump
shell
复制代码
#1.命令关闭
systemctl disable --now kdump
#2.修改启动配置文件
sed -i 's#crashkernel=1024M,high##g' /boot/grub2/grub.cfg
#3.重启linux系统
2.2.11 处理tmp
shell
复制代码
systemctl mask tmp.mount
重启检查结果
2.2.12 根据hosts文件克隆虚拟机,修改ip和hostname
- 修改主机名和ip,ip直接写NAT网卡的ip,LAN网卡的ip也会改变,两个ip的主机号相同