OpenCloudOS 使用指南
OpenCloudOS 是由腾讯主导、多家企业联合发起的开源操作系统社区项目。它在兼容 Enterprise Linux 生态的基础上,引入了 TencentOS Kernel 等差异化特性,是腾讯云生态中的核心操作系统选择。腾讯云上的「TencentOS Server」即基于 OpenCloudOS。
OpenCloudOS 版本与定位
Section titled “OpenCloudOS 版本与定位”| 版本 | 上游基础 | 生命周期 | 说明 |
|---|---|---|---|
| OpenCloudOS 8(当前 8.8) | RHEL 8 | 至 2029 年 | 兼容 CentOS 8 / AlmaLinux 8 |
| OpenCloudOS 9(当前 9.6) | RHEL 9 | 至 2032 年 | 兼容 CentOS Stream 9 / AlmaLinux 9 |
| OpenCloudOS Stream 23 | 独立演进 | 滚动维护 | 自主技术路线,社区创新版本 |
OpenCloudOS 8/9 与 RHEL 8/9 兼容,适合需要稳定生产环境的用户。OpenCloudOS Stream 23 则采用独立的版本策略,引入更多社区创新。
腾讯云上的命名对应关系:
| 腾讯云镜像名 | 对应社区版本 |
|---|---|
| TencentOS Server 3.1 | 基于 OpenCloudOS 8 |
| TencentOS Server 4 | 基于 OpenCloudOS 9 |
与标准 EL 发行版的差异
Section titled “与标准 EL 发行版的差异”OpenCloudOS 提供两种内核选择:
- 标准内核:OpenCloudOS 8 使用与 RHEL 8 兼容的 5.4 内核;OpenCloudOS 9 使用 6.6 LTS 内核(比 RHEL 9 的 5.14 更新)
- TencentOS Kernel(TK):基于上游 LTS 内核,腾讯自研优化
TencentOS Kernel 是 OpenCloudOS 区别于其他 EL 兼容发行版的核心特性。
OpenCloudOS 8 的用户态软件包与 RHEL 8 高度一致,通常可以直接使用 RHEL/CentOS 8 的 RPM 包。OpenCloudOS 9 与 RHEL 9 保持兼容。
- SELinux 默认处于 enforcing 模式
- 防火墙默认使用 firewalld
- 网络管理使用 NetworkManager
- 在腾讯云 CVM 上运行时,cloud-init 预配置了腾讯云数据源
$ cat /etc/opencloudos-release$ uname -rOpenCloudOS 8 仓库
Section titled “OpenCloudOS 8 仓库”$ dnf repolistOpenCloudOS 8 默认仓库:
| 仓库 ID | 说明 |
|---|---|
BaseOS | 基础操作系统包 |
AppStream | 应用流包 |
Extras | 额外软件包 |
PowerTools | 开发者工具 |
Plus | 社区增强包 |
OpenCloudOS 9 仓库
Section titled “OpenCloudOS 9 仓库”| 仓库 ID | 说明 |
|---|---|
BaseOS | 基础操作系统包 |
AppStream | 应用流包 |
CRB | CodeReady Builder 对应包 |
Extras | 额外软件包 |
仓库配置文件
Section titled “仓库配置文件”$ ls /etc/yum.repos.d/EPEL 支持
Section titled “EPEL 支持”OpenCloudOS 兼容 EPEL 仓库:
$ sudo dnf install epel-release -y如果 epel-release 包不在默认仓库中,可以手动安装:
$ sudo dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm$ sudo dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm使用腾讯云内网镜像
Section titled “使用腾讯云内网镜像”在腾讯云 CVM 上,OpenCloudOS 仓库默认指向腾讯云内网镜像,访问速度快且不消耗公网带宽。如果在非腾讯云环境使用:
$ sudo sed -i 's|http://mirrors.tencentyun.com|https://mirrors.cloud.tencent.com|g' /etc/yum.repos.d/OpenCloudOS*.repo$ sudo dnf makecacheTencentOS Kernel
Section titled “TencentOS Kernel”TencentOS Kernel(TK)是 OpenCloudOS 的核心差异化特性,基于上游 LTS 内核,融入了腾讯在大规模生产环境中积累的优化经验。
TK 与标准内核对比
Section titled “TK 与标准内核对比”| 特性 | 标准内核 | TencentOS Kernel |
|---|---|---|
| 基础版本 | RHEL 回移内核 | 上游 LTS + 腾讯补丁 |
| 更新频率 | 跟随 RHEL | 独立更新周期 |
| 容器优化 | 标准支持 | 深度优化 |
| 性能调优 | 通用配置 | 针对云场景优化 |
安装 TencentOS Kernel
Section titled “安装 TencentOS Kernel”在腾讯云 CVM 上,TencentOS Server 镜像默认使用 TK。手动安装方式:
$ sudo dnf install kernel-tkernel$ rpm -qa | grep kernel$ sudo grubby --set-default /boot/vmlinuz-*tkernel*$ sudo reboot$ uname -r输出中包含 tkernel 字样表示正在使用 TencentOS Kernel。
TK 主要优化特性
Section titled “TK 主要优化特性”容器与资源隔离
Section titled “容器与资源隔离”- cgroupfs 优化:改进 cgroup v2 的性能和稳定性
- 容器网络优化:减少容器网络命名空间切换的开销
- OOM 增强:改进 OOM Killer 在容器场景下的行为,避免误杀关键进程
- io_uring 增强:对异步 I/O 框架的性能优化
- 云盘 I/O 优化:针对虚拟化存储的 I/O 调度优化
- 文件系统改进:ext4 和 XFS 在高并发场景下的性能提升
- BBR 拥塞控制:预置 TCP BBR 拥塞控制算法
$ sudo sysctl -w net.core.default_qdisc=fq$ sudo sysctl -w net.ipv4.tcp_congestion_control=bbr$ echo "net.core.default_qdisc=fq" | sudo tee -a /etc/sysctl.d/99-bbr.conf$ echo "net.ipv4.tcp_congestion_control=bbr" | sudo tee -a /etc/sysctl.d/99-bbr.conf- XDP 支持:eXpress Data Path 高性能数据包处理
- MPTCP:多路径 TCP 支持
- 内核热补丁:支持在不重启的情况下修复内核漏洞
- KASLR 增强:内核地址空间布局随机化改进
内核参数调优
Section titled “内核参数调优”TencentOS Kernel 提供了一些额外的可调参数:
$ sudo sysctl -a | grep tencent 2>/dev/null# 增大 TCP 缓冲区$ sudo sysctl -w net.core.rmem_max=16777216$ sudo sysctl -w net.core.wmem_max=16777216
# 优化 TCP 连接复用$ sudo sysctl -w net.ipv4.tcp_tw_reuse=1
# 增大连接队列$ sudo sysctl -w net.core.somaxconn=65535从 CentOS 迁移到 OpenCloudOS
Section titled “从 CentOS 迁移到 OpenCloudOS”OpenCloudOS 社区提供了官方迁移工具 migrate2opencloudos:
$ curl -fsSL https://mirrors.opencloudos.tech/opencloudos/migration/migrate2opencloudos.sh -o migrate2opencloudos.sh$ chmod +x migrate2opencloudos.shCentOS 7 迁移到 OpenCloudOS 8
Section titled “CentOS 7 迁移到 OpenCloudOS 8”CentOS 7 到 OpenCloudOS 8 属于跨大版本迁移,建议采用重新部署的方式而非原地升级。如果必须原地迁移:
- 先将 CentOS 7 迁移到 OpenCloudOS 7(如果可用)
- 再执行大版本升级
更推荐的做法是新建 OpenCloudOS 8 实例,然后迁移应用和数据。
CentOS 8 迁移到 OpenCloudOS 8
Section titled “CentOS 8 迁移到 OpenCloudOS 8”CentOS 8 到 OpenCloudOS 8 属于同版本迁移,兼容性最好:
$ sudo bash migrate2opencloudos.sh --check预检查会扫描:
- 当前系统版本是否支持迁移
- 第三方仓库和包的兼容性
- 磁盘空间是否充足
- 内核模块兼容性
$ sudo bash migrate2opencloudos.sh --migrate迁移过程:
- 备份当前仓库配置
- 替换 CentOS 仓库为 OpenCloudOS 仓库
- 替换系统标识包(
centos-release→opencloudos-release) - 同步更新所有系统包
- 重建 RPM 数据库
$ cat /etc/opencloudos-release$ rpm -qa | grep centos# 应该没有 CentOS 相关包输出$ sudo reboot$ uname -r$ systemctl is-system-running$ dnf checkCentOS Stream 9 迁移到 OpenCloudOS 9
Section titled “CentOS Stream 9 迁移到 OpenCloudOS 9”$ sudo bash migrate2opencloudos.sh --os-version 9 --check$ sudo bash migrate2opencloudos.sh --os-version 9 --migrate迁移注意事项
Section titled “迁移注意事项”- 备份优先:迁移前务必创建完整快照或备份
- 测试先行:在测试环境验证迁移流程后再操作生产环境
- 第三方包:EPEL、Remi 等第三方仓库的包需在迁移后重新配置
- 自编译模块:自编译的内核模块需在新内核上重新编译
- 不可中断:迁移过程中不要中断操作或关闭电源
- 监控服务:迁移后检查所有关键服务是否正常运行
$ sudo systemctl list-units --type=service --state=failed$ sudo systemctl status nginx postgresql redis腾讯云集成特性
Section titled “腾讯云集成特性”在腾讯云 CVM 上运行 OpenCloudOS(即 TencentOS Server)时,有以下专属集成特性:
TencentOS Server 镜像预装了以下腾讯云组件:
- cloud-init:实例初始化,预配置腾讯云数据源
- tat_agent:腾讯云自动化助手 agent,支持远程命令执行
- sgagent:腾讯云监控 agent
- YunJing:腾讯云主机安全 agent
$ rpm -qa | grep -E "(cloud-init|tat_agent|sgagent)"$ systemctl status tat_agent腾讯云自动化助手(TAT)
Section titled “腾讯云自动化助手(TAT)”TAT 允许你在控制台或通过 API 远程执行命令,无需 SSH 登录:
$ systemctl status tat_agent通过 CLI 执行远程命令:
$ tccli tat RunCommand \ --Content "$(echo 'df -h && free -m' | base64)" \ --InstanceIds '["ins-xxxxxx"]' \ --CommandType SHELL腾讯云为 TencentOS Kernel 提供内核热补丁支持:
$ sudo dnf list available | grep kpatch$ sudo dnf install kpatch-patch-<kernel-version>腾讯云专属调优
Section titled “腾讯云专属调优”TencentOS Server 在 CVM 上的默认配置针对腾讯云做了调优:
- 虚拟化驱动:virtio 驱动针对腾讯云虚拟化平台优化
- 内存管理:页面回收和 swap 策略针对 CVM 调优
- 网络参数:TCP 和网卡参数针对腾讯云网络调优
- 存储调度:I/O 调度器针对云硬盘特性调优
$ cat /etc/sysctl.d/*tencent* 2>/dev/null$ cat /etc/sysctl.d/*cloud* 2>/dev/null使用腾讯云 API 管理实例
Section titled “使用腾讯云 API 管理实例”结合 tccli 可以实现自动化运维:
$ tccli cvm DescribeInstances \ --Filters '[{"Name":"instance-state","Values":["RUNNING"]}]' | \ jq '.InstanceSet[] | {InstanceId, InstanceName, PrivateIpAddresses}'$ tccli cbs CreateAutoSnapshotPolicy \ --Policy '[{"DayOfWeek":[0],"Hour":[3]}]' \ --AutoSnapshotPolicyName "weekly-backup" \ --RetentionDays 30OpenCloudOS 社区资源:
- 官方网站:https://www.opencloudos.org
- 代码仓库:https://gitee.com/OpenCloudOS
- 镜像下载:https://mirrors.opencloudos.tech
- 邮件列表:社区邮件列表可在官网找到
腾讯云用户还可以通过腾讯云工单系统获取技术支持。
如何在标准内核和 TK 之间切换
Section titled “如何在标准内核和 TK 之间切换”$ sudo grubby --info=ALL | grep title$ sudo grubby --set-default /boot/vmlinuz-4.18.0-xxx.oc8.x86_64$ sudo reboot$ sudo grubby --set-default /boot/vmlinuz-5.4.119-xxx.tkernel.x86_64$ sudo rebootOpenCloudOS 与 TencentOS Server 的关系
Section titled “OpenCloudOS 与 TencentOS Server 的关系”OpenCloudOS 是社区开源项目,TencentOS Server 是腾讯云基于 OpenCloudOS 定制的商业镜像。两者的主要区别:
- TencentOS Server 预装了腾讯云 agent 和监控组件
- TencentOS Server 的仓库指向腾讯云内网镜像
- TencentOS Server 可获得腾讯云官方技术支持
- 两者的内核和用户态软件包完全一致
第三方软件兼容性
Section titled “第三方软件兼容性”OpenCloudOS 8/9 与 RHEL 8/9 兼容,为 RHEL/CentOS 编译的软件通常可以直接运行。如遇问题:
$ ldd /path/to/binary$ dnf provides libxxx.so.1- 腾讯云 CVM 实践 — 在腾讯云 CVM 上部署 EL 发行版
- 发行版概览 — Enterprise Linux 发行版全景对比
- 从 CentOS 迁移 — 迁移路径总览
- Cloud-Init 配置 — Cloud-Init 详细配置指南