123 字
1 分钟
服务器初始化完整配置流程
本文记录生产环境服务器的完整初始化配置流程,适用于新机器的快速上线。
1. 基础配置
hostnamectl set-hostname your-hostnamevim /etc/hosts2. 换源
根据发行版替换为国内镜像源(阿里云 / 腾讯云 / 清华 TUNA)。
3. 时区配置
timedatectl set-timezone Asia/Shanghaitimedatectl status4. 安装 K8s 集群(KubeSphere 离线)
apt install -y socat conntrack
mkdir -p /etc/dockercat > /etc/docker/daemon.json <<'EOF'{ "log-opts": { "max-size": "5m", "max-file": "3" }, "exec-opts": ["native.cgroupdriver=systemd"], "data-root": "/opt/docker"}EOF
./kk init registry -f config.yaml -a kubesphere-4.1.tar.gzsh create_project_harbor.sh./kk artifact image push -f config.yaml -a kubesphere-4.1.tar.gz./kk create cluster -f config.yaml -a kubesphere-4.1.tar.gz --with-local-storage
helm upgrade --install -n kubesphere-system --create-namespace ks-core ks-core-1.1.3.tgz \ --set global.imageRegistry=harbor.local/ks \ --set extension.imageRegistry=harbor.local/ks \ --debug --wait5. 安装 MinIO
wget https://dl.min.io/server/minio/release/linux-amd64/archive/minio.RELEASE.2025-04-22T22-12-26Zmkdir -p /opt/miniomv minio.RELEASE.2025-04-22T22-12-26Z /opt/minio/miniochmod +x /opt/minio/miniosystemctl daemon-reloadsystemctl enable --now miniosystemctl status minio详细安装步骤参见:MinIO 安装指南
6. 搭建 Redis 集群(3 主 3 从)
wget https://download.redis.io/releases/redis-7.4.6.tar.gztar -zxvf redis-7.4.6.tar.gzapt install gcc make -ycd redis-7.4.6 && make && sudo make install
mkdir -p /opt/redis/cluster/{7001,7002}
# 启动所有实例后建集群redis-cli --cluster create \ node1:7001 node2:7001 node3:7001 \ node1:7002 node2:7002 node3:7002 \ --cluster-replicas 1 -a your-password
redis-cli -c -h node1 -p 7001 -a your-password cluster nodes7. 安装 MySQL 8.1(Ubuntu)
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-server_8.1.0-1ubuntu22.04_amd64.deb-bundle.tartar -xf mysql-server_8.1.0-1ubuntu22.04_amd64.deb-bundle.tar
apt install ./mysql-common_8.1.0-*.deb \ ./mysql-community-client-plugins_8.1.0-*.deb \ ./libmysqlclient22_8.1.0-*.deb \ ./mysql-community-client-core_8.1.0-*.deb \ ./mysql-community-client_8.1.0-*.deb \ ./mysql-community-server-core_8.1.0-*.deb \ ./mysql-community-server_8.1.0-*.deb
# 修改数据目录vim /etc/mysql/mysql.conf.d/mysqld.cnf# datadir = /opt/mysql/data
vim /etc/apparmor.d/usr.sbin.mysqld# 添加:/opt/mysql/ r, /opt/mysql/** rwk,
systemctl reload apparmormkdir -p /opt/mysql && chown -R mysql:mysql /opt/mysqlsudo -u mysql mysqld --initialize-insecure --user=mysql --datadir=/opt/mysql/datasystemctl start mysql && systemctl enable mysql 分享
如果这篇文章对你有帮助,欢迎分享给更多人!
相关文章 智能推荐
1
Linux 服务器时间同步配置(Chrony)
Linux 系统管理 使用 Chrony 工具为 Linux 服务器配置时间同步,支持阿里云、腾讯云等国内 NTP 源及内网 NTP 服务器。
2
PVE 疑难解答与系统优化
HomeLab 私有云 汇总 Proxmox VE 常见问题的解决方法,包括 CPU 调度优化、温度传感器显示、网卡配置修复、qemu-guest-agent 安装及黑群晖型号选择备忘。
3
JumpServer 开源堡垒机安装指南
HomeLab 私有云 介绍 JumpServer 开源堡垒机的部署方式,包括最低硬件要求、Linux 单机部署文档参考及常见问题处理。
4
Proxmox VE 9.0 安装与初始配置指南
HomeLab 私有云 从下载安装到换源、内核更新、SR-IOV 核显虚拟化、订阅弹窗去除、存储合并的 PVE 9.0 完整配置流程。
5
Beszel 服务器监控工具部署指南
HomeLab 私有云 介绍 Beszel 监控工具的 Hub 和 Agent 部署方式,支持 Docker 和二进制两种方式,可监控服务器资源、Docker、Systemd、S.M.A.R.T.、GPU 等。
