diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 Binary files /dev/null and b/.DS_Store differ diff --git a/README.md b/README.md index 783b75a550891008ad9e9c43d71af1c3c10f45b0..d6e92c5e811df6a505b3922ab27e43132e07f218 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,18 @@ openEuler Docs 仓旨在为帮助社区用户快速了解 openEuler 各类项目,本仓包含了 openEuler 社区的所有文档,包括发行说明、操作系统安装、管理员指南、虚拟化和容器的使用指导等内容。 +## 仓库 + +openEuler 官方文档存储于 openeuler/docs 仓和 openeuler/docs-centralized 仓: + +- docs 仓则用于存放基于SIG组下沉机制管理的文档; +- docs-centralized 仓用于存放集中管理模式的文档(旧版的文档管理方式)。 + +| 仓库 | openEuler 版本 | +|-----|----| +| openeuler/docs | openEuler 24.03 LTS SP2、openEuler 25.03、openEuler 24.03 LTS SP1| +| openeuler/docs-centralized | master、openEuler 24.03 LTS SP1、openEuler 24.09、openEuler 22.03 LTS SP4、openEuler 24.03 LTS、openEuler 22.03 LTS SP3、openEuler 20.03 LTS SP4、openEuler 23.09、openEuler 22.03 LTS SP2、openEuler 23.03、openEuler 22.03 LTS SP1、openEuler 22.09、openEuler 22.03 LTS、openEuler 20.03 LTS SP3、openEuler 21.09、openEuler 20.03 LTS SP2、openEuler 21.03、openEuler 20.03 LTS SP1、openEuler 20.09、openEuler 20.03 LTS | + ## 如何查看版本分支对应关系 openEuler 目前提供以下两类版本: @@ -13,50 +25,474 @@ openEuler 目前提供以下两类版本: - 长期支持 (LTS)版本:openEuler 发布间隔周期定为2年,提供4年社区支持,在较长的时间内获得安全、维护和功能的更新。 - 社区创新版本:每隔6个月会发布一个社区创新版本,具有最新的硬软件支持。 -Docs 当前使用以下三类分支,长期支持版本和社区创新版本分别以 20.03 LTS SP3 和 21.09 为例: +Docs 当前使用以下三类分支,长期支持版本和社区创新版本分别以 22.03 LTS SP3 和 24.09 为例: | 分支 | 说明 | 内容呈现 | |-----|----|----| | master | 开发分支,为默认分支|-| -| stable2-20.03_LTS_SP3 | 20.03 LTS 版本 SP3 版本分支 | 分支内容呈现在[openEuler社区](https://openeuler.org/)网站“文档->20.03 LTS SP3” | -| stable2-21.09 | 21.09 版本分支 | 分支内容呈现在[openEuler社区](https://openeuler.org/)网站“文档->21.09” | +| stable2-22.03_LTS_SP3 | 22.03 LTS 版本 SP3 版本分支 | 分支内容呈现在[openEuler社区](https://openeuler.org/)网站“文档->22.03 LTS SP3” | +| stable2-24.09 | 24.09 版本分支 | 分支内容呈现在[openEuler社区](https://openeuler.org/)网站“文档->24.09” | ## 资料清单 -| 文档名称 | 开发类型 | 文件夹 | -|-----|----|----| -| 法律声明 | 更新 | Releasenotes | -| 发行说明 | 更新 | Releasenotes | -| 快速入门 | 更新 | Quickstart | -| 安装指南 | 更新 | Installation | -| 管理员指南 | 更新 | Administration | -| 安全加固指南 | 更新 | SecHarden | -| 虚拟化用户指南 | 更新 | Virtualization | -| StratoVirt用户指南 | 更新 | StratoVirt | -| 容器用户指南 | 更新 | Container | -| A-Tune 用户指南 | 更新 | A-Tune | -| Embedded 用户指南 | 新增 | Embedded | -| 内核热升级指南 | 更新 | KernelLiveUpgrade | -| 应用开发指南 | 更新 | ApplicationDev | -| secGear 开发指南 | 更新 | secGear | -| Kubernetes 集群部署指南 | 更新 | Kubernetes | -| 第三方软件安装指南 | 更新 | thirdparty_migration | -| 桌面环境用户指南 | 更新 | desktop | -| 工具集用户指南 | 更新 | userguide | -| A-Ops用户指南 | 更新 | A-Ops | -| 容器OS升级指南 | 新增 | KubeOS | - -## 如何在Docs中查找文档 - -进入[Docs 仓](https://gitee.com/openeuler/docs), 选择 stable2-21.09 分支,进入 “docs” 文件夹,该文件夹包含了中文(“zh”文件夹)和英文(“en”文件夹)两种语言文档,以中文文档举例进行说明。在“zh”文件夹中,“docs”文件夹包含了文档的内容,“menu”展示了具体文档与 Docs 官网目录的映射关系。 “docs” 文件夹与各手册的对应关系可参考资料清单。 - -## 如何修改文档 - -当openEuler版本信息有刷新时,这里文档也需要刷新。很感谢您愿意提供刷新内容。 -请阅读[openEuler 开源社区贡献指南](https://gitee.com/openeuler/docs/blob/master/contribute/openEuler%E5%BC%80%E6%BA%90%E7%A4%BE%E5%8C%BA%E8%B4%A1%E7%8C%AE%E6%8C%87%E5%8D%97.md)进行操作参考。 +### 服务器 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
场景类别手册存放地址
服务器发行说明发行说明docs/zh/server/releasenotes/releasenotes
快速入门快速入门docs/zh/server/quickstart/quickstart
安装升级安装指南docs/zh/server/installation_upgrade/installation
升级指南docs/zh/server/installation_upgrade/upgrade
系统管理管理员指南docs/zh/server/administration/administrator
sysMaster用户指南docs/zh/server/administration/sysmaster
兼容性命令docs/zh/server/administration/compa_command
系统运维A-Ops用户指南docs/zh/server/maintenance/aops
gala用户指南docs/zh/server/maintenance/gala
sysmonitor用户指南docs/zh/server/maintenance/sysmonitor
内核热升级指南docs/zh/server/maintenance/kernel_live_upgrade
SysCare用户指南docs/zh/server/maintenance/syscare
常用技能docs/zh/server/maintenance/common_skills
常用定位定界工具docs/zh/server/maintenance/common_tools
故障应急处理docs/zh/server/maintenance/troubleshooting
安全安全加固指南docs/zh/server/security/secharden
可信计算docs/zh/server/security/trusted_computing
secGear开发指南docs/zh/server/security/secgear
CVE-ease设计指南docs/zh/server/security/cve-ease
证书签名docs/zh/server/security/cert_signature
SBOM用户指南docs/zh/server/security/sbom
国密docs/zh/server/security/shangmi
内存与存储配置和管理逻辑卷docs/zh/server/memory_storage/lvm
etmem用户指南docs/zh/server/memory_storage/etmem
GMEM用户指南docs/zh/server/memory_storage/gmem
HSAK开发指南docs/zh/server/memory_storage/hsak
网络配置网络docs/zh/server/network/network_config
Gazelle用户指南docs/zh/server/network/gazelle
性能调优系统资源与性能docs/zh/server/performance/overall/system_resource
oeAware用户指南docs/zh/server/performance/tuning_framework/oeaware
sysBoost用户指南docs/zh/server/performance/cpu_optimization/sysboost
使用KAE加速引擎docs/zh/server/performance/cpu_optimization/kae
A-Tune用户指南docs/zh/server/performance/system_optimization/atune
应用开发应用开发指南docs/zh/server/development/application_dev
GCC用户指南docs/zh/server/development/gcc
HA高可用HA用户指南docs/zh/server/high_availability/ha
多样性算力直连聚合用户指南docs/zh/server/diversified_computing/dpu_offload
DPU-OSdocs/zh/server/diversified_computing/dpu_os
+ +### 虚拟化 + + + + + + + + + + + + + + + + + + + + + + +
场景类别手册存放地址
虚拟化虚拟化平台虚拟化用户指南docs/zh/virtualization/virtualization_platform/virtualization
StratoVirt用户指南docs/zh/virtualization/virtualization_platform/stratovirt
OpenStack用户手册openstack-docs/docs/zh
+ +### 云原生 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
场景类别手册存放地址
云原生容器引擎iSula容器引擎docs/zh/cloud/container_engine/isula_container_engine
Docker容器docs/zh/cloud/container_engine/docker_engine
容器形态安全容器docs/zh/cloud/container_form/secure_container
系统容器docs/zh/cloud/container_form/system_container
容器运行时Kuasar多沙箱容器运行时docs/zh/cloud/container_runtime/kuasar
容器镜像构建工具容器镜像构建docs/zh/cloud/image_builder/isula-build
云原生操作系统容器OS升级用户指南docs/zh/cloud/kubeos/kubeos
云底座操作系统NestOS用户指南docs/zh/cloud/nestosS/nestos
混合部署云原生混合部署rubik用户指南docs/zh/cloud/hybrid_deployment/rubik
oncn-bwm用户指南docs/zh/cloud/hybrid_deployment/oncn-bwm
集群部署Kubernetes集群部署指南docs/zh/cloud/cluster_deployment/kubernetes
iSulad+k8s集群部署指南docs/zh/cloud/cluster_deployment/isulad+k8s
服务网格Kmesh用户指南docs/zh/cloud/kmesh/kmesh
+ +### 边缘计算 + + + + + + + + + + + + + + + + + + +
场景类别手册存放地址
边缘计算 / KubeEdge部署指南docs/zh/edge_computing/kube_edge
K3s部署指南docs/zh/edge_computing/k3s
+ +### 嵌入式 + + + + + + + + + + + + + + + + + + +
场景类别手册存放地址
嵌入式 / openEuler Embedded用户指南yocto-meta-openeuler/docs
UniProton用户指南docs/zh/embedded/uniproton
+ +### 工具 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
工具模块类别手册存放地址
社区工具镜像构建isocut使用指南docs/zh/tools/community_tools/image_custom/isocut
imageTailor使用指南docs/zh/tools/community_tools/image_custom/image_tailor
编译GCC用户指南docs/zh/server/development/gcc
性能优化A-Tune用户指南docs/zh/server/performance/system_optimization/atune
oeAware用户指南docs/zh/server/performance/tuning_framework/oeaware
迁移Migration-tools用户指南docs/zh/tools/community_tools/migration/migration_tools
虚拟化EulerLauncher用户指南docs/zh/tools/community_tools/virtualization/euler_launcher
epkg软件包epkg包管理器使用指南docs/zh/tools/community_tools/epkg/epkg_use
autopkg用户指南docs/zh/tools/community_tools/epkg/autopkg
社区服务源码管理patch-trackingdocs/zh/tools/devops/code_manage/patch_tracking
包管理pkgshipdocs/zh/tools/devops/package_manage/pkgship
AI / openEuler Copilot Systemdocs/zh/tools/ai/openeuler_copilot_system
AI大模型服务镜像使用指南docs/zh/tools/ai/ai_large_model_service_images_userguide
AI容器镜像用户指南docs/zh/tools/ai/ai_container_image_userguide
图形桌面使用 / Gnome用户指南docs/zh/tools/desktop/gnome
UKUI用户指南docs/zh/tools/desktop/ukui
DDE用户指南docs/zh/tools/desktop/dde
Kiran用户指南docs/zh/tools/desktop/kiran
XFCE用户指南docs/zh/tools/desktop/xfce
云原生工具 / CTinspector用户指南docs/zh/tools/cloud/ctinspector
CPDS用户指南docs/zh/tools/cloud/cpds
PilotGo用户指南docs/zh/tools/cloud/pilotgo
系统运维热补丁制作SysCare用户指南docs/zh/server/maintenance/syscare
系统监控sysmonitor用户指南docs/zh/server/maintenance/sysmonitor
安全 / secGear开发指南docs/zh/server/security/secgear
+ +## 如何参与文档开发 + +快速贡献openEuler文档,请参考[快速入门](https://gitee.com/openeuler/docs/blob/common/docs/zh/contribute/contribution_process.md)。 + +docs仓文档组成介绍,请参考[文档开发介绍](https://gitee.com/openeuler/docs/blob/common/docs/zh/contribute/directory_structure_introductory.md)。 + +此外,请关注[文档写作规范](https://gitee.com/openeuler/docs/blob/common/docs/zh/contribute/documentation_writing_specifications.md)和[文档发布流水线门禁](https://gitee.com/openeuler/docs/blob/common/docs/zh/contribute/markdownlint_rules.md)。 ## 如何参与SIG -建立或回复 issue:欢迎通过建立或回复 issue 来讨论。可选择[文档捉虫](https://docs.openeuler.org/zh/)方式快速建立 issue,可查看[活动详情](https://docs-bug.openeuler.sh/)。 +建立或回复 issue:欢迎通过建立或回复 issue 来讨论。可选择[文档捉虫](https://docs.openeuler.org/zh/)方式快速建立 issue。 提交PR:欢迎通过提交PR的方式参与SIG。具体操作方法可参考[PR提交指南](https://gitee.com/openeuler/community/blob/master/zh/contributors/pull-request.md)。 @@ -71,10 +507,9 @@ Docs 当前使用以下三类分支,长期支持版本和社区创新版本分 - amyMaYun[@amy_mayun](https://gitee.com/amy_mayun) - hujunjune[@hujunjune](https://gitee.com/hujunjune) - judithsq[@judithsq](https://gitee.com/judithsq) -- lizhongqian[@lizhongqian](https://gitee.com/lizhongqian) - echo10111111[@echo10111111](https://gitee.com/echo10111111) +- wu-donger[@wu-donger](https://gitee.com/wu-donger) ### 如何联系我们 邮件列表: - diff --git "a/contribute/MarkDown\345\270\270\347\224\250\350\257\255\346\263\225\345\217\202\350\200\203.md" "b/contribute/MarkDown\345\270\270\347\224\250\350\257\255\346\263\225\345\217\202\350\200\203.md" deleted file mode 100644 index f2f4a6098dd5d950f931b75317a1262eb3b9ae12..0000000000000000000000000000000000000000 --- "a/contribute/MarkDown\345\270\270\347\224\250\350\257\255\346\263\225\345\217\202\350\200\203.md" +++ /dev/null @@ -1,140 +0,0 @@ -# MarkDown常用语法参考 - -## 标题 - -使用\#号标记:使用 \# 号可表示 1-6 级标题,一级标题对应一个 \# 号,二级标题对应两个 \# 号,以此类推。 - -``` -# 一级标题 -## 二级标题 -### 三级标题 -#### 四级标题 -##### 五级标题 -###### 六级标题 -``` - -## 字体 - -- 斜体:使用一个星号(\*)表示斜体。 - - ``` - *斜体文本* - ``` - -- 粗体:使用两个星号(\*\*)表示粗体。 - - ``` - **粗体文本** - ``` - -- 粗斜体:使用3个星号(\*\*\*)表示粗斜体。 - - ``` - ***粗斜体文本*** - ``` - - -## 列表 - -- 无序列表:无序列表使用星号(**\***)、加号(**+**)或是减号(**-**)作为列表标记,这些标记后面要添加一个空格,然后再填写内容。同一个无序列表,建议使用同一个符号。 - - ``` - * 第一项 - * 第二项 - * 第三项 - - + 第一项 - + 第二项 - + 第三项 - - - - 第一项 - - 第二项 - - 第三项 - ``` - - -- 有序列表:有序列表使用数字并加上 **.** 号来表示。 - - ``` - 1. 第一项 - 2. 第二项 - 3. 第三项 - ``` - - -- 嵌套列表:列表嵌套只需在子列表中的选项前面添加四个空格即可。 - - ``` - 1. 第一项: - - 第一项嵌套的第一个元素 - - 第一项嵌套的第二个元素 - 2. 第二项: - - 第二项嵌套的第一个元素 - - 第二项嵌套的第二个元素 - ``` - - -## 引用 - -Markdown 区块引用是在段落开头使用 **\>** 符号 ,然后后面紧跟一个**空格**符号。 - -``` -> 说明: -``` - -## 代码 - -- 行间代码:如果是段落上的一个函数或片段的代码可以用反引号把它包起来(**\`**)。 - -``` -`printf()` 函数 -``` - -- 代码块:可以用 **\`\`\`** 包裹一段代码。 - -``` -``` -select * from table; -``` -``` - -## 链接 - -链接使用方法如下: - -``` -[链接名称](链接地址) -``` - -## 图片 - -图片使用方法如下: - -``` -![alt 属性文本](图片地址) - -![alt 属性文本](图片地址 "可选标题") -``` - -- 开头一个感叹号 (!)。 -- 接着一个方括号,里面放上图片的替代文字。 -- 接着一个普通括号,里面放上图片的网址,最后还可以用引号包住并加上选择性的 'title' 属性的文字。 - -## 表格 - -Markdown 制作表格使用 **|** 来分隔不同的单元格,使用 **-** 来分隔表头和其他行。语法格式如下: - -``` -| 表头 | 表头 | -| ---- | ---- | -| 单元格 | 单元格 | -| 单元格 | 单元格 | -``` - -我们可以设置表格的对齐方式: - -- -: 设置内容和标题栏居右对齐。 -- :- 设置内容和标题栏居左对齐。 -- :-: 设置内容和标题栏居中对齐。 - diff --git a/contribute/figures/SafetyAlert.png b/contribute/figures/SafetyAlert.png deleted file mode 100644 index 0f672abbd6d2bba5621632e953d423f06db72789..0000000000000000000000000000000000000000 Binary files a/contribute/figures/SafetyAlert.png and /dev/null differ diff --git a/contribute/figures/contribution-guide-01.png b/contribute/figures/contribution-guide-01.png deleted file mode 100644 index 2ad19522b9bf642d7c3a27c81a9c3154ad048b77..0000000000000000000000000000000000000000 Binary files a/contribute/figures/contribution-guide-01.png and /dev/null differ diff --git a/contribute/figures/contribution-guide-02.png b/contribute/figures/contribution-guide-02.png deleted file mode 100644 index a9775df9ba55e3f53269f6c78f77e79c8c0accba..0000000000000000000000000000000000000000 Binary files a/contribute/figures/contribution-guide-02.png and /dev/null differ diff --git a/contribute/figures/contribution-guide-03.png b/contribute/figures/contribution-guide-03.png deleted file mode 100644 index 02898d896379d795780ab3a7bd3a8c79e6e487eb..0000000000000000000000000000000000000000 Binary files a/contribute/figures/contribution-guide-03.png and /dev/null differ diff --git a/contribute/figures/contribution-guide-04.png b/contribute/figures/contribution-guide-04.png deleted file mode 100644 index 93be094648fa16b428d8a039559a1f7184f07194..0000000000000000000000000000000000000000 Binary files a/contribute/figures/contribution-guide-04.png and /dev/null differ diff --git a/contribute/figures/contribution-guide-05.png b/contribute/figures/contribution-guide-05.png deleted file mode 100644 index 7bf60faa4259ff400d77adbbdc39ecb7322f90d9..0000000000000000000000000000000000000000 Binary files a/contribute/figures/contribution-guide-05.png and /dev/null differ diff --git a/contribute/figures/contribution-guide-06.png b/contribute/figures/contribution-guide-06.png deleted file mode 100644 index c4889bdd53677788a0b64ec2c983ed8961a6f293..0000000000000000000000000000000000000000 Binary files a/contribute/figures/contribution-guide-06.png and /dev/null differ diff --git a/contribute/figures/contribution-guide-07.png b/contribute/figures/contribution-guide-07.png deleted file mode 100644 index b9ca9e9fa8ff5872e172708569a5cd8955228962..0000000000000000000000000000000000000000 Binary files a/contribute/figures/contribution-guide-07.png and /dev/null differ diff --git a/contribute/figures/contribution-guide-08.png b/contribute/figures/contribution-guide-08.png deleted file mode 100644 index f6c7a896888ca96333e3f4a01c933e634b1f21cc..0000000000000000000000000000000000000000 Binary files a/contribute/figures/contribution-guide-08.png and /dev/null differ diff --git a/contribute/figures/contribution-guide-09.png b/contribute/figures/contribution-guide-09.png deleted file mode 100644 index 21f1fd57b726f69ac410e2aff7e3a27cb387d6b6..0000000000000000000000000000000000000000 Binary files a/contribute/figures/contribution-guide-09.png and /dev/null differ diff --git a/contribute/figures/contribution-guide-10.png b/contribute/figures/contribution-guide-10.png deleted file mode 100644 index 9fed4d0f83d628ce4ed85315503b32fac9d820d1..0000000000000000000000000000000000000000 Binary files a/contribute/figures/contribution-guide-10.png and /dev/null differ diff --git a/contribute/figures/contribution-guide-11.png b/contribute/figures/contribution-guide-11.png deleted file mode 100644 index 4f0e23e5979a3faf8d32d66238e155a70ad96e83..0000000000000000000000000000000000000000 Binary files a/contribute/figures/contribution-guide-11.png and /dev/null differ diff --git a/contribute/figures/contribution-guide-12.png b/contribute/figures/contribution-guide-12.png deleted file mode 100644 index 89f2bec0589bd42440bac3f6aed80fa95303b027..0000000000000000000000000000000000000000 Binary files a/contribute/figures/contribution-guide-12.png and /dev/null differ diff --git a/contribute/figures/contribution-guide-13.png b/contribute/figures/contribution-guide-13.png deleted file mode 100644 index c78ce807e8f792b952d76f2623dedc1ff7644c42..0000000000000000000000000000000000000000 Binary files a/contribute/figures/contribution-guide-13.png and /dev/null differ diff --git a/contribute/figures/contribution-guide-14.png b/contribute/figures/contribution-guide-14.png deleted file mode 100644 index 543f802aaf77a0bb65b652e3085679bf2b94c3e3..0000000000000000000000000000000000000000 Binary files a/contribute/figures/contribution-guide-14.png and /dev/null differ diff --git a/contribute/figures/contribution-guide-15.png b/contribute/figures/contribution-guide-15.png deleted file mode 100644 index f8131b37b5a2fdae87f7d1e3e9167fe4ba85afde..0000000000000000000000000000000000000000 Binary files a/contribute/figures/contribution-guide-15.png and /dev/null differ diff --git a/contribute/figures/contribution-guide-16.png b/contribute/figures/contribution-guide-16.png deleted file mode 100644 index 846634a554924f23aaee75e4c5980489c6560f1b..0000000000000000000000000000000000000000 Binary files a/contribute/figures/contribution-guide-16.png and /dev/null differ diff --git a/contribute/figures/contribution-guide-17.png b/contribute/figures/contribution-guide-17.png deleted file mode 100644 index 41c280e710f013e6e999a3ac75972d8cf1fd5223..0000000000000000000000000000000000000000 Binary files a/contribute/figures/contribution-guide-17.png and /dev/null differ diff --git a/contribute/figures/contribution-guide-18.png b/contribute/figures/contribution-guide-18.png deleted file mode 100644 index e51d3f035c62a8b2858241a2ee5141f274a62c99..0000000000000000000000000000000000000000 Binary files a/contribute/figures/contribution-guide-18.png and /dev/null differ diff --git a/contribute/figures/contribution-guide-19.png b/contribute/figures/contribution-guide-19.png deleted file mode 100644 index a915b5f2c10bd3041026f880d801abbaa2337c1b..0000000000000000000000000000000000000000 Binary files a/contribute/figures/contribution-guide-19.png and /dev/null differ diff --git a/contribute/figures/contribution-guide-20.png b/contribute/figures/contribution-guide-20.png deleted file mode 100644 index 50c4232d3627ab5defd611720dcd2a041cb44de3..0000000000000000000000000000000000000000 Binary files a/contribute/figures/contribution-guide-20.png and /dev/null differ diff --git a/contribute/figures/contribution-guide-21.png b/contribute/figures/contribution-guide-21.png deleted file mode 100644 index ec9aed28e184756a148d55ead2aee24780bf04e2..0000000000000000000000000000000000000000 Binary files a/contribute/figures/contribution-guide-21.png and /dev/null differ diff --git a/contribute/figures/contribution-guide-22.png b/contribute/figures/contribution-guide-22.png deleted file mode 100644 index 9475425420ce3ccd94f36976663a7bfc594a8ec7..0000000000000000000000000000000000000000 Binary files a/contribute/figures/contribution-guide-22.png and /dev/null differ diff --git a/contribute/figures/contribution-guide-23.png b/contribute/figures/contribution-guide-23.png deleted file mode 100644 index 97385ffda8e525b64ed1ad4c029c9c6db9c204f4..0000000000000000000000000000000000000000 Binary files a/contribute/figures/contribution-guide-23.png and /dev/null differ diff --git a/contribute/figures/contribution-guide-24.png b/contribute/figures/contribution-guide-24.png deleted file mode 100644 index 1e04cc65be7482df0ae31b04733cb2fcc8099b3b..0000000000000000000000000000000000000000 Binary files a/contribute/figures/contribution-guide-24.png and /dev/null differ diff --git a/contribute/figures/contribution-guide-25.png b/contribute/figures/contribution-guide-25.png deleted file mode 100644 index 6079cb41f4ec425228cc917ae63895bb5d2a1be1..0000000000000000000000000000000000000000 Binary files a/contribute/figures/contribution-guide-25.png and /dev/null differ diff --git a/contribute/figures/contribution-guide-26.png b/contribute/figures/contribution-guide-26.png deleted file mode 100644 index 63ea42aa75ccbba99aa8a9e40a944a02294b395a..0000000000000000000000000000000000000000 Binary files a/contribute/figures/contribution-guide-26.png and /dev/null differ diff --git "a/contribute/markdownlint\346\243\200\346\237\245\350\247\204\345\210\231.md" "b/contribute/markdownlint\346\243\200\346\237\245\350\247\204\345\210\231.md" deleted file mode 100644 index d7a8cf07dd5bc3278b5176fe7e97ed8d398dbe41..0000000000000000000000000000000000000000 --- "a/contribute/markdownlint\346\243\200\346\237\245\350\247\204\345\210\231.md" +++ /dev/null @@ -1,903 +0,0 @@ -# markdownlint 检查规则 - -本文介绍了 markdownlint v0.12.0 版本规则以及 openEuler Docs 仓的规则设置,参照依据 。对 markdownlint 规则有任何疑问或交流,请联系 ECHO[@ECHO](https://gitee.com/echo10111111)。 - -## markdownlint 介绍 - -markdownlint 是一款检查 Markdown 文件格式的工具,可以根据设置的规则对 Markdown 文件进行全面的检查。文档写作时可以借助 VSCode 等工具的 markdownlint 插件修复格式问题。 - -## 规则介绍 - -### MD001 - 标题级别一次只能增加一个级别 - -- **错误示例** - - ```text - # Header1 - - ### Header3 - ``` - -- **正确示例** - - ```text - # Header1 - - ## Header2 - - ### Header3 - - #### Header4 - ``` - -### MD002 - 第一个标题应该是顶层标题 - -- **参数** - - - `level`:指定最高级标题的级数,默认值是1。 -- **错误示例** - - ```text - ## This is not a H1 header - - ### Another header - ``` - -- **正确示例** - - ```text - # Start with a H1 header - - ## Then use a H2 for subsections - ``` - -### MD003 - 标题样式 - -- **参数** - - - `style`:指定文档标题的样式,有 `consistent`、`atx`、`atx_closed`、`setext`、`setext_with_atx`五种。本仓已设置为 `atx`。 -- **错误示例** - - ```text - # ATX style H1 - - ## Closed ATX style H2 ## - - Setext style H1 - =============== - ``` - -- **正确示例** - - ```text - # ATX style H1 - - ## ATX style H2 - ``` - -### MD004 - 无序列表样式 - -- **参数** - - - `style`:指定无序列表的样式,有 `consistent(定义时符号前后保持一致)`、`astrisk(用星号定义)`、`plus(用加号定义)`、`dash(用减号定义)`、`sublist(定义多重列表的时候用不同的符号定义)`五种,默认为 `consistent`。 -- **错误示例** - - ```text - * Item 1 - + Item 2 - ``` - -- **正确示例** - - ```text - * Item 1 - * Item 2 - ``` - -### MD005 - 同一级别的列表项缩进不一致 - -- **错误示例** - - ```text - * Item1 - * nested item 1 - * nested item 2 - * A misaligned item - ``` - -- **正确示例** - - ```text - * Item1 - * nested item 1 - * nested item 2 - * nested item 3 - ``` - -### MD006 - 一级列表不能缩进 - -- **错误示例** - - ```text - Some text - - * List item - * List item - ``` - -- **正确示例** - - ```text - Some text - - * List item - * List item - ``` - -### MD007 - 无序列表缩进 - -- **参数** - - - `ident`:指定无序列表嵌套时缩进的空格数,默认值是2。本仓将其设置为4,即需要缩进4个空格。 -- **错误示例** - - ```text - * List item - * Nested list item indented by 4 spaces - ``` - -- **正确示例** - - ```text - * List item - * Nested list item indented by 2 spaces - ``` - -### MD009 - 行尾空格 - -本仓已忽略这条规则。 - -- **参数** - - `br_spaces`:指定在行尾可以添加的空格的数目,默认值为0,空格数目建议大于等于2,如果小于2,会默认为0。 - -### MD010 - 不能使用tab键缩进,要使用空格 - -- **参数** - - - `code_blocks`:指定本条规则在代码块里是否 (true or false) 生效,默认是 true。 -- **错误示例** - - ```text - Some text - - * hard tab character used to indent the list item - ``` - -- **正确示例** - - ```text - Some text - - * Spaces used to indent the list item instead - ``` - -### MD011 - 反向链接语法 - -- **错误示例** - - ```text - (Incorrect link syntax)[http://www.example.com] - ``` - -- **正确示例** - - ```text - [Correct link syntax](http://www.example.com) - ``` - -### MD012 - 多个连续的空行 - -- **参数** - - - `maximum`:指定文档中可以连续的最多的空行数,默认值是1。 -- **错误示例** - - ```text - Some text here - - - Some more text here - ``` - -- **正确示例** - - ```text - Some text here - - Some more text here - ``` - -> 注意:如果代码块内有多个连续的空行,将不会触发此规则。 - -### MD013 - 行的长度 - -本仓已忽略这条规则。 - -- **参数** - - - `line_length`:指定行的最大长度,默认是80。 - - `heading_line_length`:指定标题行的最大的长度,默认是80。 - - `code_blocks`:指定规则是否(true or false)对代码块生效,默认是true。 - - `tables`:指定规则是否(true or false)对表格生效,默认是true。 - - `headings`:指定规则是否(true or false)对标题生效,默认是true。 - -### MD014 - 命令前使用$而不显示输出 - -本仓已忽略这条规则。 - -- **错误示例** - - ```text - sl - cat foo - less bar - ``` - -- **正确示例** - - ```text - ls - cat foo - less bar - ``` - - ```text - $ ls - foo bar - $ cat foo - Hello world - $ cat bar - baz - ``` - - 在代码块中,终端命令前不需要要有\$,但是如果代码中既有终端命令,也有命令的输出,则终端前可以有\$。 - -### MD018 - atx样式的标题后没有空格 - -- **错误示例** - - ```text - #Header1 - - ##Header2 - ``` - -- **正确示例** - - ```text - # Header1 - - ## Header2 - ``` - -### MD019 - atx样式的标题后有多个空格 - -- **错误示例** - - ```text - # Header1 - - ## Header2 - ``` - -- **正确示例** - - ```text - # Header1 - - ## Header2 - ``` - -### MD020 - closed atx样式的标题内没有空格 - -本仓已忽略这条规则。 - -- **错误示例** - - ```text - #Header1# - - ##Header2## - ``` - -- **正确示例** - - ```text - # Header1 # - - ## Header2 ## - ``` - -### MD021 - closed atx样式的标题内有多个空格 - -本仓已忽略这条规则。 - -- **错误示例** - - ```text - # Header1 # - - ## Header2 ## - ``` - -- **正确示例** - - ```text - # Header1 # - - ## Header2 ## - ``` - -### MD022 - 标题行的上下行应该都是空行 - -- **参数** - - - `lines_above`:指定标题行上方的空行数,默认值是1。 - - `lines_below`:指定标题行方的空行数,默认值是1。 -- **错误示例** - - ```text - # Header1 - Some text - - Some more text - ## Header2 - ``` - -- **正确示例** - - ```text - # Header1 - - Some text - - Some more text - - ## Header2 - ``` - -### MD023 - 标题必须从行首开始 - -- **错误示例** - - ```text - Some text - ## Indented header - ``` - -- **正确示例** - - ```text - Some text - - ## Header - ``` - -### MD024 - 不能有重复内容的标题 - -本仓已忽略这条规则。 - -- **错误示例** - - ```text - # Some text - - ## Some text - ``` - -- **正确示例** - - ```text - # Some text - - ## Some more text - ``` - -### MD025 - 文档中有多个顶级标题 - -本仓已忽略这条规则。 - -- **参数** - - - `level`:指定文档最高级的标题,默认值是1。 -- **错误示例** - - ```text - # Top level header - - # Another top level header - ``` - -- **正确示例** - - ```text - # Title - - ## Header - - ### Another header - ``` - -### MD026 - 标题行尾的标点符号 - -- **参数** - - - `punctuation`:指定标题行尾不能有的标点符号,默认值是".,;:!?"。 -- **错误示例** - - ```text - # This is a header. - ``` - -- **正确示例** - - ```text - # This is a header - ``` - -### MD027 - 块引用符号后的多个空格 - -- **错误示例** - - ```text - > This is a block quote with bad indentation - > there should only be one - ``` - -- **正确示例** - - ```text - > This is a block quote with bad indentation - > there should only be one - ``` - -### MD028 - 块引用内的空行 - -- **错误示例** - - ```text - > This is a blockquote - > which is immediately followed by - - > this blockquote. Unfortunately - > in some parsers, this are treated as the same blockquote. - ``` - -- **正确示例** - - ```text - > This is a blockquote. - > - > This is the same blockquote. - ``` - -### MD029 - 有序列表的前缀序号 - -- **参数** - - - `style`:指定前缀序号的格式,有 `one`(只用1做前缀),`ordered`(从1开始的加1递增数字做前缀)两种,默认值是 `one`。本仓设置为`ordered`。 -- **错误示例** - - ```text - 1. Do this - 1. Do that - 1. Done - ``` - -- **正确示例** - - ```text - 1. Do this - 2. Do that - 3. Done - ``` - -### MD030 - 列表标记后的空格 - -- **参数** - - - `ul_single`:无序列表单个段落的前缀符号和文字之间的空格数,默认值是1。 - - `ol_single`:有序列表单个段落的前缀符号和文字之间的空格数,默认值是1。 - - `ul_multi`:无序列表多个段落的前缀符号和文字之间的空格数,默认值是1。 - - `ol_multi`:有序列表单个段落的前缀符号和文字之间的空格数,默认值是1。 -- **错误示例** - - ```text - * Foo - * Bar - * Baz - ``` - -- **正确示例** - - ```text - * Foo - * Bar - * Baz - ``` - -### MD031 - 单独的代码块前后需要用空格隔开(除非是在文档的开头或者结尾) - -- **错误示例** - - ````text - Some text - ``` - - Code block - - ``` - - ``` - - Another code block - - ``` - Some more text - ```` - -- **正确示例** - - ````text - Some text - - ``` - - Code block - - ``` - - ``` - - Another code block - - ``` - - Some more text - ```` - -### MD032 - 列表前后需要用空格隔开(除非是在文档的开头或者结尾) - -- **错误示例** - - ```text - Some text - * Some - * List - - 1. Some - 2. List - Some text - ``` - -- **正确示例** - - ```text - Some text - - * Some - * List - - 1. Some - 2. List - - Some text - ``` - -### MD033 - 内联HTML - -本仓已忽略这条规则。 - -- **错误示例** - - ```text -

Inline HTML header

- ``` - -- **正确示例** - - ```text - # Markdown header - ``` - -### MD034 - 使用纯URL - -- **错误示例** - - ```text - For more information, see http://www.example.com/. - ``` - -- **正确示例** - - ```text - For more information, see . - ``` - -### MD035 - 水平线样式 - -- **参数** - - - `style`:指定创建水平线的方式,有 `consistent`、`***`、`---`或其他指定水平线的字符串,默认值是 `consistent`。 - -### MD036 - 使用强调标记代替标题 - -本仓已忽略这条规则。 - -- **参数** - - - `punctuation`:指定用于结尾的标点符号,以此符号结尾的强调不会被视为以强调代替标题,默认值是".,;:!?" -- **错误示例** - - ```text - **My document** - - Lorem ipsum dolor sit amet... - - _Another section_ - - Consectetur adipiscing elit, sed to eiusmd - ``` - -- **正确示例** - - ```text - # My document - - Lorem ipsum dolor sit amet... - - ## Another section - - Consectetur adipiscing elit, sed to eiusmd - ``` - -### MD037 - 强调标记内强调的符号和强调的文字之间不能有空格 - -- **错误示例** - - ```text - Here is some ** bold ** text - - Here is some * italic * text - - Here is some more __ bold __ text - - Here is some more _ italic _ text - ``` - -- **正确示例** - - ```text - Here is some **bold** text - - Here is some *italic* text - - Here is some more __bold__ text - - Here is some more _italic_ text - ``` - -### MD038 - 单反引号和之间的内容不能有空格 - -- **错误示例** - - ```text - ` some text ` - `some text ` - ` some text` - ``` - -- **正确示例** - - ```text - `some text` - ``` - -### MD039 - 链接文本和包围它的中括号之间内容不能有空格 - -- **错误示例** - - ```text - [ a link ](http://www.example.com/) - ``` - -- **正确示例** - - ```text - [a link](http://www.example.com/) - ``` - -### MD040 - 代码块应指定代码块的编程语言 - -- **错误示例** - - ````text - ``` - #!/bin/bash - echo Hello world - ``` - ```` - -- **正确示例** - - ````text - ```bash - #!/bin/bash - echo Hello world - ``` - ```` - -- **常用的代码块编程语音** - - | 语言支持 | 关键字 | - | ---------------- | -------- | - | Python | python | - | C | cpp | - | Java | java | - | Shell | bash | - | Markdown | markdown | - | JavaScript | js | - | CSS | css | - | SQL | sql | - | PHP | php | - | Text | text | - | XML | html | - | Bat | bat | - | Protocol Buffers | protobuf | - -### MD041 - 文件中的第一行应该是顶级标题 - -- **参数** - - - `level`:指定文档最高级的标题,默认值是1。 -- **错误示例** - - ```text - This is a file without a header - ``` - -- **正确示例** - - ```text - # File with header - - This is a file with a top level header - ``` - -### MD046 - 代码块样式 - -- **参数** - - - `style`:指定代码块定义格式,有 `fenced(使用三个反引号)`,`indented(使用缩进)`,`consistent(上下文一致)`三种,默认值是 `fenced`。 -- **错误示例** - - ```text - Some text. - - Code block - - Some more text. - ``` - -- **正确示例** - - ````text - Some text. - - ```ruby - Code block - ``` - - Some more text. - ```` - -### MD047 - 文件应以单个换行符结尾 - -- **错误示例** - - ```text - # Header - - This file ends without a newline.[EOF] - ``` - -- **正确示例** - - ````text - # Header - - This file ends with a newline. - [EOF] - ```` - -## OpenEuler 规则设置 - -- openEuler 规则采用如下方案: - - - MD003 (标题样式) 规则将参数 `style`设置为`atx`。 - - MD007(无序列表缩进)规则将参数 `indent`设置为4。 - - MD029(有序列表的前缀序号)规则将参数`style`设置为`ordered`。 - - 忽略 MD009(行尾空格)这条规则。 - - 忽略 MD013(行的长度)这条规则。 - - 忽略 MD014(命令前使用\$而不显示输出)这条规则。 - - 忽略 MD020(closed atx样式的标题内没有空格)这条规则。 - - 忽略 MD021(closed atx样式的标题内有多个空格)这条规则。 - - 忽略 MD024(不能有重复内容的标题)这条规则。 - - 忽略 MD025 (文档中有多个顶级标题)这条规则。 - - 忽略 MD033(内联HTML)这条规则。 - - 忽略 MD036(使用强调标记代替标题)这条规则。 - -- ruby 文件的书写方式如下: - - ```bash - all - rule 'MD003', :style => :atx - rule 'MD007', :indent => 4 - rule 'MD029', :style => :ordered - exclude_rule 'MD009' - exclude_rule 'MD013' - exclude_rule 'MD014' - exclude_rule 'MD020' - exclude_rule 'MD021' - exclude_rule 'MD024' - exclude_rule 'MD025' - exclude_rule 'MD033' - exclude_rule 'MD036' - ``` - -## VSCode 中 Markdown 插件 - -### markdownlint - -markdownlint 扩展库包含 markdown 文件规则库,以保证 Markdown 文件与其标准保持一致。添加配置后,markdownlint 可以自动检查文档错误。 - -#### 安装 - -- 按下 `Ctrl_Shift+X`以打开扩展选项卡。 -- 输入 `markdownlint` 以找到扩展。 -- 点击 `Install` 按钮,然后再点击`Enable`按钮。 - -#### 配置 - -注意:VSCode 中 markdownlint 参照的版本是 David Anson 拟定的,与 openEuler 仓使用的 markdownlint 官方 v0.12.0 版本有差异。为了与 openEuler 仓配置的规则保持一致,请参考下方配置项。 - -- 在命令面板(`Ctrl+Shift+P`)中输入`Open Settings (JSON)`命令。 -- 在 Json 对象中添加如下配置: - - ```bash - "markdownlint.config":{ - "default":true, - "MD003":{"style":"atx"}, - "MD007":{"indent":4}, - "MD029":{"style":"ordered"}, - "MD009":false, - "MD013":false, - "MD014":false, - "MD020":false, - "MD021":false, - "MD024":false, - "MD025":false, - "MD033":false, - "MD036":false, - "MD042":false, - "MD043":false, - "MD044":false, - "MD045":false, - "MD048":false, - "MD049":false, - "MD050":false, - "MD051":false, - "MD052":false, - "MD053":false - } - ``` diff --git "a/contribute/openEuler\345\274\200\346\272\220\347\244\276\345\214\272\350\264\241\347\214\256\346\214\207\345\215\227.md" "b/contribute/openEuler\345\274\200\346\272\220\347\244\276\345\214\272\350\264\241\347\214\256\346\214\207\345\215\227.md" deleted file mode 100644 index bf98071a6762e0304925ca4211f855adfb80f10c..0000000000000000000000000000000000000000 --- "a/contribute/openEuler\345\274\200\346\272\220\347\244\276\345\214\272\350\264\241\347\214\256\346\214\207\345\215\227.md" +++ /dev/null @@ -1,515 +0,0 @@ -# openEuler开源社区贡献指南 - -# 前言 - -openEuler 是一款由全球开源贡献者构建的高效、稳定、安全的开源操作系统。同时, openEuler 是一个面向全球的操作系统开源社区,通过社区合作,打造创新平台。本文以贡献Gitee平台上的openEuler 社区为例,为开源社区贡献者提供详细的贡献指导,从基础介绍到网页操作到工具使用再到贡献流程,全方位推动开源社区繁荣。 - -# 开源基础 - -## 初识开源社区 - -### 介绍 - -开源即开放源代码(Open Source Code),也称为源代码公开,指的是一种软件发布模式。开源社区又称开放源代码社区(Open Source Code Community or Open Source Community),一般由拥有共同兴趣爱好的人所组成,根据相应的开源软件许可证协议公布软件源代码的网络平台,同时也为网络成员提供一个自由学习交流的空间。从一定程度上讲,开源社区与开源产品的边界较为模糊,如Linux既指开源社区,由参与者共同管理,同时又指一套性能稳健的操作系统,其内核(Linux kernel)成为许多派生操作系统如Ubuntu的搭建基础。(百度百科) -开源社区发展迅速,贡献者遍布全球且呈高速增长之势。据全球最大开源项目托管平台 GitHub 统计,2020年较上一年新增了1600万开发者用户,预计2025年开发者用户的数量将达到1亿。这其中,在 GitHub 的中国开发者数量及开源贡献度增长已成为全球最快。GitHub 预测到2030年中国开发者将成为全球最大的开源群体。(电子信息产业网) - -### 主流开源社区 - -| 名称 | 简述 | 网址 | -| :------------ | :----------------------------------------------------------- | :----------------------------------------------------------- | -| Linux内核社区 | 由全球不同地方的开发人员组成,它以代码、风格、开发流程的高质量标准著称。 | [https://www.kernel.org/](https://www.kernel.org/) | -| Alpha | Alpha处理器在Linux领域中很受欢迎,尤其用以处理高性能计算。 | [https://www.alpha.org/](https://www.alpha.org/) | -| PowerPC | 提供对使用PowerPC微处理器的Mac计算机的支持,同时也会支持一些IBM的系统。 | [https://www.powerprogress.org/en/](https://www.powerprogress.org/en/) | -| Apache | 以讨论Linux/Unix类操作系统技术、软件开发技术、数据库技术和网络应用技术等为主的开源技术社区网站。其宗旨是给所有爱好Linux/Unix技术、开源技术的朋友提供一个自由、开放、免费的交流空间。 | [https://community.apache.org/](https://community.apache.org/) | -| SourceForge | SourceForge.net (SF.net)是开源软件的开发者进行开发管理的集中式场所,也是全球最大开源软件开发平台和仓库,由VA Software提供主机,并运行SourceForge软件。 | [https://sourceforge.net/](https://sourceforge.net/) | -| Google Source | 谷歌的android代码开源网站,包含了谷歌的各代nexus的源码,这些源码都是跟随android的版本演进。 | [https://android.googlesource.com](https://android.googlesource.com); [https://github.com/android/](https://github.com/android/) | - -### 开源社区的角色 - ->![image](figures/contribution-guide-01.png) - -### 贡献开源的意义 - -**巩固现有技能**:无论是撰写代码、设计用户界面、图形设计、撰写文档、亦或是组织活动,假如你有实践的愿望,你总能在开源项目中找到自己的位置。 -**建立声誉(职业口碑)**:由于开源下所有工作都是公开的,开源项目会是一个很好展示你实力的地方。 -**遇见知己**:开源项目一般都会有一个和谐、热心的社区。很多人便是通过技术研讨会亦或是聊天室的深入探讨建立起深厚友谊。 -**学习领导和管理的艺术**:开源为实践领导力和管理技能提供了很好的机会,比如解决冲突、组织团队、工作的优先级排列。 -**寻找导师/帮助他人**:和他人在一个共享的项目下工作,这意味着需要向他人解释清楚自己是如何做的,同理,也需要向他人求助,询问别人是如何做的。相互学习和彼此教学对于每位参与者都能满载而归。 -**鼓励做出改变**:在开源的世界里,贡献者不一定非得是拥有大量经验的人。在开源的项目中,没有那么多的顾忌,你只需要做就可以了,哪怕只是纠正网站一个小小的拼写错误。开源让人们在很舒服的状态做事,而这才是这个世界应有的体验。(开源社) - -### 开源软件许可证协议 - -开源许可协议(License)是指开源社区为了维护作者和贡献者的合法权利,保证软件不被一些商业机构或个人窃取,影响软件的发展而开发的协议。License的条款由权利、义务、限制三种组成: -● 权利:你可以使用该软件做什么事情 -● 义务:你使用这个软件时必须履行什么样的义务 -● 限制:你不能够做什么事情 -开源许可证是一类组合。对于大部分开源许可证,权利(红框)均授予,著作权人几乎不承担任何义务(蓝框),只是被授权人承担的义务又较多不同(绿框)。 (License遵从性指导书) -![iamge](figures/contribution-guide-02.png) - -以下为openEuler docs SIG的许可证实例: -![image](figures/contribution-guide-03.png) - -## 初识openEuler - -### 介绍 - -openEuler 是一个开源、免费的 Linux 发行版平台,通过开放的社区形式与全球的开发者共同构建一个开放、多元和架构包容的软件生态体系。同时,openEuler也是一个创新平台,鼓励任何人在该平台上提出新想法、开拓新思路、实践新方案。 -openEuler的愿景是:通过社区合作,打造创新平台,构建支持多处理器架构、统一和开放的操作系统openEuler,推动软硬件生态繁荣发展。 - -### openEuler组织架构 - -![image](figures/contribution-guide-04.png) - -### openEuler贡献流程 - -![image](figures/contribution-guide-05.png) - -(openEuler官网) - -# Gitee基础 - -Gitee 是开源中国社区2013年推出的基于 Git 的代码托管服务,目前已经成为国内知名的代码托管平台,致力于为国内开发者提供优质稳定的托管服务。Gitee 除了提供最基础的Git代码托管之外,还提供代码在线查看、历史版本查看、Fork、Pull Request(PR)、打包下载任意版本、Issue、Wiki 、保护分支、代码质量检测、PaaS项目演示等方便管理、开发、协作、共享的功能。本章介绍Gitee贡献相关概念和操作。 (Gitee网站) - -## Issue提交指南 - -### Issue简介 - -**名词解释**:Issue是指一项待完成的工作,这个工作可以是问题、事务、需求和建议等。每一个Issue都包含该工作的所有信息和历史,便于后来的人了解该项工作的所有方面和过程。 -**来源和作用**:Issue的概念起源于客服部门,用户打电话反馈问题,客服就创建一个工单(ticket),后继每一个处理步骤、每一次和用户的交流都要更新到工单内,记录全部的过程信息,这就是Issue的前身。随着后来的不断扩展,逐步演变成制定和实施软件开发计划的全功能项目管理工具。 -openEuler社区直接使用Gitee提供的Issue跟踪和管理系统。 - -### Issue基本功能 - -Gitee的每一个仓库内都有一个Issue面板。 - -![image](figures/contribution-guide-06.png) - -进入该面板,点击“+新建Issue”,就可以新建一个Issue,可以选择需求的类别。目前openEuler有任务、需求、缺陷、版本、翻译、CVE和安全问题等类别,每个类别对应一个提交模板,如下图所示。 - -![image](figures/contribution-guide-07.png) - -### 需求类Issue提交和处理指导 - -不同类型的Issue都有各自完整的提交和处理流程,下面以需求类Issue为例。参考以下流程图。 -![image](figures/contribution-guide-08.png) - -**步骤 1** 新建需求类Issue(Issue状态:待办) -请进入需求对应的团队或项目的repository内,选择Issue面板,点击“新建Issue”。 -如果不确定该需求对应的团队或项目,请在community-issue中创建,会有社区的开发者帮助进行归属等信息的确认。 -在标题栏的单选下拉框将Issue类型设置成“需求”,系统会自动调出需求模板。 -在标题栏**简要描述需求的要点**。 -在详细说明框内说明需求的场景和价值。 -*请注意:清晰完整的描述有助于团队成员理解,并被更快的接受和排入开发计划。* - -**步骤 2** 团队成员审核Issue(Issue状态——通过:进行中;拒绝:已拒绝 ) -**2.1** 审核后接纳 -团队成员(maintainer或者committer)审核后认为可以接纳该需求,则由审核人补充接纳需求的相关信息,并包含: -● 检查并设置该需求所属的项目。 -● 设置该需求建议合入的里程碑信息(规划版本信息)。 -● 设置该需求的优先级标签,请在标签栏选择“feature:High”、“feature:Medium”或者"feature:Low"。 -完成以上的信息以后,请将该Issue的“当前状态”调整成“进行中”(**进入步骤3**)。 -**2.2** 描述不清晰挂起 -团队成员审核后认为描述的信息不清晰,可以在该Issue的评论区留言或在邮件列表中讨论,让提交人继续补充相关信息。 -● 如果在一个月内提交人未及时补充相关信息,则系统会自动关闭该问题(**跳到步骤4**)。 -● Issue提交人补充信息后,可以通过评论让团队成员审核(**跳到步骤2**)。 -**2.3** 审核后不接纳 -团队成员审核后,由于需求价值不高等原因认为暂不接纳,可以在评论区留言或在邮件列表中讨论说明原因。确认后将Issue的“当前状态”调整成“已拒绝”(**跳到步骤4**)。 - -**步骤 3** 认领或分派Issue(Issue状态:开启) -已经进入开发阶段的需求,可以主动认领,也可以由团队成员分配。可以在评论框内输入/assign来把Issue分配给自己,或分配给其他人。 - -**步骤 4** **关闭Issue**,关闭Issue有三种情况: -需求完成后关闭,可以由认领人手工修改状态,也可以通过关联PR后,由PR审核通过后系统自动关闭。 -需求被拒接关闭,由审核人手工修改状态。 -需求超期后关闭,由系统自动根据需求停滞的时间进行超期关闭的操作。 -(openEuler Issue提交指南) - -## PR提交指南 - -Pull Request(PR)是贡献者修改源代码后,请求目标仓库采纳该修改时提交的一种请求。 - -### PR提交前验证 - -提交PR是对项目上的master主干的一次合入申请,为保证合入质量,这个动作是需要小心谨慎的。在提交PR之前,请先完成本地验证,以便在一定程度上保证在提交PR后的持续集成测试的通过。由于不同项目的本地验证方法不同,可以参考此章节内容以获取帮助。 - -### PR提交 - -**步骤 1** 提交PR请求。 -在Gitee上提交PR的具体操作,请参考下文Gitee工作流说明。为了更快得到响应,可以给PR添加标签,或提供更详细的信息,这里需要特别提示的是: -● **关联Issue**:如果提交的PR是针对某个Issue的,请在提交的描述框内添加“#”字符,此时机器人会自动关联出当前存在的Issue,你可以通过此种方式快速链接到关联的Issue。 -● **标注优先级**:可以在创建PR的时候,选择PR的优先级。或者在评论区通过/priority high给PR添加高优先级标签。 -● **标注是解决bug的合入**:可以在描述框通过输入/kind bug来标注该PR是合入解决问题的代码,以便于大家更快的回应你的PR请求。 -● **标注所属SIG**:为了方便查找,也可以在描述框通过输入sig sig-name来标识该PR所属的SIG。 - -**步骤 2** 分配评审人。 -提交PR以后,社区机器人会自动分配评审人,你也可以指定评审人。指定评审人有两种方式,可以在创建PR的时候,在右侧的下拉框中选择评审人。也可以在评论框中输入/assign @reviewer把该PR分配给对应的人。如果想把PR提交给项目的核心成员评审,以便于更快的获得批准,可以有两种方式获取到核心成员的信息: -**方式一**:该Repository的owners文件(该文件通常在该repository的根目录下)中查看,此文件保存的是所有该Repository的评审人列表。 -**方式二**:可以到该项目所属的SIG的首页内查看README.md文件,此文件会列出该SIG的负责人,所有项目以及项目的负责人。 - -**步骤 3** 自动化测试。 -如果您提交成功以后,看到PR上有openeuler-cla/no的标签,说明您还未和社区签署贡献者协议,请您先按照社区机器人的提示,完成贡献者协议的签署。具体操作详见后文。 -提交成功以后,社区机器人会启动自动化测试,为了避免浪费评审人时间,通常只有自动化测试通过的PR,评审人才会参与评审。你可以在PR的下方看到自动化测试的结果。 -如果自动化测试失败,您可以通过“Build Details”查看失败的原因。 ->![image](figures/contribution-guide-09.png) - -点击“Build Details”,可以看到具体的log信息。然后可以在里面搜索“Error”,快速的定位到错误的信息。 -修改后,你可以在评论框输入/retest命令,让社区机器人重新发起一次自动化测试。 - -**步骤 4** PR审核。 -如果审核人通过你的PR,会在评论区添加/lgtm和/approve,以表示对本次PR提交的认同。 -审核人可以在评论区发表意见,也可以在审核文件的时候,在发现问题处添加审核意见。无论哪种方式,都会在评论区显示出来。区别是,后者的评论会显示出“代码评论”,你可以通过“详情”查看评论具体指向的出处。 -为了表示对评审人意见的尊重,如果对意见有异议,请回复该意见说明原因;如果接纳评审人意见,也请做出简单的回应,便于确认后继的提交是否已按照所有接纳意见完成修改。 -**请注意,在使用/approve前至少要有一个/lgtm。** - -### 未完成PR标记 - -如果想在PR请求完成之前先征求大家的意见,有两种方法可以实现此目的: - -1. 可以在评论区添加hold或hold-cancel标签 -2. 可以在PR请求的标题中添加WIP或[WIP]前缀 - -当存在这两个标签时,将不会考虑合并你的PR请求。 - -(openEuler PR提交指南) - -## Gitee贡献工作流 - ->![image](figures/contribution-guide-10.png) - -**步骤 1** 开展工作流前的准备。 -安装Git:请先确保你的电脑上已经安装了Git软件。 -在开展Gitee的工作流之前,需要先在openEuler的代码托管平台的上找到感兴趣的Repository。如果还未找到对应的Repository,请参考此章节的内容。 - -**步骤 2** 从云上fork代码分支。 -找到并打开对应的Repository的首页。 -点击右上角的 Fork 按钮,按照指引,建立一个属于个人的云上fork分支。 ->![image](figures/contribution-guide-11.png) ->![image](figures/contribution-guide-12.png) - -**步骤 3** 把fork分支复制到本地。 -请按照以下的复制过程将Repository内的代码下载到你的在计算机上。 - -1. 创建本地工作目录:需要创建本地工作目录,以便于本地代码的查找和管理。 -```mkdir /YOUR_PATH/src/gitee.com/${your_working_dir}``` -2. 完成git上用户名和邮箱的全局配置(如果之前已经完成过此项配置,请忽略)。 -把git上的 user 设置成你gitee的个人名称: -```git config --global user.name "your Gitee Name"``` -配置你的git邮箱: -```git config --global user.mail "email@your_Gitee_email"``` -3. 完成SSH公钥注册(如果没有完成此注册,每次都要重新输入账户和密码)。 -① 生成ssh公钥。 -```ssh-keygen -t rsa -C "email@your_Gitee_email"``` -```cat ~/.ssh/id_rsa.pub``` -② 登录你个人的远程仓库网站Gitee账户并添加你的ssh公钥。 -请在Gitee网页点击右上角的“个人头像”进入个人Gitee账户,并点击个人头像下的“个人设置”,进入个人设置页面。在“个人设置->安全设置”下,点击“SSH公钥”,在“添加公钥”内把cat命令获取到的ssh公钥添加进去。 -③ 在个人电脑上完成gitee在SSH上的登记。 -```ssh -T git@gitee.com``` - ->![image](figures/contribution-guide-13.png) - -**步骤 4** 克隆远程仓库到本地。 -● 请注意openEuler有几个组织,请确认你所下载的远程仓库的组织名称 -● 可以在repository内复制远程仓库的拷贝地址,得到$remote_link: ->![image](figures/contribution-guide-14.png) - -● 在本地电脑执行拷贝命令: -把远程 fork 仓库克隆到本地 -```git clone https://gitee.com/$user_name/$repository_name``` -设置本地工作目录的 upstream 源(被 fork 的上游仓库) -```git remote add upstream https://gitee.com/openeuler/$repository_name``` -设置同步方式 -```git remote set-url --push upstream no_push``` - -**步骤 5** 拉分支(可选)。 -```git fetch upstream``` -```git checkout master``` -```git rebase upstream/master``` -从这里拉分支: -```git checkout -b work``` -然后在 work 分支上编辑和修改代码。 - -**步骤 6** 保持你的分支与master同步。 -```While on your work branch``` -```git fetch upstream``` -```git rebase upstream/master``` -执行merge的时候,请不要使用 git pull 替代上面的 fetch/rebase。因为这种方式会使提交历史变得混乱,并使代码难以理解。 -**步骤 7** 在本地工作目录提交变更。 - -提交你的变更 -```git add .``` -```git commit -m "提交原因"``` -**步骤 8** 在Gitee上创建一个 pull request。 - -1. 访问你在 的页面。 -2. 把你的分支选到提交使用的 work 分支上,点击+ Pull Request 。具体位置如下图所示: -3. 在创建新PR界面,确认源分支和目标分支,选择创建。 - ->![image](figures/contribution-guide-15.png) - -**步骤 9** 查看和回应代码审查意见。 -你提交PR申请后,PR被分配给一个或多个检视者。这些检视者将进行检视,以确保提交的正确性,不仅包括代码的正确,也包括注释和文档等。 -(Gitee工作流说明) - -## Git与 VSCode基础 - -### Git - -Git是一个免费的、开源的分布式版本控制系统,可以有效、高速地处理项目版本管理。 - -#### 基本概念 - -**工作区**:就是你在电脑里能看到的目录。 -**暂存区**:英文叫 stage 或 index。一般存放在 .git 目录下的 index 文件(.git/index)中,所以我们把暂存区有时也叫作索引(index)。 -**版本库**:工作区有一个隐藏目录 .git,这个不算工作区,而是 Git 的版本库。 ->![image](figures/contribution-guide-16.png) - -● 图中左侧为工作区,右侧为版本库。在版本库中标记为 "index" 的区域是暂存区(stage/index),标记为 "master" 的是 master 分支所代表的目录树。 -● 图中我们可以看出此时 "HEAD" 实际是指向 master 分支的一个"游标"。所以图示的命令中出现 HEAD 的地方可以用 master 来替换。 -● 当对工作区修改(或新增)的文件执行 git add 命令时,暂存区的目录树被更新,同时工作区修改(或新增)的文件内容被写入到对象库中的一个新的对象中,而该对象的ID被记录在暂存区的文件索引中。 -● 当执行提交操作(git commit)时,暂存区的目录树写到版本库(对象库)中,master 分支会做相应的更新。即 master 指向的目录树就是提交时暂存区的目录树。 -● 当执行 git reset HEAD 命令时,暂存区的目录树会被重写,被 master 分支指向的目录树所替换,但是工作区不受影响。 -● 当执行 git rm --cached 命令时,会直接从暂存区删除文件,工作区则不做出改变。 - -#### Git 创建仓库 - -● Git 使用 git init 命令来初始化一个 Git 仓库,Git 的很多命令都需要在 Git 的仓库中运行,所以 git init 是使用 Git 的第一个命令。在执行完成 git init 命令后,Git仓库会生成一个.git 目录,该目录包含了资源的所有元数据,其他的项目目录保持不变。 -如果当前目录下有几个文件想要纳入版本控制,需要先用 git add 命令告诉Git开始对这些文件进行跟踪,然后提交: -```$ git add *.c``` - -```$ git add README``` - -```$ git commit -m '初始化项目版本'``` - -以上命令将目录下以 .c 结尾及README文件提交到仓库中。 ->注: 在Linux系统中,commit 信息使用单引号 ',在Windows系统,commit信息使用双引号 "。 - -所以在 git bash 中 git commit -m '提交说明' 这样是可以的,在Windows命令行中就要使用双引号 git commit -m "提交说明"。 -● 我们使用 git clone 从现有 Git 仓库中拷贝项目。 -克隆仓库的命令格式为: -```git clone ``` -如果我们需要克隆到指定的目录,可以使用以下命令格式: -```git clone ``` -参数说明: -repo: Git 仓库。 -directory: 本地目录。 -比如,要克隆 Ruby 语言的 Git 代码仓库 Grit,可以用下面的命令: -```$ git clone git://github.com/schacon/grit.git``` -执行该命令后,会在当前目录下创建一个名为grit的目录,其中包含一个 .git 的目录,用于保存下载下来的所有版本记录。 -如果要自己定义要新建的项目目录名称,可以在上面的命令末尾指定新的名字: -```$ git clone git://github.com/schacon/grit.git mygrit``` - -● 我们使用如下命令设置提交代码时的用户信息。 -```$ git config --global user.name xxx``` - -```$ git config --global user.email xxx@xxx``` - -如果去掉 --global 参数只对当前仓库有效。 - -#### Git 基本操作 - -Git常用的是以下6个命令:**git clone**、**git push**、**git add** 、**git commit**、**git checkout**、**git pull** ->![image](figures/contribution-guide-17.png) - -一个简单的操作步骤: -```$ git init``` - -```$ git add .``` - -```$ git commit``` -● git init - 初始化仓库。 -● git add . - 添加文件到暂存区。 -● git commit - 将暂存区内容添加到仓库中。 -(Git菜鸟教程) - -#### Git常用命令 - -##### 创建仓库命令 - -| 命令 | 说明 | -| :-------- | :------------------------------------- | -| git init | 初始化仓库 | -| git clone | 拷贝一份远程仓库,也就是下载一个项目。 | - -##### 提交与修改命令 - -| 命令 | 说明 | -| :--------- | :--------------------------------------- | -| git add | 添加文件到暂存区。 | -| git status | 查看仓库当前的状态,显示有变更的文件。 | -| git diff | 比较文件的不同,即暂存区和工作区的差异。 | -| git commit | 提交暂存区到本地仓库。 | -| git reset | 回退版本。 | -| git rm | 将文件从暂存区和工作区中删除。 | -| git mv | 移动或重命名工作区文件。 | - -##### 提交日志 - -| 命令 | 说明 | -| :--------------- | :------------------------------------- | -| git log | 查看历史提交记录。 | -| git blame | 以列表形式查看指定文件的历史修改记录。 | - -##### 远程操作 - -| 命令 | 说明 | -| :--------- | :------------------- | -| git remote | 远程仓库操作。 | -| git fetch | 从远程获取代码库。 | -| git pull | 下载远程代码并合并。 | -| git push | 上传远程代码并合并。 | - -#### Git 特殊操作 - -##### 处理冲突提交 - -如果发现提交的PR带有以下的标记,说明你提交的PR和本地存在冲突,需要处理冲突。 ->![image](figures/contribution-guide-18.png) - -**步骤 1** 先将分支切换到master上,并完成master的rebase。 -```git checkout master``` -```git fetch upstream``` -```git rebase upstream/master``` - -**步骤 2** 再将分支切换到您使用的分支上,并开始rebase。 -```git checkout yourbranch``` -```git rebase master``` - -**步骤 3** 此时你可以在git上看到冲突的提示,你可以通过vi等工具查看冲突。 - -**步骤 4** 解决冲突以后,再把修改提交上去。 -```git add .``` -```git rebase --continue``` -```git push -f origin yourbranch``` - -##### 合并提交 - -如果你提交了一个PR以后,根据检视意见完成修改并再次提交了PR,不想让审阅者看到多次提交的PR,因为这不便于继续在检视中修改,那么可以合并提交的PR。合并提交的PR是通过压缩Commit来实现的。 -**步骤 1** 现在本地分支上查看日志。 -```git log``` - -**步骤 2** 然后把顶部的n个提交记录聚合到一起进入,注意n是一个数字。 -```git rebase -i HEAD~n``` -把需求压缩的日志前面的pick都改成s,s是squash的缩写。注意必须保留一个pick,如果将所有的pick都改成了s就没有合并的目标了,会发生错误。 - -**步骤 3** 修改完成以后,按ESC键,再输入:wq,会跳出一个界面,问你是否进入编辑提交备注的页面,输入e以后,进入合并提交备注的页面。请把需要合并的备注都删掉,只保留合并目标的备注,再按ESC键,输入:wq保存退出即可。 - -**步骤 4** 最后完成提交。 -```git push -f origin yourbranch``` - -**步骤 5** 回到gitee上的PR提交页面查看,您就可以看到之前的提交已经合并了。 -详细请见:。 -(Gitee工作流说明) - -### VS Code - -Visual Studio Code(简称 VS Code)是由微软开发的轻量级代码编辑器,支持包括 Markdown 在内的多种语言和格式,内置了命令行工具和 Git 版本控制系统。VSCode 中很多操作可以通过软件内命令行来使用,呼出软件内命令行的默认快捷键是 F1 或 Ctrl+Shift+P,请牢记。本文内有>前缀的命令是 VS Code 命令行的命令,否则是 Git Bash 命令。 ->![image](figures/contribution-guide-19.png) - -#### 软件与扩展安装 - -1. 安装并配置好 Git。 -2. 下载安装 VS Code。 -3. 可安装中文语言包,语言包在扩展商店中以扩展的形式提供。要打开扩展商店:点击左侧边栏的扩展图标,或快捷键 Ctrl+Shift+X,或呼出命令行,输入>extensions: install extensions 以命令打开。 -注:VSCode 软件内命令行一般不需要输入完整命令,可输入>extensions 或 >install extensions 之后用键盘上下键选择命令补全。可以输入中文命令描述。 -点击[安装]按钮即可安装,点击项目可进入商店页面查看详情。 -4. 安装 GitLens 扩展,用于 Git 相关操作。 - ->![image](figures/contribution-guide-20.png) - -#### VSCode界面和Git - -为方便解说UI内容,先将Gitee仓库用VS Code打开,这里假定你已经把 openEuler/docs仓fork到了自己的远程仓,并且 >git: clone 或用 git bash clone 到了本地计算机上: -打开本地仓:在 VS Code 中用 >git: clone 克隆完成后会提示是否打开。如果是用 Git Bash 克隆的本地仓:在Windows资源管理器中打开本地仓所在文件夹,右键菜单通过Code打开,或在VSCode中点击文件>打开文件夹,或 >File: Open Folder。打开界面如下图。 ->![image](figures/contribution-guide-21.png) - -图中已经点击预览 README\.md。单击是预览文件,文件名在打开的编辑器中显示为斜体;双击是打开文件,文件名不显示斜体。预览时做任何改动也会打开文件。 -右下角显示 Markdown 处可以点击更改语言模式,如果编辑器没有自动检测到Markdown语法可以手动选择。 -查看(预览或打开)文件时,时间线会显示当前文件的提交历史,底栏会显示光标当前所在行的作者和提交时间。点击时间线中任意提交历史可以比较查看当前文件在本次提交中的改动。 ->![image](figures/contribution-guide-22.png) - -上图在 README\.md 中做了改动但没有保存,文件名前会加上圆点图标,并且有文字提示 1 个未保存。 -如要对比本地的两个文件,在文件树(即图中 DOCS)或打开的编辑器中右键点击一个文件选择以进行比较,再右键另一个文件与已选项目进行比较,或者按住 Ctrl 选择两个文件将已选项进行比较。改动后未保存的文件也可以与已保存的版本比较。 -文件树中可以进行新建文件/文件夹、复制粘贴、重命名等常规操作。在资源管理器页,按 Ctrl+E 可以在文件树中以文件名或路径进行搜索。 -在编辑器中更改并保存文件后,有改动的文件会出现在更改中。点击这里的文件可以显示对比,即本地最新的文件与最后一次拉取的文件对比。 -在更改文件树中的文件名右侧点击 + 号将文件放入暂存区。等效于对当前文件使用 >git: stage changes 命令。 -也可以 Ctrl+左键多选文件后点击 + 批量放入暂存区。命令 >git:stage all changes 可以把所有更改的文件放入暂存区。 -点击暂存区中文件名右侧的 - 可以移出暂存区。 -要提交暂存区中的文件,按源代码管理项下输入框中的提示,输入提交信息按 Ctrl+Enter 提交。等效于 >git: commit staged。 -未暂存的文件可以使用 >git: commit 或 >git: commit all 提交,确认后文件可跳过暂存直接提交。 -提交的文件存放于本地库中,还未发布到远端库。可以使用 >git: undo last commit 撤消最后一次提交。 -提交后,窗口左下角会显示提交的数量,可以点击此处发布到远端库(同时会拉取远端库的新提交)。如果要只发布而不拉取,可以使用 >git: push。如果显示远端库有新提交,先拉取至本地,以免提交后产生冲突。 ->![image](figures/contribution-guide-23.png) - -**COMMITS** 项显示当前分支中的所有提交历史。点击提交项可以展开显示更改的文件,点击文件可以显示与上个版本比较的改动。 ->![image](figures/contribution-guide-24.png) - -FILE HISTORY 即编辑器中当前打开文件的提交历史,类似于资源管理器页中的时间线。 -BRANCHES 显示本地分支中的提交。参见下文 REMOTES。 -REMOTES 显示远端库中所有分支的提交。右键选择 Switch to Branch... 切换到另一分支,并将这个分支保存到本地,显示在 BRANCHES 中。点击左下此处也可以切换分支。 ->![image](figures/contribution-guide-25.png) ->STASHES 储藏区。修改后的文件如果不满意,不想放在本次提交里,或者有未提交的更改但想要切换到其他分支进行操作,可以 >git: stash 先放入储藏区。 ->TAGS 列出每个标签对应的提交。 ->SEARCH & COMPARE 提供搜索提交和比较分支的功能。Search Commits... 可以选择按消息内容、作者、文件等搜索。Compare References... 可以选中两个分支进行比较,提交比较和文件树比较。文件树比较会显示文件路径变化,以及内容有差异的同名文件。 ->![image](figures/contribution-guide-26.png) - -创建图中的比较时,先选择了 master 分支(显示在右侧),后选择了 stable2-21.09 分支(显示在左侧)。 -文件树中 - 号表示在右侧分支中缺少的文件,+ 号表示右侧分支中多出的文件,± 表示同名文件内容有差异,点击打开对比视图。 - -#### 保持本地提交记录和远端上游仓同步 - -为防止创建的Pull Request与上游仓内容冲突,强烈建议每次提交前将上游仓的 commit 拉取到当前分支。 - -**步骤 1** 在VS Code中添加上游仓。以主仓openEuler/docs为例,在网页端克隆/下载按钮复制SSH地址 git\@gitee.com:xxxx.git。运行以下命令添加主仓,显示在源代码管理页的REMOTE下: -```git remote add upstream git@gitee.com:xxxx.git``` -upstream 为自定义名称 - -**步骤 2** 抓取主仓的commits。 -```git fetch upstream``` -```git fetch upstream``` - -**步骤 3** 将主仓的commits合并到本地的分支。以 master 分支为例: -```git checkout master``` -↑切换到 master 分支,如已在 VS Code 中切换则省略 -```git merge upstream/master``` - -**步骤 4** 解决源代码管理中提示的冲突(如有),然后提交自己的改动。 - -#### 合并commits - -为保持提交记录简洁(以及满足部分仓库的要求),一个 PR 应当只包含一个 commit。如果多个 commits已经提交到远端库,靠回退版本 (git reset)来合并 commits。 -假设**源代码管理 > COMMITS** 当前的 commit 记录如下: - -```text - YOUR_COMMIT_3 - YOUR_COMMIT_2 - YOUR_COMMIT_1 - OTHERS_COMMIT_2 - OTHERS_COMMIT_1 -``` - -要合并 YOUR_COMMIT_,(记录下 commit message)右键点击 OTHERS_COMMIT_2 选择 Reset Current Branch to Commit...,然后选择 Soft Reset,即可回退到 OTHERS_COMMIT_2 的版本,三个 YOUR_COMMIT_ 的改动会回到上方更改区域,重新填写commit message 强制提交即可。 -版本回退后,因为本地的版本早于远端库的版本,必须**使用 force push 覆盖远端库**:打开 VS Code 选项,搜索 Allow Force Push 项并勾选,然后按 F1 呼出命令行,输入 push force 等类似关键字,选择相关选项。 - -#### 推荐扩展 - -● Markdown Editor (zaaack.markdown-editor),支持所见即所得模式和分屏预览模式的 Markdown 编辑器。 -● Markdown Preview Enhanced (shd101wyy.markdown-preview-enhanced),增强 Markdown 预览功能,包含 TOC 自动生成功能。快捷方式同样为 Ctrl+Shift+V,覆盖 VSCode 自带的预览查看器。安装后如果需要使用自带的预览查看器,在编辑器窗口顶端的文件标签上右键 -> 打开预览。自带的查看器中,双击句段可以跳转到原文相应句子。 -自动生成 TOC:>markdown preview enhanced: create toc (需要保持预览窗口打开)。保存时自动更新 TOC。 -● GitHub Markdown Preview (bierner.github-markdown-preview),或仅安装其中的核心扩展 Markdown Preview Github Styling (bierner.markdown-preview-github-styles),以 GitHub 格式显示 Markdown 预览,效果接近Gitee网页。 -● Code Spell Checker (streetsidesoftware.code-spell-checker),自然语言拼写检查扩展,除英语外还有多种语言可选。 -● CJK Word Handler (sharzyl.cjk-word-handler)。VSCode 默认以空格、","、"." 等英文符号作为分隔符,导致整句中文被识别为一个整词,使用 Ctrl+←/→ 相关操作时非常不便。这个扩展可以让 VSCode 支持中文分词逻辑。 -● Bookmarks (alefragnani.bookmarks),以行为坐标添加书签。 -(VSCode for openEuler Docs Globalization)。 - -## 参考链接 - -[https://kaiyuanshe.cn/article/github/how-to-participate-in-open-source/](https://kaiyuanshe.cn/article/github/how-to-participate-in-open-source/) -[https://docs.qq.com/doc/DSnJVSmhDcHhrV25L](https://docs.qq.com/doc/DSnJVSmhDcHhrV25L) -[https://www.openeuler.org/zh/](https://www.openeuler.org/zh/) -[https://gitee.com/openeuler/community/blob/master/zh/contributors/issue-submit.md](https://gitee.com/openeuler/community/blob/master/zh/contributors/issue-submit.md) -[https://gitee.com/openeuler/community/blob/master/zh/contributors/pull-request.md](https://gitee.com/openeuler/community/blob/master/zh/contributors/pull-request.md) -[https://gitee.com/openeuler/community/blob/master/zh/contributors/Gitee-workflow.md](https://gitee.com/openeuler/community/blob/master/zh/contributors/Gitee-workflow.md) -[https://www.runoob.com/git/git-tutorial.html](https://www.runoob.com/git/git-tutorial.html) -[https://gitee.com/openeuler/G11N/blob/master/learning-materials/open-source-basics/vscode-for-g11n.md](https://gitee.com/openeuler/G11N/blob/master/learning-materials/open-source-basics/vscode-for-g11n.md) -[https://gitee.com/openeuler/globalization/blob/master/openeuler-g11n-contribution-guide.md](https://gitee.com/openeuler/globalization/blob/master/openeuler-g11n-contribution-guide.md) -[https://gitee.com/openeuler/G11N/blob/master/learning-materials/open-source-basics/markdown-basics.md](https://gitee.com/openeuler/G11N/blob/master/learning-materials/open-source-basics/markdown-basics.md) diff --git "a/contribute/\345\206\231\344\275\234\350\247\204\350\214\203.md" "b/contribute/\345\206\231\344\275\234\350\247\204\350\214\203.md" deleted file mode 100644 index 4c9566d4ca823048228c8cb544225e62a87d2632..0000000000000000000000000000000000000000 --- "a/contribute/\345\206\231\344\275\234\350\247\204\350\214\203.md" +++ /dev/null @@ -1,302 +0,0 @@ -# 写作规范 - -## 文档内容 - -根据文档分类如用户指南、开发者指南等,选择合适的大纲,要求能简洁清晰的实现文档的目的。 - -- 开源项目做什么 -- 什么语言编写 -- 项目维护、CI、依赖更新状态 -- 项目可用版本及其他版本 -- Demo 或官网地址 -- 功能特点 -- 获取 -- 安装 -- 使用(操作步骤、接口文档、开发指南等) -- FAQ - -拟定文档大纲,编辑文档内容,针对文档内容做如下规范。 - -- 提交内容必须是与 openEuler 特性相关内容。 -- 内容不能包含敏感信息、有强烈的种族歧视或性别歧视的内容。 -- 提交的内容必须是原创内容,不得侵犯他人知识产权。 -- 提交的内容必须客观、真实,不允许使用夸大宣传等词汇。 - -## 文档结构 - -项目手册内容一般包括用户指南、背景介绍、操作类文档(安装与部署、使用指南)、常见问题和附录,写作者可以根据项目实际情况增加或删减。 -以[A-Tune 项目为例](https://docs.openeuler.org/zh/docs/22.03_LTS_SP2/docs/A-Tune/A-Tune.html),可以参考如下内容: - -- **用户指南** - - 用户指南包含项目介绍和读者对象。 - -- **背景介绍类** - - 背景介绍类文档写明项目背景与简介、架构说明等。 - -- **操作类文档** - - 操作类文档写明步骤、注意事项、前提条件等,以便能对其他开发者起到帮助。 - - - 使用说明 - - 说明此操作在什么场景下使用可以解决用户的什么问题。 - - - 环境要求 - - 执行此操作需要用户准备的软硬件环境、权限以及其它约束条件。 - - - 操作步骤 - - 具体的操作步骤,需要注意如下事项: - - - 建议一步一个操作步骤,不建议多个操作步骤合并在一个步骤中描写。 - - 如果操作可选,要明确可选条件。 - - 开发步骤中,涉及调用接口(例如使用了工具或者 SQL 语句),需要对使用的接口进行说明。 - - - 结果验证 - - 说明如何验证操作结果正确。如果验证操作与步骤强相关,可以在步骤中描述。例如,执行 SQL 语句的返回信息。 - -- **常见问题** - 此类文档应该包括问题描述、产生原因及解决办法。 - -- **附录** - 附录可包含术语与缩略语介绍。 - -## 命名 - -对于新增文档,请在对应的文件目录下新增 MarkDown 文档(即以 .md 结尾的文件)。文档命名需要根据文档的内容声明。 - -- 新增文档名称不能与已有文档重名,如果有请重新命名。 -- 新增文档之后,需要在 menu 文件夹下的 index 文件中新增对应的目录,否则新增文件无法显示。目录层级不建议超过三级。 -- 文件名中不能包含括号,会导致文件目录无法正常显示。可以将括号修改为可识别的下划线(\_)或者中划线(-)。 - -## 标题 - -- 标题尽量采用简洁的语句概况反映章节的中心内容,注意不要省略必要的信息。例如:xxx概述,如果用概述来代替,就会导致读者无法从标题中获取到有用信息。 -- 操作类文档标题尽量用动宾结构(例如:申请权限)。 -- 相同级别,相同类型的标题结构保持一致。 -- 标题不使用标点符号结尾。 -- 标题中尽量采用圆括号来表示补充说明,标题中不能出现特殊字符,如“?”。 -- 标题与正文使用 1 整行换行隔开。 -- 标题使用 “#” 空格连接标题名,标题级别一次只能增加一个级别且第一个标题应该是顶层标题。 - -## 目录 - -文档为以 .md 结尾的文件,存储在 路径下。 - -docs 文件夹中包含以下内容: - -- zh:全量版中文资料。 -- en:全量版英文资料。 - -根据文档所属的手册,选择对应的文件夹。 - -- 目录层级不建议过深。 -- doc 仓库内新增文档需要同步修改 menu.json 文件,才可以在官网文档页面展示该文档。 -- doc 官网会在右侧自动生成文档的章节目录,不建议额外增加 TOC 目录。 - -## 正文 - -- 可使用*斜体* **加粗**样式。 -- 该转义的字符必须严格用转义符 \ ,例如 \* \< \> \_等。 -- 如果有连续两个转义符,转义符之间要有空格 \{ \}。 -- 国际化:需同时提供中英文文档,可联系协助翻译。 - -## 空格 - -- 编辑文档时中文和英文之间建议加空格,页面展示更美观,请保持全文一致。如果是产品名词如 “豆瓣FM”,请按照官方定义格式书写。 - - 例如:openEuler 是一款开源操作系统。当前 openEuler 内核源于 Linux ,支持鲲鹏及其它多种处理器。 - -- 中文和数字之间加空格。 - -- 数字和单位之间不加空格。 - -- 链接与正文之间加空格。 - -- 全角标点与其他字符之间不加空格。 - - 例如:刚刚成为了 openEuler 的 maintainer,好开心。 - -## 图片 - -- 图片统一存放到文档同级目录下的 figures 文件夹中。例如,[A-Tune用户指南](https://docs.openeuler.org/zh/docs/22.03_LTS_SP2/docs/A-Tune/A-Tune.html)中的手册中使用的图片,统一存储在 [A-Tune](https://gitee.com/openeuler/docs/tree/stable2-22.03_LTS_SP2/docs/zh/docs/A-Tune/figures) 路径下。该文件夹下的文件引用图片时,使用相对引用。 -- 请使用原创图片,避免存在知识产权侵权风险。 -- 图形清晰可辨识,图形信息完整,例如流程图有“开始”和“结束”。 -- 图形逻辑清晰。 -- 图文配合使用,切忌图文分离。 -- 图片格式首选 png,此外也接受 jpg。图片的高不超过 640px,宽不超过 393px,图片大小建议不超过 150K。 -- 中文用中文插图,英文用英文插图。 -- 图片路径不能包含中文。 -- 图片后缀也必须是小写,不能出现 .PNG 这种大写后缀 -- 图片建议根据内容命名,只用数字序列不利于后续图片的继承。 -- 如果是截图,请在允许的范围内只保留有用的信息。图形中需要突出的关键信息,可增加红色框线或者文字备注说明。 - -图片写作示例: - - 图片以 ![](./figures/pic_name.png) 格式书写,“./” 不可少,否则图片无法显示到现网。 - -## 代码块 - -代码示例说明了如何实现特定功能,开发人员使用代码示例来编写和调试代码。代码要求如下: - -- 代码的逻辑和语法正确。 -- 代码的输入和输出尽可能的分开。 -- 保证代码中关键步骤要有注释说明。 -- 代码源于具体实例。 -- 文中行内代码和命令行使用 1 对反引号 如: `代码行`。 -- 块级代码使用 3 个顿号或 4 个空格(不能用 TAB 键)缩进,且上下均用整行隔开,如下: - - ```python - #!/usr/bin/env python3 - print("Hello, World!"); - ``` - - ```c - #include - int main(void) - { - printf("Hello world\n"); - } - ``` - -## 列表 - -使用列号 “1.” 或者 “*”,其后内容空格隔开,示例如下: - - 1. 一层列表 - 2. 一层列表 - 3. 一层列表 - * 二层列表 - * 二层列表 - -列表内标点符号使用规则: - -1. 当项目列表是术语、短语时,统一不加标点符号。 -2. 当项目列表是句子时,统一加句号。 -3. 特殊情况下如果不能避免出现短语和句子混合的情况,统一加句号。 -4. 项目列表前几项以分号结尾,最后一项以句号结尾的形式也可以接受。 - -## 注释符号 - -文档中会出现以下注释符号,代表不同的使用场景和提示程度。如果需要提示用户注意的信息,可以根据重要程度选择对应的注释符号。 -![image](figures/SafetyAlert.png) - -## 链接 - -链接需要确保指向的目标文件存在,否则会造成链接跳转不正常,不建议使用 HTML 的链接样式。 - -链接示例: - - 这是一个链接 [菜鸟教程](https://www.runoob.com)。 - -## 表格 - -Markdown 文档中请使用以下方式创建表格,不建议使用 HTML 的表格样式。 - - | 表头 | 表头 | - | ---- | ---- | - | 单元格 | 单元格 | - | 单元格 | 单元格 | - -单元格内标点符号使用规则: - -1. 当表格内一列全部是术语、短语时,统一不加标点符号。 -2. 当表格内一列全部是句子时,统一加句号。 -3. 特殊情况下如果不能避免出现短语和句子混合的情况,统一加句号。 - -## 常用词汇 - -| 不建议使用 | 建议使用 | -| ---- | ---- | -| 阀值 | 阈值 | -| 登陆 | 登录 | - -## 标点符号 - -- 单位与数字之间不建议加空格,比如 50m,10kg,64Kbit/s。 -- 对于有序/无序列表,如果是长句子,建议统一以句号结尾,如果是短语,结尾可不用标点。**重点是前后一致,要么都加,要么都不加**。 -- 中文文档使用全角标点。 -- 数字使用半角字符。 -- 感叹号使用场景为可能引发严重后果的操作或设备安全、人身安全的警告。其他场景不允许使用感叹号。 -- 文内引用其他文档件事添加书名号,同时建议增加引用文档的跳转链接。例如:安装 openEuler 系统,安装方法参考《[openEuler 22.03 LTS SP2 安装指南](https://docs.openeuler.org/zh/docs/22.03_LTS_SP2/docs/Installation/installation.html)》。 - -## docs 仓库提交 PR 和 issue - -1. PR 规范 - - - PR 标题清晰易懂,内容描述详细具体,一个 PR 只包含一次提交(git log,git reset commit id , git push -f),一个 PR 只涉及一个主题修改。 - - 需要 2 个回复 /lgtm,1 个 /approve,一般需要需求提出或文档相关责任人进行审核。 - - CI 格式检查成功,需要满足无 markdownlint 报错。 - - PR 需要关联 issue,每个特性需求 /bug 都要转 issue 跟踪,并关联对应版本号。 - - 新增文档需要同步修改目录文件 menu.json 文件。 - - 对于同步维护的分支,PR 需要分别提交到对应分支上。 - -2. issue 规范 - -有文档需要合入需要先新建 issue,内容表述清晰即可,如果是 bug 需要指出具体哪个版本哪本文档需要修改。 - -3. PR 提交建议 - - - 修改同一类问题(例如末尾句号)建议全文一致,不仅仅修改一处。 - - 建议将同一篇文档的低错问题修改条在一个 PR 里。 - - 建议在评论区使用 /sync + 版本号的方式将当前 PR 修改同步到其它分支。 - -4. 文档贡献中不受欢迎的行为 - -短时间内通过自动化工具,提交大量的PR,提交大量的处理诸如拼写错误,语法错误,日期错误,语句不通顺等“无害的错误”的修正。 -具体内容以及处理措施详见 [openEuler社区开发行为规范 V1.0](https://gitee.com/openeuler/community/blob/master/zh/technical-committee/governance/openEuler%E7%A4%BE%E5%8C%BA%E5%BC%80%E5%8F%91%E8%A1%8C%E4%B8%BA%E8%A7%84%E8%8C%83.md)。 - -## 资料PR检视Checklist - -- **规范和低错类**问题 - - 错别字或拼写错误;标点符号使用错误 - - 链接错误、空单元格、格式错误 - - 英文中包含中文字符 - - 界面和描述不一致,但不影响操作 - - 表述不通顺,但不影响理解 - - 版本号不匹配:如软件包名称、界面版本号 - - 相同内容在同一文档中写法不一致 - - 软件名称书写不规范 - - 描述口语化 - - 图形、表格不符合规范 - - 专有名词的写作不符合业界规范或拼写错误。 - - 成双成对的标点符号使用过程中有缺失另一半,或使用不规范 - - 标题和正文中,命令的大小写写法不一致 - - 图片不显示、超大,超出正文或页面宽度、变形、缺失或冗余 - - 命令解释和命令写在一起 - - 相同内容在同一个地方重复描述 - - 操作截图与实际环境不一致 - - 步骤中命令行和回显中的命令行不一致 -- **易用性**问题 - - 关键步骤错误或缺失,无法指导用户完成任务 - - 缺少必要的前提条件、注意事项等 - - 操作场景不明确 - - 图形、表格、文字等晦涩难懂 - - 逻辑不清晰,该分类、分项、分步骤的没有给出 - - 步骤不易理解和学习,如命令缺少描述 - - 已明确说明不支持的场景,又给了该场景下的使用方法或约束 - - 文档名称不规范,根据文档名称不能快速定位手册描述重点 - - 步骤描述和实际的操作不符 -- **正确性**问题 - - 技术原理、功能、规格、配套版本、OS 等描述和软件不一致,存在错误 - - 原理图、架构图等存在错误 - - 命令、命令参数、IP等错误 - - 命令无法完成对应功能 - - 界面错误,无法指导操作 - - 链接本来就是错误的,跳转的版本或内容不正确 - - 链接未失效,但是所需内容已更新不存在 - - 代码格式不规范,如未换行,或缩进不正确,括号没有匹配等 - - 命令行中有多余的空格,导致命令报错 -- **风险提示**问题 - - 对重要数据或系统存在风险的操作,缺少安全提示 -- **合规**问题 - - 违反法律法规,涉及政治、领土主权等敏感词 - - 内容侵权 - -## 参考 - -您如需获取更多写作技巧,请参考 [Markdown常用语法参考](./MarkDown常用语法参考.md)和[markdownlint检查规则](./markdownlint检查规则.md)。 diff --git a/docs/en/docs/A-Ops/using-gala-anteater.md b/docs/en/docs/A-Ops/using-gala-anteater.md index 92907378c87b4d1b338584bc598db0763aadb5bf..9cac21cbff25f2ec88eb9940eb3ff587638bfafc 100644 --- a/docs/en/docs/A-Ops/using-gala-anteater.md +++ b/docs/en/docs/A-Ops/using-gala-anteater.md @@ -4,21 +4,21 @@ gala-anteater is an AI-based operating system exception detection platform. It p This chapter describes how to deploy and use the gala-anteater service. -#### Installation +## Installation -Mount the repo sources. +Mount the repositories. -```basic -[oe-2209] # openEuler 22.09 officially released repository -name=oe2209 -baseurl=http://119.3.219.20:82/openEuler:/22.09/standard_x86_64 +```conf +[everything] +name=everything +baseurl=http://121.36.84.172/dailybuild/EBS-openEuler-24.09/EBS-openEuler-24.09/everything/$basearch/ enabled=1 gpgcheck=0 priority=1 -[oe-2209:Epol] # openEuler 22.09: Epol officially released repository -name=oe2209_epol -baseurl=http://119.3.219.20:82/openEuler:/22.09:/Epol/standard_x86_64/ +[EPOL] +name=EPOL +baseurl=http://repo.openeuler.org/openEuler-22.03-LTS-SP4/EPOL/main/$basearch/ enabled=1 gpgcheck=0 priority=1 @@ -27,49 +27,98 @@ priority=1 Install gala-anteater. ```bash -# yum install gala-anteater +yum install gala-anteater ``` +## Configuration +> Note: gala-anteater uses a configuration file (**/etc/gala-anteater/config/gala-anteater.yaml**) for its startup settings. -#### Configuration +### Configuration Parameters -> Note: gala-anteater does not contain the config file that needs to be configured. Its parameters are passed through the startup parameters using the command line. +```yaml +Global: + data_source: "prometheus" -##### Startup Parameters +Arangodb: + url: "http://localhost:8529" + db_name: "spider" -| Parameter| Parameter Full Name| Type| Mandatory (Yes/No)| Default Value| Name| Description| -|---|---|---|---|---|---|---| -| -ks | --kafka_server | string | True | | KAFKA_SERVER | IP address of the Kafka server, for example, **localhost / xxx.xxx.xxx.xxx**.| -| -kp | --kafka_port | string | True | | KAFKA_PORT | Port number of the Kafka server, for example, **9092**.| -| -ps | --prometheus_server | string | True | | PROMETHEUS_SERVER | IP address of the Prometheus server, for example, **localhost / xxx.xxx.xxx.xxx**.| -| -pp | --prometheus_port | string | True | | PROMETHEUS_PORT | Port number of the Prometheus server, for example, **9090**.| -| -m | --model | string | False | vae | MODEL | Exception detection model. Currently, two exception detection models are supported: **random_forest** and **vae**.
**random_forest**: random forest model, which does not support online learning
**vae**: Variational Atuoencoder (VAE), which is an unsupervised model and supports model update based on historical data during the first startup.| -| -d | --duration | int | False | 1 | DURATION | Frequency of executing the exception detection model. The unit is minute, which means that the detection is performed every *x* minutes.| -| -r | --retrain | bool | False | False | RETRAIN | Whether to use historical data to update and iterate the model during startup. Currently, only the VAE model is supported.| -| -l | --look_back | int | False | 4 | LOOK_BACK | Whether to update the model based on the historical data of the last *x* days.| -| -t | --threshold | float | False | 0.8 | THRESHOLD | Threshold of the exception detection model, ranging from 0 to 1. A larger value can reduce the false positive rate of the model. It is recommended that the value be greater than or equal to 0.5.| -| -sli | --sli_time | int | False | 400 | SLI_TIME | Application performance metric. The unit is ms. A larger value can reduce the false positive rate of the model. It is recommended that the value be greater than or equal to 200.
For scenarios with a high false positive rate, it is recommended that the value be greater than 1000.| +Kafka:f + server: "192.168.122.100" + port: "9092" + model_topic: "gala_anteater_hybrid_model" + rca_topic: "gala_cause_inference" + meta_topic: "gala_gopher_metadata" + group_id: "gala_anteater_kafka" + # auth_type: plaintext/sasl_plaintext, please set "" for no auth + auth_type: "" + username: "" + password: "" +Prometheus: + server: "localhost" + port: "9090" + steps: "5" +Aom: + base_url: "" + project_id: "" + auth_type: "token" + auth_info: + iam_server: "" + iam_domain: "" + iam_user_name: "" + iam_password: "" + ssl_verify: 0 -#### Start +Schedule: + duration: 1 +``` -Start gala-anteater. +| Parameter | Description | Default Value | +| ----------- | --------------------------------------------------------------------------------------------- | ---------------------------- | +| Global | | | +| data_source | Data source | "prometheus" | +| Arangodb | | | +| url | IP address of the ArangoDB graph database | "" | +| db_name | Name of the ArangoDB database | "spider" | +| Kafka | | | +| server | IP address of the Kafka server. Configure according to the installation node IP address. | | +| port | Port of the Kafka server (for example, 9092) | | +| model_topic | Topic for reporting fault detection results | "gala_anteater_hybrid_model" | +| rca_topic | Topic for reporting root cause analysis results | "gala_cause_inference" | +| meta_topic | Topic for gopher to collect metric data | "gala_gopher_metadata" | +| group_id | Kafka group ID | "gala_anteater_kafka" | +| Prometheus | | | +| server | IP address of the Prometheus server. Configure according to the installation node IP address. | | +| port | Port of the Prometheus server (for example, 9090) | | +| steps | Metric sampling interval | | +| Schedule | | | +| duration | Interval (in minutes) between anomaly detection model executions | 1 | -> Note: gala-anteater can be started and run in command line mode, but cannot be started and run in systemd mode. +## Start -- Running in online training mode (recommended) -```bash -gala-anteater -ks {ip} -kp {port} -ps {ip} -pp {port} -m vae -r True -l 7 -t 0.6 -sli 400 -``` +Start gala-anteater. -- Running in common mode ```bash -gala-anteater -ks {ip} -kp {port} -ps {ip} -pp {port} -m vae -t 0.6 -sli 400 +systemctl start gala-anteater ``` -Query the gala-anteater service status. +### Fault Injection + +gala-anteater is a fault detection and root cause locating module. In the testing phase, you need to inject faults to construct fault scenarios. This allows gala-anteater to obtain information about faulty nodes and the root cause nodes of fault propagation. + +- Fault injection (for reference only) + + ```bash + chaosblade create disk burn --size 10 --read --write --path /var/lib/docker/overlay2/cf0a469be8a84cabe1d057216505f8d64735e9c63159e170743353a208f6c268/merged --timeout 120 + ``` + + ChaosBlade is a fault injection tool that can simulate various faults, including but not limited to drive faults, network faults, and I/O faults. + Note: Injecting different faults will cause corresponding fluctuations in related metrics monitored and reported to the Prometheus module by metric collectors (such as gala-gopher). These fluctuations will be visible in the Prometheus graph. + +### gala-anteater Service Status Query If the following information is displayed, the service is started successfully. The startup log is saved to the **logs/anteater.log** file in the current running directory. @@ -103,11 +152,9 @@ If the following information is displayed, the service is started successfully. 2022-09-01 17:53:57,975 - apscheduler.scheduler - DEBUG - Next wakeup is due at 2022-09-01 17:54:57.973533+08:00 (in 59.998006 seconds) ``` +## Output Data of Fault Detection - -#### Output Data - -If gala-anteater detects an exception, it sends the result to Kafka. The output data format is as follows: +If gala-anteater detects an exception, it sends the result to `model_topic` of Kafka. The output data format is as follows: ```json { @@ -155,3 +202,190 @@ If gala-anteater detects an exception, it sends the result to Kafka. The output "Body":"TimeStamp, WARN, APP may be impacting sli performance issues." } ``` + +## Output Data of Root Cause Locating + +Each faulty node detected triggers root cause locating. Results of root cause locating are sent to `rca_topic` of Kafka. The output data format is as follows: + +```yaml +{ + "Timestamp": 1724287883452, + "event_id": "1721125159975_475ae627-7e88-41ed-8bb8-ff0fee95a69d_l7_3459438_192.168.11.103_192.168.11.102_26_tcp_server_server_http", + "Attributes": { + "event_id": "1721125159975_475ae627-7e88-41ed-8bb8-ff0fee95a69d_l7_3459438_192.168.11.103_192.168.11.102_26_tcp_server_server_http", + "event_source": "root-cause-inference" + }, + "Resource": { + "abnormal_kpi": { + "metric_id": "gala_gopher_l7_latency_sum", + "entity_id": "", + "metric_labels": { + "client_ip": "192.168.11.103", + "comm": "python", + "container_id": "83d0c2f4a7f4", + "container_image": "ba2d060a624e", + "container_name": "/k8s_backend_backend-node2-01-5bcb47fd7c-4jxxs_default_475ae627", + "instance": "192.168.122.102:8888", + "job": "192.168.122.102", + "l4_role": "tcp_server", + "l7_role": "server", + "machine_id": "66086618-3bad-489e-b17d-05245224f29a-192.168.122.102", + "pod": "default/backend-node2-01-5bcb47fd7c-4jxxs", + "pod_id": "475ae627-7e88-41ed-8bb8-ff0fee95a69d", + "pod_namespace": "default", + "protocol": "http", + "server_ip": "192.168.11.102", + "server_port": "26", + "ssl": "no_ssl", + "tgid": "3459438" + }, + "desc": "L7 session averaged latency.", + "score": 0.3498585816683402 + }, + "cause_metrics": [ + { + "metric_id": "gala_gopher_container_cpu_user_seconds_total@4a9fcc23-8ba2-4b0a-bcb0-b1bfd89ed929", + "entity_id": "", + "metric_labels": { + "container_id": "1319ff912a6f", + "container_image": "ba2d060a624e", + "container_name": "/k8s_backend_backend-node3-02-654dd97bf9-s8jg5_default_4a9fcc23", + "instance": "192.168.122.103:8888", + "job": "192.168.122.103", + "machine_id": "494a61be-23cc-4c97-a871-902866e43747-192.168.122.103", + "pod": "default/backend-node3-02-654dd97bf9-s8jg5", + "pod_id": "4a9fcc23-8ba2-4b0a-bcb0-b1bfd89ed929", + "pod_namespace": "default" + }, + "desc": "\u5bb9\u56681s\u5185\u7528\u6237\u6001CPU\u8d1f\u8f7d", + "keyword": "process", + "score": 0.1194249668036936, + "path": [ + { + "pod_id": "4a9fcc23-8ba2-4b0a-bcb0-b1bfd89ed929", + "pod": "default/backend-node3-02-654dd97bf9-s8jg5", + "instance": "192.168.122.103:8888", + "job": "192.168.122.103", + "pod_state": "normal" + }, + { + "pod_id": "475ae627-7e88-41ed-8bb8-ff0fee95a69d", + "pod": "default/backend-node2-01-5bcb47fd7c-4jxxs", + "instance": "192.168.122.102:8888", + "job": "192.168.122.102", + "pod_state": "abnormal" + } + ] + }, + { + "metric_id": "gala_gopher_proc_wchar_bytes@67134fb4-b2a3-43c5-a5b3-b3b463ad7d43", + "entity_id": "", + "metric_labels": { + "cmdline": "python ./backend.py ", + "comm": "python", + "container_id": "de570c7328bb", + "container_image": "ba2d060a624e", + "container_name": "/k8s_backend_backend-node2-02-548c79d989-bnl9g_default_67134fb4", + "instance": "192.168.122.102:8888", + "job": "192.168.122.102", + "machine_id": "66086618-3bad-489e-b17d-05245224f29a-192.168.122.102", + "pgid": "3459969", + "pod": "default/backend-node2-02-548c79d989-bnl9g", + "pod_id": "67134fb4-b2a3-43c5-a5b3-b3b463ad7d43", + "pod_namespace": "default", + "ppid": "3459936", + "start_time": "1139543501", + "tgid": "3459969" + }, + "desc": "\u8fdb\u7a0b\u7cfb\u7edf\u8c03\u7528\u81f3FS\u7684\u5199\u5b57\u8282\u6570", + "keyword": "process", + "score": 0.37121879175399997, + "path": [ + { + "pod_id": "67134fb4-b2a3-43c5-a5b3-b3b463ad7d43", + "pod": "default/backend-node2-02-548c79d989-bnl9g", + "instance": "192.168.122.102:8888", + "job": "192.168.122.102", + "pod_state": "normal" + }, + { + "pod_id": "4a9fcc23-8ba2-4b0a-bcb0-b1bfd89ed929", + "pod": "default/backend-node3-02-654dd97bf9-s8jg5", + "instance": "192.168.122.103:8888", + "job": "192.168.122.103", + "pod_state": "normal" + }, + { + "pod_id": "475ae627-7e88-41ed-8bb8-ff0fee95a69d", + "pod": "default/backend-node2-01-5bcb47fd7c-4jxxs", + "instance": "192.168.122.102:8888", + "job": "192.168.122.102", + "pod_state": "abnormal" + } + ] + }, + { + "metric_id": "gala_gopher_l7_latency_avg@956c70a2-9918-459c-a0a8-39396251f952", + "entity_id": "", + "metric_labels": { + "client_ip": "192.168.11.103", + "comm": "python", + "container_id": "eef1ca1082a7", + "container_image": "ba2d060a624e", + "container_name": "/k8s_backend_backend-node2-03-584f4c6cfd-w4d2b_default_956c70a2", + "instance": "192.168.122.102:8888", + "job": "192.168.122.102", + "l4_role": "tcp_server", + "l7_role": "server", + "machine_id": "66086618-3bad-489e-b17d-05245224f29a-192.168.122.102", + "pod": "default/backend-node2-03-584f4c6cfd-w4d2b", + "pod_id": "956c70a2-9918-459c-a0a8-39396251f952", + "pod_namespace": "default", + "protocol": "http", + "server_ip": "192.168.11.113", + "server_port": "26", + "ssl": "no_ssl", + "tgid": "3460169" + }, + "desc": "L7 session averaged latency.", + "keyword": null, + "score": 0.5624857367147617, + "path": [ + { + "pod_id": "956c70a2-9918-459c-a0a8-39396251f952", + "pod": "default/backend-node2-03-584f4c6cfd-w4d2b", + "instance": "192.168.122.102:8888", + "job": "192.168.122.102", + "pod_state": "abnormal" + }, + { + "pod_id": "4a9fcc23-8ba2-4b0a-bcb0-b1bfd89ed929", + "pod": "default/backend-node3-02-654dd97bf9-s8jg5", + "instance": "192.168.122.103:8888", + "job": "192.168.122.103", + "pod_state": "normal" + }, + { + "pod_id": "475ae627-7e88-41ed-8bb8-ff0fee95a69d", + "pod": "default/backend-node2-01-5bcb47fd7c-4jxxs", + "instance": "192.168.122.102:8888", + "job": "192.168.122.102", + "pod_state": "abnormal" + } + ] + } + ] + }, + "desc": "L7 session averaged latency.", + "top1": "gala_gopher_container_cpu_user_seconds_total@4a9fcc23-8ba2-4b0a-bcb0-b1bfd89ed929\u5f02\u5e38", + "top2": "gala_gopher_proc_wchar_bytes@67134fb4-b2a3-43c5-a5b3-b3b463ad7d43\u5f02\u5e38", + "top3": "gala_gopher_l7_latency_avg@956c70a2-9918-459c-a0a8-39396251f952\u5f02\u5e38", + "keywords": [ + "process", + null + ], + "SeverityText": "WARN", + "SeverityNumber": 13, + "Body": "A cause inferring event for an abnormal event" +} +``` diff --git a/docs/en/docs/A-Ops/using-gala-spider.md b/docs/en/docs/A-Ops/using-gala-spider.md index 2949e6f18d9de8263579daeaae23a0cceacb67f6..e2d30f92cb12a90c8f3e11fad09b07db0eaf1c27 100644 --- a/docs/en/docs/A-Ops/using-gala-spider.md +++ b/docs/en/docs/A-Ops/using-gala-spider.md @@ -291,7 +291,7 @@ The configuration items in the gala-inference configuration file **/etc/gala-inf - `inference`: configuration information about the root cause locating algorithm. - `tolerated_bias`: tolerable time offset for querying the topology at the exception time point, in seconds. - `topo_depth`: maximum depth for topology query. - - `root_topk`: yop *K* root cause metrics generated in the root cause locating result. + - `root_topk`: top *K* root cause metrics generated in the root cause locating result. - `infer_policy`: root cause derivation policy, which can be `dfs` or `rw`. - `sample_duration`: sampling period of historical metric data, in seconds. - `evt_valid_duration`: valid period of abnormal system metric events during root cause locating, in seconds. diff --git a/docs/en/docs/Administration/IMA.md b/docs/en/docs/Administration/IMA.md new file mode 100644 index 0000000000000000000000000000000000000000..c0610aa41da74dadc2645e6e0597036fd5d47b1e --- /dev/null +++ b/docs/en/docs/Administration/IMA.md @@ -0,0 +1,1366 @@ + +# Integrity Measurement Architecture + +## Overview + +### Introduction to the Integrity Measurement Architecture (IMA) + +IMA is a kernel subsystem that measures files access through system calls such as `execve()`, `mmap()`, and `open()` based on custom policies. These measurements can be used for **local and remote attestation** or compared against known references to **control file access**. + +IMA primarily operates in two modes: + +- Measurement: This mode provides visibility into the integrity of files. When a protected file is accessed, a measurement record is added to the measurement log (located in kernel memory). If the system includes a Trusted Platform Module (TPM) chip, the measurement digest can be extended into the Platform Configure Register (PCR) of TPM to prevent tampering. This mode does not control file access but allows upper-layer applications to use the recorded file information for remote attestation. +- Appraisal: This mode verifies file integrity, preventing access to unknown or tampered files. It employs cryptographic techniques like hashing, signing, and HMAC to validate file content. If validation fails, access to the file is denied for all processes. This feature offers a fundamental layer of system resilience by sacrificing access to potentially compromised files, thus limiting the impact of attacks. + +In essence, the measurement mode acts as a passive observer, while the appraisal mode acts as a strict security guard, refusing access to any file with inconsistencies between its identity and measured attributes. + +### Introduction to the Extended Verification Module (EVM) + +EVM extends the capabilities of IMA. Building upon the file content integrity protection of IMA, EVM safeguards extended file attributes, including the UID, `security.ima`, and `security.selinux`. + +### Introduction to IMA Digest Lists + +IMA digest lists, an openEuler enhancement to the native integrity protection mechanism of the kernel, address several limitations of IMA/EVM: + +**TPM extension performance impact:** + +In the IMA measurement mode, accessing the TPM chip for each measurement event, a relatively slow process using low-frequency (dozens of MHz) SPI communication, degrades system call performance. + +![](./figures/ima_tpm.png) + +**Asymmetric cryptography performance impact:** + +In the IMA appraisal mode, signature verification for each file access during the validation of immutable files, a computationally intensive operation, also negatively impacts system call performance. + +![](./figures/ima_sig_verify.png) + +**Deployment complexity and security concerns:** + +The IMA appraisal mode requires deployment in the fix mode to initially tag files with IMA/EVM extended attributes before switching to the verification mode. Updating protected files necessitates rebooting into the fix mode, introducing operational inefficiency and potential security risks by requiring access to keys in the running environment. + +![](./figures/ima_priv_key.png) + +IMA digest lists address these issues by managing baseline digests for a set of files (such as executable files within a software package) within a single hash list file. These baseline digests can encompass both file content (for IMA) and extended attributes (for EVM). + +![](./figures/ima_digest_list_pkg.png) + +When IMA digest lists are enabled, the kernel maintains an allowlist hash pool containing imported IMA digest list entries, accessible via securityfs for import, deletion, and query. + +In the measurement mode, imported lists undergo measurement and TPM extension before being added to the allowlist. Subsequent accesses to files with matching digests bypass further measurement logging and TPM interaction. In the appraisal mode, imported lists undergo signature verification before being added to the allowlist. Subsequent file access involves comparing file digests against this allowlist for appraisal decisions. + +![](./figures/ima_digest_list_flow.png) + +Compared to native IMA/EVM, IMA digest lists offer improvements in: + +- Security: Bundling IMA digest lists with software packages ensures that baseline values originate from trusted sources (such as the openEuler community) upon installation, eliminating the need for generating these values in the running environment, thus establishing a stronger chain of trust. +- Performance: Performing measurements and validations at the digest list level reduces TPM access and asymmetric cryptography operations by a factor of _n_ (average number of file hashes per digest list), improving both system call and boot performance. +- Usability: IMA digest lists enable an out-of-the-box appraisal mode experience, allowing direct entry into this mode after installation and supporting software installation/upgrades without requiring the fix mode, simplifying deployment and enabling seamless updates. + +Note that by maintaining baseline values in kernel memory, IMA digest lists rely on the assumption of an uncompromised kernel, necessitating other security mechanisms (such as secure kernel module loading, runtime memory measurement) to protect kernel integrity. + +Ultimately, both native IMA and IMA digest lists are components within a larger security framework, emphasizing the importance of a layered security approach for overall system protection. + +## Interface Description + +### Kernel Boot Parameters + +The following table describes the kernel boot parameters provided by the openEuler IMA/EVM mechanism: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterValueFunction
ima_appraiseenforce-evmEnforced verification mode of IMA appraisal (EVM enabled)
log-evmLog mode of IMA appraisal (EVM enabled)
enforceEnforced verification mode of IMA appraisal
logLog mode of IMA appraisal
offIMA appraisal disabled
ima_appraise_digest_listdigestIMA+EVM appraisal based on the digest list (comparing file content and extended attributes)
digest-nometadataIMA appraisal based on the digest list (comparing file content only)
evmx509Directly enables EVM based on portable signatures (whether or not the EVM certificate is loaded)
completeDoes not allow modification of EVM mode through the securityfs interface after startup
allow_metadata_writesAllows modification of file metadata without EVM interception
ima_hashsha256/sha1/...Declares the IMA measurement hash algorithm
ima_templateimaDeclares the IMA measurement template (d|n)
ima-ngDeclares the IMA measurement template (d-ng|n-ng), which is used by default
ima-sigDeclares the IMA measurement template (d-ng|n-ng|sig)
ima_policyexec_tcbMeasures all executed and memory-mapped files, as well as loaded kernel modules, firmware, and kernel files
tcbOn the basis of the exec_tcb policy, additionally measures files accessed as uid=0 or euid=0
secure_bootEvaluates all loaded kernel modules, firmware, and kernel files, and specifies the use of IMA signature mode
appraise_exec_tcbOn the basis of the secure_boot policy, additionally evaluates all executed and memory-mapped files
appraise_tcbEvaluates all files accessed with owner 0
appraise_exec_immutableUsed in conjunction with the appraise_exec_tcb policy where the extended attributes of executable files are immutable
ima_digest_list_pcr10Extends the digest list-based IMA measurement results in PCR 10, disabling native IMA measurement
11Extends the digest list-based IMA measurement results in PCR 11, disabling native IMA measurement
+11Extends the digest list-based IMA measurement results in PCR 11, extending the native IMA measurement results in PCR 10
ima_digest_db_sizenn[M]Sets the upper limit of the kernel digest list size (0 MB to 64 MB). The default is 16 MB if not configured. (Not configured means that the parameter does not present. Note that the value cannot be left blank, such as "ima_digest_db_size=")
ima_capacity-1~2147483647Sets the maximum number of kernel measurement log entries. The default is 100,000 if not configured. -1 means no upper limit.
initramtmpfsNoneSupports tmpfs in initrd to carry file extended attributes
+ +Based on the user requirements, the following parameter combinations are recommended: + +**(1) Native IMA measurement** + +```conf +# Native IMA measurement + custom policy +No configuration required, enabled by default +# Native IMA measurement + TCB default policy +ima_policy="tcb" +``` + +**(2) Digest list-based IMA measurement** + +```conf +# Digest list IMA measurement + custom policy +ima_digest_list_pcr=11 ima_template=ima-ng initramtmpfs +# Digest list IMA measurement + default policy +ima_digest_list_pcr=11 ima_template=ima-ng ima_policy="exec_tcb" initramtmpfs +``` + +**(3) Digest list-based IMA appraisal, protecting file content only** + +```conf +# IMA appraisal + log mode +ima_appraise=log ima_appraise_digest_list=digest-nometadata ima_policy="appraise_exec_tcb" initramtmpfs +# IMA appraisal + enforced verification mode +ima_appraise=enforce ima_appraise_digest_list=digest-nometadata ima_policy="appraise_exec_tcb" initramtmpfs +``` + +**(4) Digest list-based IMA appraisal, protecting file content and extended attributes** + +```conf +# IMA appraisal + log mode +ima_appraise=log-evm ima_appraise_digest_list=digest ima_policy="appraise_exec_tcb|appraise_exec_immutable" initramtmpfs evm=x509 evm=complete +# IMA appraisal + enforced verification mode +ima_appraise=enforce-evm ima_appraise_digest_list=digest ima_policy="appraise_exec_tcb|appraise_exec_immutable" initramtmpfs evm=x509 evm=complete +``` + +> ![](./public_sys-resources/icon-note.gif) **Note:** +> +> The above four parameters can be configured and used independently, but only the digest list-based measurement and appraisal modes can be used in combination, that is, (2) and (3) are paired or (2) and (4) are paired. + +## Securityfs Interfaces + +The securityfs interfaces provided by openEuler IMA are located in the **/sys/kernel/security** directory. The interface names and descriptions are as follows: + +| Path | Permission | Description | +| :----------------------------- | :--------- | :----------------------------------------------------------------------- | +| ima/policy | 600 | Queries/Imports the IMA policy query. | +| ima/ascii_runtime_measurement | 440 | Queries IMA measurement log and outputs as a string. | +| ima/binary_runtime_measurement | 440 | Queries IMA measurement log and outputs in binary format. | +| ima/runtime_measurement_count | 440 | Queries the number of IMA measurement log entries. | +| ima/violations | 440 | Queries the number of abnormal IMA measurement logs. | +| ima/digests_count | 440 | Displays the total number of digests in the system hash table (IMA+EVM). | +| ima/digest_list_data | 200 | Adds digest lists. | +| ima/digest_list_data_del | 200 | Deletes digest lists | +| evm | 660 | Queries/Sets the EVM mode | + +The **/sys/kernel/security/evm** interface takes the following values: + +- **0**: Does not initialize EVM. +- **1**: Uses HMAC (symmetric encryption) to verify the integrity of extended attributes. +- **2**: Uses public key signature verification (asymmetric encryption) to verify the integrity of extended attributes. +- **6**: Disables integrity verification for extended attributes. + +### Digest List Management Tools + +The digest-list-tools package provides tools for generating and managing IMA digest list files. It mainly includes the following command-line tools. + +#### gen_digest_lists + +This tool generates IMA digest lists. Its command options are defined as follows: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OptionValueFunction
-d<path>Specifies the directory to store the generated digest list files. The value must be a valid directory.
-fcompactSpecifies the format of the generated digest list files. Currently, only the compact format is supported.
-i<option arg>:<option value>Specifies the target file range for generating the digest list. Specific parameter definitions are as follows.
I:<path>Specifies the absolute path of the file for which to generate a digest list. If a directory is specified, recursive generation is performed.
E:<path>Specifies the path or directory to exclude.
F:<path>Specifies the path or directory for which to generate digest lists for all files (when the e: parameter is also specified, the filtering effect of the e: option is ignored).
e:Generates a digest list only for executable files.
l:policyMatches file security contexts from the system SELinux policy instead of reading them directly from file extended attributes.
i:When generating a metadata digest list, includes the digest value of the file in the calculated extended attribute information (required).
M:Allows explicitly specifying the file extended attribute information (must be used with the rpmbuild command).
u:Uses the list file name specified by the L: parameter as the file name for generating the digest list (must be used with the rpmbuild command).
L:<path>Specifies the path of the list file, which contains the information data needed to generate the digest list (must be used with the rpmbuild command).
-oaddSpecifies the operation to perform on the generated digest list. Currently, only the add operation is supported, which adds the digest list to the file.
-p-1Specifies the position in the file where the digest list is written. Currently, only -1 is supported.
-tfileGenerates a digest list only for the file content.
metadataGenerates separate digest lists for the file content and extended attributes.
-TNAIf this parameter is not added, a digest list file is generated. If this parameter is added, a TLV digest list file is generated.
-A<path>Specifies the relative root directory. The file path is truncated with the specified prefix removed for path matching and SELinux label matching.
-mimmutableSpecifies the modifiers attribute of the generated digest list file. Currently, only immutable is supported. In enforce/enforce-evm mode, the digest list can only be opened in read-only mode.
-hNAPrints help information.
+ +##### Usage Examples + +- Scenario 1: Generate a digest list/TLV digest list for a single file. + + ```shell + gen_digest_lists -t metadata -f compact -i l:policy -o add -p -1 -m immutable -i I:/usr/bin/ls -d ./ -i i: gen_digest_lists -t metadata -f compact -i l:policy -o add -p -1 -m immutable -i I:/usr/bin/ls -d ./ -i i: -T + ``` + +- Scenario 2: Generate a digest list/TLV digest list for a single file and specify a relative root directory. + + ```shell + gen_digest_lists -t metadata -f compact -i l:policy -o add -p -1 -m immutable -i I:/usr/bin/ls -A /usr/ -d ./ -i i: gen_digest_lists -t metadata -f compact -i l:policy -o add -p -1 -m immutable -i I:/usr/bin/ls -A /usr/ -d ./ -i i: -T + ``` + +- Scenario 3: Recursively generate digest lists/TLV digest lists for files in a directory. + + ```shell + gen_digest_lists -t metadata -f compact -i l:policy -o add -p -1 -m immutable -i I:/usr/bin/ -d ./ -i i: + gen_digest_lists -t metadata -f compact -i l:policy -o add -p -1 -m immutable -i I:/usr/bin/ -d ./ -i i: -T + ``` + +- Scenario 4: Recursively generate digest lists/TLV digest lists for executable files in a directory. + + ```shell + gen_digest_lists -t metadata -f compact -i l:policy -o add -p -1 -m immutable -i I:/usr/bin/ -d ./ -i i: -i e:gen_digest_lists -t metadata -f compact -i l:policy -o add -p -1 -m immutable -i I:/usr/bin/ -d ./ -i i: -i e: -T + ``` + +- Scenario 5: Recursively generate digest lists/TLV digest lists for files in a directory, excluding certain subdirectories. + + ```shell + gen_digest_lists -t metadata -f compact -i l:policy -o add -p -1 -m immutable -i I:/usr/ -d ./ -i i: -i E:/usr/bin/gen_digest_lists -t metadata -f compact -i l:policy -o add -p -1 -m immutable -i I:/usr/ -d ./ -i i: -i E:/usr/bin/ -T + ``` + +- Scenario 6: In the `rpmbuild` callback script, generate a digest list by reading the list file passed in by `rpmbuild`. + + ```shell + gen_digest_lists -i M: -t metadata -f compact -d $DIGEST_LIST_DIR -i l:policy \ + -i i: -o add -p -1 -m immutable -i L:$BIN_PKG_FILES -i u: \ + -A $RPM_BUILD_ROOT -i e: \ + -i E:/usr/src \ + -i E:/boot/efi \ + -i F:/lib \ + -i F:/usr/lib \ + -i F:/lib64 \ + -i F:/usr/lib64 \ + -i F:/lib/modules \ + -i F:/usr/lib/modules \ + -i F:/lib/firmware \ + -i F:/usr/lib/firmware + + gen_digest_lists -i M: -t metadata -f compact -d $DIGEST_LIST_DIR.tlv \ + -i l:policy -i i: -o add -p -1 -m immutable -i L:$BIN_PKG_FILES -i u: \ + -T -A $RPM_BUILD_ROOT -i e: \ + -i E:/usr/src \ + -i E:/boot/efi \ + -i F:/lib \ + -i F:/usr/lib \ + -i F:/lib64 \ + -i F:/usr/lib64 \ + -i F:/lib/modules \ + -i F:/usr/lib/modules \ + -i F:/lib/firmware \ + -i F:/usr/lib/firmware + ``` + +#### manage_digest_lists + +This tool is primarily used to parse binary TLV digest list files into a human-readable text format. The command options are defined as follows: + +| Parameter Name | Value | Function | +| -------------- | ------------ | --------------------------------------------------------------------------------------------------------------- | +| -d | \ | Specifies the directory where the TLV digest list files are stored. | +| -f | \ | Specifies the TLV digest list file name. | +| -p | dump | Specifies the operation type. Currently, only `dump` is supported, which parses and prints the TLV digest list. | +| -v | N/A | Prints detailed information. | +| -h | N/A | Prints help information. | + +##### Usage Example + +View the TLV digest list information. + +```shell +manage_digest_lists -p dump -d /etc/ima/digest_lists.tlv/ +``` + +## File Format Specification + +### IMA Policy File Syntax + +An IMA policy file is a text file that can contain multiple rule statements separated by newline characters `\n`. Each rule statement must begin with an action keyword, followed by **filtering conditions**: + +```text + [Filtering condition 2] [Filtering condition 3]... +``` + +The action keyword indicates the specific action of the policy rule. Each rule can only have one action. The specific actions are shown in the table below (**you can omit the `action=` prefix**, for example, directly write `dont_measure` instead of `action=dont_measure`). + +The following types of filtering conditions are supported: + +- `func`: represents the type of file being measured or appraised. It is often used with `mask`. Each rule can only have one `func`. + - `FILE_CHECK` can only be used with `MAY_EXEC`, `MAY_WRITE`, or `MAY_READ`. + - `MODULE_CHECK`, `MMAP_CHECK`, and `BPRM_CHECK` can only be used with `MAY_EXEC`. + - Combinations other than the matching relationships above will have no effect. + +- `mask`: represents the operation being performed on the file when it is measured or appraised. Each rule can only have one `mask`. + +- `fsmagic`: represents the hexadecimal magic number of the filesystem type, defined in the **/usr/include/linux/magic.h** file. (By default, all file systems are measured unless the `dont_measure` or `dont_appraise` flag is used). + +- `fsuuid`: represents a 16-character hexadecimal string of the system device UUID. + +- `objtype`: represents the security type of the file. Each rule can only have one file type. `objtype` is more granular than `func`. For example, `obj_type=nova_log_t` represents files with the nova_log_t SELinux type. + +- `uid`: represents the user (user ID) performing the operation on the file. Each rule can only have one `uid`. + +- `fowner`: represents the owner of the file (user ID). Each rule can only have one `fowner`. + +The specific values and descriptions of the keywords are as follows: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeywordValueDescription
actionmeasureEnables IMA measurement.
dont_measureDisables IMA measurement.
appraiseEnables IMA appraisal.
dont_appraiseDisables IMA appraisal.
auditEnables auditing.
funcFILE_CHECKFile to be opened
MODULE_CHECKKernel module file to be loaded
MMAP_CHECKShared library file to be mapped to the process memory space
BRPM_CHECKExecutable file to be executed (excluding script files opened by programs like /bin/hash)
POLICY_CHECKIMA policy file to be imported
FIRMWARE_CHECKFirmware to be loaded into memory
DIGEST_LIST_CHECKDigest list file to be loaded into the kernel
KEXEC_KERNEL_CHECKKernel to be switched to by kexec
maskMAY_EXECExecute file
MAY_WRITEWrite file
MAY_READRead file
MAY_APPENDExtend file attributes
fsmagicfsmagic=xxxHexadecimal magic number of the file system type
fsuuidfsuuid=xxx16-character hexadecimal string of the system device UUID
fownerfowner=xxxUser ID of the file owner
uiduid=xxxUser ID of the user operating on the file
obj_typeobj_type=xxx_tType of the file (based on SELinux label)
pcrpcr=TPM PCR used for extending measurement values (default is 10)
appraise_typeimasigIMA appraisal based on signature
meta_immutableAppraisal of file extended attributes based on signature (digest list supported)
+ +## Usage Instructions + +> ![](./public_sys-resources/icon-note.gif) **NOte:** +> +> The native IMA/EVM is a Linux open source feature. This section only provides a brief introduction to its basic usage. For details, see the open source wiki: +> +> + +### Native IMA + +#### Measurement Mode + +Configure a measurement policy to enable IMA measurement. + +**Step 1:** You can specify the measurement policy through boot parameters or manual configuration. + +Boot parameter example: + +```conf +ima_policy="tcb" +``` + +Manual configuration example: + +```shell +echo "measure func=BPRM_CHECK" > /sys/kernel/security/ima/policy +``` + +**Step 2:** Reboot the system and check the measurement logs. + +```shell +cat /sys/kernel/security/ima/ascii_runtime_measurements +``` + +#### Appraisal Mode + +To use the appraisal mode, enter the fix mode to apply IMA signatures to files. Then, switch to the log or enforce mode. + +**Step 1:** Configure the boot parameters and reboot the system to the enter fix mode. + +```conf +ima_appraise=fix ima_policy=appraise_tcb +``` + +**Step 2:** Generate IMA extended attributes for all files that need appraisal. + +The signature mode can be used for immutable files (such as binary files). This involves writing the signature of the file hash into the IMA extended attribute. In the following example, **/path/to/ima.key** is the path to the IMA signing private key. + +```shell +find /usr/bin -fstype ext4 -type f -executable -uid 0 -exec evmctl -a sha256 ima_sign --key /path/to/ima.key '{}' \; +``` + +The hash mode can be used for mutable files (such as data files). This involves writing the file hash into the IMA extended attribute. IMA supports automatic tagging in the fix mode. Accessing a file will automatically generate the IMA extended attribute. + +```shell +find / -fstype ext4 -type f -uid 0 -exec dd if='{}' of=/dev/null count=0 status=none \; +``` + +You can check if a file has the IMA extended attribute (`security.ima`) by running the following command: + +```shell +getfattr -m - -d /sbin/init +``` + +**Step 3:** Switch to log or enforce mode by configuring the boot parameters and rebooting the system. + +```conf +ima_appraise=enforce ima_policy=appraise_tcb +``` + +## IMA Digest Lists + +### Prerequisites + +Before using the IMA digest lists, you need to install the ima-evm-utils and digest-list-tools packages: + +```shell +yum install ima-evm-utils digest-list-tools +``` + +### Mechanism Introduction + +#### Digest List Files + +After installing an RPM package released by openEuler, a digest list file is generated in the **/etc/ima** directory by default. There are several types of files depending on the file name: + +- **/etc/ima/digest_lists/0-metadata_list-compact-** + +This is the IMA digest list file, generated by the `gen_digest_lists` command (see the [gen_digest_lists](#gen_digest_lists) section for details). This file is in binary format and contains header information and a series of SHA256 hash values, representing the legitimate file content digest values and file extended attribute digest values, respectively. The file will be imported to the kernel after it is measured or appraised. The allowlist digest values in this file are used as the basis for IMA digest list measurement or appraisal. + +- **/etc/ima/digest_lists/0-metadata_list-rpm-** + +This is the RPM digest list file, which **is actually the header information of the RPM package.** After the RPM package is installed, if the IMA digest list file does not contain a signature, the RPM header information will be written to this file, and the signature of the header information will be written to the `security.ima` extended attribute. In this way, the authenticity of the RPM header information can be verified through the signature. Since the RPM header information also contains the digest value of the digest list file, indirect verification of the digest list can be achieved. + +- **/etc/ima/digest_lists/0-parser_list-compact-libexec** + +This is the IMA PARSER digest list file, which stores the digest value of the **/usr/libexec/rpm_parser** file. This file is used to implement the RPM digest list -> IMA digest list chain of trust. The kernel IMA digest list mechanism will perform special verification on the process generated by executing this file. If it is determined to be the `rpm_parser` program, it will trust all the digest lists it imports without verifying the signature. + +- **/etc/ima/digest_lists.sig/0-metadata_list-compact-.sig** + +This is the signature file of the IMA digest list. If the RPM package contains this file, the content of this file will be written to the `security.ima` extended attribute of the corresponding RPM digest list file during the RPM package installation phase, so as to perform signature verification during the IMA digest list import kernel phase. + +- **/etc/ima/digest_lists.tlv/0-metadata_list-compact_tlv-** + +This is the TLV digest list file, which is usually generated along with the IMA digest list file for the target file. It stores the integrity information of the target file (such as the file content digest value and file extended attributes). The function of this file is to assist users in querying and recovering the integrity information of the target file. + +#### Digest List File Signature Modes + +In IMA appraisal mode, the IMA digest list file needs to be signed and verified before it can be imported into the kernel and used for subsequent file allowlist matching. The IMA digest list file supports the following signature modes: + +**(1) Extended attribute signature** + +This is the native IMA signature mechanism. The signature information is stored in a certain format in the `security.ima` extended attribute. It can be generated and added using the `evmctl` command: + +```shell +evmctl ima_sign --key /path/to/ima.key -a sha256 +``` + +You can also add the `-f` parameter to store the signature information and header information in a separate file: + +```shell +evmctl ima_sign -f --key /path/to/ima.key -a sha256 +``` + +When the IMA appraisal mode is enabled, the digest list file path can be directly written to a kernel interface to import or delete the digest list. This process will automatically trigger the appraisal, and the signature verification of the digest list file content will be performed based on the `security.ima` extended attribute: + +```shell +# Import the IMA digest list file. +echo > /sys/kernel/security/ima/digest_list_data +# Delete the IMA digest list file. +echo > /sys/kernel/security/ima/digest_list_data_del +``` + +**(2) IMA digest list appended signature (default in openEuler 24.03 LTS)** + +Starting from openEuler 24.03 LTS, a dedicated IMA signature key is supported, and CMS signature is adopted. Since the signature information contains a certificate chain, it may be too long to be written into the `security.ima` extended attribute of a file. Therefore, appended signatures similar to kernel modules are adopted: + +![](./figures/ima-modsig.png) + +The signature mechanism is as follows: + +1. The CMS signature information is appended to the end of the IMA digest list file. + +2. A structure is populated and added to the end of the signature information. The structure is defined as follows: + + ```c + struct module_signature { + u8 algo; /* Public-key crypto algorithm [0] */ + u8 hash; /* Digest algorithm [0] */ + u8 id_type; /* Key identifier type [PKEY_ID_PKCS7] */ + u8 signer_len; /* Length of signer's name [0] */ + u8 key_id_len; /* Length of key identifier [0] */ + u8 __pad[3]; + __be32 sig_len; /* Length of signature data */ + }; + ``` + +3. Magic string `~Module signature appended~` is added. + + The reference script for this step is as follows: + + ```shell + #!/bin/bash + DIGEST_FILE=$1 # IMA digest list file path + SIG_FILE=$2 # IMA digest list signature information save path + OUT=$3 # Output path of the digest list file after the signature information is added + + cat $DIGEST_FILE $SIG_FILE > $OUT + echo -n -e "\x00\x00\x02\x00\x00\x00\x00\x00" >> $OUT + echo -n -e $(printf "%08x" "$(ls -l $SIG_FILE | awk '{print $5}')") | xxd -r -ps >> $OUT + echo -n "~Module signature appended~" >> $OUT + echo -n -e "\x0a" >> $OUT + ``` + +**(3) Reused RPM signature (default in openEuler 22.03 LTS)** + +openEuler 22.03 LTS supports reusing of RPM signatures to sign the IMA digest list file. This mechanism aims to solve the problem that the version does not have a dedicated IMA signature key. The signing process is transparent to users. When the RPM package contains an IMA digest list file but does not contain a signature file for the IMA digest list, this signature mechanism will be used automatically. Its core principle is to verify the IMA digest list through the header information of the RPM package. + +For RPM packages released by openEuler, each package file can contain two parts: + +- **RPM header information:** RPM package attribute fields, such as package name and file digest value list. Its integrity is guaranteed by the RPM header signature. + +- **RPM files:** Files actually installed to the system, including the IMA digest list file generated during the build phase. + +![](./figures/ima_rpm.png) + +During RPM package installation, if the RPM process detects that the digest list file in the package does not contain a signature, it will create an RPM digest list file in the **/etc/ima** directory, write the RPM header information to the file content, and write the RPM header signature to the `security.ima` extended attribute of the file. Subsequently, the RPM digest list can be indirectly used to verify and import the IMA digest list. + +#### IMA Digest List Import + +In the IMA measurement mode, importing the IMA digest list file does not require signature verification. You can directly write the path to the kernel interface to import or delete the digest list. + +```shell +# Import the IMA digest list file. +echo > /sys/kernel/security/ima/digest_list_data +# Delete the IMA digest list file. +echo > /sys/kernel/security/ima/digest_list_data_del +``` + +In the IMA appraisal mode, importing the digest list requires signature verification. There are two import methods according to the signature methods. + +**Direct import** + +For IMA digest list files that already contain signature information (Extended attribute signature or IMA digest list appended signature), you can directly write the path to the kernel interface to import or delete the digest list. This process will automatically trigger the appraisal, and the signature verification of the digest list file content will be completed based on the `security.ima` extended attribute: + +```shell +# Import the IMA digest list file. +echo > /sys/kernel/security/ima/digest_list_data +# Delete the IMA digest list file. +echo > /sys/kernel/security/ima/digest_list_data_del +``` + +**Import using `upload_digest_lists`** + +For IMA digest list files that reuse RPM signatures, you need to run the `upload_digest_lists` command to import them. The specific commands are as follows (note that the specified path is the corresponding RPM digest list): + +```shell +# Import the IMA digest list file. +upload_digest_lists add +# Delete the IMA digest list file. +upload_digest_lists del +``` + +This process is relatively complicated and needs to meet the following prerequisites: + +1. The digest list in the digest_list_tools package released by openEuler has been imported into the system (including the IMA digest list and the IMA PARSER digest list). + +2. The IMA appraisal policy for application execution (`BPRM_CHECK`) has been configured. + +### Operation Guide + +#### Automatic Generation of Digest Lists During RPM Build + +The openEuler RPM toolchain supports the `%__brp_digest_list` macro. The configuration format is as follows: + +```text +%__brp_digest_list /usr/lib/rpm/brp-digest-list %{buildroot} +``` + +After this macro is configured, when the you call the `rpmbuild` command to build the software package, the **/usr/lib/rpm/brp-digest-list** script will be called during the RPM packaging phase to generate and sign the digest list. By default, openEuler generates digest lists for key files such as executable files, dynamic libraries, and kernel modules. You can also modify the script to configure the scope of digest list generation and specify the signing key. The following example uses the user-defined signing key **/path/to/ima.key** to sign the digest list. + +```shell +...... (line 66) +DIGEST_LIST_TLV_PATH="$DIGEST_LIST_DIR.tlv/0-metadata_list-compact_tlv-$(basename $BIN_PKG_FILES)" +[ -f $DIGEST_LIST_TLV_PATH ] || exit 0 + +chmod 644 $DIGEST_LIST_TLV_PATH +echo $DIGEST_LIST_TLV_PATH + +evmctl ima_sign -f --key /path/to/ima.key -a sha256 $DIGEST_LIST_PATH &> /dev/null +chmod 400 $DIGEST_LIST_PATH.sig +mkdir -p $DIGEST_LIST_DIR.sig +mv $DIGEST_LIST_PATH.sig $DIGEST_LIST_DIR.sig +echo $DIGEST_LIST_DIR.sig/0-metadata_list-compact-$(basename $BIN_PKG_FILES).sig +``` + +#### IMA Digest List Measurement + +You can enable IMA digest list measurement following the steps below: + +**Step 1:** Configure the boot parameter measurement policy to enable the IMA measurement function. The specific steps are the same as **Native IMA measurement**. The difference is that the TPM PCR used for measurement needs to be configured separately. The boot parameter example is as follows: + +```conf +ima_policy=exec_tcb ima_digest_list_pcr=11 +``` + +**Step 2:** Import the IMA digest list. Take the digest list of the bash software package as an example: + +```shell +echo /etc/ima/digest_lists/0-metadata_list-compact-bash-5.1.8-6.oe2203sp1.x86_64 > /sys/kernel/security/ima/digest_list_data +``` + +You can query the measurement log of the IMA digest list. + +```shell +cat /sys/kernel/security/ima/ascii_runtime_measurements +``` + +After the IMA digest list is imported, if the subsequently measured file digest value is included in the IMA digest list, no additional measurement log will be recorded. + +#### IMA Digest List Appraisal + +##### Startup with the Default Policy + +You can configure the **ima_policy** parameter in the boot parameters to specify the IMA default policy. Then, in the kernel boot phase, the default policy will be enabled immediately after IMA initialization to perform appraisal. You can enable the IMA digest list appraisal function following the steps below: + +**Step 1:** Run the `dracut` command to write the digest list file to initrd: + +```shell +dracut -f -e xattr +``` + +**Step 2:** Configure the boot parameters and IMA policy. Typical configurations are as follows: + +```conf +# IMA appraisal log/enforce mode based on the digest list, only protecting the file content, configuring the default policy as appraise_exec_tcb +ima_appraise=log ima_appraise_digest_list=digest-nometadata ima_policy="appraise_exec_tcb" initramtmpfs module.sig_enforce +ima_appraise=enforce ima_appraise_digest_list=digest-nometadata ima_policy="appraise_exec_tcb" initramtmpfs module.sig_enforce +# IMA appraisal log/enforce mode based on the digest list, protecting the file content and extended attributes, configuring the default policy as appraise_exec_tcb+appraise_exec_immutable +ima_appraise=log-evm ima_appraise_digest_list=digest ima_policy="appraise_exec_tcb|appraise_exec_immutable" initramtmpfs evm=x509 evm=complete module.sig_enforce +ima_appraise=enforce-evm ima_appraise_digest_list=digest ima_policy="appraise_exec_tcb|appraise_exec_immutable" initramtmpfs evm=x509 evm=complete module.sig_enforce +``` + +Reboot the system to enable the IMA digest list appraisal function. The IMA policy will take effect and the IMA digest list file will be imported automatically during the startup process. + +##### Startup without the Default Policy + +You can choose not to configure the **ima_policy** parameter in the boot parameters, which means that there is no default policy during the system startup phase. The IMA appraisal mechanism will take effect and be enabled after you import the policy. + +**Step 1:** Configure the boot parameters. Typical configurations are as follows: + +```conf +# IMA appraisal log/enforce mode based on the digest list, only protecting the file content, no default policy +ima_appraise=log ima_appraise_digest_list=digest-nometadata initramtmpfs +ima_appraise=enforce ima_appraise_digest_list=digest-nometadata initramtmpfs +# IMA appraisal log/enforce mode based on the digest list, protecting the file content and extended attributes, no default policy +ima_appraise=log-evm ima_appraise_digest_list=digest initramtmpfs evm=x509 evm=complete +ima_appraise=enforce-evm ima_appraise_digest_list=digest initramtmpfs evm=x509 evm=complete +``` + +Reboot the system. At this time, since there is no policy in the system, IMA appraisal will not take effect. + +**Step 2:** Import the IMA policy. Write the full path of the policy file to the kernel interface. + +```shell +echo /path/to/policy > /sys/kernel/security/ima/policy +``` + +> ![](./public_sys-resources/icon-note.gif) **Note:** +> +> The policy needs to include some fixed rules. Refer to the policy templates below. +> +> The policy template for openEuler 22.03 LTS is as follows (reusing the RPM signature): +> + +```conf +# Do not appraise the access behavior of the securityfs file system. +dont_appraise fsmagic=0x73636673 +# Other user-defined dont_appraise rules +...... +# Appraise the imported IMA digest list file. +appraise func=DIGEST_LIST_CHECK appraise_type=imasig +# Appraise all files opened by the /usr/libexec/rpm_parser process. +appraise parser appraise_type=imasig +# Appraise the executed application (trigger the appraisal of /usr/libexec/rpm_parser, and you can also add other restrictions, such as SELinux labels). +appraise func=BPRM_CHECK appraise_type=imasig +# Other user-defined appraise rules +...... +``` +> +> The policy template for openEuler 24.03 LTS is as follows (Extended attribute signature or appended signature scenario): +> + +```conf +# User-defined dont_appraise rules +...... +# Appraise the imported IMA digest list file. +appraise func=DIGEST_LIST_CHECK appraise_type=imasig|modsig +# Other user-defined appraise rules +...... +``` + +**Step 3:** Import the IMA digest list file. For digest lists with different signature methods, different import methods need to be used. + +The method of importing the digest list for openEuler 22.03 LTS is as follows (IMA digest list that reuses the RPM signature): + +```shell +# Import the digest list of the digest_list_tools package. +echo /etc/ima/digest_lists/0-metadata_list-compact-digest-list-tools-0.3.95-13.x86_64 > /sys/kernel/security/ima/digest_list_data +echo /etc/ima/digest_lists/0-parser_list-compact-libexec > /sys/kernel/security/ima/digest_list_data +# Import other RPM digest lists. +upload_digest_lists add /etc/ima/digest_lists +# Check the number of imported digest list entries. +cat /sys/kernel/security/ima/digests_count +``` + +The method of importing the digest list for openEuler 24.03 LTS is as follows (IMA digest list with appended signature): + +```shell +find /etc/ima/digest_lists -name "0-metadata_list-compact-*" -exec echo {} > /sys/kernel/security/ima/digest_list_data \; +``` + +#### Software Upgrade + +After the IMA digest list function is enabled, for files within the IMA protection scope, the digest list needs to be updated synchronously during software upgrades. For RPM packages released by openEuler, the digest lists in the RPM packages will be automatically added, updated, and deleted during package installation, upgrade, and uninstallation, without manual intervention. For user-maintained software packages in non-RPM format, the digest list needs to be imported manually. + +#### User Certificate Import + +You can import custom certificates to perform measurement or appraisal on software not released by openEuler. The openEuler IMA appraisal mode supports obtaining certificates from the following two key rings for signature verification: + +- `builtin_trusted_keys` key ring: root certificates preset during kernel compilation + +- `ima` key ring: imported using **/etc/keys/x509_ima.der** in initrd, which needs to be a sub-certificate of any certificate in the `builtin_trusted_keys` key ring. + +**The steps to import the root certificate into the `builtin_trusted_keys` key ring are as follows:** + +**Step 1:** Generate a root certificate. Take the `openssl` command as an example. + +```shell +echo 'subjectKeyIdentifier=hash' > root.cfg +openssl genrsa -out root.key 4096 +openssl req -new -sha256 -key root.key -out root.csr -subj "/C=AA/ST=BB/O=CC/OU=DD/CN=openeuler test ca" +openssl x509 -req -days 3650 -extfile root.cfg -signkey root.key -in root.csr -out root.crt +openssl x509 -in root.crt -out root.der -outform DER +``` + +**Step 2:** Get the openEuler kernel source code. Take the latest **OLK-5.10** branch as an example. + +```shell +git clone https://gitee.com/openeuler/kernel.git -b OLK-5.10 +``` + +**Step 3:** Go to the source code directory and copy the root certificate to the directory. + +```shell +cd kernel +cp /path/to/root.der . +``` + +Modify the `CONFIG_SYSTEM_TRUSTED_KEYS` option in the config file: + +```conf +CONFIG_SYSTEM_TRUSTED_KEYS="./root.crt" +``` + +**Step 4:** Compile and install the kernel (the steps are omitted, note that you need to generate a digest list for the kernel module). + +**Step 5:** Check whether the certificate is successfully imported after a reboot. + +```shell +keyctl show %:.builtin_trusted_keys +``` + +**The steps to import the sub-certificate into the ima key ring are as follows. Note that the root certificate needs to be imported into the `builtin_trusted_keys` key ring in advance:** + +**Step 1:** Generate a sub-certificate based on the root certificate. Take the `openssl` command as an example. + +```shell +echo 'subjectKeyIdentifier=hash' > ima.cfg +echo 'authorityKeyIdentifier=keyid,issuer' >> ima.cfg +echo 'keyUsage=digitalSignature' >> ima.cfg +openssl genrsa -out ima.key 4096 +openssl req -new -sha256 -key ima.key -out ima.csr -subj "/C=AA/ST=BB/O=CC/OU=DD/CN=openeuler test ima" +openssl x509 -req -sha256 -CAcreateserial -CA root.crt -CAkey root.key -extfile ima.cfg -in ima.csr -out ima.crt +openssl x509 -outform DER -in ima.crt -out x509_ima.der +``` + +**Step 2:** Copy the IMA certificate to the **/etc/keys** directory: + +```shell +mkdir -p /etc/keys/ +cp x509_ima.der /etc/keys/ +``` + +**Step 3:** Package initrd and put the IMA certificate and digest list into the initrd image. + +```shell +echo 'install_items+=" /etc/keys/x509_ima.der "' >> /etc/dracut.conf +dracut -f -e xattr +``` + +**Step 4:** Check whether the certificate is successfully imported after a reboot. + +```shell +keyctl show %:.ima +``` + +#### Typical Use Cases + +According to different operating modes, the IMA digest list can be applied to trusted measurement scenarios and user-mode secure boot scenarios. + +##### Trusted Measurement + +The trusted measurement scenario is mainly based on the IMA digest list measurement mode. The measurement of key files is completed jointly by the kernel and the hardware trusted root (such as TPM), and then the remote attestation tool chain is combined to complete the attestation of the file trusted state of the system. + +![](./figures/ima_trusted_measurement.png) + +**Runtime Phase** + +- The digest list is imported synchronously when the software package is deployed, and IMA measures the digest list and records the measurement log (synchronously extending TPM). + +- When the application is executed, IMA measurement is triggered. If the file digest value matches the allowlist, it will be ignored. Otherwise, the measurement log will be recorded (synchronously extending TPM). + +**Attestation Phase (Industry Common Process)** + +- The remote attestation server sends an attestation request, and the client returns the IMA measurement log and the signed TPM PCR value. + +- The remote attestation server verifies the correctness of the PCR (signature verification), measurement log (PCR replay), and file measurement information (comparing with the local baseline value) in sequence, and reports the result to the security center. + +- The security management center takes corresponding actions, such as event notification and node isolation. + +##### User-Mode Secure Boot + +The user-mode secure boot scenario is mainly based on the IMA digest list appraisal mode. Similar to secure boot, it aims to perform integrity verification on the executed application or accessed key files. If the verification fails, the access will be denied. + +![](./figures/ima_secure_boot.png) + +**Runtime Phase** + +- The digest list is imported when the application is deployed. After the kernel verifies the signature, the digest value is loaded into the kernel hash table as an allowlist. + +- When the application is executed, IMA verification is triggered, and the file hash value is calculated. If it is consistent with the baseline value, access is allowed; otherwise, the log is recorded or access is denied. + +## Appendix + +### Kernel Compile Option Description + +The compile options provided by native IMA/EVM are as follows: + +| Option | Function | +| :------------------------------- | :----------------------------------------------- | +| CONFIG_INTEGRITY | Overall compile switch for IMA/EVM | +| CONFIG_INTEGRITY_SIGNATURE | Enables IMA signature verification. | +| CONFIG_INTEGRITY_ASYMMETRIC_KEYS | Enables IMA asymmetric signature verification. | +| CONFIG_INTEGRITY_TRUSTED_KEYRING | Enables the IMA/EVM keyring. | +| CONFIG_INTEGRITY_AUDIT | Compiles the IMA audit module. | +| CONFIG_IMA | Overall compile switch for IMA | +| CONFIG_IMA_WRITE_POLICY | Allows updating the IMA policy at runtime. | +| CONFIG_IMA_MEASURE_PCR_IDX | Allows specifying the IMA measurement PCR index. | +| CONFIG_IMA_LSM_RULES | Allows configuring LSM rules. | +| CONFIG_IMA_APPRAISE | Overall compile switch for IMA appraisal | +| IMA_APPRAISE_BOOTPARAM | Enables the boot parameter for IMA appraisal. | +| CONFIG_EVM | Overall compile switch for EVM | + +The compile options provided by the openEuler IMA digest list feature (enabled by default in the openEuler kernel) are as follows: + +| Compile Option | Function | +| :----------------- | :------------------------------------- | +| CONFIG_DIGEST_LIST | Switch for the IMA digest list feature | + +### IMA Digest List Root Certificates + +openEuler 22.03 LTS uses RPM key pairs to sign IMA digest lists. To ensure that the IMA function is available out of the box, the openEuler kernel imports the RPM root certificate (PGP certificate) into the kernel by default during compilation. Currently, the kernel includes the OBS certificate used in older versions and the openEuler certificate switched to in openEuler 22.03 LTS SP1: + +```shell +$ cat /proc/keys | grep PGP +1909b4ad I------ 1 perm 1f030000 0 0 asymmetri private OBS b25e7f66: PGP.rsa b25e7f66 [] +2f10cd36 I------ 1 perm 1f030000 0 0 asymmetri openeuler fb37bc6f: PGP.rsa fb37bc6f [] +``` + +Because the current kernel does not support importing PGP sub-public keys, and the switched openEuler certificate uses sub-keys for signing, the openEuler kernel preprocesses the certificate before compilation, extracts the sub-public key, and imports it into the kernel. For details about the processing process, see the **[process_pgp_certs.sh](https://gitee.com/src-openeuler/kernel/blob/openEuler-22.03-LTS-SP1/process_pgp_certs.sh)** script file in the kernel software package code repository. + +openEuler 24.03 LTS and later versions support dedicated IMA certificates. + +If you do not use the IMA digest list function or use other keys for signing or verification, you can remove the related code and configure kernel root certificates yourself. + +### FAQ + +#### FAQ1: The System Fails to Start after the IMA Appraisal Enforce Mode Is Enabled and the Default Policy Is Configured + +The default IMA policy may include verification of key file access processes such as application execution and kernel module loading. If key file access fails, the system may fail to start. Common causes are as follows: + +1. The IMA verification certificate is not imported into the kernel, resulting in failure to verify the digest list. +2. The digest list file is not signed correctly, resulting in digest list verification failure. +3. The digest list file is not imported into the initrd, resulting in failure to import the digest list during startup. +4. The digest list file does not match the application, resulting in application matching failure with the imported digest list. + +You need to enter the system in the log mode to locate and fix the problem. Reboot the system, go to the GRUB menu, modify the boot parameters, and start the system in the log mode. + +```conf +ima_appraise=log +``` + +After the system starts, you can troubleshoot the problem by referring to the following process: + +**Step 1**: Check the IMA certificate in the keyring. + +```shell +keyctl show %:.builtin_trusted_keys +``` + +For openEuler LTS versions, at least the following kernel certificates should exist (for other unlisted versions, determine whether the certificates should exist based on the release time): + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
VersionCertificate
openEuler 22.03 LTSprivate OBS b25e7f66
openEuler 22.03 LTS SP1/2/3private OBS b25e7f66
openeuler <openeuler@compass-ci.com> b675600b
openEuler 22.03 LTS SP4private OBS b25e7f66
openeuler <openeuler@compass-ci.com> b675600b
openeuler <openeuler@compass-ci.com> fb37bc6f
openEuler 24.03 LTSopenEuler kernel ICA 1: 90bb67eb4b57eb62bf6f867e4f56bd4e19e7d041
+ +If you have imported other kernel root certificates, you also need to use the `keyctl` command to query and confirm whether the certificate has been successfully imported. openEuler does not use the IMA keyring by default. If you are using it, use the following command to query whether the user certificate exists in the IMA keyring: + +```shell +keyctl show %:.ima +``` + +If the result shows that the certificate is not imported correctly, follow the process in the [User Certificate Import](#user-certificate-import) section. + +**Step 2:** Check whether the digest list carries signature information. + +You can use the following command to query the digest list file in the system: + +```shell +ls /etc/ima/digest_lists | grep '_list-compact-' +``` + +For each digest list file, check for the existence of **one of the following three** signature information: + +1. Check whether the digest list file has a corresponding **RPM digest list file**, and whether the IMA extended attribute of the **RPM digest list file** contains the signature value. Taking the digest list of the bash software package as an example, the digest list file path is: + + ```text + /etc/ima/digest_lists/0-metadata_list-compact-bash-5.1.8-6.oe2203sp1.x86_64 + ``` + + The RPM digest list path is: + + ```text + /etc/ima/digest_lists/0-metadata_list-rpm-bash-5.1.8-6.oe2203sp1.x86_64 + ``` + + Confirm that the RPM digest list signature, that is, the `security.ima` extended attribute of the file is not empty: + + ```shell + getfattr -n security.ima /etc/ima/digest_lists/0-metadata_list-rpm-bash-5.1.8-6.oe2203sp1.x86_64 + ``` + +2. Confirm that the `security.ima` extended attribute of the digest list file is not empty: + + ```shell + getfattr -n security.ima /etc/ima/digest_lists/0-metadata_list-compact-bash-5.1.8-6.oe2203sp1.x86_64 + ``` + +3. Confirm that the end of the digest list file contains signature information. You can judge by checking whether the end of the file content contains the magic string `~Module signature appended~` (for signing methods supported in openEuler 24.03 LTS and later versions): + + ```shell + tail -c 28 /etc/ima/digest_lists/0-metadata_list-compact-kernel-6.6.0-28.0.0.34.oe2403.x86_64 + ``` + + If the result shows that the digest list does not contain signature information, follow the process in the [Mechanism Introduction](#mechanism-introduction) section. + +**Step 3:** Check whether the signature information of the digest list is correct. + +After ensuring that the digest list carries signature information, you also need to ensure that the digest list is signed with the correct private key, that is, the signature private key that matches the certificate in the kernel. In addition to checking the private key, you can also check the dmesg log or audit log (the default path is **/var/log/audit/audit.log**). A typical log output is as follows: + +```log +type=INTEGRITY_DATA msg=audit(1722578008.756:154): pid=3358 uid=0 auid=0 ses=1 subj=unconfined_u:unconfined_r:haikang_t:s0-s0:c0.c1023 op=appraise_data cause=invalid-signature comm="bash" name="/root/0-metadata_list-compact-bash-5.1.8-6.oe2203sp1.x86_64" dev="dm-0" ino=785161 res=0 errno=0UID="root" AUID="root" +``` + +If the result shows that the signature information is incorrect, follow the process in the [Mechanism Introduction](#mechanism-introduction) section. + +**Step 4:** Check whether the digest list file is imported in the initrd. + +Use the following command to query whether the digest list file exists in the current initrd: + +```shell +lsinitrd | grep 'etc/ima/digest_lists' +``` + +If the digest list file is not found, remake the initrd and check whether the digest list is successfully imported. + +```shell +dracut -f -e xattr +``` + +**Step 5:** Check whether the IMA digest list matches the application. + +Refer to FAQ2. + +#### FAQ2: After the IMA Appraisal Enforce Mode Is Enabled, the Execution of Some Files Fails + +After the IMA appraisal enforce mode is enabled, for a file configured with the IMA policy, if the content or extended attributes of the file are incorrect (inconsistent with the imported digest list), the file access may be rejected. Common reasons include: + +1. The digest list is not imported successfully (refer to FAQ1). +2. The file content or attributes have been tampered with. + +If file execution fails, first determine whether the digest list file has been successfully imported into the kernel. You can check the number of digest lists to determine the import status. + +```shell +cat /sys/kernel/security/ima/digests_count +``` + +Then, determine which file verification failed and the reason through the audit log (the default path is **/var/log/audit/audit.log**). A typical log output is as follows: + +```log +type=INTEGRITY_DATA msg=audit(1722811960.997:2967): pid=7613 uid=0 auid=0 ses=1 subj=unconfined_u:unconfined_r:haikang_t:s0-s0:c0.c1023 op=appraise_data cause=IMA-signature-required comm="bash" name="/root/test" dev="dm-0" ino=814424 res=0 errno=0UID="root" AUID="root" +``` + +After determining the file that failed the verification, compare the TLV digest list to determine the reason why the file was tampered with. If extended attribute verification is not enabled, only compare the SHA256 hash value of the file and the **IMA digest** item in the TLV digest list. If extended attribute verification is enabled, you also need to compare the current attributes of the file and the extended attributes displayed in the TLV digest list. + +After determining the cause, you can solve the issue by restoring the content and attributes of the file, or regenerating the digest list for the current file, signing it, and importing it into the kernel. + +#### FAQ3: An Error Message Appears during Installation of a Software Package of a Different SP Version of openEuler 22.03 LtLTS after the IMA Appraisal Mode Is Enabled + +After the IMA appraisal mode is enabled, when a software package of a different SP version of openEuler 22.03 LTS is installed, the import of the IMA digest list will be automatically triggered. This includes the signature verification process for the digest list, which uses the certificate in the kernel to verify the signature of the digest list. Since the signing certificate changes during the evolution of openEuler, there are backward compatibility issues in some cross-version installation scenarios (no forward compatibility issues, that is, the new kernel can verify the IMA digest list file of older versions normally). + +You are advised to confirm that the current kernel contains the following signature certificates: + +```shell +# keyctl show %:.builtin_trusted_keys +Keyring + 566488577 ---lswrv 0 0 keyring: .builtin_trusted_keys + 383580336 ---lswrv 0 0 \_ asymmetric: openeuler b675600b + 453794670 ---lswrv 0 0 \_ asymmetric: private OBS b25e7f66 + 938520011 ---lswrv 0 0 \_ asymmetric: openeuler fb37bc6f +``` + +If a certificate is missing, upgrade the kernel to the latest version. + +```shell +yum update kernel +``` + +openEuler 24.03 LTS and later versions have dedicated IMA certificates and support certificate chain verification. The certificate life cycle can cover the entire LTS version. + +#### FAQ4: After the IMA Appraisal Mode Is Enabled, the IMA Digest List File Is Signed Correctly, but the Import Fails + +The IMA digest list import involves a check mechanism. If the signature verification of the digest list fails during an import process, the digest list import function will be disabled, resulting in even correctly signed digest list files not being imported later. Check whether the following information exists in the dmesg log: + +```shell +# dmesg +ima: 0-metadata_list-compact-bash-5.1.8-6.oe2203sp1.x86_64 not appraised, disabling digest lists lookup for appraisal +``` + +The above information indicates that the IMA appraisal mode is enabled and a digest list file with an incorrect signature has been imported, resulting in the function being disabled. In this case, reboot the system and repair the incorrect digest list signature information. + +#### FAQ5: Importing User-Defined IMA Certificates Fails in openEuler 24.03 LTS and Later Versions + +Linux kernel 6.6 adds field verification restrictions to the imported certificate. For certificates imported into the IMA keyring, the following constraints need to be met (following the X.509 standard format): + +- It is a digital signature certificate, that is, the `keyUsage=digitalSignature` field is set. +- It is not a CA certificate, that is, the `basicConstraints=CA:TRUE` field cannot be set. +- It is not an intermediate certificate, that is, the `keyUsage=keyCertSign` field cannot be set. + +#### FAQ6: The kdump Service Fails to Start after the IMA Appraisal Mode Is Enabled + +After the IMA appraisal enforce mode is enabled, if the following `KEXEC_KERNEL_CHECK` rule is configured in the IMA policy, the kdump service may fail to start: + +```shell +appraise func=KEXEC_KERNEL_CHECK appraise_type=imasig +``` + +The reason is that in this case, all files loaded by `kexec` need to go through integrity verification, so the kernel requires the `kexec_file_load` system call to be used when kdump loads the kernel image file. The `kexec_file_load` system call can be enabled by configuring the `KDUMP_FILE_LOAD` in the **/etc/sysconfig/kdump** configuration file. + +```conf +KDUMP_FILE_LOAD="on" +``` + +At the same time, the `kexec_file_load` system call itself will also perform signature verification on the file, so the kernel image file to be loaded must contain a correct secure boot signature, and the current kernel must contain a corresponding verification certificate. diff --git a/docs/en/docs/Administration/TPCM.md b/docs/en/docs/Administration/TPCM.md new file mode 100644 index 0000000000000000000000000000000000000000..a5612cb6dbf36d43dc42a6f5c5d8cb9a58f9ab00 --- /dev/null +++ b/docs/en/docs/Administration/TPCM.md @@ -0,0 +1,38 @@ +# Trusted Platform Control Module + +## Background + +Trusted computing has undergone continuous development and improvement in the past 40 years and has become an important branch of information security. Trusted computing technologies have developed rapidly in recent years and have solved the challenges in Trusted Computing 2.0—integration of trusted systems and existing systems, trusted management, and simplification of trusted application development. These technical breakthroughs form Trusted Computing 3.0, that is, trusted computing based on an active immune system. Compared with the passive plug-in architecture of the previous generation, Trusted Computing 3.0 proposes a new trusted system framework based on self-controlled cryptography algorithms, control chips, trusted software, trusted connections, policy management, and secure and trusted protection applications, implementing trust across the networks. + +The trusted platform control module (TPCM) is a base and core module that can be integrated into a trusted computing platform to establish and ensure a trust source. As one of the innovations in Trusted Computing 3.0 and the core of active immunity, TPCM implements active control over the entire platform. + +The TPCM-based Trusted Computing 3.0 architecture consists of the protection module and the computing module. On the one hand, based on the Trusted Cryptography Module (TPM), the TPCM main control firmware measures the reliability of the protection and computing modules, as well as their firmware. On the other hand, the Trusted Software Base (TSB) measures the reliability of system software and application software. In addition, the TPCM management platform verifies the reliability measurement and synchronizes and manages the trust policies. + +## Feature Description + +The overall system design consists of the protection module, computing module, and trusted management center software, as shown in the following figure. + +![](./figures/TPCM.png) + +- Trusted management center: This centralized management platform, provided by a third-party vendor, formulates, delivers, maintains, and stores protection policies and reference values for trusted computing nodes. +- Protection module: This module operates independently of the computing module and provides trusted computing protection functions that feature active measurement and active control to implement security protection during computing. The protection module consists of the TPCM main control firmware, TCB, and TCM. As a key module for implementing trust protection in a trusted computing node, the TPCM can be implemented in multiple forms, such as cards, chips, and IP cores. It contains a CPU and memory, firmware, and software such as an OS and trusted function components. The TPCM operates alongside the computing module and works according to the built-in protection policy to monitor the trust of protected resources, such as hardware, firmware, and software of the computing module. The TPCM is the Root of Trust in a trusted computing node. +- Computing module: This module includes hardware, an OS, and application layer software. The running of the OS can be divided into the boot phase and the running phase. In the boot phase, GRUB2 and shim of openEuler support the reliability measurement capability, which protects boot files such as shim, GRUB2, kernel, and initramfs. In the running phase, openEuler supports the deployment of the trusted verification agent (provided by third-party vendor HTTC). The agent sends +data to the TPCM for trusted measurement and protection in the running phase. + +The TPCM interacts with other components as follows: + +1. The TPCM hardware, firmware, and software provide an operating environment for the TSB. The trusted function components of the TPCM provide support for the TSB to implement measurement, control, support, and decision making based on the policy library interpretation requirements. +2. The TPCM accesses the TCM for trusted cryptography functions to complete computing tasks such as trusted verification, measurement, and confidential storage, and provides services for TCM access. +3. The TPCM connects to the trusted management center through the management interface to implement protection policy management and trusted report processing. +4. The TPCM uses the built-in controller and I/O port to interact with the controller of the computing module through the bus to actively monitor the computing module. +5. The built-in protection agent in the OS of the computing module obtains the code and data related to the preset protection object and provides them to the TPCM. The TPCM forwards the monitoring information to the TSB, and the TSB analyzes and processes the information according to the policy library. + +## Constraints + +Supported server: TaiShan 200 server (model 2280) VF + +Supported BMC card: BC83SMMC + +## Application Scenarios + +The TPCM enables a complete trust chain to ensure that the OS boots into a trusted computing environment. diff --git a/docs/en/docs/Administration/basic-configuration.md b/docs/en/docs/Administration/basic-configuration.md index 670406e23a8acf2d4fc17c3ec6138b6e79bdbce8..7ab41eaca958a79b4a011fd4b85239b530daabbd 100644 --- a/docs/en/docs/Administration/basic-configuration.md +++ b/docs/en/docs/Administration/basic-configuration.md @@ -42,7 +42,7 @@ System locale settings are stored in the /etc/locale.conf file and can be modifi To display the current locale status, run the following command: ```shell -localectl status +$ localectl status ``` Example command output: @@ -96,7 +96,7 @@ Keyboard layout settings are stored in the /etc/locale.conf file and can be modi To display the current keyboard layout settings, run the following command: ```shell -localectl status +$ localectl status ``` Example command output: diff --git a/docs/en/docs/Administration/faqs.md b/docs/en/docs/Administration/faqs.md index d39cc95ce3648e3f69ef2a1f04f78d604f1ab37e..776e3cae0b296e6bbfd96408ce072dd1a48c6930 100644 --- a/docs/en/docs/Administration/faqs.md +++ b/docs/en/docs/Administration/faqs.md @@ -193,7 +193,7 @@ If a software package is missing, perform the following steps \(the missed softw The **python3-edk2-devel.noarch** file conflicts with the **build.noarch** file due to duplicate file names. ```shell - $ yum install python3-edk2-devel.noarch build.noarch + # yum install python3-edk2-devel.noarch build.noarch ... Error: Transaction test error: file /usr/bin/build conflicts between attempted installs of python3-edk2-devel-202002-3.oe1.noarch and build-20191114-324.4.oe1.noarch @@ -203,7 +203,7 @@ If a software package is missing, perform the following steps \(the missed softw ### Symptom -libiscsi-1.19.4 or later fails to be downgraded to libiscsi-1.19.3 or earlier. +libiscsi-1.19.0-4 or later fails to be downgraded to libiscsi-1.19.0-3 or earlier. ```text Error: @@ -217,8 +217,8 @@ Problem: problem with installed package libiscsi-utils-1.19.0-4.oe1.x86_64 ### Possible Cause -In libiscsi-1.19.3 or earlier, binary files named **iscsi-xxx** are packed into the main package **libiscsi**. However, these binary files introduce improper dependency CUnit. To solve this problem, in libiscsi-1.19.4, these binary files are separated into the **libiscsi-utils** subpackage. The main package is weakly dependent on the subpackage. You can integrate or uninstall the subpackage during image building based on product requirements. If the subpackage is not integrated or is uninstalled, the functions of the **libiscsi** main package are not affected. -When libiscsi-1.19.4 or later is downgraded to libiscsi-1.19.3 or earlier and the **libiscsi-utils** subpackage is installed in the system, because libiscsi-1.19.3 or earlier does not contain **libiscsi-utils**, **libiscsi-utils** will fail to be downgraded. Due to the fact that **libiscsi-utils** depends on the **libiscsi** main package before the downgrade, a dependency problem occurs and the libiscsi downgrade fails. +In libiscsi-1.19.0-3 or earlier, binary files named **iscsi-xxx** are packed into the main package **libiscsi**. However, these binary files introduce improper dependency CUnit. To solve this problem, in libiscsi-1.19.0-4, these binary files are separated into the **libiscsi-utils** subpackage. The main package is weakly dependent on the subpackage. You can integrate or uninstall the subpackage during image building based on product requirements. If the subpackage is not integrated or is uninstalled, the functions of the **libiscsi** main package are not affected. +When libiscsi-1.19.0-4 or later is downgraded to libiscsi-1.19.0-3 or earlier and the **libiscsi-utils** subpackage is installed in the system, because libiscsi-1.19.0-3 or earlier does not contain **libiscsi-utils**, **libiscsi-utils** will fail to be downgraded. Due to the fact that **libiscsi-utils** depends on the **libiscsi** main package before the downgrade, a dependency problem occurs and the libiscsi downgrade fails. ### Solution diff --git a/docs/en/docs/Administration/figures/ima-modsig.png b/docs/en/docs/Administration/figures/ima-modsig.png new file mode 100644 index 0000000000000000000000000000000000000000..c3e54e27b6ce30bd21e97908b6168a73f318c117 Binary files /dev/null and b/docs/en/docs/Administration/figures/ima-modsig.png differ diff --git a/docs/en/docs/Administration/figures/ima_digest_list_flow.png b/docs/en/docs/Administration/figures/ima_digest_list_flow.png new file mode 100644 index 0000000000000000000000000000000000000000..73a93fd310b074471be5e307b74f1c8f539aac42 Binary files /dev/null and b/docs/en/docs/Administration/figures/ima_digest_list_flow.png differ diff --git a/docs/en/docs/Administration/figures/ima_digest_list_pkg.png b/docs/en/docs/Administration/figures/ima_digest_list_pkg.png new file mode 100644 index 0000000000000000000000000000000000000000..68fc2bb921b60f47c99c38030f44d8f136dfa396 Binary files /dev/null and b/docs/en/docs/Administration/figures/ima_digest_list_pkg.png differ diff --git a/docs/en/docs/Administration/figures/ima_priv_key.png b/docs/en/docs/Administration/figures/ima_priv_key.png new file mode 100644 index 0000000000000000000000000000000000000000..8ced564c45e8861a338f7c0fae5fff837501e96b Binary files /dev/null and b/docs/en/docs/Administration/figures/ima_priv_key.png differ diff --git a/docs/en/docs/Administration/figures/ima_rpm.png b/docs/en/docs/Administration/figures/ima_rpm.png new file mode 100644 index 0000000000000000000000000000000000000000..6f9abe39c887bfb1c997e6adcd0c7555a77fb6d5 Binary files /dev/null and b/docs/en/docs/Administration/figures/ima_rpm.png differ diff --git a/docs/en/docs/Administration/figures/ima_secure_boot.png b/docs/en/docs/Administration/figures/ima_secure_boot.png new file mode 100644 index 0000000000000000000000000000000000000000..01cf1782f9748b7d77c3929f2766bc744c31e59a Binary files /dev/null and b/docs/en/docs/Administration/figures/ima_secure_boot.png differ diff --git a/docs/en/docs/Administration/figures/ima_sig_verify.png b/docs/en/docs/Administration/figures/ima_sig_verify.png new file mode 100644 index 0000000000000000000000000000000000000000..69623c75374a56615dce1199f0dc3a42892838c1 Binary files /dev/null and b/docs/en/docs/Administration/figures/ima_sig_verify.png differ diff --git a/docs/en/docs/Administration/figures/ima_tpm.png b/docs/en/docs/Administration/figures/ima_tpm.png new file mode 100644 index 0000000000000000000000000000000000000000..0986f2f955449cbdb1a4e0bd485977ef373beb6a Binary files /dev/null and b/docs/en/docs/Administration/figures/ima_tpm.png differ diff --git a/docs/en/docs/Administration/figures/ima_trusted_measurement.png b/docs/en/docs/Administration/figures/ima_trusted_measurement.png new file mode 100644 index 0000000000000000000000000000000000000000..9212fc722d13a114b86208d68f2c539107a5e2a4 Binary files /dev/null and b/docs/en/docs/Administration/figures/ima_trusted_measurement.png differ diff --git a/docs/en/docs/Administration/setting-up-the-database-server.md b/docs/en/docs/Administration/setting-up-the-database-server.md index b84c1dc97a4923bc3d3b86bcb3a512304f5edada..95e1b400008fe854416928f6904a0213b9f7de2a 100644 --- a/docs/en/docs/Administration/setting-up-the-database-server.md +++ b/docs/en/docs/Administration/setting-up-the-database-server.md @@ -1,5 +1,7 @@ # Setting Up the Database Server + + - [Setting Up the Database Server](#setting-up-the-database-server) - [PostgreSQL Server](#postgresql-server) - [Software Description](#software-description) @@ -19,6 +21,12 @@ - [Installing, Running, and Uninstalling MySQL](#installing-running-and-uninstalling-mysql) - [Managing Database Users](#managing-database-users-1) - [Managing Databases](#managing-databases-2) + - [GreatSQL Server](#greatsql-server) + - [Software Description](#software-description-3) + - [Configuring the Environment](#configuring-the-environment-3) + - [Installing, Running, and Uninstalling MySQL](#installing-running-and-uninstalling-mysql) + - [Managing Database Users](#managing-database-users-2) + - [Managing Databases](#managing-databases-3) @@ -29,7 +37,7 @@ [Figure 1](#fig26022387391) shows the PostgreSQL architecture and [Table 1](#table62020913417) describes the main processes. **Figure 1** PostgreSQL architecture -![](./figures/postgresql-architecture.png "postgresql-architecture") +![](./figures/postgresql-architecture.png) **Table 1** Main processes in PostgreSQL @@ -162,8 +170,8 @@ >![](./public_sys-resources/icon-note.gif) **NOTE:** > ->- When testing the ultimate performance, you are advised to attach NVMe SSDs with better I/O performance to create PostgreSQL test instances to avoid the impact of disk I/O on the performance test result. This section uses NVMe SSDs as an example. For details, see Step 1 to Step 4. ->- In a non-performance test, run the following command as the **root** user to create a data directory. Then skip this section. +>When testing the ultimate performance, you are advised to attach NVMe SSDs with better I/O performance to create PostgreSQL test instances to avoid the impact of disk I/O on the performance test result. This section uses NVMe SSDs as an example. For details, see Step 1 to Step 4. +>In a non-performance test, run the following command as the **root** user to create a data directory. Then skip this section. > `mkdir /data` 1. Create a file system \(xfs is used as an example as the **root** user. Create the file system based on the site requirements.\). If a file system has been created for a disk, an error will be reported when you run this command. You can use the **-f** parameter to forcibly create a file system. @@ -789,7 +797,7 @@ The MariaDB database management system is a branch of MySQL and is maintained by [Figure 2](#fig13492418164520) shows the MariaDB architecture. **Figure 2** MariaDB logical architecture -![](./figures/mariadb-logical-architecture.png "mariadb-logical-architecture") +![](./figures/mariadb-logical-architecture.png) When MariaDB receives a SQL statement, the execution process is as follows: @@ -869,8 +877,8 @@ Each storage engine manages and stores data in different ways, and supports diff >![](./public_sys-resources/icon-note.gif) **NOTE:** > ->- If a performance test needs to be performed, an independent drive is required for the data directory. You need to format and mount the drive. For details, see Method 1 or Method 2. ->- In a non-performance test, run the following command as the **root** user to create a data directory. Then skip this section. +>If a performance test needs to be performed, an independent drive is required for the data directory. You need to format and mount the drive. For details, see Method 1 or Method 2. +>In a non-performance test, run the following command as the **root** user to create a data directory. Then skip this section. > `mkdir /data` ##### Method 1: Using fdisk for Drive Management as the **root** user @@ -910,13 +918,14 @@ Each storage engine manages and stores data in different ways, and supports diff ![](./figures/creat_datadisk1.png) ##### Method 2: Using LVM for Drive Management as the **root** user + > >![](./public_sys-resources/icon-note.gif) **NOTE:** ->Install the LVM2 package in the image as follows: +>Install the LVM2 package in the image as follows: > ->1. Configure the local yum source. For details, see [Configuring the Repo Server](./configuring-the-repo-server.md). If the repository has been configured, skip this step. ->2. Install LVM2. -> **yum install lvm2** +> Configure the local yum source. For details, see [Configuring the Repo Server](./configuring-the-repo-server.md). If the repository has been configured, skip this step. +> Install LVM2. +> **yum install lvm2** 1. Create a physical volume, for example, **sdb**. @@ -1496,8 +1505,8 @@ The Structured Query Language \(SQL\) used by MySQL is the most common standard >![](./public_sys-resources/icon-note.gif) **NOTE:** > ->- If a performance test needs to be performed, an independent drive is required for the data directory. You need to format and mount the drive. For details, see Method 1 or Method 2. ->- In a non-performance test, run the following command as the **root** user to create a data directory. Then skip this section. +>If a performance test needs to be performed, an independent drive is required for the data directory. You need to format and mount the drive. For details, see Method 1 or Method 2. +>In a non-performance test, run the following command as the **root** user to create a data directory. Then skip this section. > `mkdir /data` ##### Method 1: Using fdisk for Drive Management as the **root** user @@ -1537,13 +1546,14 @@ The Structured Query Language \(SQL\) used by MySQL is the most common standard ![](./figures/creat_datadisk.png) ##### Method 2: Using LVM for Drive Management as the **root** user + > >![](./public_sys-resources/icon-note.gif) **NOTE:** ->Install the LVM2 package in the image as follows: +>Install the LVM2 package in the image as follows: > ->1. Configure the local yum source. For details, see [Configuring the Repo Server](./configuring-the-repo-server.md). If the repository has been configured, skip this step. ->2. Install LVM2. -> **yum install lvm2** +>Configure the local yum source. For details, see [Configuring the Repo Server](./configuring-the-repo-server.md). If the repository has been configured, skip this step. +>Install LVM2. +> **yum install lvm2** 1. Create a PV, for example, **sdb**. @@ -1733,8 +1743,8 @@ The Structured Query Language \(SQL\) used by MySQL is the most common standard >![](./public_sys-resources/icon-note.gif) **NOTE:** > - >- Enter the initial password generated during database initialization \([3](#li15634560582)\). - >- If MySQL is installed by using an RPM package obtained from the official website, the **mysqld** file is located in the **/usr/sbin** directory. Ensure that the directory specified in the command is correct. + >Enter the initial password generated during database initialization \([3](#li15634560582)\). + >If MySQL is installed by using an RPM package obtained from the official website, the **mysqld** file is located in the **/usr/sbin** directory. Ensure that the directory specified in the command is correct. ```shell /usr/local/mysql/bin/mysql -uroot -p -S /data/mysql/run/mysql.sock @@ -2171,3 +2181,681 @@ In the preceding information: ```shell mysql -h 192.168.202.144 -P 3306 -uroot -p123456 -t db1 < db1.sql ``` + +## GreatSQL Server + +### Software Introduction + +GreatSQL is a donation project under the OpenAtom Foundation, certified by the China Academy of Information and Communications Technology (CAICT) as both a trusted open-source community and a trusted open-source project. + +GreatSQL is an **open-source and free** database that can meet financial-grade application scenarios on ordinary hardware. It features **high availability**, **high performance**, **high compatibility**, and **high security**, making it an ideal alternative to MySQL or Percona Server for MySQL. + +GreatSQL strives to maintaining the openness of open-source. It adopts the [GPLv2 license](https://gitee.com/GreatSQL/GreatSQL/blob/master/LICENSE). + +GreatSQL is primarily maintained and operated by the [GreatSQL Community](https://greatsql.cn). It has attracted numerous community maintainers, enthusiasts, and users who contribute in various ways, including code submissions, feature testing, bug discovery, and documentation improvements. + +### Configuring the Environment + +>![](./public_sys-resources/icon-note.gif) **NOTE:** +>The following environment configuration is for reference only. Configure the environment based on the site requirements. + +#### Turn off the firewall and cancel the startup auto start + +>![](./public_sys-resources/icon-note.gif) **NOTE:** +>In testing environments, firewalls are usually turned off to avoid the influence of some network factors, and configurations are made according to actual needs. + +1. Stop the firewall with root privileges. + +```shell +systemctl stop firewalld +``` + +1. Turn off the firewall with root privileges. + +```shell +systemctl disable firewalld +``` + +>![](./public_sys-resources/icon-note.gif) **NOTE:** +>At the same time as executing the disable command to turn off the firewall, it also cancels the startup self start. + +#### Change SELINOX to disabled + +1. Modify configuration files with root privileges. + +```shell +sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux +``` + +#### Creating a User Group and a User + +>![](./public_sys-resources/icon-note.gif) **NOTE:** +>In the server environment, independent users are assigned to each process to implement permission isolation for security purposes. The user group and user are created for the OS, not for the database. + +Create a GreatSQL user or user group as the **root** user. + +```shell +groupadd mysql + +useradd -r -g mysql -s /sbin/nologin mysql +``` + +#### Creating Data Drives + +>![](./public_sys-resources/icon-note.gif) **NOTE:** +> +>When testing the ultimate performance, you are advised to attach NVMe SSDs with better I/O performance to create GreatSQL test instances to avoid the impact of disk I/O on the performance test result. This section uses NVMe SSDs as an example. For details, see Step 1 to Step 4. +>In a non-performance test, run the following command as the **root** user to create a data directory. Then skip this section. +> `mkdir /data` + +1. Create a file system \(xfs is used as an example as the **root** user. Create the file system based on the site requirements.\). If a file system has been created for a disk, an error will be reported when you run this command. You can use the **-f** parameter to forcibly create a file system. + + ```shell + mkfs.xfs /dev/nvme0n1 + ``` + +2. Create a data directory. + + ```shell + mkdir /data + ``` + +3. Mount disks. + + ```shell + mount -o noatime,nobarrier /dev/nvme0n1 /data + ``` + +#### Creating GreatSQL Data Directory + +In the created data directory **/data**, create directories for processes and grant permissions to the GreatSQL group or user created as the **root** user. + +```shell +mkdir -p /data/GreatSQL +cd /data/GreatSQL +chown -R mysql:mysql /data/GreatSQL +``` + +### Installing, Running, and Uninstalling GreatSQL + +#### Installing GreatSQL + +>![](./public_sys-resources/icon-note.gif) **NOTE:** +>Before installing GreatSQL, please check if MySQL/Percona Server For MySQL/MariaDB and other MySQL homomorphic databases have been installed first. If they have already been installed, they need to be uninstalled first, otherwise GreatSQL cannot be installed again, which may cause conflicts. + +1. Configure the local yum source. For details, see [Configuring the Repo Server](./configuring-the-repo-server.md). + +2. Clear the cache. + + ```shell + dnf clean all + ``` + +3. Create a cache. + + ```shell + dnf makecache + ``` + +4. Install the GreatSQL server as the **root** user. + + ```shell + dnf install greatsql-server + ``` + + If there is a conflict error during installation, you need to uninstall MySQL/Percona Server For MySQL/MariaDB and other MySQL homomorphic databases first. + +5. Check the installed RPM package. + + ```shell + rpm -qa | grep greatsql-server + ``` + +#### Running GreatSQL + +1. Modify the/etc/my.cnf file with **root** user, including the software installation path basedir, datadir, listening port number, innobd_fuffer_pool_2, etc., according to the actual situation. + + ```shell + vi /etc/my.cnf + ``` + + Edit `/etc/my.cnf` as follows (the following is a example): + + ```shell + [client] + datadir = /data/GreatSQL/mysql.sock + + [mysqld] + !includedir /etc/my.cnf.d + user = mysql + datadir = /data/GreatSQL + socket = /data/GreatSQL/mysql.sock + log-error = /data/GreatSQL/mysqld.log + pid-file = /data/GreatSQL/mysqld.pid + slow_query_log = ON + long_query_time = 0.01 + log_slow_verbosity = FULL + log_error_verbosity = 3 + innodb_buffer_pool_size = 1G + innodb_redo_log_capacity = 256M + innodb_io_capacity = 10000 + innodb_io_capacity_max = 20000 + innodb_flush_sync = OFF + ``` + + If you want GreatSQL to achieve better running status and performance, you can refer to the [my.cnf configuration file reference template](https://gitee.com/GreatSQL/GreatSQL-Doc/blob/master/docs/my.cnf-example) provided by the GreatSQL community. + +2. Ensure that the my.cnf configuration file is modified correctly. + + ```shell + cat /etc/my.cnf + ``` + +3. Start GreatSQL database with root user + + ```shell + systemctl start mysqld + ``` + + The initial startup may be slower and may take several minutes due to the task of initializing the GreatSQL database. + + After initialization is complete, check if there are already data files in the directory corresponding to the 'datadir' configuration parameter, as well as the corresponding log files `/data/GreatSQL/mysqld.log`. + + ```shell + ls -la /data/GreatSQL + ``` + + Check the `/data/GreatSQL/mysqld.log` log file. If it includes the message "Bootstrapping complete," it indicates that the database initialization is finished. Additionally, if it contains a line such as "A temporary password is generated for root@localhost: =dz;kqt8svrF," the string "=dz;kqt8svrF" is the initial temporary password for the `root@localhost` account in the GreatSQL database. After logging in for the first time, you must change this password immediately to continue using GreatSQL. + +4. Login to GreatSQL。 + + >![](./public_sys-resources/icon-note.gif) **NOTE:** + >When prompted to enter a password, please enter the temporary password generated in [step 4](#li15634560588). + + ```shell + mysql -uroot -p + ``` + +5. Change the temporary password + + As shown in the screenshot above, after logging into the GreatSQL database for the first time, you must modify the temporary password before proceeding with further operations. + + ```shell + greatsql [(none)]> \s + ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. + greatsql [(none)]> ALTER USER USER() IDENTIFIED BY 'GreatSQL@202X'; + Query OK, 0 rows affected (0.00 sec) + ``` + +6. Create a new database account named `GreatSQL` that allows access from any server, and grant this account full permissions to perform all operations on all data objects within the database named `test`. + + ```shell + -- Specify the password for the new account GreatSQL as "GreatSQL-202X". It is recommended to modify it to a password of your own + greatsql [(none)]> CREATE USER GreatSQL@'%' IDENTIFIED BY 'GreatSQL-202X'; + Query OK, 0 rows affected (0.00 sec) + + greatsql [(none)]> GRANT ALL ON test.* TO GreatSQL@'%'; + Query OK, 0 rows affected (0.00 sec) + ``` + +7. Creating a new database named `test` + + ```shell + greatsql [(none)]> CREATE DATABASE test; + Query OK, 1 row affected (0.00 sec) + ``` + +8. exit GreatSQL server + + Run SQL command `\q` or `exit` to exit GreatSQL database Server. + + ```shell + greatsql> exit + ``` + +9. Switch to the newly created `GreatSQL` account to log in and operate the database. + + ```shell + -- Use the password "GreatSQL-202X" specified when creating the GreatSQL account, or use the password you have set yourself. + -- The test specified afterward means that the test database will be used immediately after logging in. Ensure to include a space; otherwise, it will be interpreted as part of the password. + mysql -uGreatSQL -p test + Enter password: + ... + + -- Creating new table + greatsql [test]> CREATE TABLE t1(id INT PRIMARY KEY); + Query OK, 0 rows affected (1.48 sec) + + -- show tables + greatsql [test]> SHOW TABLES; + +----------------+ + | Tables_in_test | + +----------------+ + | t1 | + +----------------+ + 1 row in set (0.00 sec) + + -- inserting some rows + greatsql [test]> INSERT INTO t1 SELECT RAND()*1024; + Query OK, 1 row affected (0.34 sec) + Records: 1 Duplicates: 0 Warnings: 0 + + -- reading rows from table + greatsql [test]> SELECT * FROM t1; + +-----+ + | id | + +-----+ + | 565 | + +-----+ + 1 row in set (0.00 sec) + ``` + +This completes the basic operations for the GreatSQL database. + +For more related SQL commands/syntax, please refer to the manual: [SQL Statements](https://dev.mysql.com/doc/refman/8.0/en/sql-statements.html). + +For more content on application development based on GreatSQL, please refer to: [Application Development](https://greatsql.cn/docs/12-dev-guide/12-dev-guide.html). + +#### Uninstalling GreatSQL + +1. Stop the database process as the **root** user. + +```shell +systemctl stop mysqld +``` + +1. Execute the command **dnf remove -y greatsql-server** with root privileges to uninstall GreatSQL. + +```shell +dnf remove -y greasql-server +``` + +### Managing Database Users + +#### Creating Users + +Run the **CREATE USER** statement to create one or more users and set corresponding passwords. + +```sql +CREATE USER 'username'@'hostname' IDENTIFIED BY 'password'; +``` + +In the preceding information: + +- _username_: name of a user. +- _host_: hostname, that is, the name of the host where the user connects to the database. As a local user, you can set the parameter to **localhost**. If the host name is not specified during user creation, the host name is **%** by default, indicating a group of hosts. +- _password_: password for logging in to the server. The password can be null. If the password is null, the user can log in to the server without entering the password. This method, however, is not recommended because it provides low security. + +To use the **CREATE USER** statement, you must have the **INSERT** permission on the database or the global **CREATE USER** permission. + +After a user account is created using the **CREATE USER** statement, a record is added to the user table in the database. If the account to be created exists, an error will occur during statement execution. + +A new user has few permissions and can perform only operations that do not require permissions. For example, a user can run the **SHOW** statement to query the list of all storage engines and character sets. + +##### Example + + Create a local user whose password is "GreatSQL@202X-local" and username is "GreatSQL-local". + +```sql +CREATE USER GreatSQL_local@localhost IDENTIFIED BY 'GreatSQL@202X'; +``` + + Create a user whose password is "GreatSQL@202X-remote", username is **GreatSQL_remote**, and hostname is **192.168.1.100**. + +```sql +CREATE USER 'GreatSQL_remote'@'192.168.1.100' IDENTIFIED BY 'GreatSQL@202X-remote'; +``` + +#### Viewing Users + +Run the **SHOW GRANTS** or **SELECT** statement to view one or more users. + +View a specific user: + +```sql +SHOW GRANTS [FOR 'username'@'hostname']; +``` + +```sql +SELECT USER,HOST,PASSWORD FROM mysql.user WHERE USER='username'; +``` + +View all users: + +```sql +SELECT USER,HOST FROM mysql.user; +``` + +In the preceding information: + +- _username_: name of a user. +- _hostname_: host name. + +##### Example + + View the user **userexample1**. + +```sql +SHOW GRANTS FOR GreatSQL; ++----------------------------------------------------+ +| Grants for GreatSQL@% | ++----------------------------------------------------+ +| GRANT USAGE ON *.* TO `GreatSQL`@`%` | +| GRANT ALL PRIVILEGES ON `test`.* TO `GreatSQL`@`%` | ++----------------------------------------------------+ +2 rows in set (0.00 sec) +``` + + View all users in the MySQL database. + +```sql +SELECT USER,HOST FROM mysql.user; +``` + +#### Modifying Users + +##### Modifying a Username + +Run the **RENAME USER** statement to change one or more existing usernames. + +```sql +RENAME USER 'oldusername'@'hostname' TO 'newusername'@'hostname'; +``` + +In the preceding information: + +- _oldusername_: original username. +- _newusername_: new username. +- _hostname_: host name. + +The **RENAME USER** statement is used to rename an existing account. If the original account does not exist in the system or the new account exists, an error will occur when the statement is executed. + +To use the **RENAME USER** statement, you must have the **UPDATE** permission on the database or the global **CREATE USER** permission. + +##### Example of Modifying a User + + Change the username **userexample1** to **userexample2** and change the hostname to **localhost**. + +```sql +RENAME USER 'userexample1'@'localhost' TO 'userexample2'@'localhost'; +``` + +##### Modifying a User Password + +Use the **SET PASSWORD** statement to modify the login password of a user. + +```sql +SET PASSWORD FOR 'username'@'hostname' = 'newpassword'; +``` + +In the preceding information: + +- **FOR'**_username_**'@'**_hostname_**'**: specifies the username and hostname whose password is to be changed. This parameter is optional. +- _newpassword_: new password. + +If the **FOR** clause is not added to the **SET PASSWORD** statement, the password of the current user is changed. + +The **FOR** clause must be given in the format of **'**_username_**'@'**_hostname_**'**, where _username_ indicates the username of the account and _hostname_ indicates the hostname of the account. + +The account whose password is to be changed must exist in the system. Otherwise, an error occurs when the statement is executed. + +##### Example of Changing a User Password + + Change the password of user **GreatSQL_remote** whose hostname is **localhost** to "GreatSQL@@202X-remote". + +```sql +SET PASSWORD FOR 'GreatSQL_remote'@'192.168.1.100' = 'GreatSQL@@202X-remote'; +``` + +#### Deleting Users + +Use the **DROP USER** statement to delete one or more user accounts and related permissions. + +```sql +DROP USER 'username1'@'hostname1' [,'username2'@'hostname2']...; +``` + +>![](./public_sys-resources/icon-caution.gif) **CAUTION:** +>The deletion of users does not affect the tables, indexes, or other database objects that they have created, because the database does not record the accounts that have created these objects. + +The **DROP USER** statement can be used to delete one or more database accounts and their original permissions. + +To use the **DROP USER** statement, you must have the **DELETE** permission on the database or the global **CREATE USER** permission. + +In the **DROP USER** statement, if the hostname of an account is not specified, the hostname is **%** by default. + +##### Example + + Delete the local user **userexample**. + +```sql +DROP USER 'userexample'@'localhost'; +``` + +#### Granting Permissions to a User + +Run the **GRANT** statement to grant permissions to a new user. + +```sql +GRANT privileges ON databasename.tablename TO 'username'@'hostname'; +``` + +In the preceding information: + +- **ON** clause: specifies the object and level on which the permission is granted. +- _privileges_: indicates the operation permissions of a user, such as **SELECT**, INSERT, and **UPDATE**. To grant all permissions to a user, use **ALL**. +- _databasename_: database name. +- _tablename_: table name. +- **TO** clause: sets the user password and specifies the user to whom the permission is granted. +- _username_: name of a user. +- _hostname_: host name. + +To grant the user the permission to operate all databases and tables, use asterisks \(\*\), for example, **\*.\***. + +If you specify a password for an existing user in the **TO** clause, the new password will overwrite the original password. + +If the permission is granted to a non-existent user, a **CREATE USER** statement is automatically executed to create the user, but the password must be specified for the user. + +##### Example + + Grant the **SELECT** and **INSERT** permissions to local user **userexample**. + +```sql +GRANT SELECT,INSERT ON *.* TO 'userexample'@'localhost'; +``` + +#### Deleting User Permissions + +Run the **REVOKE** statement to delete the permissions of a user, but the user will not be deleted. + +```sql +REVOKE privilege ON databasename.tablename FROM 'username'@'hostname'; +``` + +The parameters in the **REVOKE** statement are the same as those in the **GRANT** statement. + +To use the **REVOKE** statement, you must have the global **CREATE USER** or **UPDATE** permission for the database. + +##### Example + + Delete the **INSERT** permission of local user **userexample**. + +```sql +REVOKE INSERT ON *.* FROM 'userexample'@'localhost'; +``` + +### Managing Databases + +#### Creating a Database + +Run the **CREATE DATABASE** statement to create a database. + +```sql +CREATE DATABASE databasename; +``` + +In the preceding command, _databasename_ can be replaced with the database name, which is case insensitive. + +##### Example + + Create a database named **databaseexample**. + +```sql +CREATE DATABASE databaseexample; +``` + +#### Viewing a Database + +Run the **SHOW DATABASES** statement to view a database. + +```sql +SHOW DATABASES; +``` + +##### Example + + View all databases. + +```sql +SHOW DATABASES; +``` + +#### Selecting a Database + +Generally, you need to select a target database before creating or querying a table. Use the **USE** statement to select a database. + +```sql +USE databasename; +``` + +In the preceding command, _databasename_ indicates the database name. + +##### Example + + Select the **databaseexample** database. + +```sql +USE databaseexample; +``` + +#### Deleting a Database + +Run the **DROP DATABASE** statement to delete a database. + +>![](./public_sys-resources/icon-caution.gif) **CAUTION:** +>Exercise caution when deleting a database. Once a database is deleted, all tables and data in the database will be deleted. + +```sql +DROP DATABASE databasename; +``` + +In the preceding command, _databasename_ indicates the database name. + +The **DROP DATABASE** command is used to delete an existing database. After this command is executed, all tables in the database are deleted, but the user permissions of the database are not automatically deleted. + +To use **DROP DATABASE**, you need the **DROP** permission on the database. + +**DROP SCHEMA** is a synonym of **DROP DATABASE**. + +##### Example + + Delete the **databaseexample** database. + +```sql +DROP DATABASE databaseexample; +``` + +#### Backing Up a Database + +Run the **mysqldump** command as the **root** user to back up the database. + +Back up one or more tables: + +```shell +mysqldump [options] databasename [tablename ...] > outfile +``` + +Back up one or more databases: + +```shell +mysqldump [options] -databases databasename ... > outfile +``` + +Back up all databases: + +```shell +mysqldump [options] -all-databases > outputfile +``` + +In the preceding information: + +- _databasename_: database name. +- _tablename_: name of a data table. +- _outfile_: database backup file. +- _options_: parameter option of the **mysqldump** command. Multiple parameters can be separated by spaces. The common parameters of the **mysqldump** command are as follows: + - **-u, \-\-user**= _username_: specifies the username. + - **-p, \-\-password**\[= _password_\]: specifies the password. In the following examples, the password is specified as "123456". You need to adjust it according to your actual situation. + - **-P, \-\-port**= _portnumber_: specifies the port number. + - **-h, \-\-host**= _hostname_: specifies the hostname. + - **-r, \-\-result-file**= _filename_: saves the export result to a specified file, which is equivalent to **\>**. + - **-t**: backs up data only. + - **-d**: backs up the table structure only. + +##### Example + + Back up all the databases of user **root** on port **3306** of the host whose IP address is **192.168.202.144** to the **alldb.sql** file. + +```shell +mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 --all-databases > alldb.sql +``` + + Back up the db1 database of user **root** on port **3306** of the host whose IP address is **192.168.202.144** to the **db1.sql** file. + +```shell +mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 --databases db1 > db1.sql +``` + + Back up the tb1 table of the db1 database of user **root** on port **3306** of the host whose IP address is **192.168.202.144** to the **db1tb1.sql** file. + +```shell +mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 db1 tb1 > db1tb1.sql +``` + + Back up only the table structure of the db1 database of user **root** on port **3306** of the host whose IP address is **192.168.202.144** to the **db1.sql** file. + +```shell +mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 -d db1 > db1.sql +``` + + Back up only the table structure of the db1 database of user **root** on port **3306** of the host whose IP address is **192.168.202.144** to the **db1.sql** file. + +```shell +mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 -t db1 > db1.sql +``` + +#### Restoring a Database + +Run the **mysql** command as the **root** user to restore the database. + +Restore one or more tables: + +```shell +mysql -h hostname -P portnumber -u username -ppassword databasename < infile +``` + +In the preceding information: + +- _hostname_: host name. +- _portnumber_: port number. +- _username_: name of a user. +- _password_: password. +- _databasename_: database name. +- _infile_: **outfile** parameter in the **mysqldump** command. + +##### Example + + Restore a database. + +```shell +mysql -h 192.168.202.144 -P 3306 -uroot -p123456 -t db1 < db1.sql +``` diff --git a/docs/en/docs/Administration/trusted-computing.md b/docs/en/docs/Administration/trusted-computing.md index 0f18f3830c87139ecb13abfb79fd7802135a1230..5ba4816f745e1d327673467a9882645ae6b1d100 100644 --- a/docs/en/docs/Administration/trusted-computing.md +++ b/docs/en/docs/Administration/trusted-computing.md @@ -1836,7 +1836,7 @@ The TPCM interacts with other components as follows: ### Constraints -Supported server: TaiShan 200 server (model 2280) +Supported server: TaiShan 200 server (model 2280) Supported BMC card: BC83SMMC ### Application Scenarios diff --git a/docs/en/docs/CTinspector/usage.md b/docs/en/docs/CTinspector/usage.md index f7cbe3ce9656a584c2a9b5eb6cb72bb960fa2dc0..b4487f99ce8e7f99be9269c2bb8e5ff5c0a69c93 100644 --- a/docs/en/docs/CTinspector/usage.md +++ b/docs/en/docs/CTinspector/usage.md @@ -39,5 +39,5 @@ clang -O2 -fno-inline -emit-llvm -I/usr/include/ctinspector/ -c migrate.c -o - | Running **vm_migrate** on node 1. ![](./figures/migrate_node_1.png) -Running the CTinspector main prgram on node 2. +Running the CTinspector main program on node 2. ![](./figures/migrate_node_2.png) diff --git a/docs/en/docs/Container/interconnecting-isula-shim-v2-with-stratovirt.md b/docs/en/docs/Container/interconnecting-isula-shim-v2-with-stratovirt.md index 180081851db7c53da48c45ade53e9d0d1ccfc85a..649c5ccadabe6183ce2fa013d1640dfb61991c8e 100644 --- a/docs/en/docs/Container/interconnecting-isula-shim-v2-with-stratovirt.md +++ b/docs/en/docs/Container/interconnecting-isula-shim-v2-with-stratovirt.md @@ -4,11 +4,11 @@ shim v2 is a next-generation shim solution. Compared with shim v1, shim v2 features shorter call chains, clearer architecture, and lower memory overhead in multi-service container scenarios. iSula can run secure containers through isulad-shim or containerd-shim-kata-v2. The isulad-shim component is the implementation of the shim v1 solution, and the containerd-shim-kata-v2 component is the implementation of the shim v2 solution in the secure container scenario. This document describes how to interconnect iSula with containerd-shim-kata-v2. -## Interconnecting with containerd-shim-v2-kata +## Interconnecting with containerd-shim-kata-v2 ### Prerequisites -Before interconnecting iSula with containerd-shim-v2-kata, ensure that the following prerequisites are met: +Before interconnecting iSula with containerd-shim-kata-v2, ensure that the following prerequisites are met: - iSulad and kata-containers have been installed. - StratoVirt supports only the devicemapper storage driver. Therefore, you need to configure the devicemapper environment and ensure that the devicemapper storage driver used by iSulad works properly. diff --git a/docs/en/docs/Container/querying-information.md b/docs/en/docs/Container/querying-information.md index 34bc33a21945d246c518b75c690b3b68b74d536c..0c27a9d1d2e26769e8055e13206df1448fbbe32d 100644 --- a/docs/en/docs/Container/querying-information.md +++ b/docs/en/docs/Container/querying-information.md @@ -81,7 +81,7 @@ Containers: 2 Images: 8 Server Version: 1.0.31 Logging Driver: json-file -Cgroup Driverr: cgroupfs +Cgroup Driver: cgroupfs Hugetlb Pagesize: 2MB Kernel Version: 4.19 Operating System: Fedora 29 (Twenty Nine) diff --git a/docs/en/docs/Gazelle/Gazelle.md b/docs/en/docs/Gazelle/Gazelle.md index 257c1d37a6c8a2cc3c0c0672a5717c671f3ce8be..ed174db457a30ba51bbc2d541fb8e3bf38dfeae7 100644 --- a/docs/en/docs/Gazelle/Gazelle.md +++ b/docs/en/docs/Gazelle/Gazelle.md @@ -337,7 +337,7 @@ You need to evaluate the use of Gazelle based on application scenarios. **Shared Memory** - Current situation: - The memory huge pages are mounted to the **/mnt/hugepages-lstack** directory. During process initialization, files are created in the **/mnt/hugepages-lstack** directory. Each file corresponds to a huge page, and the mmap function is performed on the files. After receiving the registration information of lstask, ltran also perform the mmap function on the file in the directory based on the huge page memory configuration information to implement shared huge page memory. + The memory huge pages are mounted to the **/mnt/hugepages-lstack** directory. During process initialization, files are created in the **/mnt/hugepages-lstack** directory. Each file corresponds to a huge page, and the mmap function is performed on the files. After receiving the registration information of lstask, ltran configures the files in the **mmap** directory of the information page based on the huge page memory configurations, implementing shared huge page memory. The procedure also applies to the files in the **/mnt/hugepages-ltran** directory. - Current mitigation measures The huge page file permission is **600**. Only the owner can access the files. The default owner is the **root** user. Other users can be configured. diff --git a/docs/en/docs/HCK/HCK-description-and-usage.md b/docs/en/docs/HCK/HCK-description-and-usage.md new file mode 100644 index 0000000000000000000000000000000000000000..1cc400ae51072fd970e14ae206f8b9d21f3ef729 --- /dev/null +++ b/docs/en/docs/HCK/HCK-description-and-usage.md @@ -0,0 +1,114 @@ +# Description + +High-performance Computing Kit (HCK) is a software base of HPC applications. It provides an isolated and low-overhead running environment for HPC applications by customizing system calls and optimizing scheduling on the Linux platform. In addition, HCK is compatible with the Linux ecosystem to improve HPC application performance. To use HCK, enable the **CONFIG_PURPOSE_BUILT_KERNEL** option when building the kernel. With HCK, during system startup, some CPUs are isolated to run HPC applications while the non-isolated CPUs run kernel-mode and other user-mode processes. + +# Usage Instructions + +If the kernel supports the HCK feature, add the **pbk_cpus** parameter to the kernel boot options to specify the reserved CPU resources. By default, the CPU resources are not reserved. You can set this parameter by modifying the GRUB configuration file **grub.cfg** or on the GRUB boot page. +The format of the boot parameter is **pbk_cpus=**. **** can contain commas (,) and hyphens (-). For example, **1,3-4** indicates that CPUs 1, 3 and 4 are reserved. Currently, the HCK feature does not support the x86 architecture, and CPU 0 cannot be reserved in the AArch64 architecture. +After the boot parameter is set, the kernel automatically isolates and reserves CPU resources. No additional step is required after the system is booted. + +# `launcher` + +HCK provides a user-mode tool `launcher`, which can be used to specify a program to run on a specific isolated core. `launcher` needs to be installed separately. + +## Basic Options + +For details, run `launcher -?`. + +```shell +Usage: launcher [OPTION...] + +launcher: launch process to pbk domain + +EXAMPLES: + launcher -c 1,2 prog # alloc CPU 1,2 from pbk root domain to run prog + launcher -n 2 prog # alloc 2 CPUs from pbk root domain to run prog + launcher -v prog # prog will only touch pbk + launcher -c 1 prog # alloc CPU 1 and 1M memory + + -c, --cpulist=CPULIST cpulist to run prog + -n, --nr_cpu=NR_CPU nr_cpus to run prog + -v, --pbk_view run prog with pbk view + -?, --help Give this help list + --usage Give a short usage message + +Mandatory or optional arguments to long options are also mandatory or optional +for any corresponding short options. +``` + +## Option Description + +### `launcher -?` + +Displays the usage description of the command. + +### `launcher -c` + +Specify **cpulist** to run a program. For example: + +```shell +launcher -c 1,2 ./test +``` + +`launcher` applies for CPUs 1 and 2 to execute the test program. If CPU 1 or CPU 2 are not isolated or has been applied for by other programs, a failure message is returned. + +An exception is as follows: + +```shell +launcher -c 1,2 ./test1 +launcher -c 1,2 ./test2 +``` + +The same **cpulist** is specified to execute **test2**. In this case, no failure message is returned. Instead, **test2** is also executed on CPUs 1 and 2. + +### `launcher -n` + +Specifies the number of CPUs to run a program: + +```shell +launcher -n 1 ./test +``` + +`launcher` applies for a CPU from the isolated CPUs to run **test**. If the remaining isolated CPUs are insufficient, a failure message is returned. + +### `launcher -v` + +After CPUs are isolated, CPU resources are divided into Linux resources and isolated CPU resources. To support programs that can identify and allocate resources, such as mpirun, `launcher` supports resource perspective modification. For example: + +```shell +launcher -v cat /proc/cpuinfo +``` + +In this case, only isolated CPUs are displayed. + +This option can also be used together with the `-n` and `-c` options. For example: + +```shell +launcher -c 1,2 -v cat /proc/cpuinfo +``` + +In this case, only information about CPU 1 and CPU 2 is displayed. + +The affected procfs and sysfs interfaces are as follows: + +procfs: + +```text +/proc/cpuinfo +``` + +sysfs: + +```text +/sys/devices/system/cpu/online +/sys/devices/system/cpu/present +/sys/devices/system/cpu/possible +/sys/devices/system/cpu/cpu/online +/sys/devices/system/node/node/cpumap +/sys/devices/system/node/node/cpulist +/sys/fs/cgroup/cpuset/cpuset.cpus +/sys/fs/cgroup/cpuset/cpuset.effective_cpus +``` + +Note: By default, only Linux resources are displayed for the two interfaces related to **cgroup** (because isolated CPUs are not added to **cpuset** of **cgroup**). Other interfaces display Linux resources and isolated CPU resources by default and are not affected by isolation. diff --git a/docs/en/docs/Installation/More-Resources.md b/docs/en/docs/Installation/More-Resources.md index fab0df5d93e9e7c5283d8d46368d3c4d6402c887..0bd1cf551733501720f02ae721327361288e7fa7 100644 --- a/docs/en/docs/Installation/More-Resources.md +++ b/docs/en/docs/Installation/More-Resources.md @@ -1,4 +1,4 @@ # Reference -- How to Create a Raspberry Pi Image File -- How to Use Raspberry Pi +- How to Create a Raspberry Pi Image File +- How to Use Raspberry Pi diff --git a/docs/en/docs/Installation/installation-guideline.md b/docs/en/docs/Installation/installation-guideline.md index 99464095ca2af3ad86c5eb2a8d0d9575a978eaf5..8daaf4b7d4efa72da7f340df04af0eeba61adf90 100644 --- a/docs/en/docs/Installation/installation-guideline.md +++ b/docs/en/docs/Installation/installation-guideline.md @@ -48,8 +48,7 @@ Installation wizard options are described as follows: - **Troubleshooting**: Troubleshooting mode, which is used when the system cannot be installed properly. In troubleshooting mode, the following options are available: - **Install openEuler 21.09 in basic graphics mode**: Basic graphics installation mode. In this mode, the video driver is not started before the system starts and runs. - - **Rescue the openEuler system**: Rescue mode, which is used to restore the system. In rescue mode, the installation process is printed in the VNC or BMC, and the serial port is unavailable. - + - **Rescue the openEuler system**: Rescue mode, which is used to restore the system. In rescue mode, the installation process is printed to the Virtual Network Computing (VNC) or BMC interface, and the serial port is unavailable. On the installation wizard screen, press **e** to go to the parameter editing screen of the selected option, and press **c** to go to the command line interface (CLI). ### Installation in GUI Mode diff --git a/docs/en/docs/KubeOS/installation-and-deployment.md b/docs/en/docs/KubeOS/installation-and-deployment.md index 6788abf9d804c7aea5a53c81ddcd778d51ada3fe..b609e26dcf3e7961c630d962f49b8c7a9e678231 100644 --- a/docs/en/docs/KubeOS/installation-and-deployment.md +++ b/docs/en/docs/KubeOS/installation-and-deployment.md @@ -21,7 +21,7 @@ This chapter describes how to install and deploy the KubeOS tool. ### Software Requirements -- OS: openEuler 22.09 +- OS: openEuler 24.09 ### Environment Preparation @@ -32,24 +32,15 @@ This chapter describes how to install and deploy the KubeOS tool. To install KubeOS, perform the following steps: -1. Configure the Yum sources openEuler 22.09 and openEuler 22.09:EPOL: +1. Configure the Yum sources openEuler 24.09 and openEuler 24.09:EPOL: ```conf - [openEuler22.09] # openEuler 22.09 official source - name=openEuler22.09 - baseurl=http://repo.openeuler.org/openEuler-22.09/everything/$basearch/ + [openEuler24.09] # openEuler 24.09 official source + name=openEuler24.09 + baseurl=http://repo.openeuler.org/openEuler-24.09/everything/$basearch/ enabled=1 gpgcheck=1 - gpgkey=http://repo.openeuler.org/openEuler-22.09/everything/$basearch/RPM-GPG-KEY-openEuler - ``` - - ```conf - [Epol] # openEuler 22.09:EPOL official source - name=Epol - baseurl=http://repo.openeuler.org/openEuler-22.09/EPOL/main/$basearch/ - enabled=1 - gpgcheck=1 - gpgkey=http://repo.openeuler.org/openEuler-22.09/OS/$basearch/RPM-GPG-KEY-openEuler + gpgkey=http://repo.openeuler.org/openEuler-24.09/everything/$basearch/RPM-GPG-KEY-openEuler ``` 2. Install KubeOS as the **root** user. @@ -167,7 +158,7 @@ To create a KubeOS VM image, perform the following steps: After the KubeOS image is created, the following files are generated in the **/opt/kubeOS/scripts** directory: - - **system.img**: system image in raw format. The default size is 20 GB. The size of the root file system partition is less than 2,020 MiB, and the size of the Persist partition is less than 16 GiB. + - **system.img**: system image in raw format. The default size is 20 GB. The size of the root file system partition is less than 2,560 MiB, and the size of the Persist partition is less than 14 GiB. - **system.qcow2**: system image in QCOW2 format. - **update.img**: partition image of the root file system that is used for upgrade. @@ -177,9 +168,9 @@ To create a KubeOS VM image, perform the following steps: #### Precautions -- The Kubernetes cluster must be deployed first. For details, see the *openEuler 22.09 Kubernetes Cluster Deployment Guide*. +- The Kubernetes cluster must be deployed first. For details, see the *openEuler 24.09 Kubernetes Cluster Deployment Guide*. -- The OS of the worker nodes to be upgraded in the cluster must be the KubeOS built using the method described in the previous section. If it is not, use **system.qcow2** to deploy the VM again. For details about how to deploy a VM, see the *openEuler 22.09 Virtualization User Guide*. Currently, KubeOS does not support the master nodes. Use openEuler 22.09 to deploy the upgrade on the master nodes. +- The OS of the worker nodes to be upgraded in the cluster must be the KubeOS built using the method described in the previous section. If it is not, use **system.qcow2** to deploy the VM again. For details about how to deploy a VM, see the *openEuler 24.09 Virtualization User Guide*. Currently, KubeOS does not support the master nodes. Use openEuler 24.09 to deploy the upgrade on the master nodes. - The YAML files for deploying CustomResourceDefinition (CRD), os-operator, os-proxy, and role-based access control (RBAC) of the OS need to be compiled. - The os-operator and os-proxy components are deployed in the Kubernetes cluster. os-operator must be deployed as a Deployment, and os-proxy as a DaemonSet. - Kubernetes security mechanisms, such as the RBAC, pod service account, and security policies, must be deployed. diff --git a/docs/en/docs/KubeOS/kubeos-image-creation.md b/docs/en/docs/KubeOS/kubeos-image-creation.md index cda7c1acc2e2c5d8585f11b2e6737b86eef042ba..382573d2f0d819c2c372933f3a2aa9a2d55e93fe 100644 --- a/docs/en/docs/KubeOS/kubeos-image-creation.md +++ b/docs/en/docs/KubeOS/kubeos-image-creation.md @@ -16,7 +16,7 @@ kbimg is an image creation tool required for KubeOS deployment and upgrade. You | Parameter | Description | | ------------- | ---------------------------------------------- | - | upgrade-image | Generates a Docker image for installation and upgrade.| + | upgrade-image | Generates a OCI image for installation and upgrade.| | vm-image | Generates a VM image for installation and upgrade. | | pxe-image | Generates images and files required for physical machine installation. | @@ -39,11 +39,11 @@ kbimg is an image creation tool required for KubeOS deployment and upgrade. You * Currently, only the x86 and AArch64 architectures are supported. * The RPM sources of the kbimg are the **everything** and **EPOL** repositories of openEuler of a specific version. In the Repo file provided during image creation, you are advised to configure the **everything** and **EPOL** repositories of a specific openEuler version for the Yum source. -### Creating a KubeOS Docker Image +### Creating a KubeOS OCI Image #### Precautions -* The created Docker image can be used only for subsequent VM or physical machine image creation or upgrade. It cannot be used to start containers. +* The created OCI image can be used only for subsequent VM or physical machine image creation or upgrade. It cannot be used to start containers. * If the default RPM list is used to create a KubeOS image, at least 6 GB drive space is required. If the RPM list is customized, the occupied drive space may exceed 6 GB. #### Example diff --git a/docs/en/docs/KubeOS/usage-instructions.md b/docs/en/docs/KubeOS/usage-instructions.md index 0f3500160214567d2b9c183e7fea6c2f380ade6a..4e115b388212ff76f7fcb39a8b055f246baa76a0 100644 --- a/docs/en/docs/KubeOS/usage-instructions.md +++ b/docs/en/docs/KubeOS/usage-instructions.md @@ -1,169 +1,517 @@ # Usage Instructions -- [Usage Instructions](#usage-instructions) - - [Precautions](#precautions) - - [Upgrade](#upgrade) - - [Rollback](#rollback) - - [Application Scenarios](#application-scenarios) - - [Manual Rollback](#manual-rollback) - - [KubeOS-based Rollback](#kubeos-based-rollback) + +- [Usage Instructions](#usage-instructions) + - [Precautions](#precautions) + - [OS CR Parameters](#os-cr-parameters) + - [Upgrade](#upgrade) + - [Settings](#settings) + - [Rollback](#rollback) + - [Appendixes](#appendixes) + - [Settings List](#settings-list) + - [kernel Settings](#kernel-settings) + - [GRUB Settings](#grub-settings) + + ## Precautions -1. KubeOS upgrades the container OS in an atomic manner, where all software packages are upgraded at the same time. By default, single-package upgrade is not supported. -2. KubeOS supports container OSs with two partitions. Partitions more than two are not supported. -3. You can view the upgrade logs of a single node in the **/var/log/messages** file on the node. -4. Strictly follow the upgrade and rollback procedures described in this document. If the steps are performed in a wrong sequence, the system may fail to be upgraded or rolled back. -5. Upgrade using a Docker image and mTLS two-way authentication are supported only in openEuler 22.09 or later. -6. Cross-major version upgrade is not supported. +- General precautions + - KubeOS currently only supports virtual machines (VMs) and physical machines using UEFI with x86 and AArch64 architectures. + - When creating or updating the OS CustomResource (CR) using `kubectl apply` with a YAML file, avoid concurrent `apply` operations. Excessive concurrent requests may overwhelm the kube-apiserver, leading to failures. + - If you configure certificates or keys for the container image registry, ensure that the permissions on these files are set to the minimum necessary. +- Upgrade precautions + - Upgrades are performed as atomic upgrades for all packages. Individual package upgrades are not supported. + - Upgrades use a dual-partition upgrade strategy. Configurations with more than two partitions are not supported. + - Cross-major version upgrades are not currently supported. + - Logs for the upgrade process on a single node can be found in the **/var/log/messages** file on that node. + - Strictly adhere to the provided upgrade and rollback procedures. Deviation from the prescribed order of operations may result in upgrade or rollback failures. + - If you need to configure private images for `ctr` (used by `containerd`) on a node, place the **host.toml** configuration file in the `/etc/containerd/certs.d` directory, following the `ctr` guidelines. + - Upgrades using OCI images and mutual TLS (mTLS) authentication are only supported on openEuler 22.09 and later. + - Features `nodeselector`, `executionmode`, `timewindow`, and `timeinterval` are only supported on openEuler 24.09 and later. + - KubeOS 24.09 is not compatible with previous versions. + +- Configuration Precautions + - Users are responsible for the security and reliability of any custom configurations, particularly persistent configurations such as `kernel.sysctl.persist`, `grub.cmdline.current`, and `grub.cmdline.next`. KubeOS does not validate the effectiveness of these parameters. + - When `opstype` is set to `config`, configurations will not be applied if the specified `osversion` does not match the OS version of the target nodes in the cluster. + - Currently, only temporary kernel parameter configuration (`kernel.sysctl`), persistent kernel parameter configuration (`kernel.sysctl.persist`), and GRUB command line configuration (`grub.cmdline.current` and `grub.cmdline.next`) are supported. + - Persistent configurations are written to the persistent partition and will be retained after upgrades and reboots. Temporary kernel parameter configurations will not be retained after a reboot. + - When configuring `grub.cmdline.current` or `grub.cmdline.next`, if a single parameter is provided (not in the `key=value` format), specify the parameter as the key and leave the value empty. + - When deleting a configuration (`operation=delete`), ensure that the key and value in the `key=value` format match the actual configuration. + - Configuration changes cannot be rolled back. If a rollback is required, modify the configuration version and content and reapply the configuration. + - If a configuration error occurs and a node enters the `config` state, revert the configuration version to the previous version and reapply it. This should return the node to the `idle` state. However, note that parameters successfully configured before the error occurred cannot be reverted. + - When configuring `grub.cmdline.current` or `grub.cmdline.next`, if you need to update an existing parameter in the format of `key=value` to a format with only key and no value, for example, updating `rd.info=0` to `rd.info`, you need to delete `key=value` first, and then add the key in the next configuration. Direct updates or updates and deletions in the same operation are not supported. + +## OS CR Parameters + +Create a custom object of the OS type in the cluster and set the corresponding fields. The OS type comes from the CRD object created in the installation and deployment sections. The following describes the fields. + +- The `imageurl` field specifies the location of the operating system image. This URL must use either the `http` or `https` protocol. For `https`, the image transfer is secure. For `http`, you must set the `flagSafe` parameter to `true`. This explicitly signals that you trust the source and allows the image download to proceed. If `imageurl` uses `http` and `flagSafe` is not `true`, the URL is considered unsafe, the image will not be downloaded, and an error message will appear in the node upgrade log. +- You are advised to use the `https` protocol for security. When using `https`, ensure that the target machines being upgraded have the necessary certificates installed. If you maintain the image server yourself, you must sign the images to guarantee their authenticity and ensure the nodes being upgraded trust your certificate. Place the certificate file in the `/etc/KubeOS/certs` directory. The administrator provides the `imageurl` and is responsible for ensuring the security and validity of this URL. An internal network address is recommended for enhanced security. +- The provider of the container OS image is responsible for its integrity. Verify that you obtain images from a trustworthy source. +- When your cluster uses multiple OS versions (meaning that there are multiple OS instances), each OS must have a distinct `nodeselector`. This ensures that a group of nodes identified by a specific label corresponds to only one OS instance. + - If an OS instance has `nodeselector` set to `all-label`, it will be the only valid instance in the cluster (only nodes matching its criteria will be managed). + - Similarly, only one OS instance can have an unconfigured `nodeselector`. This is because an absent `nodeselector` is interpreted as targeting nodes without any labels. +- `timewinterval` parameter + - When not set, the default value is 15 seconds. + - Setting this parameter to `0` will cause the task dispatch interval of the operator to gradually increase until it reaches 1000 seconds. This behavior is due to rate limiting imposed by the Kubernetes `controller-runtime`. + - In parallel execution mode, `timeinterval` defines the delay between the operator dispatching upgrade/configuration tasks for each batch of nodes. + - In serial execution mode, `timeinterval` represents the delay between the completion of one batch of nodes (upgraded/configured serially) and the dispatch of the next upgrade/configuration task. Within a batch, the interval between individual nodes remains 15 seconds. + - Any update to fields of an OS instance will immediately trigger the operator. + + | Parameter |Type | Description | Usage Notes | Mandatory | + | -------------- | ------ | ------------------------------------------------------------ | ----- | ---------------- | + | `imagetype` | string | Type of image used for the upgrade | The value can be `docker`, `containerd`, or `disk` and is valid only for upgrades. **Note:** When the value is `containerd`, the agent prioritizes the `crictl` tool for pulling images. If `crictl` is unavailable, it uses the `ctr` command. When `ctr` is used to pull images from a private repository, configure the repository host information in the **/etc/containerd/certs.d** directory according to the [containerd official documentation](https://github.com/containerd/containerd/blob/main/docs/hosts.md). | Yes | + | `opstype` | string | Operation type (upgrade, configuration, or rollback) | The value can be `upgrade`, `config`, or `rollback`. | Yes | + | `osversion` | string | Target version for the upgrade or rollback | `osversion` must match the target OS version of the nodes (specified in the `PRETTY_NAME` field in the **/etc/os-release** file or the OS version detected by Kubernetes). For example: `KubeOS 1.0.0`. | Yes | + | `maxunavailable`| int | Maximum number of nodes undergoing upgrade/configuration/rollback concurrently | If `maxunavailable` exceeds the actual number of nodes, the operation proceeds with the actual number of nodes. | Yes | + | `containerimage` | string | Container image used for the upgrade | This parameter is only applicable when `imagetype` is a container type. The value can be one of the three container image address formats: `repository/name`, `repository/name@sha256:xxxx`, and `repository/name:tag`. | Yes | + | `imageurl` | string | URL of the drive image used for the upgrade | `imageurl` must include the protocol and supports only `http` or `https`. Example: `https://192.168.122.15/update.img`. Valid only for upgrades using drive images. | Yes | + | `checksum` | string | Checksum (SHA-256) of the drive image used for the upgrade or the digests of the container image | This parameter is valid only for upgrades. | Yes | + | `flagSafe` | bool | Whether the address specified by `imageurl` is safe when the `http` protocol is used | The value must be `true` or `false`. This parameter is valid only when `imageurl` uses the `http` protocol. | Yes | + | `mtls` | bool | Whether the connection to `imageurl` uses two-way HTTPS authentication | The value must be `true` or `false`. This parameter is valid only when `imageurl` uses the `https` protocol. | Yes | + | `cacert` | string | Root certificate file used for HTTPS or two-way HTTPS authentication | This parameter is valid only when `imageurl` uses the `https` protocol. | Required when `imageurl` uses `https` | + | `clientcert` | string | Client certificate file used for two-way HTTPS authentication | This parameter is valid only when two-way HTTPS authentication is used. | Required when `mtls` is `true` | + | `clientkey` | string | Client private key file used for two-way HTTPS authentication | This parameter is valid only when two-way HTTPS authentication is used. | Required when `mtls` is `true` | + | `evictpodforce` | bool | Whether to forcibly evict pods during upgrade/rollback | Must be `true` or `false`. This parameter is valid only for upgrades or rollbacks. | Yes | + | `sysconfigs` | / | Configuration settings | 1. When `opstype` is `config`, only configuration is performed.
2. When `opstype` is `upgrade/rollback`, it indicates post-upgrade/rollback configuration, meaning it takes effect after the upgrade/rollback and subsequent reboot. For detailed field descriptions, see the [Settings](#settings). | Required when `opstype` is `config` | + | `upgradeconfigs`| / | Configuration settings to apply before an upgrade. | This parameter is valid for upgrades or rollbacks and takes effect before the upgrade or rollback operation. For detailed field descriptions, see the [Settings](#settings). | Optional | + | `nodeselector` | string | Label of the nodes targeted for the upgrade/configuration/rollback | This parameter is used to perform operations on nodes with specific labels, rather than all worker nodes in the cluster. The nodes targeted for the operation need to have a label with the `upgrade.openeuler.org/node-selector` key. The `nodeselector` parameter should be set to the value of this label. **Notes:** 1. When this parameter is not set or is set to `no-label`, operations are performed on nodes that do not have the `upgrade.openeuler.org/node-selector` label.
2. When this parameter is set to `""` (an empty string), operations are performed on nodes that have the `upgrade.openeuler.org/node-selector=""` label.
3. To ignore labels and perform operations on all nodes, set this parameter to `all-label`. | Optional | + | `timewindow` | / | Time window during which the upgrade/configuration/rollback can take place. | 1. When specifying a time window, both `starttime` and `endtime` must be specified. That is, they should either both be empty or both be non-empty.
1. Both `starttime` and `endtime` are strings and should be in the `YYYY-MM-DD HH:MM:SS` or `HH:MM:SS` format, and both should follow the same format.
2. When in `HH:MM:SS` format, if `starttime` is less than `endtime`, it is assumed that `starttime` refers to that time on the next day.
3. When `timewindow` is not specified, it defaults to no time window restrictions. | Optional | + | `timeinterval` | int | The time interval between each batch of tasks for the upgrade/configuration/rollback operation. | This parameter is in seconds and defines the time interval between the operator dispatching tasks. If the Kubernetes cluster is busy and cannot immediately respond to the operator's request, the actual interval may be longer than the specified time. | Optional | + | `executionmode` | string | The mode in which the upgrade/configuration/rollback operation is executed. | The value can be `serial` or `parallel`. If this parameter is not set, the operation defaults to parallel mode. | Optional | ## Upgrade -Create a custom object of the OS type in the cluster and set the corresponding fields. The OS type comes from the CRD object created in the installation and deployment sections. The following table describes the fields. - -| Parameter |Type | Description | How to Use| Mandatory (Yes/No) | -| -------------- | ------ | ------------------------------------------------------------ | ----- | ---------------- | -| imagetype | string | Type of the upgrade image | The value must be `docker` or `disk`. Other values are invalid. This parameter is valid only in upgrade scenarios.|Yes | -| opstype | string | Operation, that is, upgrade or rollback| The value must be `upgrade` or `rollback`. Other values are invalid.|Yes | -| osversion | string | OS version of the image used for upgrade or rollback | The value must be a KubeOS version, for example, `KubeOS 1.0.0`.|Yes | -| maxunavailable | int | Number of nodes to be upgraded or rolled back at the same time| If the value of `maxunavailable` is greater than the actual number of nodes in the cluster, the deployment can be performed. The upgrade or rollback is performed based on the actual number of nodes in the cluster.|Yes | -| dockerimage | string | Docker image used for upgrade | The value must be in the *repository/name:tag* format. This parameter is valid only when the Docker image is used for upgrade.|Yes | -| imageurl | string | Address of the disk image used for the upgrade| `imageurl` contains the protocol and only HTTP or HTTPS is supported. For example, `https://192.168.122.15/update.img` is valid only when a disk image is used for upgrade.|Yes | -| checksum | string | Checksum (SHA-256) value for disk image verification during the upgrade. | This parameter is valid only when a disk image is used for upgrade.|Yes | -| flagSafe | bool | Whether `imageurl` specifies a secure HTTP address | The value must be `true` or `false`. This parameter is valid only when `imageurl` specifies an HTTP address.|Yes | -| mtls | bool | Whether HTTPS two-way authentication is used for the connection to the `imageurl` address. | The value must be `true` or `false`. This parameter is valid only when `imageurl` specifies an HTTPS address.|Yes | -| cacert | string | Root certificate file used for HTTPS or HTTPS two-way authentication | This parameter is valid only when `imageurl` specifies an HTTPS address.| This parameter is mandatory when `imageurl` specifies an HTTPS address.| -| clientcert | string | Client certificate file used for HTTPS two-way authentication | This parameter is valid only when HTTPS two-way authentication is used.|This parameter is mandatory when `mtls` is set to `true`.| -| clientkey | string | Client public key used for HTTPS two-way authentication | This parameter is valid only when HTTPS two-way authentication is used.|This parameter is mandatory when `mtls` is set to `true`.| - -The address specified by `imageurl` contains the protocol. Only the HTTP or HTTPS protocol is supported. If `imageurl` is set to an HTTPS address, secure transmission is used. If `imageurl` is set to an HTTP address, set `flagSafe` to `true`, because the image can be downloaded only when the address is secure. If `imageurl` is set to an HTTP address but `flagSafe` is not set to `true`, the address is insecure by default. The image will not be downloaded, and a message is written to the log of the node to be upgraded indicating that the address is insecure. - -You are advised to set `imageurl` to an HTTPS address. In this case, ensure that the required certificate has been installed on the node to be upgraded. If the image server is maintained by yourself, you need to sign the certificate and ensure that the certificate has been installed on the node to be upgraded. Place the certificate in the **/etc/KubeOS/certs** directory of KubeOS. The administrator specifies the address and must ensure the security of the address. An intranet address is recommended. - -The container OS image provider must check the validity of the image to ensure that the downloaded container OS image is from a reliable source. - -Compile the YAML file for deploying the OS as a custom resource (CR) instance in the cluster. The following is an example YAML file for deploying the CR instance: - -- Upgrade using a disk image - - ``` - apiVersion: upgrade.openeuler.org/v1alpha1 - kind: OS - metadata: - name: os-sample - spec: - imagetype: disk - opstype: upgrade - osversion: edit.os.version - maxunavailable: edit.node.upgrade.number - dockerimage: "" - imageurl: edit.image.url - checksum: image.checksum - flagSafe: imageurl.safety - mtls: imageurl use mtls or not - cacert: ca certificate - clientcert: client certificate - clientkey: client certificate key - ``` - -- Upgrade using a Docker image - - ``` shell - apiVersion: upgrade.openeuler.org/v1alpha1 - kind: OS - metadata: - name: os-sample - spec: - imagetype: docker - opstype: upgrade - osversion: edit.os.version - maxunavailable: edit.node.upgrade.number - dockerimage: dockerimage like repository/name:tag - imageurl: "" - checksum: "" - flagSafe: false - mtls: true - ``` - - Before using a Docker image to perform the upgrade, create the image first. For details about how to create a Docker image, see **KubeOS Image Creation**. - -Assume that the YAML file is **upgrade_v1alpha1_os.yaml**. - -Check the OS version of the node that is not upgraded. - -``` -kubectl get nodes -o custom-columns='NAME:.metadata.name,OS:.status.nodeInfo.osImage' -``` - -Run the following command to deploy the CR instance in the cluster. The node is upgraded based on the configured parameters. - -``` -kubectl apply -f upgrade_v1alpha1_os.yaml -``` - -Check the node OS version again to determine whether the node upgrade is complete. - -``` -kubectl get nodes -o custom-columns='NAME:.metadata.name,OS:.status.nodeInfo.osImage' -``` - -> ![](./public_sys-resources/icon-note.gif)**NOTE**: -> -> If you need to perform the upgrade again, modify the `imageurl`, `osversion`, `checksum`, `maxunavailable`, `flagSafe`, or `dockerimage` parameters in **upgrade_v1alpha1_os.yaml**. - -## Rollback - -### Application Scenarios +1. Create a YAML file and deploy an instance of the OS Custom Resource (CR) in the cluster. This YAML file defines the upgrade process. The following example assumes you save the YAML content to **upgrade_v1alpha1_os.yaml**. + + - Upgrade using a drive image + + ```yaml + apiVersion: upgrade.openeuler.org/v1alpha1 + kind: OS + metadata: + name: os-sample + spec: + imagetype: disk + opstype: upgrade + osversion: edit.os.version + maxunavailable: edit.node.upgrade.number + containerimage: "" + evictpodforce: true/false + imageurl: edit.image.url + checksum: image.checksum + flagSafe: imageurl.safety + mtls: imageurl use mtls or not + cacert: ca certificate + clientcert: client certificate + clientkey: client certificate key + ``` + + - Upgrade using a container image + - Before you can upgrade using a container image, you need to create a container image specifically for the upgrade process. For detailed instructions on how to create this image, see [KubeOS OCI 镜像制作](./kubeos-image-creation.md#creating-a-kubeos-oci-image) in [KubeOS Image Creation](./kubeos-image-creation.md). + + ``` yaml + apiVersion: upgrade.openeuler.org/v1alpha1 + kind: OS + metadata: + name: os-sample + spec: + imagetype: docker + opstype: upgrade + osversion: edit.os.version + maxunavailable: edit.node.upgrade.number + containerimage: container image like repository/name:tag + evictpodforce: true/false + imageurl: "" + checksum: container image digests + flagSafe: false + mtls: true + ``` + + - Using containerd as the container engine + + ```yaml + apiVersion: upgrade.openeuler.org/v1alpha1 + kind: OS + metadata: + name: os-sample + spec: + imagetype: containerd + opstype: upgrade + osversion: edit.os.version + maxunavailable: edit.node.upgrade.number + containerimage: container image like repository/name:tag + evictpodforce: true/false + imageurl: "" + checksum: container image digests + flagSafe: false + mtls: true + ``` + + - Example of upgrading and applying configurations + - This example uses containerd as the container engine. The upgrade method does not affect the configuration process. `upgradeconfigs` are applied before the upgrade. `sysconfigs` are applied after the machine reboots from the upgrade. See [Settings](#settings) for detailed information about the configuration parameters. + - When upgrading and configuring, set the `opstype` field to `upgrade`. + + ```yaml + apiVersion: upgrade.openeuler.org/v1alpha1 + kind: OS + metadata: + name: os-sample + spec: + imagetype: "" + opstype: upgrade + osversion: edit.os.version + maxunavailable: edit.node.upgrade.number + containerimage: "" + evictpodforce: true/false + imageurl: "" + checksum: container image digests + flagSafe: false + mtls: false + sysconfigs: + version: edit.os.version + configs: + - model: kernel.sysctl + contents: + - key: kernel param key1 + value: kernel param value1 + - key: kernel param key2 + value: kernel param value2 + - model: kernel.sysctl.persist + configpath: persist file path + contents: + - key: kernel param key3 + value: kernel param value3 + - key: "" + value: "" + upgradeconfigs: + version: 1.0.0 + configs: + - model: kernel.sysctl + contents: + - key: kernel param key4 + value: kernel param value4 + ``` + + - Example of upgrading specific nodes using `nodeselector`, `timewindow`, `timeinterval`, and `executionmode` + - This example uses containerd as the container engine. The upgrade method does not affect node selection. + - Nodes targeted for upgrade must include the `upgrade.openeuler.org/node-selector` label. The value of `nodeselector` in the YAML file should match the value of this label on the desired nodes. For example, if `nodeselector` is set to `kubeos`, only worker nodes with the `upgrade.openeuler.org/node-selector=kubeos` label will be upgraded. + - `nodeselector`, `timewindow`, `timeinterval`, and `executionmode` are also applicable to configuration and rollback operations. + - Example commands for managing node labels: + + ``` shell + # Add a label to node kubeos-node1 + kubectl label nodes kubeos-node1 upgrade.openeuler.org/node-selector=kubeos-v1 + # Modify the label of node kubeos-node1 + kubectl label --overwrite nodes kubeos-node1 upgrade.openeuler.org/node-selector=kubeos-v2 + # Delete the label from node kubeos-node1 + kubectl label nodes kubeos-node1 upgrade.openeuler.org/node-selector- + # View the labels of all nodes + kubectl get nodes --show-labels + ``` + + - Example YAML file: + + ```yaml + apiVersion: upgrade.openeuler.org/v1alpha1 + kind: OS + metadata: + name: os-sample + spec: + imagetype: containerd + opstype: upgrade + osversion: edit.os.version + maxunavailable: edit.node.upgrade.number + containerimage: container image like repository/name:tag + evictpodforce: true/false + imageurl: "" + checksum: container image digests + flagSafe: false + mtls: true + nodeselector: edit.node.label.key + timewindow: + starttime: "HH::MM::SS/YYYY-MM-DD HH::MM::SS" + endtime: "HH::MM::SS/YYYY-MM-DD HH::MM::SS" + timeinterval: time intervel like 30 + executionmode: serial/parallel + ``` + +2. Check the OS version of nodes that have not been upgraded. + + ```shell + kubectl get nodes -o custom-columns='NAME:.metadata.name,OS:.status.nodeInfo.osImage' + ``` -- If a node cannot be started, you can only manually roll back the container OS to the previous version that can be properly started. -- If a node can be started and run the system, you can manually or use KubeOS (similar to the upgrade) to roll back the container OS. You are advised to use KubeOS. +3. Deploy the CR instance in the cluster. Nodes will be upgraded based on the parameters specified in the YAML file. -### Manual Rollback + ```shell + kubectl apply -f upgrade_v1alpha1_os.yaml + ``` -Manually restart the node and select the second boot option to roll back the container OS. Manual rollback can only roll back the container OS to the version before the upgrade. +4. Check the OS version of the nodes again to confirm if the upgrade is complete. -### KubeOS-based Rollback + ```shell + kubectl get nodes -o custom-columns='NAME:.metadata.name,OS:.status.nodeInfo.osImage' + ``` -- Roll back to any version. - - Modify the YAML configuration file (for example, **upgrade_v1alpha1_os.yaml**) of the CR instance of the OS and set the corresponding fields to the image information of the target source version. The OS type comes from the CRD object created in the installation and deployment sections. For details about the fields and examples, see the previous section. +5. If you need to perform the upgrade again, modify the corresponding fields in **upgrade_v1alpha1_os.yaml**. - - After the YAML is modified, run the update command. After the custom object is updated in the cluster, the node performs rollback based on the configured field information. +> ![](./public_sys-resources/icon-note.gif)**Note:** +> +> If you need to perform the upgrade again, modify the `imageurl`, `osversion`, `checksum`, `maxunavailable`, `flagSafe`, or `dockerimage` parameters in **upgrade_v1alpha1_os.yaml**. - ``` - kubectl apply -f upgrade_v1alpha1_os.yaml - ``` +## Settings -- Roll back to the previous version. +- Settings parameters - - Modify the **upgrade_v1alpha1_os.yaml** file. Set **osversion** to the previous version and **opstype** to **rollback** to roll back to the previous version (that is, switch to the previous partition). Example YAML: + This section describes the configuration parameters using an example YAML file. Your configuration should follow the same indentation as the example: - ``` + ```yaml apiVersion: upgrade.openeuler.org/v1alpha1 kind: OS metadata: - name: os-sample + name: os-sample spec: - imagetype: "" - opstype: rollback - osversion: KubeOS pervious version - maxunavailable: 2 - dockerimage: "" - imageurl: "" - checksum: "" - flagSafe: false - mtls:true + imagetype: "" + opstype: config + osversion: edit.os.version + maxunavailable: edit.node.config.number + containerimage: "" + evictpodforce: false + checksum: "" + sysconfigs: + version: edit.sysconfigs.version + configs: + - model: kernel.sysctl + contents: + - key: kernel param key1 + value: kernel param value1 + - key: kernel param key2 + value: kernel param value2 + operation: delete + - model: kernel.sysctl.persist + configpath: persist file path + contents: + - key: kernel param key3 + value: kernel param value3 + - model: grub.cmdline.current + contents: + - key: boot param key1 + - key: boot param key2 + value: boot param value2 + - key: boot param key3 + value: boot param value3 + operation: delete + - model: grub.cmdline.next + contents: + - key: boot param key4 + - key: boot param key5 + value: boot param value5 + - key: boot param key6 + value: boot param value6 + operation: delete ``` - - After the YAML is modified, run the update command. After the custom object is updated in the cluster, the node performs rollback based on the configured field information. + Configuration parameters + + | Parameter | Type | Description | Usage Note | Mandatory | + | ---------- | -------- | --------------------------- | ------------------------------------------------------------ | ----------------------- | + | `version` | string | Configuration version | This parameter determines if the configuration should be applied by comparing versions. If `version` is empty (`""` or not set), the comparison will still be performed. Therefore, if `sysconfigs` or `upgradeconfigs` is not configured, the existing `version` will be cleared, triggering the configuration. | Yes | + | `configs` | / | Specific configuration content | This parameter contains a list of specific configuration items. | Yes | + | `model` | string | Configuration type | See the [Settings List](#settings-list) in the appendix for supported configuration types. | Yes | + | `configpath` | string | Configuration file path | This parameter is only effective for the `kernel.sysctl.persist` configuration type. See the [Settings List](#settings-list) in the appendix for the description of the configuration file path. | No | + | `contents` | / | Specific key/value pairs and operation type | This parameter contains a list of specific configuration items. | Yes | + | `key` | string | Parameter name | `key` cannot be empty or contain `=`. You are advised not to configure strings containing spaces or tabs. For specific usage of `key` for each configuration type, see the [Settings List](#settings-list) in the appendix. | Yes | + | `value` | string | Parameter value | `value` cannot be empty for parameters in the `key=value` format. You are advised not to configure strings containing spaces or tabs. For specific usage of `value` for each configuration type, see the [Settings List](#settings-list) in the appendix. | Required for parameters in the `key=value` format | + | `operation` | string | Operation to be performed on the parameter | This parameter is only effective for `kernel.sysctl.persist`, `grub.cmdline.current`, and `grub.cmdline.next` parameter types. The default behavior is to add or update. The value can only be `delete`, which means deleting the existing parameter (the `key=value` must match exactly for deletion). | No | + - `upgradeconfigs` has the same parameters as `sysconfigs`. `upgradeconfigs` is for configuration before upgrade/rollback and only takes effect in upgrade/rollback scenarios. `sysconfigs` supports both configuration only and configuration after upgrade/rollback reboot. + +- Usage + + 1. Create a YAML file like the **upgrade_v1alpha1_os.yaml** example above and deploy the OS CR instance in the cluster. + + 2. Check the configuration version and node status before applying the configuration (`NODESTATUS` should be `idle`). + + ```shell + kubectl get osinstances -o custom-columns='NAME:.metadata.name,NODESTATUS:.spec.nodestatus,SYSCONFIG:status.sysconfigs.version,UPGRADECONFIG:status.upgradeconfigs.version' + ``` + + 3. Apply the configuration, then check the node status again (`NODESTATUS` should change to `config`). + + ```shell + kubectl apply -f upgrade_v1alpha1_os.yaml + kubectl get osinstances -o custom-columns='NAME:.metadata.name,NODESTATUS:.spec.nodestatus,SYSCONFIG:status.sysconfigs.version,UPGRADECONFIG:status.upgradeconfigs.version' + ``` + + 4. Check the node configuration version again to confirm whether the configuration is complete (`NODESTATUS` should return to `idle`): + + ```shell + kubectl get osinstances -o custom-columns='NAME:.metadata.name,NODESTATUS:.spec.nodestatus,SYSCONFIG:status.sysconfigs.version,UPGRADECONFIG:status.upgradeconfigs.version' + ``` + +- If you need to perform the configuration again, modify the corresponding fields in **upgrade_v1alpha1_os.yaml**. + +## Rollback + +- Scenarios + - When a VM fails to start, you can manually select the previous version from the GRUB boot menu. This method only supports rollback to the previous version. + - When a VM starts successfully and you can access the system, you can use the rollback tool (recommended) or manually select the previous version from the GRUB boot menu. + - You can use the rollback tool in two ways: + 1. Rollback mode: reverts to the previous version. + 2. Upgrade mode: re-upgrades to the previous version. +- Manual rollback instructions + - Restart the VM and select the second boot option in the GRUB boot menu to roll back to the previous version. +- Rollback tool instructions + - Rolling back to any version + 1. Modify the YAML configuration file of the OS CR instance (for example, **upgrade_v1alpha1_os.yaml**). Set the relevant fields to the image information of the desired version. The OS category originates from the CRD object created in the installation and deployment document. Refer to the upgrade instructions in the previous section for field descriptions and examples. + + 2. After modifying the YAML file, execute the update command. Nodes will then roll back according to the configured field information. + + ```shell + kubectl apply -f upgrade_v1alpha1_os.yaml + ``` + + - Rolling back to the previous version + - To roll back to the previous OS version, modify the **upgrade_v1alpha1_os.yaml** file. Set `osversion` to the previous version and `opstype` to `rollback` to roll back to the previous version (that is, switch to the previous partition). Example YAML file: + + ```yaml + apiVersion: upgrade.openeuler.org/v1alpha1 + kind: OS + metadata: + name: os-sample + spec: + imagetype: "" + opstype: rollback + osversion: KubeOS pervious version + maxunavailable: 2 + containerimage: "" + evictpodforce: true/false + imageurl: "" + checksum: "" + flagSafe: false + mtls: true + ``` + + - To roll back to the previous configuration version (note that already configured parameters cannot be rolled back), modify the `upgrade_v1alpha1_os.yaml` file. Set `version` of `sysconfigs/upgradeconfigs` to the previous version. Example YAML file: + + ```yaml + apiVersion: upgrade.openeuler.org/v1alpha1 + kind: OS + metadata: + name: os-sample + spec: + imagetype: "" + opstype: config + osversion: edit.os.version + maxunavailable: edit.node.config.number + containerimage: "" + evictpodforce: true/false + imageurl: "" + checksum: "" + flagSafe: false + mtls: false + sysconfigs: + version: previous config version + configs: + - model: kernel.sysctl + contents: + - key: kernel param key1 + value: kernel param value1 + - key: kernel param key2 + value: kernel param value2 + - model: kernel.sysctl.persist + configpath: persist file path + contents: + - key: kernel param key3 + value: kernel param value3 + ``` + + 3. After modifying the YAML file and executing the update command, the nodes will roll back based on the configured information. + + ```shell + kubectl apply -f upgrade_v1alpha1_os.yaml + ``` + + 4. Verify that the rollback was successful. + - To check the container OS version (for OS version rollback), verify container OS version of the node. + - To check the configuration version (for configuration rollback), verify the node configuration version and that the node status is `idle`. + + ```shell + kubectl get osinstances -o custom-columns='NAME:.metadata.name,NODESTATUS:.spec.nodestatus,SYSCONFIG:status.sysconfigs.version,UPGRADECONFIG:status.upgradeconfigs.version' + ``` + +## Appendixes + +### Settings List + +#### kernel Settings + +- `kernel.sysctl`: temporarily sets kernel parameters. These settings will be lost after a reboot. The key/value pairs represent key/value pairs of kernel parameters. Both keys and values cannot be empty. Keys cannot contain the `=` character. The value of `operation` cannot be `delete`. Example: + + ```yaml + configs: + - model: kernel.sysctl + contents: + - key: user.max_user_namespaces + value: 16384 + - key: net.ipv4.tcp_tw_recycle + value: 0 + operation: delete ``` - kubectl apply -f upgrade_v1alpha1_os.yaml + +- `kernel.sysctl.persist`: sets persistent kernel parameters that will be retained after a reboot. The key/value pairs represent key/value pairs of kernel parameters. Both keys and values cannot be empty. Keys cannot contain the `=` character. `configpath` specifies the path to the configuration file, which can be a new file (given that the parent directory exists). If not specified, it defaults to **/etc/sysctl.conf**. Example: + + ```yaml + configs: + - model: kernel.sysctl.persist + configpath : /etc/persist.conf + contents: + - key: user.max_user_namespaces + value: 16384 + - key: net.ipv4.tcp_tw_recycle + value: 0 + operation: delete ``` - After the update is complete, the node rolls back the container OS based on the configuration information. +#### GRUB Settings + +- `grub.cmdline.current/next`: sets the kernel boot parameters in the **grub.cfg** file. These parameters appear on the line resembling the following example in **grub.cfg**: -- Check the OS version of the container on the node to determine whether the rollback is successful. + ```text + linux /boot/vmlinuz root=/dev/sda2 ro rootfstype=ext4 nomodeset quiet oops=panic softlockup_panic=1 nmi_watchdog=1 rd.shell=0 selinux=0 crashkernel=256M panic=3 + ``` - ``` - kubectl get nodes -o custom-columns='NAME:.metadata.name,OS:.status.nodeInfo.osImage' - ``` + - The `grub.cmdline.current/next` settings allow configuration for either the current or the next partition: + + - `grub.cmdline.current`: Configures the boot parameters for the current partition. + - `grub.cmdline.next`: Configures the boot parameters for the next partition. + + - Note: During upgrades/rollbacks, the `current` and `next` partition designations in the configuration (`sysconfigs`) are determined at the time the upgrade/rollback operation is initiated. For instance, if the current partition is `A` and an upgrade is initiated with `grub.cmdline.current` configured in `sysconfigs`, the configuration will still be applied to partition `A` after the reboot, even though it may no longer be the `current` partition. + + - `grub.cmdline.current/next` supports both `key=value` (where `value` cannot be empty) and single `key` formats. If `value` contains an equal sign (for example, `root=UUID=some-uuid`), `key` should be set to all characters before the first `=` and `value` should be set to all characters after the first `=`. Example: + + ```yaml + configs: + - model: grub.cmdline.current + contents: + - key: selinux + value: "0" + - key: root + value: UUID=e4f1b0a0-590e-4c5f-9d8a-3a2c7b8e2d94 + - key: panic + value: "3" + operation: delete + - key: crash_kexec_post_notifiers + - model: grub.cmdline.next + contents: + - key: selinux + value: "0" + - key: root + value: UUID=e4f1b0a0-590e-4c5f-9d8a-3a2c7b8e2d94 + - key: panic + value: "3" + operation: delete + - key: crash_kexec_post_notifiers + ``` diff --git a/docs/en/docs/SecHarden/file-permissions.md b/docs/en/docs/SecHarden/file-permissions.md index 62925c84449cc2c3bf75485b33abf4ee47206147..eaee0cb7a3f59b3cb970a7bf89d015934f036e16 100644 --- a/docs/en/docs/SecHarden/file-permissions.md +++ b/docs/en/docs/SecHarden/file-permissions.md @@ -221,7 +221,7 @@ The **cron** command is used to create a routine task. Users who can run the ### Description -A common user can use the **sudo** command to run commands as the user **root**. To harden system security, it is necessary to restrict permissions on the **sudo** command. Only user **root** can use the **sudo** command. By default, openEuler does not retrict the permission of non-root users to run the sudo command. +A common user can use the **sudo** command to run commands as the user **root**. To harden system security, it is necessary to restrict permissions on the **sudo** command. Only user **root** can use the **sudo** command. By default, openEuler does not restrict the permission of non-root users to run the sudo command. ### Implementation diff --git a/docs/en/docs/StratoVirt/VM_configuration.md b/docs/en/docs/StratoVirt/VM_configuration.md index b705276e53e7a8c4758e91f4045098953238419f..72170ecfb81206f635507287db1746cbcdf6e040 100644 --- a/docs/en/docs/StratoVirt/VM_configuration.md +++ b/docs/en/docs/StratoVirt/VM_configuration.md @@ -679,8 +679,8 @@ This section provides an example of the minimum configuration for creating a sta $ /path/to/stratovirt \ -kernel /path/to/vmlinux.bin \ -append console=ttyAMA0 root=/dev/vda rw reboot=k panic=1 \ - -drive file=/path/to/code_storage_file,if=pflash,unit=0[,readonly=true] \ - -drive file=/path/to/data_storage_file,if=pfalsh,unit=1, \ + -drive file=/path/to/edk2/code_storage_file,if=pflash,unit=0[,readonly=true] \ + -drive file=/path/to/edk2/data_storage_file,if=pflash,unit=1, \ -drive file=/home/rootfs.ext4,id=rootfs,readonly=false \ -device virtio-blk-device,drive=rootfs,bus=pcie.0,addr=0x1 \ -qmp unix:/tmp/stratovirt.socket,server,nowait \ diff --git a/docs/en/docs/Virtualization/Skylark.md b/docs/en/docs/Virtualization/Skylark.md index b844683707094f67ee57b094595aa48cb9612b3d..6528aeb5c97d4aa7970e868557bfef731c6ecd8d 100644 --- a/docs/en/docs/Virtualization/Skylark.md +++ b/docs/en/docs/Virtualization/Skylark.md @@ -127,7 +127,7 @@ After the Skylark component is installed, you can modify the configuration file Skylark's interference control on LLC/MB depends on the RDT/MPAM function provided by hardware. For Intel x86_64 processors, **rdt=cmt,mbmtotal,mbmlocal,l3cat,mba** needs to be added to kernel command line parameters. For Kunpeng920 processors, **mpam=acpi** needs to be added to kernel command line parameters. -- **MIN_LLC_WAYS_LOW_VMS** is an integer used to control the number of LLC ways that can be accessed by low-priority VMs. The value ranges from 1 to 3, with the default value being 2. During initialization, Skylark limits the numfer of accessible LLC ways for low-priority VMs to this value. +- **MIN_LLC_WAYS_LOW_VMS** is an integer used to control the number of LLC ways that can be accessed by low-priority VMs. The value ranges from 1 to 3, with the default value being 2. During initialization, Skylark limits the number of accessible LLC ways for low-priority VMs to this value. - **MIN_MBW_LOW_VMS** is a floating point number used to control the memory bandwidth ratio available to low-priority VMs. The value ranges from 0.1 to 0.2, with the default value being 0.1. Skylark limits the memory bandwidth of low-priority VMs based on this value during initialization. diff --git a/docs/en/docs/Virtualization/environment-preparation.md b/docs/en/docs/Virtualization/environment-preparation.md index b9c39a0897156e257aca2b00c1e628b2fb393ce5..60e4deb98481479f30484321e76b7569e079e845 100644 --- a/docs/en/docs/Virtualization/environment-preparation.md +++ b/docs/en/docs/Virtualization/environment-preparation.md @@ -110,9 +110,6 @@ To enable the VM to communicate with external networks, you need to configure th This section describes how to set up a Linux bridge and an Open vSwitch bridge to connect a VM to the network. You can select a bridge type based on the site requirements. -**Figure 1** Virtual network structure -![](./figures/virtual-network-structure.png "virtual-network-structure") - ### Setting Up a Linux Bridge The following describes how to bind the physical NIC eth0 to the Linux bridge br0. @@ -245,6 +242,10 @@ The following describes how to set up an Open vSwitch layer-1 bridge br0. ``` 4. Assign an IP address to OVS bridge br0. + + > ![](./public_sys-resources/icon-note.gif) **illustrate:** + > + > If you use DHCP to set a dynamic IP address for br0, you need to clear the existing dynamic IP address. Run the dhclient -r command to clear the possible dynamic IP addresses. - If a DHCP server is available, set a dynamic IP address through the dhclient. ```shell diff --git a/docs/en/docs/desktop/Gnome_userguide.md b/docs/en/docs/desktop/Gnome_userguide.md index a18db4f7bd5820047eb680dd25da7f9e9e412f0f..ac254c0a8dcdf5e7835ff71fd7fc6bfa31cac351 100644 --- a/docs/en/docs/desktop/Gnome_userguide.md +++ b/docs/en/docs/desktop/Gnome_userguide.md @@ -90,7 +90,7 @@ If there are so many apps and you know their names, you can enter an app name in #### 3.1.3 List of Active Apps -Active apps, that is, running apps are displayed one by one after the last app in **Favorites**. There is a white dot under each active app. +Active apps, that is, running apps are displayed one by one after the last app in **Favorites**. There is a white dot under the icon of each active app. ![](./figures/gnome-8.PNG) diff --git a/docs/en/docs/memsafety/utshell/utshell_guide.md b/docs/en/docs/memsafety/utshell/utshell_guide.md index 77f6d2ed3b85610ea8acc2fd3fbb33e64c210fd0..b722699436ab3eda88c54ef1460d2cefbf8addd8 100644 --- a/docs/en/docs/memsafety/utshell/utshell_guide.md +++ b/docs/en/docs/memsafety/utshell/utshell_guide.md @@ -181,7 +181,7 @@ done **{1..500..2}** indicates that the start number is 1, the end number is 500 (included), and the step is 2. -#### util +#### until ```shell until [condition]; do diff --git a/docs/en/docs/oeDeploy/Introduction.md b/docs/en/docs/oeDeploy/Introduction.md new file mode 100644 index 0000000000000000000000000000000000000000..aa9d11c0507f077a68f3000b7eac810808bb5f22 --- /dev/null +++ b/docs/en/docs/oeDeploy/Introduction.md @@ -0,0 +1,3 @@ +# Introduction + +The current document has not been written yet. Please refer to the [Chinese document](../../../zh/docs/oeDeploy/Introduction.md). diff --git a/docs/en/docs/ops_guide/information-collection.md b/docs/en/docs/ops_guide/information-collection.md index 2f2c8d036bfc55d89e966667e1d56a683140416d..3b2d7e31a29bed9e79c94851e82a155c547459ea 100644 --- a/docs/en/docs/ops_guide/information-collection.md +++ b/docs/en/docs/ops_guide/information-collection.md @@ -115,7 +115,7 @@ 4. View the file list of a software package. ```shell - rpm -ql python3-rpm # (python3-rpm is used as an emple.) + rpm -ql python3-rpm # (python3-rpm is used as an example.) ``` ## Viewing OS Logs diff --git a/docs/en/docs/secGear/introduction-to-secGear.md b/docs/en/docs/secGear/introduction-to-secGear.md index aa0bc3a4db74c44bdcc2b3fcaf777e1070e79c41..04faa00a5345a2b85a4e0b92b938a231b8f3b5c9 100644 --- a/docs/en/docs/secGear/introduction-to-secGear.md +++ b/docs/en/docs/secGear/introduction-to-secGear.md @@ -34,14 +34,15 @@ Switchless is a technology that uses shared memory to reduce the number of conte ```c typedef struct { - uint32_t num_uworkers; - uint32_t num_tworkers; - uint32_t switchless_calls_pool_size; - uint32_t retries_before_fallback; - uint32_t retries_before_sleep; - uint32_t parameter_num; - uint32_t workers_policy; - uint32_t rollback_to_common; + uint32_t num_uworkers; + uint32_t num_tworkers; + uint32_t switchless_calls_pool_size; + uint32_t retries_before_fallback; + uint32_t retries_before_sleep; + uint32_t parameter_num; + uint32_t workers_policy; + uint32_t rollback_to_common; + cpu_set_t num_cores; } cc_sl_config_t; ``` @@ -55,8 +56,9 @@ Switchless is a technology that uses shared memory to reduce the number of conte | parameter_num | Maximum number of parameters supported by a switchless function. This field takes effect only on the Arm platform.
Specifications:
Arm: maximum value: **16**; minimum value: **0**.| | workers_policy | Running mode of the switchless proxy thread. This field takes effect only on the Arm platform.
Specifications:
Arm:
**WORKERS_POLICY_BUSY**: The proxy thread always occupies CPU resources regardless of whether there are tasks to be processed. This mode applies to scenarios that require high performance and extensive system software and hardware resources.
**WORKERS_POLICY_WAKEUP**: The proxy thread wakes up only when there is a task. After the task is processed, the proxy thread enters the sleep state and waits to be woken up by a new task.| | rollback_to_common | Whether to roll back to a common call when an asynchronous switchless call fails. This field takes effect only on the Arm platform.
Specifications:
Arm:
**0**: No. If the operation fails, only the error code is returned.
Other values: Yes. If the operation fails, an asynchronous switchless call is rolled back to a common call and the return value of the common call is returned.| + | num_cores | Cores for binding processes in the REE. The maximum value is number of CPU cores. | -2. Add the **transition_using_threads** flag when defining the API in the enclave description language (EDL) file. +1. Add the **transition_using_threads** flag when defining the API in the enclave description language (EDL) file. ```ocaml enclave { @@ -82,7 +84,8 @@ A secure channel is a technology that combines confidential computing remote att #### How to Use -The secure channel is provided as a library and consists of the client, host, and enclave, which are icalled by the client, server client application (CA), and server trusted application (TA) of the service program respectively. +The secure channel is provided as a library and consists of the client, host, and enclave, which are called by the client, server client application (CA), and server trusted application (TA) of the service program respectively. + | Module | Header File | Library File | Dependency | |------------|--------------------------|-----------------------|---------| | Client | secure_channel_client.h | libcsecure_channel.so | OpenSSL| @@ -110,10 +113,54 @@ The secure channel is provided as a library and consists of the client, host, an A secure channel encapsulates only the key negotiation process and encryption and decryption APIs, but does not establish any network connection. The negotiation process reuses the network connection of the service. The network connection between the client and server is established and maintained by the service. The message sending hook function and network connection pointer are transferred during the initialization of the secure channel on the client and the server. For details, see [secure channel examples](https://gitee.com/openeuler/secGear/tree/master/examples/secure_channel). +## Remote Attestation + +### Customer Pain Points + +With the development of confidential computing technology, several mainstream technologies have emerged, including Arm TrustZone/CCA, Intel SGX/TDX, QingTian Enclave, and Hygon CSV. Product solutions may involve multiple confidential computing hardware and even collaboration between different TEEs. Remote attestation is a crucial part of the trust chain for any confidential computing technology. However, each technology has its own format for remote attestation reports and verification processes. Users need to integrate different verification processes for different TEE attestation reports, which increases integration burdens and hinders the expansion of new TEE types. + +### Solution + +The unified remote attestation framework of secGear addresses the key components related to remote attestation in confidential computing, abstracting away the differences between different TEEs. It provides two components: attestation agent and attestation service. The agent is integrated by users to obtain attestation reports and connect to the attestation service. The service can be deployed independently and supports the verification of iTrustee and virtCCA remote attestation reports. + +### Features + +The unified remote attestation framework focuses on confidential computing functionalities, while service deployment and operation capabilities are provided by third-party deployment services. The key features of the unified remote attestation framework are as follows: + +- Report verification plugin framework: Supports runtime compatibility with attestation report verification for different TEE platforms, such as iTrustee, virtCCA, and CCA. It also supports the extension of new TEE report verification plugins. +- Certificate baseline management: Supports the management of TCB/TA baseline values and public key certificates for different TEE types. Centralized deployment on the server ensures transparency for users. +- Policy management: Provides default policies for ease of use and customizable policies for flexibility. +- Identity token: Issues identity tokens for different TEEs, endorsed by a third party for mutual authentication between different TEE types. +- Attestation agent: Supports connection to attestation service/peer-to-peer attestation, compatible with TEE report retrieval and identity token verification. It is easy to integrate, allowing users to focus on their service logic. + +Two modes are supported depending on the usage scenario: Peer-to-peer verification and attestation service verification. + +Attestation service verification process: + +1. The user (regular node or TEE) initiates a challenge to the TEE platform. +2. The TEE platform obtains the TEE attestation report through the attestation agent and returns it to the user. +3. The user-side attestation agent forwards the report to the remote attestation service. +4. The remote attestation service verifies the report and returns a unified format identity token endorsed by a third party. +5. The attestation agent verifies the identity token and parses the attestation report verification result. +6. Once the verification passes, a secure connection is established. + +Peer-to-peer verification process (without the attestation service): + +1. The user initiates a challenge to the TEE platform, and the TEE platform returns the attestation report to the user. +2. The user uses a local peer-to-peer TEE verification plugin to verify the report. + +> ![](./public_sys-resources/icon-note.gif) **Note:** +> +> The attestation agents used for peer-to-peer verification and attestation service verification are different. During compilation, the compilation options determine whether to compile attestation agents for attestation service mode or peer-to-peer mode. + +### Application Scenarios + +In scenarios like finance and AI, where confidential computing is used to protect the security of privacy data during runtime, remote attestation is a technical means to verify the legitimacy of the confidential computing environment and applications. secGear provides components that are easy to integrate and deploy, helping users quickly enable confidential computing remote attestation capabilities. + ## Acronyms and Abbreviations | Acronym/Abbreviation| Full Name | -| ------ | ----------------------------- | ---------------- | +| ------ | ----------------------------- | | REE | rich execution environment | | TEE | trusted execution environment| | EDL | enclave description language | diff --git a/docs/en/docs/secGear/secGear-installation.md b/docs/en/docs/secGear/secGear-installation.md index 277cb1631fadc6d29222ca050f03550e413efde8..34d17b1fb4881f7635a1054adb5421298dd45948 100644 --- a/docs/en/docs/secGear/secGear-installation.md +++ b/docs/en/docs/secGear/secGear-installation.md @@ -30,14 +30,14 @@ openEuler 22.03 LTS or later ### Environment Preparation - For details, see [Environment Requirements](https://www.hikunpeng.com/document/detail/en/kunpengcctrustzone/fg-tz/kunpengtrustzone_04_0006.html) and [Procedure](https://www.hikunpeng.com/document/detail/en/kunpengcctrustzone/fg-tz/kunpengtrustzone_04_0007.html) on the Kunpeng official website. +For details, see [Environment Requirements](https://www.hikunpeng.com/document/detail/en/kunpengcctrustzone/fg-tz/kunpengtrustzone_20_0018.html) and [Procedure](https://www.hikunpeng.com/document/detail/en/kunpengcctrustzone/fg-tz/kunpengtrustzone_20_0019.html) on the Kunpeng official website. ### Installation 1. Configure the openEuler Yum source. You can configure an online Yum source or configure a local Yum source by mounting an ISO file. The following uses openEuler 22.03 LTS as an example. For other versions, use the Yum source of the corresponding version. ```shell - vi openEuler.repo + /etc/yum.repo/openEuler.repo [osrepo] name=osrepo baseurl=http://repo.openeuler.org/openEuler-22.03-LTS/everything/aarch64/ @@ -103,10 +103,10 @@ Purchase a device that supports the Intel SGX feature and enable the SGX feature ```shell #Install the compiler. yum install cmake ocaml-dune - + #Install secGear. yum install secGear-devel - + #Check whether the installations are successful. If the command output is as follows, the installations are successful. rpm -qa | grep -E 'secGear|ocaml-dune|sgx' secGear-xxx diff --git "a/docs/zh/docs/A-Ops/AOps\351\203\250\347\275\262\346\214\207\345\215\227.md" "b/docs/zh/docs/A-Ops/AOps\351\203\250\347\275\262\346\214\207\345\215\227.md" index 56c9f263e3aedae8221bc46ecef9f589496061ee..5857848ccc87962391fa650c355d29a4a559a23c 100644 --- "a/docs/zh/docs/A-Ops/AOps\351\203\250\347\275\262\346\214\207\345\215\227.md" +++ "b/docs/zh/docs/A-Ops/AOps\351\203\250\347\275\262\346\214\207\345\215\227.md" @@ -2,11 +2,11 @@ ## 一、环境要求 -- 2台openEuler 23.09机器 +- 2台openEuler 24.09机器 分别用于部署check模块的两种模式:调度器,执行器。其他服务如mysql、elasticsearch、aops-manager等可在任意一台机器独立部署,为便于操作,将这些服务部署在机器A。 -- 内存尽量为8G+ +- 内存尽量为:8G+ ## 二、配置部署环境 @@ -393,7 +393,7 @@ yum install aops-check vim /etc/aops/check.ini ``` -将配置文件中各服务的地址修改为真实地址,除check服务为机器B的地址外,其他服务都部署在机器A,故需把IP地址配置为机器A的地址即可。 +将配置文件中各服务的地址修改为真实地址,除check服务为机器B的地址外,其他服务都部署在机器A,故只需把IP地址配置为机器A的地址即可。 ```shell [check] @@ -455,4 +455,4 @@ task_group_id=CHECK_TASK_GROUP_ID systemctl start aops-check ``` -至此,两台机器的服务部署完成。 \ No newline at end of file +至此,两台机器的服务部署完成。 diff --git "a/docs/zh/docs/A-Ops/aops-agent\351\203\250\347\275\262\346\214\207\345\215\227.md" "b/docs/zh/docs/A-Ops/aops-agent\351\203\250\347\275\262\346\214\207\345\215\227.md" index da0184bd611a216be79c106127936885d17e2b59..81ec4dec353887f75eacf0b7e9bf027d0e2afc9a 100644 --- "a/docs/zh/docs/A-Ops/aops-agent\351\203\250\347\275\262\346\214\207\345\215\227.md" +++ "b/docs/zh/docs/A-Ops/aops-agent\351\203\250\347\275\262\346\214\207\345\215\227.md" @@ -621,7 +621,7 @@ gala-gopher更多信息可参考文档https://gitee.com/openeuler/gala-gopher/bl } ``` -## FAQ +## 注意事项 1. 若有报错,请查看日志/var/log/aops/aops.log,根据日志中相关报错提示解决问题,并重启服务。 diff --git "a/docs/zh/docs/A-Ops/dnf\346\217\222\344\273\266\345\221\275\344\273\244\346\214\207\345\257\274\346\211\213\345\206\214.md" "b/docs/zh/docs/A-Ops/dnf\346\217\222\344\273\266\345\221\275\344\273\244\346\214\207\345\257\274\346\211\213\345\206\214.md" index a6782b7ac2ecf52c276baec8f94acc8a0fb1fbcd..01fcfba8acffcddc517f437b88a24e881c4b2f4f 100644 --- "a/docs/zh/docs/A-Ops/dnf\346\217\222\344\273\266\345\221\275\344\273\244\346\214\207\345\257\274\346\211\213\345\206\214.md" +++ "b/docs/zh/docs/A-Ops/dnf\346\217\222\344\273\266\345\221\275\344\273\244\346\214\207\345\257\274\346\211\213\345\206\214.md" @@ -227,7 +227,7 @@ command-specific options: Apply hot patch failed: redis-6.2.5-1/HP002. ``` -- Case2: 热补丁未安装时,使用`dnf hotupgrade`命令安装存在的所有热补丁,将显示安装信息。(补充:使用hotupgrade命令时,如果热补丁已安装,会提示case1中的返回信息,如果未安装,则会返回次case中的信息。) +- Case2: 热补丁未安装时,使用`dnf hotupgrade`命令安装存在的所有热补丁,将显示安装信息。(补充:使用hotupgrade命令时,如果热补丁已安装,会提示case1中的返回信息,如果未安装,则会返回本次case中的信息。) ```shell [root@openEuler A-ops]# dnf hotupgrade @@ -320,7 +320,7 @@ command-specific options: ## 使用场景说明 -本段落介绍上述命令的使用场景及顺序介绍,需要提前确认本机的热补丁repo源和相应冷补丁repo源已开启。 +本节介绍上述命令的使用场景和使用顺序,需要提前确认本机的热补丁repo源和相应冷补丁repo源已开启。 使用热补丁扫描命令查看本机待修复cve。 diff --git a/docs/zh/docs/A-Ops/figures/chuangjianyewuyu.png b/docs/zh/docs/A-Ops/figures/chuangjianyewuyu.png index 4f5b8de2d2c4ddb9bfdfba1ac17258a834561e2d..8849a2fc81dbd14328c6c66c53033164a0b67b52 100644 Binary files a/docs/zh/docs/A-Ops/figures/chuangjianyewuyu.png and b/docs/zh/docs/A-Ops/figures/chuangjianyewuyu.png differ diff --git a/docs/zh/docs/A-Ops/figures/conf_file_trace.png b/docs/zh/docs/A-Ops/figures/conf_file_trace.png new file mode 100644 index 0000000000000000000000000000000000000000..e1e518157f8def332adfa5516b37fdb89768499c Binary files /dev/null and b/docs/zh/docs/A-Ops/figures/conf_file_trace.png differ diff --git "a/docs/zh/docs/A-Ops/gala-anteater\344\275\277\347\224\250\346\211\213\345\206\214.md" "b/docs/zh/docs/A-Ops/gala-anteater\344\275\277\347\224\250\346\211\213\345\206\214.md" index cb22de01deaa10ae68de83da577831fe45337647..3ce38364e33c1ffdef169323cc0b67cad7a0019e 100644 --- "a/docs/zh/docs/A-Ops/gala-anteater\344\275\277\347\224\250\346\211\213\345\206\214.md" +++ "b/docs/zh/docs/A-Ops/gala-anteater\344\275\277\347\224\250\346\211\213\345\206\214.md" @@ -1,6 +1,6 @@ # gala-anteater使用手册 -gala-anteater是一款基于AI的操作系统异常检测平台。主要提供时序数据预处理、异常点发现、异常上报等功能。基于线下预训练、线上模型的增量学习与模型更新,能够很好地适应于多维多模态数据故障诊断。 +gala-anteater是一款基于AI的操作系统异常检测平台。主要提供时序数据预处理、异常点发现、异常上报等功能。基于线下预训练、线上模型的增量学习与模型更新,能够很好地适用于多维多模态数据故障诊断。 本文主要介绍如何部署和使用gala-anteater服务。 @@ -9,63 +9,112 @@ gala-anteater是一款基于AI的操作系统异常检测平台。主要提供 挂载repo源: ```basic -[oe-2309] # openEuler 2309 官方发布源 -name=oe2309 -baseurl=http://119.3.219.20:82/openEuler:/23.09/standard_x86_64 +[everything] +name=everything +baseurl=http://121.36.84.172/dailybuild/EBS-openEuler-24.09/EBS-openEuler-24.09/everything/$basearch/ enabled=1 gpgcheck=0 priority=1 -[oe-2309:Epol] # openEuler 2309:Epol 官方发布源 -name=oe2309_epol -baseurl=http://119.3.219.20:82/openEuler:/23.09:/Epol/standard_x86_64/ +[EPOL] +name=EPOL +baseurl=http://repo.openeuler.org/openEuler-22.03-LTS-SP4/EPOL/main/$basearch/ enabled=1 gpgcheck=0 priority=1 + ``` 安装gala-anteater: ```bash -# yum install gala-anteater +yum install gala-anteater ``` ## 配置 -> 说明:gala-anteater不包含额外需要配置的config文件,其参数通过命令行的启动参数传递。 +> 说明:gala-anteater采用配置的config文件设置参数启动,配置文件位置: /etc/gala-anteater/config/gala-anteater.yaml。 -##### 启动参数介绍 +##### 配置文件默认参数 -| 参数项 | 参数详细名 | 类型 | 是否必须 | 默认值 | 名称 | 含义 | -|---|---|---|---|---|---|---| -| -ks | --kafka_server | string | True | | KAFKA_SERVER | Kafka Server的ip地址,如:localhost / xxx.xxx.xxx.xxx | -| -kp | --kafka_port | string | True | | KAFKA_PORT | Kafka Server的port,如:9092 | -| -ps | --prometheus_server | string | True | | PROMETHEUS_SERVER | Prometheus Server的ip地址,如:localhost / xxx.xxx.xxx.xxx | -| -pp | --prometheus_port | string | True | | PROMETHEUS_PORT | Prometheus Server的port,如:9090 | -| -m | --model | string | False | vae | MODEL | 异常检测模型,目前支持两种异常检测模型,可选(random_forest,vae)
random_forest:随机森林模型,不支持在线学习
vae:Variational Atuoencoder,无监督模型,支持首次启动时,利用历史数据,进行模型更新迭代 | -| -d | --duration | int | False | 1 | DURATION | 异常检测模型执行频率(单位:分),每x分钟,检测一次 | -| -r | --retrain | bool | False | False | RETRAIN | 是否在启动时,利用历史数据,进行模型更新迭代,目前仅支持vae模型 | -| -l | --look_back | int | False | 4 | LOOK_BACK | 利用过去x天的历史数据,更新模型 | -| -t | --threshold | float | False | 0.8 | THRESHOLD | 异常检测模型的阈值:(0,1),较大的值,能够减少模型的误报率,推荐大于等于0.5 | -| -sli | --sli_time | int | False | 400 | SLI_TIME | 表示应用性能指标(单位:毫秒),较大的值,能够减少模型的误报率,推荐大于等于200
对于误报率较高的场景,推荐1000以上 | +```yaml +Global: + data_source: "prometheus" -## 启动 +Arangodb: + url: "http://localhost:8529" + db_name: "spider" -执行如下命令启动gala-anteater。 +Kafka:f + server: "192.168.122.100" + port: "9092" + model_topic: "gala_anteater_hybrid_model" + rca_topic: "gala_cause_inference" + meta_topic: "gala_gopher_metadata" + group_id: "gala_anteater_kafka" + # auth_type: plaintext/sasl_plaintext, please set "" for no auth + auth_type: "" + username: "" + password: "" -> 说明:gala-anteter支持命令行方式启动运行,不支持systemd方式。 +Prometheus: + server: "localhost" + port: "9090" + steps: "5" -### 在线训练方式运行(推荐) +Aom: + base_url: "" + project_id: "" + auth_type: "token" + auth_info: + iam_server: "" + iam_domain: "" + iam_user_name: "" + iam_password: "" + ssl_verify: 0 + +Schedule: + duration: 1 -```bash -gala-anteater -ks {ip} -kp {port} -ps {ip} -pp {port} -m vae -r True -l 7 -t 0.6 -sli 400 ``` -### 普通方式运行 +| 参数 | 含义 | 默认值 | +| ----------- | --------------------------------------------------- | ---------------------------- | +| Global | | | +| data_source | 设置数据来源 | “prometheus” | +| Arangodb | | | +| url | 图数据库Arangodb的ip地址 | "http://localhost:8529" | +| db_name | 图数据库名 | "spider" | +| Kafka | | | +| server | Kafka Server的ip地址,根据安装节点ip配置 | | +| port | Kafka Server的port,如:9092 | | +| model_topic | 故障检测结果上报topic | "gala_anteater_hybrid_model" | +| rca_topic | 根因定位结果上报topic | "gala_cause_inference" | +| meta_topic | gopher采集指标数据topic | "gala_gopher_metadata" | +| group_id | kafka设置组名 | "gala_anteater_kafka" | +| Prometheus | | | +| server | Prometheus Server的ip地址,根据安装节点ip配置 | | +| port | Prometheus Server的port,如:9090 | | +| steps | 指标采样间隔 | | +| Schedule | | | +| duration | 异常检测模型执行频率(单位:分),每x分钟,检测一次 | 1 | -```bash -gala-anteater -ks {ip} -kp {port} -ps {ip} -pp {port} -m vae -t 0.6 -sli 400 +## 启动 + +执行如下命令启动gala-anteater +``` +systemctl start gala-anteater ``` +** 注意 **:gala-anteater支持启动一个进程实例,启动多个会导致内存占用过大,日志混乱。 +### 故障注入 +gala-anteater为故障检测与根因定位模块,测试阶段需要通过故障注入来构造故障,从而通过故障检测和根因定位模块获得故障节点信息和故障传播根因节点信息。 +* 故障注入(仅提供参考) + ```bash + chaosblade create disk burn --size 10 --read --write --path /var/lib/docker/overlay2/cf0a469be8a84cabe1d057216505f8d64735e9c63159e170743353a208f6c268/merged --timeout 120 + + ``` + *chaosblade 为故障注入工具, 可以模拟各种故障, 包括但不限于磁盘故障、网络故障、IO故障等待 + 备注: 通过注入不一样的故障, 指标采集器(例如 gala-gopher) 监控关联指标并上报到 promethues 模块, prometheus graph 指标图部分关联指标会存在明显波动。 ### 查询gala-anteater服务状态 @@ -101,9 +150,9 @@ gala-anteater -ks {ip} -kp {port} -ps {ip} -pp {port} -m vae -t 0.6 -sli 400 2022-09-01 17:53:57,975 - apscheduler.scheduler - DEBUG - Next wakeup is due at 2022-09-01 17:54:57.973533+08:00 (in 59.998006 seconds) ``` -## 输出数据 +## 异常检测输出数据 -gala-anteater如果检测到的异常点,会将结果输出至kafka。输出数据格式如下: +gala-anteater如果检测到异常点,会将结果输出至kafka的model_topic,输出数据格式如下: ```json { @@ -151,3 +200,190 @@ gala-anteater如果检测到的异常点,会将结果输出至kafka。输出 "Body":"TimeStamp, WARN, APP may be impacting sli performance issues." } ``` + +## 根因定位输出数据 + +异常检测结果的每个异常节点都会触发根因定位,根因定位的结果会上报至kafka的rca_topic。输出数据格式如下: + +```yaml +{ + "Timestamp": 1724287883452, + "event_id": "1721125159975_475ae627-7e88-41ed-8bb8-ff0fee95a69d_l7_3459438_192.168.11.103_192.168.11.102_26_tcp_server_server_http", + "Attributes": { + "event_id": "1721125159975_475ae627-7e88-41ed-8bb8-ff0fee95a69d_l7_3459438_192.168.11.103_192.168.11.102_26_tcp_server_server_http", + "event_source": "root-cause-inference" + }, + "Resource": { + "abnormal_kpi": { + "metric_id": "gala_gopher_l7_latency_sum", + "entity_id": "", + "metric_labels": { + "client_ip": "192.168.11.103", + "comm": "python", + "container_id": "83d0c2f4a7f4", + "container_image": "ba2d060a624e", + "container_name": "/k8s_backend_backend-node2-01-5bcb47fd7c-4jxxs_default_475ae627", + "instance": "192.168.122.102:8888", + "job": "192.168.122.102", + "l4_role": "tcp_server", + "l7_role": "server", + "machine_id": "66086618-3bad-489e-b17d-05245224f29a-192.168.122.102", + "pod": "default/backend-node2-01-5bcb47fd7c-4jxxs", + "pod_id": "475ae627-7e88-41ed-8bb8-ff0fee95a69d", + "pod_namespace": "default", + "protocol": "http", + "server_ip": "192.168.11.102", + "server_port": "26", + "ssl": "no_ssl", + "tgid": "3459438" + }, + "desc": "L7 session averaged latency.", + "score": 0.3498585816683402 + }, + "cause_metrics": [ + { + "metric_id": "gala_gopher_container_cpu_user_seconds_total@4a9fcc23-8ba2-4b0a-bcb0-b1bfd89ed929", + "entity_id": "", + "metric_labels": { + "container_id": "1319ff912a6f", + "container_image": "ba2d060a624e", + "container_name": "/k8s_backend_backend-node3-02-654dd97bf9-s8jg5_default_4a9fcc23", + "instance": "192.168.122.103:8888", + "job": "192.168.122.103", + "machine_id": "494a61be-23cc-4c97-a871-902866e43747-192.168.122.103", + "pod": "default/backend-node3-02-654dd97bf9-s8jg5", + "pod_id": "4a9fcc23-8ba2-4b0a-bcb0-b1bfd89ed929", + "pod_namespace": "default" + }, + "desc": "\u5bb9\u56681s\u5185\u7528\u6237\u6001CPU\u8d1f\u8f7d", + "keyword": "process", + "score": 0.1194249668036936, + "path": [ + { + "pod_id": "4a9fcc23-8ba2-4b0a-bcb0-b1bfd89ed929", + "pod": "default/backend-node3-02-654dd97bf9-s8jg5", + "instance": "192.168.122.103:8888", + "job": "192.168.122.103", + "pod_state": "normal" + }, + { + "pod_id": "475ae627-7e88-41ed-8bb8-ff0fee95a69d", + "pod": "default/backend-node2-01-5bcb47fd7c-4jxxs", + "instance": "192.168.122.102:8888", + "job": "192.168.122.102", + "pod_state": "abnormal" + } + ] + }, + { + "metric_id": "gala_gopher_proc_wchar_bytes@67134fb4-b2a3-43c5-a5b3-b3b463ad7d43", + "entity_id": "", + "metric_labels": { + "cmdline": "python ./backend.py ", + "comm": "python", + "container_id": "de570c7328bb", + "container_image": "ba2d060a624e", + "container_name": "/k8s_backend_backend-node2-02-548c79d989-bnl9g_default_67134fb4", + "instance": "192.168.122.102:8888", + "job": "192.168.122.102", + "machine_id": "66086618-3bad-489e-b17d-05245224f29a-192.168.122.102", + "pgid": "3459969", + "pod": "default/backend-node2-02-548c79d989-bnl9g", + "pod_id": "67134fb4-b2a3-43c5-a5b3-b3b463ad7d43", + "pod_namespace": "default", + "ppid": "3459936", + "start_time": "1139543501", + "tgid": "3459969" + }, + "desc": "\u8fdb\u7a0b\u7cfb\u7edf\u8c03\u7528\u81f3FS\u7684\u5199\u5b57\u8282\u6570", + "keyword": "process", + "score": 0.37121879175399997, + "path": [ + { + "pod_id": "67134fb4-b2a3-43c5-a5b3-b3b463ad7d43", + "pod": "default/backend-node2-02-548c79d989-bnl9g", + "instance": "192.168.122.102:8888", + "job": "192.168.122.102", + "pod_state": "normal" + }, + { + "pod_id": "4a9fcc23-8ba2-4b0a-bcb0-b1bfd89ed929", + "pod": "default/backend-node3-02-654dd97bf9-s8jg5", + "instance": "192.168.122.103:8888", + "job": "192.168.122.103", + "pod_state": "normal" + }, + { + "pod_id": "475ae627-7e88-41ed-8bb8-ff0fee95a69d", + "pod": "default/backend-node2-01-5bcb47fd7c-4jxxs", + "instance": "192.168.122.102:8888", + "job": "192.168.122.102", + "pod_state": "abnormal" + } + ] + }, + { + "metric_id": "gala_gopher_l7_latency_avg@956c70a2-9918-459c-a0a8-39396251f952", + "entity_id": "", + "metric_labels": { + "client_ip": "192.168.11.103", + "comm": "python", + "container_id": "eef1ca1082a7", + "container_image": "ba2d060a624e", + "container_name": "/k8s_backend_backend-node2-03-584f4c6cfd-w4d2b_default_956c70a2", + "instance": "192.168.122.102:8888", + "job": "192.168.122.102", + "l4_role": "tcp_server", + "l7_role": "server", + "machine_id": "66086618-3bad-489e-b17d-05245224f29a-192.168.122.102", + "pod": "default/backend-node2-03-584f4c6cfd-w4d2b", + "pod_id": "956c70a2-9918-459c-a0a8-39396251f952", + "pod_namespace": "default", + "protocol": "http", + "server_ip": "192.168.11.113", + "server_port": "26", + "ssl": "no_ssl", + "tgid": "3460169" + }, + "desc": "L7 session averaged latency.", + "keyword": null, + "score": 0.5624857367147617, + "path": [ + { + "pod_id": "956c70a2-9918-459c-a0a8-39396251f952", + "pod": "default/backend-node2-03-584f4c6cfd-w4d2b", + "instance": "192.168.122.102:8888", + "job": "192.168.122.102", + "pod_state": "abnormal" + }, + { + "pod_id": "4a9fcc23-8ba2-4b0a-bcb0-b1bfd89ed929", + "pod": "default/backend-node3-02-654dd97bf9-s8jg5", + "instance": "192.168.122.103:8888", + "job": "192.168.122.103", + "pod_state": "normal" + }, + { + "pod_id": "475ae627-7e88-41ed-8bb8-ff0fee95a69d", + "pod": "default/backend-node2-01-5bcb47fd7c-4jxxs", + "instance": "192.168.122.102:8888", + "job": "192.168.122.102", + "pod_state": "abnormal" + } + ] + } + ] + }, + "desc": "L7 session averaged latency.", + "top1": "gala_gopher_container_cpu_user_seconds_total@4a9fcc23-8ba2-4b0a-bcb0-b1bfd89ed929\u5f02\u5e38", + "top2": "gala_gopher_proc_wchar_bytes@67134fb4-b2a3-43c5-a5b3-b3b463ad7d43\u5f02\u5e38", + "top3": "gala_gopher_l7_latency_avg@956c70a2-9918-459c-a0a8-39396251f952\u5f02\u5e38", + "keywords": [ + "process", + null + ], + "SeverityText": "WARN", + "SeverityNumber": 13, + "Body": "A cause inferring event for an abnormal event" +} +``` \ No newline at end of file diff --git "a/docs/zh/docs/A-Ops/gala-gopher\344\275\277\347\224\250\346\211\213\345\206\214.md" "b/docs/zh/docs/A-Ops/gala-gopher\344\275\277\347\224\250\346\211\213\345\206\214.md" index df94faa69bae053c932b0ae757d9a114d5a1c7ac..571247a8b5e055c944220a812eaabc044e824527 100644 --- "a/docs/zh/docs/A-Ops/gala-gopher\344\275\277\347\224\250\346\211\213\345\206\214.md" +++ "b/docs/zh/docs/A-Ops/gala-gopher\344\275\277\347\224\250\346\211\213\345\206\214.md" @@ -1042,6 +1042,84 @@ file_conn_head:记录java进程的最后一个sessionId,以备L7probe读jsse 将sock_conn和conn_data上报到map中。 +## sliprobe 介绍 + +基于 ebpf 采集并周期性上报容器粒度的 SLI 指标。 + +### 特性 + +- 按照容器粒度采集周期内CPU调度事件的时延总计和统计直方图,关注的事件包括:调度等待,主动睡眠,锁/IO引起的阻塞,调度延迟,长系统调用等 +- 按照容器粒度采集周期内Memory分配事件的时延总计和统计直方图,关注的事件包括:内存回收,换页,内存规整等 +- 按照容器粒度采集周期内BIO层IO操作的时延总计和统计直方图 + +### 使用说明 + +启动命令示例:指定上报周期为15秒,观测容器id为abcd12345678和abcd87654321的两个容器的SLI指标。 + +```shell +curl -X PUT http://localhost:9999/sli -d json='{"params":{"report_period":15}, "snoopers":{"container_id":[{"container_id": "abcd12345678","abcd87654321"}]}, "state":"running"}' +``` + +### 代码逻辑 +#### 总体思路 + +1. 用户态接收待观测的容器列表,将容器的cpuacct子系统目录inode记录在ebpf map中,共享给内核态。 + +2. 通过ebpf kprobe/tracepoint跟踪相关内核事件,判断当前进程是否属于待观测范围,记录事件类型,时间戳等信息。每隔一定周期将同一cgroup内进程的SLI指标进行聚合上报。 +3. 用户态接收并打印内核态上报的SLI指标信息。 + +#### SLI指标计算方式 + +##### CPU SLI + +1. **cpu_wait** + + 在sched_stat_wait观测点,获取第二个参数delay的值 + +2. **cpu_sleep** + + 在sched_stat_sleep观测点,获取第二个参数delay的值 + +3. **cpu_iowait** + + 在sched_stat_blocked观测点,判断当前进程in_iowait,则获取第二个参数delay的值 + +4. **cpu_block** + + 在sched_stat_blocked观测点,判断当前进程非in_iowait,则获取第二个参数delay的值 + +5. **cpu_rundelay** + + 在sched_switch观测点,通过第三个参数next获取将被调度进程的run_delay值:next->sched_info.run_delay,记录在task_sched_map中。计算同一进程两次被调度时run_delay的差值 + +6. **cpu_longsys** + + 在sched_switch观测点,通过第三个参数next获取将被调度进程的task结构体,从task结构体中获取上下文切换次数(nvcsw+nivcsw)和用户态执行时间utime。如果同一进程两次被调度时的上下文切换次数和用户态执行时间都不变,则说明在该进程在执行一个较长的系统调用,累积该进程处在内核态的时间 + +##### MEM SLI + +1. **mem_reclaim** + + 计算mem_cgroup_handle_over_high函数返回时间戳和进入时间戳的差值 + + 计算mm_vmscan_memcg_reclaim_end观测点和mm_vmscan_memcg_reclaim_begin观测点时间戳的差值 + +2. **mem_swapin** + + 计算do_swap_page函数返回时间戳和进入时间戳的差值 + +3. **mem_compact** + + 计算try_to_compact_pages函数返回时间戳和进入时间戳的差值 + +##### IO SLI + +1. **bio_latency** + + 计算进入bio_endio函数和触发block_bio_queue观测点的时间戳差值 + + 计算进入bio_endio函数和退出generic_make_request_checks函数的时间戳差值 + ## 使用方法 @@ -1049,15 +1127,15 @@ file_conn_head:记录java进程的最后一个sessionId,以备L7probe读jsse ![gopher软件架构图](./figures/gopher软件架构图.png) -如上图所示,绿色部分为gala-gopher的外部依赖组件。gala-gopher会将指标数据metrics输出到promethous,将元数据metadata、异常事件event输出到kafka,灰色部分的gala-anteater和gala-spider会从promethous和kafka获取数据。 +如上图所示,绿色部分为gala-gopher的外部依赖组件。gala-gopher会将指标数据metrics输出到prometheus,将元数据metadata、异常事件event输出到kafka,灰色部分的gala-anteater和gala-spider会从prometheus和kafka获取数据。 -> 说明:安装kafka、promethous软件包时,需要从官网获取安装包进行部署。 +> 说明:安装kafka、prometheus软件包时,需要从官网获取安装包进行部署。 ### 输出数据 - **指标数据metrics** - Promethous Server内置了Express Browser UI,用户可以通过PromQL查询语句查询指标数据内容。详细教程参见官方文档:[Using the expression browser](https://prometheus.io/docs/prometheus/latest/getting_started/#using-the-expression-browser)。示例如下: + Prometheus Server内置了Express Browser UI,用户可以通过PromQL查询语句查询指标数据内容。详细教程参见官方文档:[Using the expression browser](https://prometheus.io/docs/prometheus/latest/getting_started/#using-the-expression-browser)。示例如下: 指定指标名称为`gala_gopher_tcp_link_rcv_rtt`,UI显示的指标数据为: diff --git "a/docs/zh/docs/A-Ops/image/\344\273\273\345\212\241\347\273\223\346\236\234\346\237\245\347\234\213.png" "b/docs/zh/docs/A-Ops/image/\344\273\273\345\212\241\347\273\223\346\236\234\346\237\245\347\234\213.png" new file mode 100644 index 0000000000000000000000000000000000000000..31fe24f44facaaa62fbeddd3eef0090a3be88908 Binary files /dev/null and "b/docs/zh/docs/A-Ops/image/\344\273\273\345\212\241\347\273\223\346\236\234\346\237\245\347\234\213.png" differ diff --git "a/docs/zh/docs/A-Ops/image/\345\210\233\345\273\272\350\204\232\346\234\254.png" "b/docs/zh/docs/A-Ops/image/\345\210\233\345\273\272\350\204\232\346\234\254.png" new file mode 100644 index 0000000000000000000000000000000000000000..feb95836d056335d9d7ef673acc5fdf39e29bd8e Binary files /dev/null and "b/docs/zh/docs/A-Ops/image/\345\210\233\345\273\272\350\204\232\346\234\254.png" differ diff --git "a/docs/zh/docs/A-Ops/image/\345\210\233\345\273\272\350\204\232\346\234\254\344\273\273\345\212\241.png" "b/docs/zh/docs/A-Ops/image/\345\210\233\345\273\272\350\204\232\346\234\254\344\273\273\345\212\241.png" new file mode 100644 index 0000000000000000000000000000000000000000..e7b1c5fc77c4027f1cdb96941440220db8637e5f Binary files /dev/null and "b/docs/zh/docs/A-Ops/image/\345\210\233\345\273\272\350\204\232\346\234\254\344\273\273\345\212\241.png" differ diff --git "a/docs/zh/docs/A-Ops/image/\345\215\225\346\254\241\346\211\247\350\241\214.png" "b/docs/zh/docs/A-Ops/image/\345\215\225\346\254\241\346\211\247\350\241\214.png" new file mode 100644 index 0000000000000000000000000000000000000000..8020c60843c11e566778a1a03c1fa7516de9dd6b Binary files /dev/null and "b/docs/zh/docs/A-Ops/image/\345\215\225\346\254\241\346\211\247\350\241\214.png" differ diff --git "a/docs/zh/docs/A-Ops/image/\345\221\250\346\234\237\346\211\247\350\241\214.png" "b/docs/zh/docs/A-Ops/image/\345\221\250\346\234\237\346\211\247\350\241\214.png" new file mode 100644 index 0000000000000000000000000000000000000000..b75743556384fe58690847b3794607ef9a890d6d Binary files /dev/null and "b/docs/zh/docs/A-Ops/image/\345\221\250\346\234\237\346\211\247\350\241\214.png" differ diff --git "a/docs/zh/docs/A-Ops/image/\345\221\275\344\273\244\346\211\247\350\241\214.png" "b/docs/zh/docs/A-Ops/image/\345\221\275\344\273\244\346\211\247\350\241\214.png" new file mode 100644 index 0000000000000000000000000000000000000000..b5c9fbbeb5a4bba5f81d753fa5aa620ad261804c Binary files /dev/null and "b/docs/zh/docs/A-Ops/image/\345\221\275\344\273\244\346\211\247\350\241\214.png" differ diff --git "a/docs/zh/docs/A-Ops/image/\345\221\275\344\273\244\347\256\241\347\220\206\347\225\214\351\235\242.png" "b/docs/zh/docs/A-Ops/image/\345\221\275\344\273\244\347\256\241\347\220\206\347\225\214\351\235\242.png" new file mode 100644 index 0000000000000000000000000000000000000000..c0357fc88d33c8b706203b70016d53629a3db70c Binary files /dev/null and "b/docs/zh/docs/A-Ops/image/\345\221\275\344\273\244\347\256\241\347\220\206\347\225\214\351\235\242.png" differ diff --git "a/docs/zh/docs/A-Ops/image/\346\223\215\344\275\234\347\256\241\347\220\206.png" "b/docs/zh/docs/A-Ops/image/\346\223\215\344\275\234\347\256\241\347\220\206.png" new file mode 100644 index 0000000000000000000000000000000000000000..3a1b8c3accdfb688da2e8e54eb17e86d18ee4d0b Binary files /dev/null and "b/docs/zh/docs/A-Ops/image/\346\223\215\344\275\234\347\256\241\347\220\206.png" differ diff --git "a/docs/zh/docs/A-Ops/image/\346\226\207\344\273\266\346\216\250\351\200\201.png" "b/docs/zh/docs/A-Ops/image/\346\226\207\344\273\266\346\216\250\351\200\201.png" new file mode 100644 index 0000000000000000000000000000000000000000..c449eb18608e0146275f1b9f4ca41d05d48af021 Binary files /dev/null and "b/docs/zh/docs/A-Ops/image/\346\226\207\344\273\266\346\216\250\351\200\201.png" differ diff --git "a/docs/zh/docs/A-Ops/image/\346\226\260\345\273\272\345\221\275\344\273\244.png" "b/docs/zh/docs/A-Ops/image/\346\226\260\345\273\272\345\221\275\344\273\244.png" new file mode 100644 index 0000000000000000000000000000000000000000..50d5bd4ce5499512acf2b8af86445fe6df6ce29f Binary files /dev/null and "b/docs/zh/docs/A-Ops/image/\346\226\260\345\273\272\345\221\275\344\273\244.png" differ diff --git "a/docs/zh/docs/A-Ops/image/\346\226\260\345\273\272\345\221\275\344\273\244\344\273\273\345\212\241.png" "b/docs/zh/docs/A-Ops/image/\346\226\260\345\273\272\345\221\275\344\273\244\344\273\273\345\212\241.png" new file mode 100644 index 0000000000000000000000000000000000000000..792ec4e81017575fd27466a275c0502563808296 Binary files /dev/null and "b/docs/zh/docs/A-Ops/image/\346\226\260\345\273\272\345\221\275\344\273\244\344\273\273\345\212\241.png" differ diff --git "a/docs/zh/docs/A-Ops/image/\350\204\232\346\234\254\346\211\247\350\241\214.png" "b/docs/zh/docs/A-Ops/image/\350\204\232\346\234\254\346\211\247\350\241\214.png" new file mode 100644 index 0000000000000000000000000000000000000000..4ab626ad5949e17a5d486431ae4c0481ca42a442 Binary files /dev/null and "b/docs/zh/docs/A-Ops/image/\350\204\232\346\234\254\346\211\247\350\241\214.png" differ diff --git "a/docs/zh/docs/A-Ops/image/\350\204\232\346\234\254\347\256\241\347\220\206.png" "b/docs/zh/docs/A-Ops/image/\350\204\232\346\234\254\347\256\241\347\220\206.png" new file mode 100644 index 0000000000000000000000000000000000000000..62c60399dc58a79a9ab48a7eb584ce615c11b05c Binary files /dev/null and "b/docs/zh/docs/A-Ops/image/\350\204\232\346\234\254\347\256\241\347\220\206.png" differ diff --git "a/docs/zh/docs/A-Ops/\347\244\276\345\214\272\347\203\255\350\241\245\344\270\201\345\210\266\344\275\234\345\217\221\345\270\203\346\265\201\347\250\213.md" "b/docs/zh/docs/A-Ops/\347\244\276\345\214\272\347\203\255\350\241\245\344\270\201\345\210\266\344\275\234\345\217\221\345\270\203\346\265\201\347\250\213.md" index 1c2d4ab7fabed91e8dce2ed214ec26afd1dea637..badbd49f038a3ba7920b61cb5d3479ed773027b1 100644 --- "a/docs/zh/docs/A-Ops/\347\244\276\345\214\272\347\203\255\350\241\245\344\270\201\345\210\266\344\275\234\345\217\221\345\270\203\346\265\201\347\250\213.md" +++ "b/docs/zh/docs/A-Ops/\347\244\276\345\214\272\347\203\255\350\241\245\344\270\201\345\210\266\344\275\234\345\217\221\345\270\203\346\265\201\347\250\213.md" @@ -200,7 +200,7 @@ pr内容: ### 2、生成安全公告热补丁信息 -社区根据收集到的热补丁issue信息,在生成安全公告的同时生成hotpatch字段补丁,过滤已经发布的漏洞。 +社区根据收集到的热补丁issue信息,在生成安全公告的同时生成hotpatch字段补丁,过滤已经发布的漏洞补丁。 - 在安全公告文件新增HotPatchTree字段,记录和公告相关漏洞的热补丁,每个补丁按架构和CVE字段区分(Type=ProductName 记录分支,Type=ProductArch 记录补丁具体的rpm包)。 diff --git "a/docs/zh/docs/A-Ops/\350\207\252\345\212\250\345\214\226\350\277\220\347\273\264\346\234\215\345\212\241\344\275\277\347\224\250\346\211\213\345\206\214.md" "b/docs/zh/docs/A-Ops/\350\207\252\345\212\250\345\214\226\350\277\220\347\273\264\346\234\215\345\212\241\344\275\277\347\224\250\346\211\213\345\206\214.md" new file mode 100644 index 0000000000000000000000000000000000000000..c075767137aa34c9753000d5752f1789fa97f88f --- /dev/null +++ "b/docs/zh/docs/A-Ops/\350\207\252\345\212\250\345\214\226\350\277\220\347\273\264\346\234\215\345\212\241\344\275\277\347\224\250\346\211\213\345\206\214.md" @@ -0,0 +1,66 @@ +# 自动化运维服务使用手册 + +## 主要功能 + +本服务主要包括批量命令执行和批量脚本执行的功能,两者均支持定时任务。 + +#### 命令相关 + +命令页面包含命令管理和命令执行两个页签 + +##### 命令管理 + +命令管理界面可以对命令进行增删查改功能: +![](./image/新建命令.png) +![](./image/命令管理界面.png) + + +##### 命令执行 + +命令执行界面可以创建命令执行任务: +![](./image/新建命令任务.png) + + +命令执行界面可以对创建的任务进行任务信息查看,任务执行,任务结果查看,删除任务等操作: +![](./image/命令执行.png) +任务结果查看: +![](./image/任务结果查看.png) + + +#### 脚本相关 + +脚本页面包含脚本管理、脚本执行、操作管理三个页签 + +##### 操作管理 + +为了屏蔽操作系统的架构,系统对脚本执行的影响,抽象出操作的概念。一个操作对应一组包括各类架构和系统的脚本,脚本执行时选择主机和操作后,根据主机的系统和架构选择对应的脚本进行执行。 + +操作管理界面可以对操作进行增删查改功能: + +![](./image/操作管理.png) + +##### 脚本管理 + +脚本管理界面可以对脚本进行上传,查询,删除,编辑功能: +![](./image/脚本管理.png) +创建脚本: +![](./image/创建脚本.png) + +##### 脚本执行 + +脚本执行界面可以创建脚本执行任务,创建脚本任务仅能通过选择操作来选择对应脚本: +![](./image/脚本执行.png) +创建脚本任务: +![](./image/创建脚本任务.png) + +#### 定时任务 + +定时任务支持指定时间执行和周期执行功能 +单次执行: +![](./image/单次执行.png) +周期执行: +![](./image/周期执行.png) +#### 文件推送 + +文件推送功能支持将脚本推送至指定目录,此类任务不会执行脚本,且推送任务与定时任务互斥: +![](./image/文件推送.png) \ No newline at end of file diff --git "a/docs/zh/docs/A-Ops/\351\205\215\347\275\256\346\272\257\346\272\220\346\234\215\345\212\241\344\275\277\347\224\250\346\211\213\345\206\214.md" "b/docs/zh/docs/A-Ops/\351\205\215\347\275\256\346\272\257\346\272\220\346\234\215\345\212\241\344\275\277\347\224\250\346\211\213\345\206\214.md" index 2d65810c8165b028cea96792b1db600a84c2dd9e..d694fc7092316ce414f95d314295e8a831acdf6d 100644 --- "a/docs/zh/docs/A-Ops/\351\205\215\347\275\256\346\272\257\346\272\220\346\234\215\345\212\241\344\275\277\347\224\250\346\211\213\345\206\214.md" +++ "b/docs/zh/docs/A-Ops/\351\205\215\347\275\256\346\272\257\346\272\220\346\234\215\345\212\241\344\275\277\347\224\250\346\211\213\345\206\214.md" @@ -149,3 +149,11 @@ port = 11114 #### 配置同步 ![](./figures/peizhitongbu.png) + +#### 配置文件追溯 +##### 打开监控开关 +![](./figures/chuangjianyewuyu.png) +##### 配置文件修改记录追溯 +![](./figures/conf_file_trace.png) + + diff --git a/docs/zh/docs/A-Tune/native-turbo.md b/docs/zh/docs/A-Tune/native-turbo.md index 93817638470e1a8548de2292190ae12d52e761e4..af52f6d94e2863ae47389ebfd43a3d4f6f6bf4ad 100644 --- a/docs/zh/docs/A-Tune/native-turbo.md +++ b/docs/zh/docs/A-Tune/native-turbo.md @@ -46,10 +46,9 @@ 2. 使用前需要预留足够的大页,否则程序会执行失败。 如果使用cgroup,请注意hugetlb的限制,如果限制小于所需大页数量,可能导致运行时崩溃。 - + 3. 由于进程页表改为2M,mprotect等系统调用的参数需要按2M对齐,否则会执行失败。 4. 不支持libcareplus热补丁机制。 5. 多个进程间无法共享大页,会消耗多倍内存。 - diff --git "a/docs/zh/docs/A-Tune/\345\270\270\350\247\201\351\227\256\351\242\230\344\270\216\350\247\243\345\206\263\346\226\271\346\263\225.md" "b/docs/zh/docs/A-Tune/\345\270\270\350\247\201\351\227\256\351\242\230\344\270\216\350\247\243\345\206\263\346\226\271\346\263\225.md" deleted file mode 100644 index 52bed705a43e1dc733bf3beb167a9c93d18c35d2..0000000000000000000000000000000000000000 --- "a/docs/zh/docs/A-Tune/\345\270\270\350\247\201\351\227\256\351\242\230\344\270\216\350\247\243\345\206\263\346\226\271\346\263\225.md" +++ /dev/null @@ -1,52 +0,0 @@ -# 常见问题与解决方法 - -## **问题1:train命令训练模型出错,提示“training data failed”** - -原因:collection命令只采集一种类型的数据。 - -解决方法:至少采集两种数据类型的数据进行训练。 - -## **问题2:atune-adm无法连接atuned服务** - -可能原因: - -1. 检查atuned服务是否启动,并检查atuned侦听地址。 - - ```shell - # systemctl status atuned - # netstat -nap | grep atuned - ``` - -2. 防火墙阻止了atuned的侦听端口。 -3. 系统配置了http代理导致无法连接。 - -解决方法: - -1. 如果atuned没有启动,启动该服务,参考命令如下: - - ```shell - # systemctl start atuned - ``` - -2. 分别在atuned和atune-adm的服务器上执行如下命令,允许侦听端口接收网络包,其中60001为atuned的侦听端口号。 - - ```shell - # iptables -I INPUT -p tcp --dport 60001 -j ACCEPT - # iptables -I INPUT -p tcp --sport 60001 -j ACCEPT - ``` - -3. 不影响业务的前提下删除http代理,或对侦听IP不进行http代理,命令如下: - - ```shell - # no_proxy=$no_proxy,侦听地址 - ``` - -## **问题3:atuned服务无法启动,提示“Job for atuned.service failed because a timeout was exceeded.”** - -原因:hosts文件中缺少localhost配置 - -解决方法:在/etc/hosts文件中127.0.0.1这一行添加上localhost - -```conf -127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 -``` diff --git "a/docs/zh/docs/AI/AI\345\244\247\346\250\241\345\236\213\346\234\215\345\212\241\351\225\234\345\203\217\344\275\277\347\224\250\346\214\207\345\215\227.md" "b/docs/zh/docs/AI/AI\345\244\247\346\250\241\345\236\213\346\234\215\345\212\241\351\225\234\345\203\217\344\275\277\347\224\250\346\214\207\345\215\227.md" new file mode 100644 index 0000000000000000000000000000000000000000..c7c492b104b74e25ac87980c2d8580885a43df0e --- /dev/null +++ "b/docs/zh/docs/AI/AI\345\244\247\346\250\241\345\236\213\346\234\215\345\212\241\351\225\234\345\203\217\344\275\277\347\224\250\346\214\207\345\215\227.md" @@ -0,0 +1,94 @@ +# 支持百川、chatglm、星火等AI大模型的容器化封装 + +已配好相关依赖,分为CPU和GPU版本,降低使用门槛,开箱即用。 + +## 拉取镜像(CPU版本) + +```bash +docker pull openeuler/llm-server:1.0.0-oe2203sp3 +``` + +## 拉取镜像(GPU版本) + +```bash +docker pull icewangds/llm-server:1.0.0 +``` + +## 下载模型, 并转换为gguf格式 + +```bash +# 安装huggingface +pip install huggingface-hub + +# 下载你想要部署的模型 +export HF_ENDPOINT=https://hf-mirror.com +huggingface-cli download --resume-download baichuan-inc/Baichuan2-13B-Chat --local-dir /root/models/Baichuan2-13B-Chat --local-dir-use-symlinks False + +# gguf格式转换 +cd /root/models/ +git clone https://github.com/ggerganov/llama.cpp.git +python llama.cpp/convert-hf-to-gguf.py ./Baichuan2-13B-Chat +# 生成的gguf格式的模型路径 /root/models/Baichuan2-13B-Chat/ggml-model-f16.gguf +``` + +## 启动方式 + +需要Docker v25.0.0及以上版本。 + +若使用GPU镜像,需要OS上安装nvidia-container-toolkit,安装方式见。 + +docker-compose.yaml: + +```yaml +version: '3' +services: + model: + image: : #镜像名称与tag + restart: on-failure:5 + ports: + - 8001:8000 #监听端口号,修改“8001”以更换端口 + volumes: + - /root/models:/models # 大模型挂载目录 + environment: + - MODEL=/models/Baichuan2-13B-Chat/ggml-model-f16.gguf # 容器内的模型文件路径 + - MODEL_NAME=baichuan13b # 自定义模型名称 + - KEY=sk-12345678 # 自定义API Key + - CONTEXT=8192 # 上下文大小 + - THREADS=8 # CPU线程数,仅CPU部署时需要 + deploy: # 指定GPU资源, 仅GPU部署时需要 + resources: + reservations: + devices: + - driver: nvidia + count: all + capabilities: [gpu] +``` + +```bash +docker-compose -f docker-compose.yaml up +``` + +docker run: + +```text +cpu部署: docker run -d --restart on-failure:5 -p 8001:8000 -v /root/models:/models -e MODEL=/models/Baichuan2-13B-Chat/ggml-model-f16.gguf -e MODEL_NAME=baichuan13b -e KEY=sk-12345678 openeuler/llm-server:1.0.0-oe2203sp3 + +gpu部署: docker run -d --gpus all --restart on-failure:5 -p 8001:8000 -v /root/models:/models -e MODEL=/models/Baichuan2-13B-Chat/ggml-model-f16.gguf -e MODEL_NAME=baichuan13b -e KEY=sk-12345678 icewangds/llm-server:1.0.0 +``` + +## 调用大模型接口测试,成功返回则表示大模型服务已部署成功 + +```bash +curl -X POST http://127.0.0.1:8001/v1/chat/completions \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer sk-12345678" \ + -d '{ + "model": "baichuan13b", + "messages": [ + {"role": "system", "content": "你是一个社区助手,请回答以下问题。"}, + {"role": "user", "content": "你是谁?"} + ], + "stream": false, + "max_tokens": 1024 + }' +``` diff --git "a/docs/zh/docs/AI/AI\345\256\271\345\231\250\351\225\234\345\203\217\347\224\250\346\210\267\346\214\207\345\215\227.md" "b/docs/zh/docs/AI/AI\345\256\271\345\231\250\351\225\234\345\203\217\347\224\250\346\210\267\346\214\207\345\215\227.md" new file mode 100644 index 0000000000000000000000000000000000000000..53a19a7a261a6bd79e9664204b1cddcabc601cb2 --- /dev/null +++ "b/docs/zh/docs/AI/AI\345\256\271\345\231\250\351\225\234\345\203\217\347\224\250\346\210\267\346\214\207\345\215\227.md" @@ -0,0 +1,110 @@ +# openEuler AI 容器镜像用户指南 + +## 简介 + +openEuler AI 容器镜像封装了不同硬件算力的 SDK 以及 AI 框架、大模型应用等软件,用户只需要在目标环境中加载镜像并启动容器,即可进行 AI 应用开发或使用,大大减少了应用部署和环境配置的时间,提升效率。 + +## 获取镜像 + +目前,openEuler 已发布支持 Ascend 和 NVIDIA 平台的容器镜像,获取路径如下: + +- [openeuler/cann](https://hub.docker.com/r/openeuler/cann) +存放 SDK 类镜像,在 openEuler 基础镜像之上安装 CANN 系列软件,适用于 Ascend 环境。 + +- [openeuler/cuda](https://hub.docker.com/r/openeuler/cuda) +存放 SDK 类镜像,在 openEuler 基础镜像之上安装 CUDA 系列软件,适用于 NVIDIA 环境。 + +- [openeuler/pytorch](https://hub.docker.com/r/openeuler/pytorch) +存放 AI 框架类镜像,在 SDK 镜像基础之上安装 PyTorch,根据安装的 SDK 软件内容区分适用平台。 + +- [openeuler/tensorflow](https://hub.docker.com/r/openeuler/tensorflow) +存放 AI 框架类镜像,在 SDK 镜像基础之上安装 TensorFlow,根据安装的 SDK 软件内容区分适用平台。 + +- [openeuler/llm](https://hub.docker.com/r/openeuler/tensorrt) +存放模型应用类镜像,在 AI 框架镜像之上包含特定大模型及工具链,根据安装的 SDK 软件内容区分适用平台。 + +详细的 AI 容器镜像分类和镜像 tag 的规范说明见[oEEP-0014](https://gitee.com/openeuler/TC/blob/master/oEEP/oEEP-0014%20openEuler%20AI容器镜像软件栈规范.md)。 + +由于 AI 容器镜像的体积一般较大,推荐用户在启动容器前先通过如下命令将镜像拉取到开发环境中。 + +```sh +docker pull image:tag +``` + +其中,`image`为仓库名,如`openeuler/cann`,`tag`为目标镜像的 TAG,待镜像拉取完成后即可启动容器。注意,使用`docker pull`命令需按照下文方法安装`docker`软件。 + +## 启动容器 + +1. 在环境中安装`docker`,官方安装方法见[Install Docker Engine](https://docs.docker.com/engine/install/),也可直接通过如下命令进行安装。 + + ```sh + yum install -y docker + ``` + + 或 + + ```sh + apt-get install -y docker + ``` + +2. NVIDIA环境安装`nvidia-container` + + 1)配置yum或apt repo + - 使用yum安装时,执行: + + ```sh + curl -s -L https://nvidia.github.io/libnvidia-container/stable/rpm/nvidia-container-toolkit.repo | \ + sudo tee /etc/yum.repos.d/nvidia-container-toolkit.repo + ``` + + - 使用apt安装时,执行: + + ```sh + curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg + ``` + + ```sh + curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \ + sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \ + sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list + ``` + + 2)安装`nvidia-container-toolkit`,`nvidia-container-runtime`,执行: + + ```sh + # yum安装 + yum install -y nvidia-container-toolkit nvidia-container-runtime + ``` + + ```sh + # apt安装 + apt-get install -y nvidia-container-toolkit nvidia-container-runtime + ``` + + 3)配置docker + + ```sh + nvidia-ctk runtime configure --runtime=docker + systemctl restart docker + ``` + + 非NVIDIA环境不执行此步骤。 + +3. 确保环境中安装`driver`及`firmware`,用户可从[NVIDIA](https://www.nvidia.com/)或[Ascend](https://www.hiascend.com/)官网获取正确版本进行安装。安装完成后 Ascend 平台使用`npu-smi`命令、NVIDIA 平台使用`nvidia-smi`进行测试,正确显示硬件信息则说明安装正常。 + +4. 完成上述操作后,即可使用`docker run`命令启动容器。 + +```sh +# Ascend环境启动容器 +docker run --rm --network host \ + --device /dev/davinci0:/dev/davinci0 \ + --device /dev/davinci_manager --device /dev/devmm_svm --device /dev/hisi_hdc \ + -v /usr/local/dcmi:/usr/local/dcmi -v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \ + -v /usr/local/Ascend/driver/lib64/:/usr/local/Ascend/driver/lib64/ \ + -ti image:tag +``` + +```sh +# NVIDIA环境启动容器 +docker run --gpus all -d -ti image:tag +``` diff --git a/docs/zh/docs/AI/openEuler_Copilot_System/README.md b/docs/zh/docs/AI/openEuler_Copilot_System/README.md new file mode 100644 index 0000000000000000000000000000000000000000..86ca0760c450b7656acc53c7b68cbadfe66d828e --- /dev/null +++ b/docs/zh/docs/AI/openEuler_Copilot_System/README.md @@ -0,0 +1,42 @@ +# openEuler Copilot System + +## 功能描述 + +openEuler Copilot System 智能问答平台目前支持 Web 和智能 Shell 两个入口。 + +- Web 入口:操作简单,可咨询操作系统相关基础知识,openEuler 动态数据、openEuler 运维问题解决方案、openEuler 项目介绍与使用指导等等。 +- 智能 Shell 入口:自然语言和 openEuler 交互,启发式的运维。 + +## 应用场景 + +- 面向 openEuler 普通用户:深入了解 openEuler 相关知识和动态数据,比如咨询如何迁移到 openEuler。 +- 面向 openEuler 开发者:熟悉 openEuler 开发贡献流程、关键特性、相关项目的开发等知识。 +- 面向 openEuler 运维人员:熟悉 openEuler 常见或疑难问题的解决思路和方案、openEuler 系统管理知识和相关命令。 + +## 用户手册目录 + +### 部署手册 + +- [Web 端部署指南](./部署指南) + - [网络环境下部署指南](./部署指南/网络环境下部署指南.md) + - [无网络环境下部署指南](./部署指南/无网络环境下部署指南.md) + +- [插件部署指南](./部署指南/插件部署指南) + - [智能调优](./部署指南/插件部署指南/智能调优/插件—智能调优部署指南.md) + - [智能诊断](./部署指南/插件部署指南/智能诊断/插件—智能诊断部署指南.md) + - [AI容器栈](./部署指南/插件部署指南/AI容器栈/插件—AI容器栈部署指南.md) + +- [本地资产库构建指南](./部署指南/本地资产库构建指南.md) + +### 使用手册 + +- [Web 端 (Gitee AI) 使用手册](./使用指南/线上服务/前言.md) + - [注册与登录](./使用指南/线上服务/注册与登录.md) + - [智能问答](./使用指南/线上服务/智能问答使用指南.md) + - [智能插件](./使用指南/线上服务/智能插件简介.md) + +- [智能 Shell 使用手册](./使用指南/命令行客户端/命令行助手使用指南.md) + - [准备工作:获取 API Key](./使用指南/命令行客户端/获取%20API%20Key.md) + - [智能插件](./使用指南/命令行客户端/命令行助手使用指南.md#智能插件) + - [智能调优](./使用指南/命令行客户端/智能调优.md) + - [智能诊断](./使用指南/命令行客户端/智能诊断.md) diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-chat-ask.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-chat-ask.png" new file mode 100644 index 0000000000000000000000000000000000000000..00d5cf5ecf894dd62366ec086bf96eae532f0b5d Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-chat-ask.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-chat-continue-result.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-chat-continue-result.png" new file mode 100644 index 0000000000000000000000000000000000000000..f30f9fe7a015e775742bc184b8ac75790dc482fa Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-chat-continue-result.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-chat-continue.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-chat-continue.png" new file mode 100644 index 0000000000000000000000000000000000000000..7e4801504fd53fab989574416e6220c4fa3f1d38 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-chat-continue.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-chat-exit.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-chat-exit.png" new file mode 100644 index 0000000000000000000000000000000000000000..0bb81190a3039f6c5a311b365376ec230c1ad4b5 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-chat-exit.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-cmd-edit-result.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-cmd-edit-result.png" new file mode 100644 index 0000000000000000000000000000000000000000..c5e6f8245e7d66cdbe5370f18d15a791a33a517a Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-cmd-edit-result.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-cmd-edit.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-cmd-edit.png" new file mode 100644 index 0000000000000000000000000000000000000000..bb6209373a6d2a1881728bee352e7c3b46cc91d7 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-cmd-edit.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-cmd-exec-multi-select.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-cmd-exec-multi-select.png" new file mode 100644 index 0000000000000000000000000000000000000000..2dda108a39af54fc15a4ff8c0dca107de38b9cf0 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-cmd-exec-multi-select.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-cmd-exec-result.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-cmd-exec-result.png" new file mode 100644 index 0000000000000000000000000000000000000000..f4fff6a62b8b4220b52fdf55b133f2ba37850569 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-cmd-exec-result.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-cmd-explain-result.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-cmd-explain-result.png" new file mode 100644 index 0000000000000000000000000000000000000000..707dd36aa7c7eadae4f29254cf5fc18ce877f597 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-cmd-explain-result.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-cmd-explain-select.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-cmd-explain-select.png" new file mode 100644 index 0000000000000000000000000000000000000000..bf58b69e241ea11a6945f21e3fc69d22a401be2e Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-cmd-explain-select.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-cmd-interact.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-cmd-interact.png" new file mode 100644 index 0000000000000000000000000000000000000000..00bb3a288fbd2fb962b08f34fbe90c733afe0343 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-cmd-interact.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-cmd.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-cmd.png" new file mode 100644 index 0000000000000000000000000000000000000000..619172c8ed60a7b536364944a306fbf76fcbfb1f Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-cmd.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-help.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-help.png" new file mode 100644 index 0000000000000000000000000000000000000000..97d0dedd3f7b1c749bc5fded471744923d766b8b Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-help.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-init.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-init.png" new file mode 100644 index 0000000000000000000000000000000000000000..bbb2257eb1ff2bfec36110409fc6c55a26386c9e Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-init.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-diagnose-detail.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-diagnose-detail.png" new file mode 100644 index 0000000000000000000000000000000000000000..7bd624e025eaae4b77c603d88bf1b9ad5e235fe7 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-diagnose-detail.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-diagnose-detect.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-diagnose-detect.png" new file mode 100644 index 0000000000000000000000000000000000000000..2b38259ff0c1c7045dbff9abf64f36a109a3377b Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-diagnose-detect.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-diagnose-profiling.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-diagnose-profiling.png" new file mode 100644 index 0000000000000000000000000000000000000000..0e63c01f35dbc291f805b56de749eac09e0a079d Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-diagnose-profiling.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-diagnose-report.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-diagnose-report.png" new file mode 100644 index 0000000000000000000000000000000000000000..c16f0184a2ad3d2468466b33d0e861d2a31bc4e2 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-diagnose-report.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-diagnose-switch-mode.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-diagnose-switch-mode.png" new file mode 100644 index 0000000000000000000000000000000000000000..165c6c453353b70c3e1e2cb07d7f43d5ee3525e3 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-diagnose-switch-mode.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-result.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-result.png" new file mode 100644 index 0000000000000000000000000000000000000000..3e3f45a974a0700d209f7d30af89eb2050a392d6 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-result.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-select.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-select.png" new file mode 100644 index 0000000000000000000000000000000000000000..13959203c77eaa9f41051897cf9e847ff3642a8a Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-select.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-tuning-metrics-collect.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-tuning-metrics-collect.png" new file mode 100644 index 0000000000000000000000000000000000000000..4d5678b7f77b05d48552fcb9656f4a4372dbbe61 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-tuning-metrics-collect.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-tuning-report.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-tuning-report.png" new file mode 100644 index 0000000000000000000000000000000000000000..01daaa9a84c13158a95afddffeb8a7e3303f1e76 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-tuning-report.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-tuning-script-exec.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-tuning-script-exec.png" new file mode 100644 index 0000000000000000000000000000000000000000..0b694c3fba6918ef39cca977b2072b2913d12b95 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-tuning-script-exec.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-tuning-script-gen.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-tuning-script-gen.png" new file mode 100644 index 0000000000000000000000000000000000000000..6e95551767e213f59669d03fd4cceba05801a983 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-tuning-script-gen.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-tuning-script-view.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-tuning-script-view.png" new file mode 100644 index 0000000000000000000000000000000000000000..c82c77bf6f4e4e19f400395aaadc9f99dc8d373c Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-tuning-script-view.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-tuning-switch-mode.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-tuning-switch-mode.png" new file mode 100644 index 0000000000000000000000000000000000000000..0f06c803ea3621a0f4fb83bbbe731e2bb4bba788 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin-tuning-switch-mode.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin.png" new file mode 100644 index 0000000000000000000000000000000000000000..4c1afd306a6aee029f5bda38aa7b1fce57227e31 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/pictures/shell-plugin.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/\345\221\275\344\273\244\350\241\214\345\212\251\346\211\213\344\275\277\347\224\250\346\214\207\345\215\227.md" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/\345\221\275\344\273\244\350\241\214\345\212\251\346\211\213\344\275\277\347\224\250\346\214\207\345\215\227.md" new file mode 100644 index 0000000000000000000000000000000000000000..751a5f48d6fcdefaa5b2ed13b56915b4459d600c --- /dev/null +++ "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/\345\221\275\344\273\244\350\241\214\345\212\251\346\211\213\344\275\277\347\224\250\346\214\207\345\215\227.md" @@ -0,0 +1,169 @@ +# 命令行助手使用指南 + +## 简介 + +openEuler Copilot System 命令行助手是一个命令行(Shell)AI 助手,您可以通过它来快速生成 Shell 命令并执行,从而提高您的工作效率。除此之外,基于 Gitee AI 在线服务的标准版本还内置了 openEuler 的相关知识,可以助力您学习与使用 openEuler 操作系统。 + +## 环境要求 + +- 操作系统:openEuler 22.03 LTS SP3,或者 openEuler 24.03 LTS 及以上版本 +- 命令行软件: + - Linux 桌面环境:支持 GNOME、KDE、DDE 等桌面环境的内置终端 + - 远程 SSH 链接:支持兼容 xterm-256 与 UTF-8 字符集的终端 + +## 安装 + +openEuler Copilot System 命令行助手支持通过 OEPKGS 仓库进行安装。 + +### 配置 OEPKGS 仓库 + +```bash +sudo dnf config-manager --add-repo https://repo.oepkgs.net/openeuler/rpm/`sed 's/release //;s/[()]//g;s/ /-/g' /etc/openEuler-release`/extras/`uname -m` +``` + +```bash +sudo dnf clean all +``` + +```bash +sudo dnf makecache +``` + +### 安装命令行助手 + +```bash +sudo dnf install eulercopilot-cli +``` + +若遇到 `Error: GPG check FAILED` 错误,使用 `--nogpgcheck` 跳过检查。 + +```bash +sudo dnf install --nogpgcheck eulercopilot-cli +``` + +## 初始化 + +```bash +copilot --init +``` + +然后根据提示输入 API Key 完成配置。 + +![shell-init](./pictures/shell-init.png) + +初次使用前请先退出终端或重新连接 SSH 会话使配置生效。 + +- **查看助手帮助页面** + + ```bash + copilot --help + ``` + + ![shell-help](./pictures/shell-help.png) + +## 使用 + +在终端中输入问题,按下 `Ctrl + O` 提问。 + +### 快捷键 + +- 输入自然语言问题后,按下 `Ctrl + O` 可以直接向 AI 提问。 +- 直接按下 `Ctrl + O` 可以自动填充命令前缀 `copilot`,输入参数后按下 `Enter` 即可执行。 + +### 智能问答 + +命令行助手初始化完成后,默认处于智能问答模式。 +命令提示符**左上角**会显示当前模式。 +若当前模式不是“智能问答”,执行 `copilot -c` (`copilot --chat`) 切换到智能问答模式。 + +![chat-ask](./pictures/shell-chat-ask.png) + +AI 回答完毕后,会根据历史问答生成推荐问题,您可以复制、粘贴到命令行中进行追问。输入追问的问题后,按下 `Enter` 提问。 + +![chat-next](./pictures/shell-chat-continue.png) + +![chat-next-result](./pictures/shell-chat-continue-result.png) + +智能问答模式下支持连续追问,每次追问最多可以关联3条历史问答的上下文。 + +输入 `exit` 可以退出智能问答模式,回到 Linux 命令行。 + +![chat-exit](./pictures/shell-chat-exit.png) + +- 若问答过程中遇到程序错误,可以按下 `Ctrl + C` 立即退出当前问答,再尝试重新提问。 + +### Shell 命令 + +AI 会根据您的问题返回 Shell 命令,openEuler Copilot System 命令行助手可以解释、编辑或执行这些命令,并显示命令执行结果。 + +![shell-cmd](./pictures/shell-cmd.png) + +命令行助手会自动提取 AI 回答中的命令,并显示相关操作。您可以通过键盘上下键选择操作,按下 `Enter` 确认。 + +![shell-cmd-interact](./pictures/shell-cmd-interact.png) + +#### 解释 + +如果 AI 仅返回了一条命令,选择解释后会直接请求 AI 解释命令,并显示回答。 +若 AI 回答了多条命令,选择后会显示命令列表,您每次可以选择**一条**请求 AI 解释。 + +![shell-cmd-explain-select](./pictures/shell-cmd-explain-select.png) + +完成解释后,您可以继续选择其他操作。 + +![shell-cmd-explain-result](./pictures/shell-cmd-explain-result.png) + +#### 编辑 + +![shell-cmd-edit](./pictures/shell-cmd-edit.png) + +选择一条命令进行编辑,编辑完成后按下 `Enter` 确认。 + +![shell-cmd-edit-result](./pictures/shell-cmd-edit-result.png) + +完成编辑后,您可以继续编辑其他命令或选择其他操作。 + +#### 执行 + +如果 AI 仅返回了一条命令,选择执行后会直接执行命令,并显示执行结果。 +若 AI 回答了多条命令,选择后会显示命令列表,您每次可以选择**多条**命令来执行。 + +您可以通过键盘上下键移动光标,按下 `空格键` 选择命令,按下 `Enter` 执行所选命令。 +被选中的命令会显示**蓝色高亮**,如图所示。 + +![shell-cmd-exec-multi-select](./pictures/shell-cmd-exec-multi-select.png) + +若不选择任何命令,直接按下 `Enter`,则会跳过执行命令,直接进入下一轮问答。 + +按下 `Enter` 后,被选中的命令会从上到下依次执行。 + +![shell-cmd-exec-result](./pictures/shell-cmd-exec-result.png) + +若执行过程中遇到错误,命令行助手会显示错误信息,并**终止执行命令**,进入下一轮问答。 +您可以在下一轮问答中提示 AI 更正命令,或要求 AI 重新生成命令。 + +### 智能插件 + +在 Linux 命令行中执行 `copilot -p` (`copilot --plugin`) 切换到智能插件模式。 + +![shell-plugin](./pictures/shell-plugin.png) + +输入问题并按下 `Ctrl + O` 提问后,从列表中选择插件,按下 `Enter` 调用插件回答问题。 + +![shell-plugin-select](./pictures/shell-plugin-select.png) + +![shell-plugin-result](./pictures/shell-plugin-result.png) + +## 卸载 + +```bash +sudo dnf remove eulercopilot-cli +``` + +然后使用以下命令删除配置文件。 + +```bash +rm ~/.config/eulercopilot/config.json +``` + +卸载完成后请重启终端或重新连接 SSH 会话使配置还原。 diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/\346\231\272\350\203\275\350\257\212\346\226\255.md" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/\346\231\272\350\203\275\350\257\212\346\226\255.md" new file mode 100644 index 0000000000000000000000000000000000000000..eb999cb5483620450b2e2aea77a818382aeca2a4 --- /dev/null +++ "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/\346\231\272\350\203\275\350\257\212\346\226\255.md" @@ -0,0 +1,50 @@ +# 智能插件:智能诊断 + +部署智能诊断工具后,可以通过 openEuler Copilot System 智能体框架实现对本机进行诊断。 +在智能诊断模式提问,智能体框架服务可以调用本机的诊断工具诊断异常状况、分析并生成报告。 + +## 操作步骤 + +**步骤1** 切换到“智能插件”模式 + +```bash +copilot -p +``` + +![切换到智能插件模式](./pictures/shell-plugin-diagnose-switch-mode.png) + +**步骤2** 异常事件检测 + +```bash +帮我进行异常事件检测 +``` + +按下 `Ctrl + O` 键提问,然后在插件列表中选择“智能诊断”。 + +![异常事件检测](./pictures/shell-plugin-diagnose-detect.png) + +**步骤3** 查看异常事件详情 + +```bash +查看 XXX 容器的异常事件详情 +``` + +![查看异常事件详情](./pictures/shell-plugin-diagnose-detail.png) + +**步骤4** 执行异常事件分析 + +```bash +请对 XXX 容器的 XXX 指标执行 profiling 分析 +``` + +![异常事件分析](./pictures/shell-plugin-diagnose-profiling.png) + +**步骤5** 查看异常事件分析报告 + +等待 5 至 10 分钟,然后查看分析报告。 + +```bash +查看 对应的 profiling 报告 +``` + +![执行优化脚本](./pictures/shell-plugin-diagnose-report.png) diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/\346\231\272\350\203\275\350\260\203\344\274\230.md" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/\346\231\272\350\203\275\350\260\203\344\274\230.md" new file mode 100644 index 0000000000000000000000000000000000000000..b5c40581668ae4f6074043e62a93b2c4b240e5b3 --- /dev/null +++ "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/\346\231\272\350\203\275\350\260\203\344\274\230.md" @@ -0,0 +1,53 @@ +# 智能插件:智能调优 + +部署智能调优工具后,可以通过 openEuler Copilot System 智能体框架实现对本机进行调优。 +在智能调优模式提问,智能体框架服务可以调用本机的调优工具采集性能指标,并生成性能分析报告和性能优化建议。 + +## 操作步骤 + +**步骤1** 切换到“智能调优”模式 + +```bash +copilot -t +``` + +![切换到智能调优模式](./pictures/shell-plugin-tuning-switch-mode.png) + +**步骤2** 采集性能指标 + +```bash +帮我进行性能指标采集 +``` + +![性能指标采集](./pictures/shell-plugin-tuning-metrics-collect.png) + +**步骤3** 生成性能分析报告 + +```bash +帮我生成性能分析报告 +``` + +![性能分析报告](./pictures/shell-plugin-tuning-report.png) + +**步骤4** 生成性能优化建议 + +```bash +请生成性能优化脚本 +``` + +![性能优化脚本](./pictures/shell-plugin-tuning-script-gen.png) + +**步骤5** 选择“执行命令”,运行优化脚本 + +![执行优化脚本](./pictures/shell-plugin-tuning-script-exec.png) + +- 脚本内容如图: + ![优化脚本内容](./pictures/shell-plugin-tuning-script-view.png) + +## 远程调优 + +如果需要对其他机器进行远程调优,请在上文示例的问题前面加上对应机器的 IP 地址。 + +例如:`请对 192.168.1.100 这台机器进行性能指标采集。` + +进行远程调优前请确保目标机器已部署智能调优工具,同时请确保 openEuler Copilot System 智能体框架能够访问目标机器。 diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/\350\216\267\345\217\226 API Key.md" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/\350\216\267\345\217\226 API Key.md" new file mode 100644 index 0000000000000000000000000000000000000000..6c6c2ac56bdcfa2e0bbe6a880e420b17394e2306 --- /dev/null +++ "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\221\275\344\273\244\350\241\214\345\256\242\346\210\267\347\253\257/\350\216\267\345\217\226 API Key.md" @@ -0,0 +1,28 @@ +# 获取 API Key + +## 前言 + +openEuler Copilot System 命令行助手使用 API Key 来验证用户身份,并获取 API 访问权限。 +因此,开始使用前,您需要先获取 API Key。 + +## 注意事项 + +- 请妥善保管您的 API Key,不要泄露给他人。 +- API Key 仅用于命令行助手与 DevStation 桌面端,不用于其他用途。 +- 每位用户仅可拥有一个 API Key,重复创建 API Key 将导致旧密钥失效。 +- API Key 仅在创建时显示一次,请务必及时保存。若密钥丢失,您需要重新创建。 +- 若您在使用过程中遇到“请求过于频繁”的错误,您的 API Key 可能已被他人使用,请及时前往官网刷新或撤销 API Key。 + +## 获取方法 + +1. 登录 [openEuler Copilot System (Gitee AI) 官网](https://eulercopilot.gitee.com)。 +2. 点击右上角头像,选择“API KEY”。 +3. 点击“新建”按钮。 +4. **请立即保存 API Key,它仅在创建时显示一次,请勿泄露给他人。** + +## 管理 API Key + +1. 登录 [openEuler Copilot System (Gitee AI) 官网](https://eulercopilot.gitee.com)。 +2. 点击右上角头像,选择“API KEY”。 +3. 点击“刷新”按钮,刷新 API Key;点击“撤销”按钮,撤销 API Key。 + - 刷新 API Key 后,旧密钥失效,请立即保存新生成的 API Key。 diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\272\224\347\224\250\345\274\200\345\217\221\346\241\206\346\236\266\345\267\245\345\205\267\344\275\277\347\224\250\346\214\207\345\215\227.md" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\272\224\347\224\250\345\274\200\345\217\221\346\241\206\346\236\266\345\267\245\345\205\267\344\275\277\347\224\250\346\214\207\345\215\227.md" new file mode 100644 index 0000000000000000000000000000000000000000..4a0547db01de86fa8ad7041aa288ddd0cc6a026d --- /dev/null +++ "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\345\272\224\347\224\250\345\274\200\345\217\221\346\241\206\346\236\266\345\267\245\345\205\267\344\275\277\347\224\250\346\214\207\345\215\227.md" @@ -0,0 +1,239 @@ +# 应用开发框架工具使用指南 + +- 应用开发框架工具是用于协助AI应用开发的脚本工具,该指南主要是为个人及企业开发者在使用openEuler_Copilot_System进行AI应用开发时,提供以命令行的方式进行问答对生成、文档优化、Embedding模型微调的工具。 + +## 1. 生成问答对 + +### 1.1 功能简介 + +该功能用于将原始数据转换为问答对,并将问答对保存为 json(默认)/xlsx/yaml 格式的文件。 + +### 1.2 功能参数说明 + +| 参数名 | 默认值 | 说明 | +| ------------- | ------ | ------------------------------------------------------------ | +| path | | 必填,指定待处理的文件路径,支持 docx、pdf、txt 等格式 | +| output_path | | 必填,指定输出路径 | +| output_format | json | 可选,指定输出格式,支持 json、xlsx、yaml 三种格式 | +| enhance | False | 可选,是否使用增强模式,增强模式下,将通过验证机制增强生成的问答对的准确率 | +| qa_count | 5 | 可选,指定生成问答对的数量,对于每个文档随机选择若干chunk生成qa_count个问答对 | + +### 1.3 使用示范 + +```bash +python utils/main.py \ +qa_generate \ +--path docs/examples.xlsx \ +--output_path output \ +--output_format json \ +--enhance \ +--qa_count 10 +``` + +### 1.4 结果输出 + +结果输出在 output_path 目录下 + +## 2. 文档治理 + +### 2.1 功能简介 + +该功能用于优化文档的表现形式,功能包括: + +1. 去除重复段落、文本 +2. 敏感信息脱敏(自定义敏感词、敏感内容格式) +3. 文档内容标准化,包括统一编码格式、统一全半角等 +4. 文档内容格式化,包括通用场景(段落总结,支持自定义格式)、开发场景(代码注释)、运维场景(案例整理)三种类别 + +### 2.2 功能参数说明 + +| 参数名 | 默认值 | 说明 | +| ------------- | ------- | ------------------------------------------------------------ | +| method | | 必填,指定脚本的功能,此处为 "document_governance" | +| path | | 必填,指定待处理的文件路径,支持 docx、pdf、txt 等格式 | +| output_path | | 必填,指定输出路径 | +| output_format | json | 可选,指定输出格式,支持 json、xlsx、yaml 三种格式 | +| standardize | False | 可选,是否进行文档内容标准化,包括统一编码格式、统一全半角等 | +| unique | False | 可选,是否去除重复段落、文本 | +| format | False | 可选,是否进行文档内容格式化,包括通用场景(段落总结)、开发场景(代码注释)、运维场景(案例整理)三种类别 | +| format_mode | general | 可选,指定文档内容格式化模式,包括 "general"、"develop"、"OPS" 分别对应上述三种场景 | + +### 2.3 使用示范 + +```bash +python3 utils/main.py \ + document_governance \ + --path docs/test.txt \ + --output_path output/document \ + --standardize \ + --format \ + --unique \ + --output_format md \ + --format_mode develop +``` + +### 2.4 自定义内容 + +#### 2.4.1 自定义敏感词 + +敏感词文件为 sensitive_words.txt,每行一个敏感词,示例如下: + +```text +暴力 +色情 +赌博 +毒品 +诈骗 +``` + +敏感格式表文件为 sensitive_pattern.txt,每行一个敏感句式,通过正则表达式匹配,示例如下: + +```text +\b(赌|博)\b +\b(毒|品)\b +\b(诈|骗)\b +\b(暴|力)\b +\b(色|情)\b +``` + +术语替换文件为 term_replacements.txt,每行一个替换词,示例如下: + +```text +医生:医师 +护士:护理人员 +医院:医疗机构 +手术:外科操作 +药物:药剂 +``` + +### 2.5 结果输出 + +结果输出在 output_path 目录下 + +## 3. 向量模型微调 + +### 3.1 功能简介 + +该功能用于微调指定的向量模型,包括 bge-large-zh、bge-large-en、bge-small-zh、bge-small-en 等。 + +### 3.2 数据集/测试集 + +#### 3.2.1 数据格式 + +数据集格式为 jsonl,示例如下: + +```json +{"query": str, "pos": List[str], "neg":List[str], "pos_scores": List[int], "neg_scores": List[int], "prompt": str, "type": str} +``` + +其中 query 为问题,pos 为正例,neg 为负例,pos_scores 为正例的打分,neg_scores 为负例的打分,prompt 为提示词,type 为数据分类。 + +测试集格式为 json,示例如下: + +```json +{ + "corpus": { + "content": list[str], + }, + "test_data": { + "query": list[str], + "mapper": { # key: query, value: answer + str: str, + } + } +} + +``` + +其中 corpus 为语料库,test_data 为测试集,query 为问题,mapper 为正确答案。 + +#### 3.2.2 生成方式 + +1) 使用脚本生成问答对到 output_path,或者使用数据集和测试集自行构造成 xlsx 格式,格式为 question 列为 query,answer 列为答案。 +2) 使用脚本生成训练集和测试集,生成方法如下:请执行 data_processing.py 脚本将你的数据处理成如下 jsonl 格式 + +```json +{"query": str, "pos": List[str], "neg":List[str]} +``` + +query是查询指令,pos是正例列表,neg是负例列表 + +```bash +python utils/my_tools/bge_finetune/data_processing.py \ +--input_dir data_path \ +--output_dir output_path \ +--train_num 10000 +``` + +- input_dir 问答对数据存放目录 +- output_dir 训练集和测试机输出目录 +- train_num 训练集数量 + +如果数据中没有负例,则可以使用以下命令从整个语料库中随机抽取样本做负例增强: + +```bash +python ./utils/my_tools/bge_finetune/hn_mine.py \ + --model_name_or_path BAAI/bge-large-zh-v1.5 \ + --input_file path/to/data.jsonl \ + --output_file path/to/data_minedHN.jsonl \ + --range_for_sampling 2-200 \ + --negative_number 15 \ + --use_gpu_for_searching +``` + +- input_file:jsonl 格式的原始训练数据 +- output_file:负例增强后输出的 jsonl 数据的路径 +- range_for_sampling:采样区间,例如,2-100表示从 top2-top200 文档中采样负样本 +- negative_number:采样负样本的数量 +- use_gpu_for_searching:是否使用 faiss-gpu 来检索 + +### 3.3 功能参数说明 + +| 参数名 | 默认值 | 说明 | +| ------------------ | ------ | --------------------------------------------------- | +| method | | 必填,指定脚本的功能,此处为 "embedding_training" | +| train_data | | 必填,指定训练数据路径,支持 jsonl 格式 | +| test_data | | 必填,指定测试数据路径,支持 json 格式 | +| output_path | | 必填,指定模型输出路径 | +| batch_size | 8 | 可选,指定训练批次大小 | +| learning_rate | 5e-5 | 可选,指定学习率 | +| deepspeed | | 可选,指定 deepspeed 配置文件路径,用于优化微调速度 | +| epochs | 3 | 可选,指定训练轮数 | +| save_steps | 1000 | 可选,指定保存模型的步数 | +| logging_steps | 100 | 可选,指定日志输出的步数 | +| gpu_num | 1 | 可选,指定使用的 GPU 数量 | +| model_name_or_path | | 可选,指定微调的模型路径,默认为 bge-large-zh-v1.5 | +| temperature | 0.02 | 可选,指定温度参数,默认为 0.02 | +| warmup | 0.1 | 可选,指定预热比例,默认为 0.1 | + +### 3.4 准备工作 + +安装FlagEmbedding库,安装对应CUDA和torch版本,并配置好需要的环境变量 + +### 3.5 使用示范 + +```bash +python3 utils/main.py \ + embedding_training \ + --train_data output/bge/train_data_mineHN.jsonl \ + --test_data output/bge/test_data.json \ + --output_path output/test_encoder_only_base_bge-large-en-v1.5 \ + --batch_size 2 \ + --learning_rate 5e-5 \ + --deepspeed utils/my_tools/bge_finetune/ds_stage0.json \ + --epochs 50 \ + --save_steps 1000 \ + --logging_steps 100 \ + --gpu_num 2 \ + --model_name_or_path ./bge_model/bge-large-en-v1.5 \ + --temperature 0.02 \ + --warmup 0.1 +``` + +由于具体执行环境不同,可能需要配置一些其他的环境变量,依照错误指示处理即可 + +### 3.6 结果输出 + +微调后模型输出在 **output_path** 对应目录下,报告输出在 **./report/embedding/{训练完成时间}** 目录下,报告包含训练过程曲线图、模型预测结果等。 + +需要进行模型评估和合并,请参考./utils/my_tools/bge_finetune/README.md diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/bulk-delete-confirmation.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/bulk-delete-confirmation.png" new file mode 100644 index 0000000000000000000000000000000000000000..33230200fbe9f1e0fa72c27f51b8786192aa14f2 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/bulk-delete-confirmation.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/bulk-delete-multi-select.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/bulk-delete-multi-select.png" new file mode 100644 index 0000000000000000000000000000000000000000..96d8201681c4a7772c815a2b9183a0efca9179c2 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/bulk-delete-multi-select.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/bulk-delete.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/bulk-delete.png" new file mode 100644 index 0000000000000000000000000000000000000000..929230cd06cc792b633ab183155225926d2c300d Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/bulk-delete.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/chat-area.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/chat-area.png" new file mode 100644 index 0000000000000000000000000000000000000000..752f18ad4bd85aaa1132c50cc4c7b7dc159aec91 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/chat-area.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/context-support.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/context-support.png" new file mode 100644 index 0000000000000000000000000000000000000000..0bd5f091d0eff34d9b5f36eec6df63b191656daa Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/context-support.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/delete-session-confirmation.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/delete-session-confirmation.png" new file mode 100644 index 0000000000000000000000000000000000000000..efd07828e97de46c9660c162ef553362765d5577 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/delete-session-confirmation.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/delete-session.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/delete-session.png" new file mode 100644 index 0000000000000000000000000000000000000000..596af33f7be41d456a57e6a297820530f8485f34 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/delete-session.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/feedback-illegal.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/feedback-illegal.png" new file mode 100644 index 0000000000000000000000000000000000000000..b6e84ba45977d911db960da97bdff714624ba18c Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/feedback-illegal.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/feedback-misinfo.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/feedback-misinfo.png" new file mode 100644 index 0000000000000000000000000000000000000000..cc5505226add1e6fbde7b93ff09877038e8cfdce Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/feedback-misinfo.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/feedback.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/feedback.png" new file mode 100644 index 0000000000000000000000000000000000000000..9fe1c27acb57d4d24a26c8dde61ee4272f954e46 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/feedback.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/gitee-login-click2signup.jpg" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/gitee-login-click2signup.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..dde8fbe201a44c116e58c3d435737f1a6a3f6f34 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/gitee-login-click2signup.jpg" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/gitee-login.jpg" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/gitee-login.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..ac922094fd513e3f8642f885351f541200e6450b Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/gitee-login.jpg" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/gitee-signup.jpg" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/gitee-signup.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..57e473466cba423be0d6f76814b5a0656804a884 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/gitee-signup.jpg" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/icon-arrow-next.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/icon-arrow-next.png" new file mode 100644 index 0000000000000000000000000000000000000000..1a36c84e0965f9dbf1f90e9a3daadcd1a2560951 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/icon-arrow-next.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/icon-arrow-prev.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/icon-arrow-prev.png" new file mode 100644 index 0000000000000000000000000000000000000000..eb667e93cc6d51aa191a0ac7607e72d4d6923cbc Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/icon-arrow-prev.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/icon-cancel.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/icon-cancel.png" new file mode 100644 index 0000000000000000000000000000000000000000..34d4454b6f92ee12db6841dafe0e94a12c3b9584 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/icon-cancel.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/icon-confirm.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/icon-confirm.png" new file mode 100644 index 0000000000000000000000000000000000000000..1d650f8192e04fae8f7b7c08cd527227c91b833a Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/icon-confirm.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/icon-edit.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/icon-edit.png" new file mode 100644 index 0000000000000000000000000000000000000000..f7b28aa605b5e899855a261d641d27a2674703eb Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/icon-edit.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/icon-search.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/icon-search.png" new file mode 100644 index 0000000000000000000000000000000000000000..7902923196c3394ae8eafaf5a2b6fdf7f19b1f40 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/icon-search.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/icon-thumb-down.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/icon-thumb-down.png" new file mode 100644 index 0000000000000000000000000000000000000000..cda14d196d92898da920ed64ad37fa9dd124c775 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/icon-thumb-down.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/icon-thumb-up.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/icon-thumb-up.png" new file mode 100644 index 0000000000000000000000000000000000000000..c75ce44bff456e24bc19040c18e4e644bbb77bd1 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/icon-thumb-up.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/icon-user.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/icon-user.png" new file mode 100644 index 0000000000000000000000000000000000000000..e6b06878b76d9e6d268d74070539b388129fa8c4 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/icon-user.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/login-popup.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/login-popup.png" new file mode 100644 index 0000000000000000000000000000000000000000..4ac4116f72aa56c81affdb31b806325966331aa9 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/login-popup.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/logout.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/logout.png" new file mode 100644 index 0000000000000000000000000000000000000000..e2288c35d89d598f3bb8d939bdf6a9d125bcae83 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/logout.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/main-page-sections.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/main-page-sections.png" new file mode 100644 index 0000000000000000000000000000000000000000..155b68928177de0785f4705d2df14c0233b24743 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/main-page-sections.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/new-chat.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/new-chat.png" new file mode 100644 index 0000000000000000000000000000000000000000..176bb3e1e932caa758a56540345218c57ee2ff20 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/new-chat.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/plugin-list.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/plugin-list.png" new file mode 100644 index 0000000000000000000000000000000000000000..2745f7d82a21cd9eba139898f5ea0c5ab979037f Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/plugin-list.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/plugin-result.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/plugin-result.png" new file mode 100644 index 0000000000000000000000000000000000000000..7056aebeecba8760e0ca2773348cce0a0b8167f1 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/plugin-result.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/plugin-selected.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/plugin-selected.png" new file mode 100644 index 0000000000000000000000000000000000000000..9182ffa57db9da349cb36186a7b3cb035b51b8aa Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/plugin-selected.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/plugin-suggestion.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/plugin-suggestion.png" new file mode 100644 index 0000000000000000000000000000000000000000..bb416881550349000f61b0c1bd3dd540878bd6ad Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/plugin-suggestion.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/privacy-policy-entry.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/privacy-policy-entry.png" new file mode 100644 index 0000000000000000000000000000000000000000..d7efce3e6e8d477ef47a1bc8a9bba0d087cf8058 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/privacy-policy-entry.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/privacy-policy.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/privacy-policy.png" new file mode 100644 index 0000000000000000000000000000000000000000..dc22c50de7f9d2dc3e0bf523175e7915c91c630f Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/privacy-policy.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/recommend-questions.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/recommend-questions.png" new file mode 100644 index 0000000000000000000000000000000000000000..076ec7092af7fe7987e5dc7c864a6b9f8b2b1160 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/recommend-questions.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/regenerate.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/regenerate.png" new file mode 100644 index 0000000000000000000000000000000000000000..655c9d5002df4a17aaf84e8780fff4a0118c6c01 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/regenerate.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/rename-session-confirmation.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/rename-session-confirmation.png" new file mode 100644 index 0000000000000000000000000000000000000000..d64708bd57d53deafdc5ddbb70d9deaeaca0d132 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/rename-session-confirmation.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/rename-session.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/rename-session.png" new file mode 100644 index 0000000000000000000000000000000000000000..73e7e19c5ac8e8035df0e4b553a9b78ff5c9a051 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/rename-session.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/report-options.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/report-options.png" new file mode 100644 index 0000000000000000000000000000000000000000..8a54fd2598d51fc40b57052f404dd830cf621f4d Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/report-options.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/report.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/report.png" new file mode 100644 index 0000000000000000000000000000000000000000..471bcbe8614fc8bab4dcc1805fa1bf4574990fc8 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/report.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/search-history.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/search-history.png" new file mode 100644 index 0000000000000000000000000000000000000000..2239d14a7aa8bc13a7b8d3ec71ba9ed71b95e850 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/pictures/search-history.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/\345\211\215\350\250\200.md" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/\345\211\215\350\250\200.md" new file mode 100644 index 0000000000000000000000000000000000000000..2f03aeedc7b21343282f29d0e8774fa2c211ecfa --- /dev/null +++ "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/\345\211\215\350\250\200.md" @@ -0,0 +1,67 @@ +# 前言 + +## 概述 + +本文档介绍了 openEuler Copilot System 的使用方法,对 openEuler Copilot System 线上服务的 Web 界面的各项功能做了详细介绍,同时提供了常见的问题解答,详细请参考对应手册。 + +## 读者对象 + +本文档主要适用于 openEuler Copilot System 的使用人员。使用人员必须具备以下经验和技能: + +- 熟悉 openEuler 操作系统相关情况。 +- 有 AI 对话使用经验。 + +## 修改记录 + +| 文档版本 | 发布日期 | 修改说明 | +|--------|------------|----------------| +| 03 | 2024-09-19 | 更新新版界面。 | +| 02 | 2024-05-13 | 优化智能对话操作指引。 | +| 01 | 2024-01-28 | 第一次正式发布。 | + +## 介绍 + +### 免责声明 + +- 使用过程中涉及的非工具本身验证功能所用的用户名和密码,不作他用,且不会被保存在系统环境中。 +- 在您进行对话或操作前应当确认您为应用程序的所有者或已获得所有者的充足授权同意。 +- 对话结果中可能包含您所分析应用的内部信息和相关数据,请妥善管理。 +- 除非法律法规或双方合同另有规定,openEuler 社区对分析结果不做任何明示或暗示的声明和保证,不对分析结果的适销性、满意度、非侵权性或特定用途适用性等作出任何保证或者承诺。 +- 您根据分析记录所采取的任何行为均应符合法律法规的要求,并由您自行承担风险。 +- 未经所有者授权,任何个人或组织均不得使用应用程序及相关分析记录从事任何活动。openEuler 社区不对由此造成的一切后果负责,亦不承担任何法律责任。必要时,将追究其法律责任。 + +### openEuler Copilot System 简介 + +openEuler Copilot System 是一个基于 openEuler 操作系统的人工智能助手,可以帮助用户解决各种技术问题,提供技术支持和咨询服务。它使用了最先进的自然语言处理技术和机器学习算法,能够理解用户的问题并提供相应的解决方案。 + +### 场景内容 + +1. OS 领域通用知识:openEuler Copilot System 可以咨询 Linux 常规知识、上游信息和工具链介绍和指导。 +2. openEuler 专业知识:openEuler Copilot System 可以咨询 openEuler 社区信息、技术原理和使用指导。 +3. openEuler 扩展知识:openEuler Copilot System 可以咨询 openEuler 周边硬件特性知识和ISV、OSV相关信息。 +4. openEuler 应用案例:openEuler Copilot System 可以提供 openEuler 技术案例、行业应用案例。 +5. shell 命令生成:openEuler Copilot System 可以帮助用户生成单条 shell 命令或者复杂命令。 + +总之,openEuler Copilot System 可以应用于各种场景,帮助用户提高工作效率和了解 Linux、openEuler 等的相关知识。 + +### 访问和使用 + +openEuler Copilot System 通过网址访问 Web 网页进行使用。账号注册与登录请参考[注册与登录](./注册与登录.md)。使用方法请参考[智能问答使用指南](./智能问答使用指南.md)。 + +### 界面说明 + +#### 界面分区 + +openEuler Copilot System 界面主要由如图 1 所示的区域组成,各个区域的作用如表 1 所示。 + +- 图 1 openEuler Copilot System 界面 +![Copilot 界面](./pictures/main-page-sections.png) + +- 表 1 openEuler Copilot System 首页界面分区说明 + +| 区域 | 名称 | 说明 | +|-----|------------|----------------------------------------------------------------| +| 1 | 设置管理区 | 提供账号登录和退出操作入口和明亮/黑暗模式切换功能 | +| 2 | 对话管理区 | 用于用户新建对话、对话历史记录管理和对话历史记录批量删除操作 | +| 3 | 对话区 | 用于用户和 openEuler Copilot System 的对话聊天 | +| 4 | 服务协议和隐私政策区 | 提供查看服务协议和隐私政策入口 | diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/\346\231\272\350\203\275\346\217\222\344\273\266\347\256\200\344\273\213.md" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/\346\231\272\350\203\275\346\217\222\344\273\266\347\256\200\344\273\213.md" new file mode 100644 index 0000000000000000000000000000000000000000..3a37dc9384dcc2080ceb7a687e94e9700e4513eb --- /dev/null +++ "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/\346\231\272\350\203\275\346\217\222\344\273\266\347\256\200\344\273\213.md" @@ -0,0 +1,19 @@ +# 智能插件 + +## 使用方法 + +1. 如图所示,在输入框左上角可以选择插件,点击显示插件列表。 + + ![智能插件](./pictures/plugin-list.png) + +2. 勾选一个插件,然后提问。 + + ![智能插件](./pictures/plugin-selected.png) + +3. 等待服务响应,查看返回结果。 + + 智能插件模式下,推荐问题将置顶推荐的工作流,蓝色文字为对应插件名称,点击后可快捷追问。 + + ![智能插件](./pictures/plugin-suggestion.png) + + ![智能插件](./pictures/plugin-result.png) diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/\346\231\272\350\203\275\351\227\256\347\255\224\344\275\277\347\224\250\346\214\207\345\215\227.md" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/\346\231\272\350\203\275\351\227\256\347\255\224\344\275\277\347\224\250\346\214\207\345\215\227.md" new file mode 100644 index 0000000000000000000000000000000000000000..a4d0c0e270b9931d6aa1a72d0397655ac4d9c1ca --- /dev/null +++ "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/\346\231\272\350\203\275\351\227\256\347\255\224\344\275\277\347\224\250\346\214\207\345\215\227.md" @@ -0,0 +1,134 @@ +# 智能问答使用指南 + +## 开始对话 + +在对话区下侧输入框即可输入对话想要提问的内容,输入 `Shift + Enter` 可进行换行,输入 `Enter` 即可发送对话提问内容,或者单击“发送”也可发送对话提问内容。 + +> **说明** +> 对话区位于页面的主体部分,如图 1 所示。 + +- 图 1 对话区 + ![对话区](./pictures/chat-area.png) + +### 多轮连续对话 + +openEuler Copilot System 智能问答支持多轮连续对话。只需要在同一个对话中继续追问即可使用,如图 2 所示。 + +- 图 2 多轮对话 + ![多轮对话](./pictures/context-support.png) + +### 重新生成 + +如遇到 AI 生成的内容有误或不完整的特殊情况,可以要求 AI 重新回答问题。单击对话回答左下侧的“重新生成”文字,可让 openEuler Copilot System 重新回答用户问题,重新回答后,在对话回答右下侧,会出现回答翻页的图标![向前翻页](./pictures/icon-arrow-prev.png)和![向后翻页](./pictures/icon-arrow-next.png),单击![向前翻页](./pictures/icon-arrow-prev.png)或![向后翻页](./pictures/icon-arrow-next.png)可查看不同的回答,如图 3 所示。 + +- 图 3 重新生成 + ![重新生成](./pictures/regenerate.png) + +### 推荐问题 + +在 AI 回答的下方,会展示一些推荐的问题,单击即可进行提问,如图 4 所示。 + +- 图 4 推荐问题 + ![推荐问题](./pictures/recommend-questions.png) + +## 管理对话 + +> **须知** +> +> 对话管理区页面左侧。 + +### 新建对话 + +单击“新建对话”按钮即可新建对话,如图 5 所示。 + +- 图 5 新建对话 + ![新建对话](./pictures/new-chat.png) + +### 对话历史记录搜索 + +在页面左侧历史记录搜索输入框输入关键词,然后单击![icon-search](./pictures/icon-search.png)即可进行对话历史记录搜索如图 6 所示。 + +- 图 6 对话历史记录搜索 + ![对话历史记录搜索](./pictures/search-history.png) + +### 对话历史记录单条管理 + +历史记录的列表位于历史记录搜索栏的下方,在每条对话历史记录的右侧,单击![编辑](./pictures/icon-edit.png)即可编辑对话历史记录的名字,如图 7 所示。 + +- 图 7 重命名历史记录 + ![重命名历史记录](./pictures/rename-session.png) + +在对话历史记录名字重新书写完成后,单击右侧![确认](./pictures/icon-confirm.png)即可完成重命名,或者单击右侧![取消](./pictures/icon-cancel.png)放弃本次重命名,如图 8 所示。 + +- 图 8 完成/取消重命名历史记录 + ![完成/取消重命名历史记录](./pictures/rename-session-confirmation.png) + +另外,单击对话历史记录右侧的删除图标,如图 9 所示,即可对删除单条对话历史记录进行二次确认,在二次确认弹出框,如图 10 所示,单击“确认”,可确认删除单条对话历史记录,或者单击“取消”,取消本次删除。 + +- 图 9 删除单条历史记录 + ![删除单条历史记录](./pictures/delete-session.png) + +- 图 10 删除单条历史记录二次确认 + ![删除单条历史记录二次确认](./pictures/delete-session-confirmation.png) + +### 对话历史记录批量删除 + +首先单击“批量删除”,如图 11 所示。 + +- 图 11 批量删除 + ![批量删除](./pictures/bulk-delete.png) + +然后可对历史记录进行选择删除,如图 12 所示。单击“全选”,即对所有历史记录选中,单击单条历史记录或历史记录左侧的选择框,可对单条历史记录进行选中。 + +- 图 12 批量删除历史记录选择 + ![批量删除历史记录选择](./pictures/bulk-delete-multi-select.png) + +最后需要对批量删除历史记录进行二次确认,如图 13 所示,单击“确认”,即删除,单击“取消”,即取消本次删除。 + +- 图 13 批量删除二次确认 + ![批量删除二次确认](./pictures/bulk-delete-confirmation.png) + +## 反馈与举报 + +在对话记录区,对话回答的右下侧,可进行对话回答反馈,如图 14 所示,单击![满意](./pictures/icon-thumb-up.png),可给对话回答点赞;单击![不满意](./pictures/icon-thumb-down.png),可以给对话回答反馈不满意的原因。 + +- 图 14 点赞和不满意反馈 + ![点赞和不满意反馈](./pictures/feedback.png) + +对于反馈不满意原因,如图 15 所示,在单击![不满意](./pictures/icon-thumb-down.png)之后,对话机器人会展示反馈内容填写的对话框,可选择相关的不满意原因的选项。 + +- 图 15 回答不满意反馈 + ![回答不满意反馈](./pictures/feedback-illegal.png) + +其中单击选择“存在错误信息”,需要填写参考答案链接和描述,如图 16 所示。 + +- 图 16 回答不满意反馈——存在错误信息 + ![回答不满意反馈——存在错误信息](./pictures/feedback-misinfo.png) + +### 举报 + +如果发现 AI 返回的内容中有违规信息,可以点击右下角按钮举报,如图 17 所示。点击举报后选择举报类型并提交,若没有合适的选项,请选择“其他”并输入原因,如图 18 所示。 + +- 图 17 举报按钮 + ![举报1](./pictures/report.png) + +- 图 18 选择举报类型 + ![举报2](./pictures/report-options.png) + +## 查看服务协议和隐私政策 + +单击文字“服务协议”,即可查看服务协议,单击文字“隐私政策”,即可查看隐私政策,如图 19、图 20 所示。 + +- 图 19 服务协议和隐私政策入口 + ![服务协议和隐私政策入口](./pictures/privacy-policy-entry.png) + +- 图 20 服务协议和隐私政策 + ![服务协议和隐私政策](./pictures/privacy-policy.png) + +## 附录 + +### 用户信息导出说明 + +#### 具体说明 + +openEuler Copilot System 后台存在用户信息导出功能,如用户需要,需主动通过 邮箱联系我们,运维会将导出的用户信息通过邮箱回送给用户。 diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/\346\263\250\345\206\214\344\270\216\347\231\273\345\275\225.md" "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/\346\263\250\345\206\214\344\270\216\347\231\273\345\275\225.md" new file mode 100644 index 0000000000000000000000000000000000000000..9fda980c7756f599db97a97f70f79e213c4136ef --- /dev/null +++ "b/docs/zh/docs/AI/openEuler_Copilot_System/\344\275\277\347\224\250\346\214\207\345\215\227/\347\272\277\344\270\212\346\234\215\345\212\241/\346\263\250\345\206\214\344\270\216\347\231\273\345\275\225.md" @@ -0,0 +1,68 @@ +# 登录 openEuler Copilot System + +本章节以 Windows 10 操作系统安装的 Chrome 121 浏览器为例介绍登录 openEuler Copilot System 界面的操作步骤。 + +## 浏览器要求 + +浏览器要求如表 1 所示。 + +- 表 1 浏览器要求 + +| 浏览器类型 | 最低版本 | 推荐版本 | +| ----- | ----- | ----- | +| Google Chrome | 72 | 121 或更高版本 | +| Mozilla Firefox | 89 | 122 或更高版本 | +| Apple Safari | 11.0 | 16.3 或更高版本 | + +## 申请访问权限 + +访问 openEuler Copilot System 在线环境,需要依照[【GITEE AI】openEuler Copilot System 在线环境体验申请教程](https://gitee.com/openeuler/euler-copilot-framework/issues/IARUWT?from=project-issue)申请访问权限 + +## 操作步骤 + +> **须知** +> openEuler Copilot System 线上服务 (Gitee AI) 账号和 Gitee 官网账号是通用的。 + +**步骤1** 打开本地 PC 机的浏览器,在地址栏输入 [https://ai.gitee.com/apps/zhengw99/openEulerCopilotSystem](https://ai.gitee.com/apps/zhengw99/openEulerCopilotSystem),按 `Enter`。在未登录状态,进入 openEuler Copilot System,会出现登录提示弹出框,如图 1 所示。 + +- 图 1 未登录 +![未登录](./pictures/login-popup.png) + +**步骤2** 登录 openEuler Copilot System(已注册账号)。 + +打开登录界面,如图 2 所示。 + +- 图 2 登录 openEuler Copilot System +![登录 openEuler Copilot System](./pictures/gitee-login.jpg) + +## 注册 openEuler Copilot System 账号 + +> **前提条件** +> 未注册 Gitee 账号。 + +**步骤1** 进入登录页,单击“点此注册”,如图 3 所示。 + +- 图 3 点此注册 +![点此注册](./pictures/gitee-login-click2signup.jpg) + +**步骤2** 进入账号注册页,根据页面提示填写相关内容,如图 4 所示。 + +- 图 4 账号注册 +![账号注册](./pictures/gitee-signup.jpg) + +**步骤3** 按页面要求填写账号信息后,单击“立即注册”,即可注册成功。注册后即可返回登录。 + +## 退出登录 + +> **前提条件** +> 已登录 openEuler Copilot System + +**步骤1** 单击![退出登录](./pictures/icon-user.png)后,会出现“退出登录”下拉框,如图 5 所示。 + +> **说明** +> 账号管理区位于页面的右上角部分,如图 5 所示。 + +- 图 5 账号管理区 +![账号管理区](./pictures/logout.png) + +**步骤2** 单击“退出登录”即可退出登录,如图 5 所示。 diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/WEB\347\225\214\351\235\242.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/WEB\347\225\214\351\235\242.png" new file mode 100644 index 0000000000000000000000000000000000000000..bb9be4e33ce470865fe5a07decbc056b9ee4e9bb Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/WEB\347\225\214\351\235\242.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/authhub\347\231\273\345\275\225\347\225\214\351\235\242.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/authhub\347\231\273\345\275\225\347\225\214\351\235\242.png" new file mode 100644 index 0000000000000000000000000000000000000000..341828b1b6f728888d1dd52eec755033680155da Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/authhub\347\231\273\345\275\225\347\225\214\351\235\242.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\345\210\233\345\273\272\345\272\224\347\224\250\346\210\220\345\212\237\347\225\214\351\235\242.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\345\210\233\345\273\272\345\272\224\347\224\250\346\210\220\345\212\237\347\225\214\351\235\242.png" new file mode 100644 index 0000000000000000000000000000000000000000..a871907f348317e43633cf05f5241cb978476fb4 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\345\210\233\345\273\272\345\272\224\347\224\250\346\210\220\345\212\237\347\225\214\351\235\242.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\345\210\233\345\273\272\345\272\224\347\224\250\347\225\214\351\235\242.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\345\210\233\345\273\272\345\272\224\347\224\250\347\225\214\351\235\242.png" new file mode 100644 index 0000000000000000000000000000000000000000..d82c736a94b106a30fd8d1f7b781f9e335bb441f Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\345\210\233\345\273\272\345\272\224\347\224\250\347\225\214\351\235\242.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/k8s\351\233\206\347\276\244\344\270\255postgres\346\234\215\345\212\241\347\232\204\345\220\215\347\247\260.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/k8s\351\233\206\347\276\244\344\270\255postgres\346\234\215\345\212\241\347\232\204\345\220\215\347\247\260.png" new file mode 100644 index 0000000000000000000000000000000000000000..473a0006c9710c92375e226a760c3a79989312f9 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/k8s\351\233\206\347\276\244\344\270\255postgres\346\234\215\345\212\241\347\232\204\345\220\215\347\247\260.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/postgres\346\234\215\345\212\241\347\253\257\345\217\243.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/postgres\346\234\215\345\212\241\347\253\257\345\217\243.png" new file mode 100644 index 0000000000000000000000000000000000000000..cfee6d88da56bc939886caece540f7de8cf77bbc Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/postgres\346\234\215\345\212\241\347\253\257\345\217\243.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/rag_port.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/rag_port.png" new file mode 100644 index 0000000000000000000000000000000000000000..b1d93f9c9d7587aa88a27d7e0bf185586583d438 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/rag_port.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/rag\351\205\215\347\275\256\344\277\241\346\201\257\346\210\220\345\212\237.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/rag\351\205\215\347\275\256\344\277\241\346\201\257\346\210\220\345\212\237.png" new file mode 100644 index 0000000000000000000000000000000000000000..fec3cdaa2b260e50f5523477da3e58a9e14e2130 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/rag\351\205\215\347\275\256\344\277\241\346\201\257\346\210\220\345\212\237.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\345\210\233\345\273\272\350\265\204\344\272\247\345\272\223\345\244\261\350\264\245\347\224\261\344\272\216\347\273\237\344\270\200\350\265\204\344\272\247\344\270\213\345\255\230\345\234\250\345\220\214\345\220\215\350\265\204\344\272\247\345\272\223.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\345\210\233\345\273\272\350\265\204\344\272\247\345\272\223\345\244\261\350\264\245\347\224\261\344\272\216\347\273\237\344\270\200\350\265\204\344\272\247\344\270\213\345\255\230\345\234\250\345\220\214\345\220\215\350\265\204\344\272\247\345\272\223.png" new file mode 100644 index 0000000000000000000000000000000000000000..624459821de4542b635eeffa115eeba780929a4e Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\345\210\233\345\273\272\350\265\204\344\272\247\345\272\223\345\244\261\350\264\245\347\224\261\344\272\216\347\273\237\344\270\200\350\265\204\344\272\247\344\270\213\345\255\230\345\234\250\345\220\214\345\220\215\350\265\204\344\272\247\345\272\223.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\345\210\233\345\273\272\350\265\204\344\272\247\346\210\220\345\212\237.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\345\210\233\345\273\272\350\265\204\344\272\247\346\210\220\345\212\237.png" new file mode 100644 index 0000000000000000000000000000000000000000..3104717bfa8f6615ad6726577a24938bc29884b2 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\345\210\233\345\273\272\350\265\204\344\272\247\346\210\220\345\212\237.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\345\210\240\351\231\244\344\270\215\345\255\230\345\234\250\347\232\204\350\265\204\344\272\247\345\244\261\350\264\245.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\345\210\240\351\231\244\344\270\215\345\255\230\345\234\250\347\232\204\350\265\204\344\272\247\345\244\261\350\264\245.png" new file mode 100644 index 0000000000000000000000000000000000000000..454b9fdfa4b7f209dc370f78677a2f4e71ea49be Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\345\210\240\351\231\244\344\270\215\345\255\230\345\234\250\347\232\204\350\265\204\344\272\247\345\244\261\350\264\245.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\345\210\240\351\231\244\350\257\255\346\226\231.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\345\210\240\351\231\244\350\257\255\346\226\231.png" new file mode 100644 index 0000000000000000000000000000000000000000..d52d25d4778f6db2d2ec076d65018c40cd1da4d3 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\345\210\240\351\231\244\350\257\255\346\226\231.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\345\210\240\351\231\244\350\265\204\344\272\247\345\272\223\345\244\261\350\264\245\357\274\214\350\265\204\344\272\247\344\270\213\344\270\215\345\255\230\345\234\250\345\257\271\345\272\224\350\265\204\344\272\247\345\272\223.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\345\210\240\351\231\244\350\265\204\344\272\247\345\272\223\345\244\261\350\264\245\357\274\214\350\265\204\344\272\247\344\270\213\344\270\215\345\255\230\345\234\250\345\257\271\345\272\224\350\265\204\344\272\247\345\272\223.png" new file mode 100644 index 0000000000000000000000000000000000000000..82ed79c0154bd8e406621440c4e4a7caaab7e06e Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\345\210\240\351\231\244\350\265\204\344\272\247\345\272\223\345\244\261\350\264\245\357\274\214\350\265\204\344\272\247\344\270\213\344\270\215\345\255\230\345\234\250\345\257\271\345\272\224\350\265\204\344\272\247\345\272\223.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\345\210\240\351\231\244\350\265\204\344\272\247\346\210\220\345\212\237.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\345\210\240\351\231\244\350\265\204\344\272\247\346\210\220\345\212\237.png" new file mode 100644 index 0000000000000000000000000000000000000000..7dd2dea945f39ada1d7dd053d150a995b160f203 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\345\210\240\351\231\244\350\265\204\344\272\247\346\210\220\345\212\237.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\345\273\272\347\253\213\350\265\204\344\272\247\345\272\223.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\345\273\272\347\253\213\350\265\204\344\272\247\345\272\223.png" new file mode 100644 index 0000000000000000000000000000000000000000..84737b4185ce781d7b32ab42d39b8d2452138dad Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\345\273\272\347\253\213\350\265\204\344\272\247\345\272\223.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\346\214\207\345\256\232\344\270\215\345\255\230\345\234\250\347\232\204\350\265\204\344\272\247\345\210\233\345\273\272\350\265\204\344\272\247\345\272\223\345\244\261\350\264\245.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\346\214\207\345\256\232\344\270\215\345\255\230\345\234\250\347\232\204\350\265\204\344\272\247\345\210\233\345\273\272\350\265\204\344\272\247\345\272\223\345\244\261\350\264\245.png" new file mode 100644 index 0000000000000000000000000000000000000000..be89bdfde2518bba3941eee5d475f52ad9124343 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\346\214\207\345\256\232\344\270\215\345\255\230\345\234\250\347\232\204\350\265\204\344\272\247\345\210\233\345\273\272\350\265\204\344\272\247\345\272\223\345\244\261\350\264\245.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\346\225\260\346\215\256\345\272\223\345\210\235\345\247\213\345\214\226.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\346\225\260\346\215\256\345\272\223\345\210\235\345\247\213\345\214\226.png" new file mode 100644 index 0000000000000000000000000000000000000000..27530840aaa5382a226e1ed8baea883895d9d75e Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\346\225\260\346\215\256\345\272\223\345\210\235\345\247\213\345\214\226.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\346\225\260\346\215\256\345\272\223\351\205\215\347\275\256\344\277\241\346\201\257\346\210\220\345\212\237.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\346\225\260\346\215\256\345\272\223\351\205\215\347\275\256\344\277\241\346\201\257\346\210\220\345\212\237.png" new file mode 100644 index 0000000000000000000000000000000000000000..aa04e6f7f0648adfca1240c750ca5b79b88da5f9 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\346\225\260\346\215\256\345\272\223\351\205\215\347\275\256\344\277\241\346\201\257\346\210\220\345\212\237.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\346\227\240\350\265\204\344\272\247\346\227\266\346\237\245\350\257\242\350\265\204\344\272\247.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\346\227\240\350\265\204\344\272\247\346\227\266\346\237\245\350\257\242\350\265\204\344\272\247.png" new file mode 100644 index 0000000000000000000000000000000000000000..74905172c0c0a0acc4c4d0e35efd2493dc421c4e Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\346\227\240\350\265\204\344\272\247\346\227\266\346\237\245\350\257\242\350\265\204\344\272\247.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\346\237\245\347\234\213\346\226\207\346\241\243\344\272\247\347\224\237\347\211\207\346\256\265\346\200\273\346\225\260\345\222\214\344\270\212\344\274\240\346\210\220\345\212\237\346\200\273\346\225\260.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\346\237\245\347\234\213\346\226\207\346\241\243\344\272\247\347\224\237\347\211\207\346\256\265\346\200\273\346\225\260\345\222\214\344\270\212\344\274\240\346\210\220\345\212\237\346\200\273\346\225\260.png" new file mode 100644 index 0000000000000000000000000000000000000000..432fbfcd02f6d2220e7d2a8512aee893d67be24d Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\346\237\245\347\234\213\346\226\207\346\241\243\344\272\247\347\224\237\347\211\207\346\256\265\346\200\273\346\225\260\345\222\214\344\270\212\344\274\240\346\210\220\345\212\237\346\200\273\346\225\260.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\346\237\245\350\257\242\345\205\250\351\203\250\350\257\255\346\226\231.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\346\237\245\350\257\242\345\205\250\351\203\250\350\257\255\346\226\231.png" new file mode 100644 index 0000000000000000000000000000000000000000..a4f4ea8a3999a9ab659ccd9ea39b80b21ff46e84 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\346\237\245\350\257\242\345\205\250\351\203\250\350\257\255\346\226\231.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\346\237\245\350\257\242\350\265\204\344\272\247.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\346\237\245\350\257\242\350\265\204\344\272\247.png" new file mode 100644 index 0000000000000000000000000000000000000000..675b40297363664007f96948fb21b1cb90d6beea Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\346\237\245\350\257\242\350\265\204\344\272\247.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\350\216\267\345\217\226\346\225\260\346\215\256\345\272\223pod\345\220\215\347\247\260.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\350\216\267\345\217\226\346\225\260\346\215\256\345\272\223pod\345\220\215\347\247\260.png" new file mode 100644 index 0000000000000000000000000000000000000000..8fc0c988e8b3830c550c6be6e42b88ac13448d1a Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\350\216\267\345\217\226\346\225\260\346\215\256\345\272\223pod\345\220\215\347\247\260.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\350\257\255\346\226\231\344\270\212\344\274\240\346\210\220\345\212\237.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\350\257\255\346\226\231\344\270\212\344\274\240\346\210\220\345\212\237.png" new file mode 100644 index 0000000000000000000000000000000000000000..5c897e9883e868bf5160d92cb106ea4e4e9bc356 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\350\257\255\346\226\231\344\270\212\344\274\240\346\210\220\345\212\237.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\350\257\255\346\226\231\345\210\240\351\231\244\345\244\261\350\264\245\357\274\214\346\234\252\346\237\245\350\257\242\345\210\260\347\233\270\345\205\263\350\257\255\346\226\231.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\350\257\255\346\226\231\345\210\240\351\231\244\345\244\261\350\264\245\357\274\214\346\234\252\346\237\245\350\257\242\345\210\260\347\233\270\345\205\263\350\257\255\346\226\231.png" new file mode 100644 index 0000000000000000000000000000000000000000..407e49b929b7ff4cf14703046a4ba0bfe1bb441e Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\350\257\255\346\226\231\345\210\240\351\231\244\345\244\261\350\264\245\357\274\214\346\234\252\346\237\245\350\257\242\345\210\260\347\233\270\345\205\263\350\257\255\346\226\231.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\350\257\255\346\226\231\346\237\245\350\257\242\346\210\220\345\212\237.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\350\257\255\346\226\231\346\237\245\350\257\242\346\210\220\345\212\237.png" new file mode 100644 index 0000000000000000000000000000000000000000..a4f4ea8a3999a9ab659ccd9ea39b80b21ff46e84 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\350\257\255\346\226\231\346\237\245\350\257\242\346\210\220\345\212\237.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\350\265\204\344\272\247\344\270\213\346\234\252\346\237\245\350\257\242\345\210\260\350\265\204\344\272\247\345\272\223.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\350\265\204\344\272\247\344\270\213\346\234\252\346\237\245\350\257\242\345\210\260\350\265\204\344\272\247\345\272\223.png" new file mode 100644 index 0000000000000000000000000000000000000000..45ab521ec5f5afbd81ad54f023aae3b7a867dbf2 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\350\265\204\344\272\247\344\270\213\346\234\252\346\237\245\350\257\242\345\210\260\350\265\204\344\272\247\345\272\223.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\350\265\204\344\272\247\344\270\213\346\237\245\350\257\242\350\265\204\344\272\247\345\272\223\346\210\220\345\212\237.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\350\265\204\344\272\247\344\270\213\346\237\245\350\257\242\350\265\204\344\272\247\345\272\223\346\210\220\345\212\237.png" new file mode 100644 index 0000000000000000000000000000000000000000..90ed5624ae93ff9784a750514c53293df4e961f0 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\350\265\204\344\272\247\344\270\213\346\237\245\350\257\242\350\265\204\344\272\247\345\272\223\346\210\220\345\212\237.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\350\265\204\344\272\247\345\272\223\345\210\233\345\273\272\346\210\220\345\212\237.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\350\265\204\344\272\247\345\272\223\345\210\233\345\273\272\346\210\220\345\212\237.png" new file mode 100644 index 0000000000000000000000000000000000000000..7b2cc38a931c9c236517c14c86fa93e3eb2b6dcd Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\350\265\204\344\272\247\345\272\223\345\210\233\345\273\272\346\210\220\345\212\237.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\350\265\204\344\272\247\345\272\223\345\210\240\351\231\244\345\244\261\350\264\245\357\274\214\344\270\215\345\255\230\345\234\250\350\265\204\344\272\247.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\350\265\204\344\272\247\345\272\223\345\210\240\351\231\244\345\244\261\350\264\245\357\274\214\344\270\215\345\255\230\345\234\250\350\265\204\344\272\247.png" new file mode 100644 index 0000000000000000000000000000000000000000..1365a8d69467dec250d3451ac63e2615a2194c18 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\350\265\204\344\272\247\345\272\223\345\210\240\351\231\244\345\244\261\350\264\245\357\274\214\344\270\215\345\255\230\345\234\250\350\265\204\344\272\247.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\350\265\204\344\272\247\345\272\223\345\210\240\351\231\244\346\210\220\345\212\237png.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\350\265\204\344\272\247\345\272\223\345\210\240\351\231\244\346\210\220\345\212\237png.png" new file mode 100644 index 0000000000000000000000000000000000000000..1bd944264baa9369e6f8fbfd04cabcd12730c0e9 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\350\265\204\344\272\247\345\272\223\345\210\240\351\231\244\346\210\220\345\212\237png.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\350\265\204\344\272\247\345\272\223\346\237\245\350\257\242\345\244\261\350\264\245\357\274\214\344\270\215\345\255\230\345\234\250\350\265\204\344\272\247.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\350\265\204\344\272\247\345\272\223\346\237\245\350\257\242\345\244\261\350\264\245\357\274\214\344\270\215\345\255\230\345\234\250\350\265\204\344\272\247.png" new file mode 100644 index 0000000000000000000000000000000000000000..58bcd320e145dd29d9e5d49cb6d86964ebb83b51 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\350\265\204\344\272\247\345\272\223\346\237\245\350\257\242\345\244\261\350\264\245\357\274\214\344\270\215\345\255\230\345\234\250\350\265\204\344\272\247.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\351\205\215\347\275\256\346\230\240\345\260\204\344\270\255\351\227\264\345\261\202.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\351\205\215\347\275\256\346\230\240\345\260\204\344\270\255\351\227\264\345\261\202.png" new file mode 100644 index 0000000000000000000000000000000000000000..809b785b999b6663d9e9bd41fed953925093d6bd Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\351\205\215\347\275\256\346\230\240\345\260\204\344\270\255\351\227\264\345\261\202.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\351\205\215\347\275\256\346\230\240\345\260\204\346\272\220\347\233\256\345\275\225.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\351\205\215\347\275\256\346\230\240\345\260\204\346\272\220\347\233\256\345\275\225.png" new file mode 100644 index 0000000000000000000000000000000000000000..62ba5f6615f18deb3d5a71fd68ee8c929638d814 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\351\205\215\347\275\256\346\230\240\345\260\204\346\272\220\347\233\256\345\275\225.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\351\205\215\347\275\256\346\230\240\345\260\204\347\233\256\346\240\207\347\233\256\345\275\225.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\351\205\215\347\275\256\346\230\240\345\260\204\347\233\256\346\240\207\347\233\256\345\275\225.png" new file mode 100644 index 0000000000000000000000000000000000000000..d32c672fafcb0ef665bda0bcfdce19d2df44db01 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\351\205\215\347\275\256\346\230\240\345\260\204\347\233\256\346\240\207\347\233\256\345\275\225.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\351\207\215\345\244\215\345\210\233\345\273\272\350\265\204\344\272\247\345\244\261\350\264\245.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\351\207\215\345\244\215\345\210\233\345\273\272\350\265\204\344\272\247\345\244\261\350\264\245.png" new file mode 100644 index 0000000000000000000000000000000000000000..a5ecd6b65abc97320e7467f00d82ff1fd9bf0e44 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272/\351\207\215\345\244\215\345\210\233\345\273\272\350\265\204\344\272\247\345\244\261\350\264\245.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\351\203\250\347\275\262\350\247\206\345\233\276.png" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\351\203\250\347\275\262\350\247\206\345\233\276.png" new file mode 100644 index 0000000000000000000000000000000000000000..181bf1d2ddbe15cfd296c27df27d865bdbce8d69 Binary files /dev/null and "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/pictures/\351\203\250\347\275\262\350\247\206\345\233\276.png" differ diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/sysHAX\351\203\250\347\275\262\346\214\207\345\215\227.md" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/sysHAX\351\203\250\347\275\262\346\214\207\345\215\227.md" new file mode 100644 index 0000000000000000000000000000000000000000..6910b00e766670fcdb5f10ffa5605583f9cb3802 --- /dev/null +++ "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/sysHAX\351\203\250\347\275\262\346\214\207\345\215\227.md" @@ -0,0 +1,164 @@ +# vllm部署指南 + +**高吞吐、低内存占用** 的 **大语言模型(LLM)推理与服务引擎**,支持 **CPU 计算加速**,提供高效的算子下发机制,包括: + +- **Schedule(调度)**:优化任务分发,提高并行计算效率 +- **Prepare Input(准备数据)**:高效的数据预处理,加速输入构建 +- **Ray 框架**:利用分布式计算提升推理吞吐 +- **Sample(模型后处理)**:优化采样策略,提升生成质量 +- **框架后处理**:融合多种优化策略,提升整体推理性能 + +该引擎结合 **高效计算调度与优化策略**,为 LLM 推理提供 **更快、更稳定、更可扩展** 的解决方案。 + +## 环境准备 + +| **服务器型号** | **Atlas 800T/I A2 训练/推理服务器** | +| --------------- | --------------------------------------------------------- | +| **操作系统** | **openEuler 22.03(LTS)** | +| **NPU驱动版本** | **Ascend-hdk-910b-npu-driver_24.1.rc3_linux-aarch64.run** | +| **固件版本** | **Ascend-hdk-910b-firmware_7.5.0.1.129.run** | + +### **安装驱动固件** + +- **创建驱动运行用户HwHiAiUser(运行驱动进程的用户),安装驱动时无需指定运行用户,默认即为HwHiAiUser。** + +```shell +groupadd -g 1000 HwHiAiUser +useradd -g HwHiAiUser -u 1000 -d /home/HwHiAiUser -m HwHiAiUser -s /bin/bash +``` + +- **将驱动包和固件包上传到服务器任意目录如“/home”。** +- **执行如下命令,增加驱动和固件包的可执行权限。** + +```shell +chmod +x Ascend-hdk-910b-npu-driver_24.1.rc3_linux-aarch64.run +chmod +x Ascend-hdk-910b-firmware_7.5.0.1.129.run +``` + +\- **安装驱动** + +```shell +./Ascend-hdk-910b-npu-driver_24.1.rc3_linux-aarch64.run --full --install-for-all + +# 若执行上述安装命令出现类似如下回显信息 +# [ERROR]The list of missing tools: lspci,ifconfig, +# 请执行yum install -y net-tools pciutils + +# 若系统出现如下关键回显信息,则表示驱动安装成功。 +# Driver package installed successfully! +``` + +\- **安装固件** + +```shell +./Ascend-hdk-910b-firmware_7.5.0.1.129.run --full + +# 若系统出现如下关键回显信息,表示固件安装成功。 +# Firmware package installed successfully! Reboot now or after driver installation for the installation/upgrade to take effect +``` + +- **执行reboot命令重启系统。** +- **执行npu-smi info查看驱动加载是否成功。** + +## 容器部署场景 + +### 部署Ascend-Docker(容器引擎插件) + +-**参考版本:"Ascend-docker-runtime_6.0.RC3.1_linux-aarch64.run"** + +```shell +# 将软件包”Ascend-docker-runtime_6.0.RC3.1_linux-aarch64.run”上传到服务器任意目录(如“/home”)。 +chmod +x Ascend-docker-runtime_6.0.RC3.1_linux-aarch64.run +``` + +```shell +./Ascend-docker-runtime_6.0.RC3.1_linux-aarch64.run --install +# 安装完成后,若显示类似如下信息,则说明软件安装成功: +xxx install success +``` + +- **执行systemctl restart docker命令重启docker,使容器引擎插件在docker配置文件中添加的内容生效。** + +### 容器场景vllm搭建 + +```shell +docker pull hub.oepkgs.net/neocopilot/vllm@sha256:c72a0533b8f34ebd4d352ddac3a969d57638c3d0c9c4af9b78c88400c6edff7a + +# /home路径不要全部映射,防止覆盖/home/HwHiAiUser +docker run -itd \ + -p 1111:22 \ + --name vllm_oe \ + --shm-size 16G \ + --device /dev/davinci0 \ + --device /dev/davinci1 \ + --device /dev/davinci2 \ + --device /dev/davinci3 \ + --device /dev/davinci4 \ + --device /dev/davinci5 \ + --device /dev/davinci6 \ + --device /dev/davinci7 \ + --device /dev/davinci_manager \ + --device /dev/devmm_svm \ + --device /dev/hisi_hdc \ + -v /usr/local/dcmi:/usr/local/dcmi \ + -v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \ + -v /usr/local/Ascend/driver:/usr/local/Ascend/driver \ + -w /home \ + hub.oepkgs.net/neocopilot/vllm:0.6.6-aarch64-910B-oe2203-sp3 bash + +# 启动vllm,模型自行下载 +vllm serve /home/models/DeepSeek-R1-Distill-Llama-70B --distributed-executor-backend ray --tensor-parallel-size 8 --block-size 32 --preemption_mode swap +``` + +## 物理机部署场景 + +### cann安装 + +| **Ascend-cann-toolkit** | **Ascend-cann-toolkit_8.0.RC3_linux-aarch64.run** | +| ----------------------- | ------------------------------------------------------ | +| **Ascend-cann-kernels** | **Ascend-cann-kernels-910b_8.0.RC3_linux-aarch64.run** | + +```shell +# 安装第三方依赖 +yum install -y gcc gcc-c++ make cmake unzip zlib-devel libffi-devel openssl-devel pciutils net-tools sqlite-devel lapack-devel gcc-gfortran +# 可执行如下命令检查系统是否安装满足要求的Python开发环境(要求python3.7.5~3.7.11、python3.8.0~3.8.11、python3.9.0~3.9.7和python3.10.0~3.10.12)。 +python3 --version +pip3 --version +# 安装相关依赖 +pip3 install attrs numpy decorator sympy cffi pyyaml pathlib2 psutil protobuf scipy requests absl-py wheel typing_extensions + +chmod +x Ascend-cann-toolkit_8.0.RC3_linux-aarch64.run +chmod +x Ascend-cann-kernels-910b_8.0.RC3_linux-aarch64.run + +# 安装toolkit +./Ascend-cann-toolkit_8.0.RC3_linux-aarch64.run --install --install-for-all --quiet +# 等待回显xxx install success + +vi ~/.bashrc +# 文件最后一行加入 +source /usr/local/Ascend/ascend-toolkit/set_env.sh +# wq!退出 +source ~/.bashrc + +# 安装二进制算子包 +./Ascend-cann-kernels-910b_8.0.RC3_linux-aarch64.run --install --install-for-all --quiet +# 等待回显xxx install success +``` + +### 物理机场景vllm搭建 + +```shell +# 拉取代码 +https://gitee.com/qmzznbxhl/sysHAX_oe +cd sysHAX_oe +git checkout npu_support + +# 安装第三方依赖 +yum install gcc make +VLLM_TARGET_DEVICE=npu pip install -e . +# 等待安装完成 +pip install ray + +# 启动vllm,模型自行下载 +vllm serve /home/models/DeepSeek-R1-Distill-Llama-70B --distributed-executor-backend ray --tensor-parallel-size 8 --block-size 32 --preemption_mode swap +``` diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/AI\345\256\271\345\231\250\346\240\210/Compatibility-AI-Infra/flows/get_all_docker_images_flow.yaml" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/AI\345\256\271\345\231\250\346\240\210/Compatibility-AI-Infra/flows/get_all_docker_images_flow.yaml" new file mode 100644 index 0000000000000000000000000000000000000000..d1c4332203be24d3395d45eee2b1620b18d6f06c --- /dev/null +++ "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/AI\345\256\271\345\231\250\346\240\210/Compatibility-AI-Infra/flows/get_all_docker_images_flow.yaml" @@ -0,0 +1,15 @@ +name: get_all_supported_AI_docker_images +description: "获取所有支持的docker容器镜像,输入为空,输出为支持的AI容器镜像列表,包括名字、tag、registry、repository" +steps: + - name: start + call_type: api + params: + endpoint: GET /docker/images + next: list2markdown + - name: list2markdown + call_type: llm + params: + user_prompt: | + 当前已有的docker容器及tag为:{data}。请将这份内容输出为markdown表格,表头为registry、repository、image_name、tag,请注意如果一个容器镜像有多个tag版本,请分多行展示。 +next_flow: + - docker_pull_specified_AI_docker_images \ No newline at end of file diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/AI\345\256\271\345\231\250\346\240\210/Compatibility-AI-Infra/flows/pull_images_flow.yaml" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/AI\345\256\271\345\231\250\346\240\210/Compatibility-AI-Infra/flows/pull_images_flow.yaml" new file mode 100644 index 0000000000000000000000000000000000000000..277677924f152672e5f0b02305733347900d4e4b --- /dev/null +++ "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/AI\345\256\271\345\231\250\346\240\210/Compatibility-AI-Infra/flows/pull_images_flow.yaml" @@ -0,0 +1,15 @@ +name: docker_pull_specified_AI_docker_images +description: "从dockerhub拉取指定的docker容器镜像,输入为容器镜像的名字和tag" +steps: + - name: start + call_type: api + params: + endpoint: POST /docker/pull + next: extract_key + - name: extract_key + call_type: extract + params: + keys: + - data.shell +next_flow: + - docker_run_specified_AI_docker_images \ No newline at end of file diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/AI\345\256\271\345\231\250\346\240\210/Compatibility-AI-Infra/flows/run_images_flow.yaml" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/AI\345\256\271\345\231\250\346\240\210/Compatibility-AI-Infra/flows/run_images_flow.yaml" new file mode 100644 index 0000000000000000000000000000000000000000..54fe3ca39d9fe16b3c1bbcc506b7cf6f0e673ea9 --- /dev/null +++ "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/AI\345\256\271\345\231\250\346\240\210/Compatibility-AI-Infra/flows/run_images_flow.yaml" @@ -0,0 +1,13 @@ +name: docker_run_specified_AI_docker_images +description: "运行指定的容器镜像,输入为容器镜像的名字和tag" +steps: + - name: start + call_type: api + params: + endpoint: POST /docker/run + next: extract_key + - name: extract_key + call_type: extract + params: + keys: + - data.shell diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/AI\345\256\271\345\231\250\346\240\210/Compatibility-AI-Infra/openapi.yaml" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/AI\345\256\271\345\231\250\346\240\210/Compatibility-AI-Infra/openapi.yaml" new file mode 100644 index 0000000000000000000000000000000000000000..b46bf07f044302169c6c02f4f61be22f2fb5657f --- /dev/null +++ "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/AI\345\256\271\345\231\250\346\240\210/Compatibility-AI-Infra/openapi.yaml" @@ -0,0 +1,190 @@ +openapi: 3.0.2 +info: + title: compatibility-ai-infra + version: 0.1.0 +servers: + - url: http://ai-infra-service.compatibility-ai-infra.svc.cluster.local:8101 +paths: + /docker/images: + get: + description: 获取所有支持的AI容器信息,返回容器名字和tag + responses: + '200': + description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/ResponseData' + /docker/pull: + post: + description: 输入容器镜像名字和容器镜像tag,返回拉取该容器的shell命令 + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/PullDockerImages' + required: true + responses: + '200': + description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/ResponseData' + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + /docker/run: + post: + description: 输入容器名字和tag,返回运行该容器的shell命令 + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/RunDockerImages' + required: true + responses: + '200': + description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/ResponseData' + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' +components: + schemas: + HTTPValidationError: + description: HTTP校验错误 + type: object + properties: + detail: + title: Detail + type: array + items: + $ref: '#/components/schemas/ValidationError' + PullDockerImages: + description: 生成容器拉取命令的接口的入参 + required: + - image_name + - image_tag + type: object + properties: + image_name: + description: 容器镜像的名字,不要包含转义符 + type: string + enum: + - cann + - oneapi-runtime + - oneapi-basekit + - llm-server + - mlflow + - llm + - tensorflow + - pytorch + - cuda + image_tag: + description: 容器镜像的tag,不要包含转义符 + type: string + enum: + - "8.0.RC1-oe2203sp4" + - "cann7.0.RC1.alpha002-oe2203sp2" + - "2024.2.0-oe2403lts" + - "1.0.0-oe2203sp3" + - "2.11.1-oe2203sp3" + - "2.13.1-oe2203sp3" + - "chatglm2_6b-pytorch2.1.0.a1-cann7.0.RC1.alpha002-oe2203sp2" + - "llama2-7b-q8_0-oe2203sp2" + - "chatglm2-6b-q8_0-oe2203sp2" + - "fastchat-pytorch2.1.0.a1-cann7.0.RC1.alpha002-oe2203sp2" + - "tensorflow2.15.0-oe2203sp2" + - "tensorflow2.15.0-cuda12.2.0-devel-cudnn8.9.5.30-oe2203sp2" + - "pytorch2.1.0-oe2203sp2" + - "pytorch2.1.0-cuda12.2.0-devel-cudnn8.9.5.30-oe2203sp2" + - "pytorch2.1.0.a1-cann7.0.RC1.alpha002-oe2203sp2" + - "cuda12.2.0-devel-cudnn8.9.5.30-oe2203sp2" + ResponseData: + description: 接口返回值的固定格式 + required: + - code + - message + - data + type: object + properties: + code: + description: 状态码 + type: integer + message: + description: 状态信息 + type: string + data: + description: 返回数据 + type: any + RunDockerImages: + description: 生成容器运行命令的接口的入参 + required: + - image_name + - image_tag + type: object + properties: + image_name: + description: 容器镜像的名字,不要包含转义符 + type: string + enum: + - cann + - oneapi-runtime + - oneapi-basekit + - llm-server + - mlflow + - llm + - tensorflow + - pytorch + - cuda + image_tag: + description: 容器镜像的tag,不要包含转义符 + type: string + enum: + - "8.0.RC1-oe2203sp4" + - "cann7.0.RC1.alpha002-oe2203sp2" + - "2024.2.0-oe2403lts" + - "1.0.0-oe2203sp3" + - "2.11.1-oe2203sp3" + - "2.13.1-oe2203sp3" + - "chatglm2_6b-pytorch2.1.0.a1-cann7.0.RC1.alpha002-oe2203sp2" + - "llama2-7b-q8_0-oe2203sp2" + - "chatglm2-6b-q8_0-oe2203sp2" + - "fastchat-pytorch2.1.0.a1-cann7.0.RC1.alpha002-oe2203sp2" + - "tensorflow2.15.0-oe2203sp2" + - "tensorflow2.15.0-cuda12.2.0-devel-cudnn8.9.5.30-oe2203sp2" + - "pytorch2.1.0-oe2203sp2" + - "pytorch2.1.0-cuda12.2.0-devel-cudnn8.9.5.30-oe2203sp2" + - "pytorch2.1.0.a1-cann7.0.RC1.alpha002-oe2203sp2" + - "cuda12.2.0-devel-cudnn8.9.5.30-oe2203sp2" + ValidationError: + description: 接口的入参校验错误时返回的内容格式 + required: + - loc + - msg + - type + type: object + properties: + loc: + title: Location + type: array + items: + anyOf: + - type: string + - type: integer + msg: + title: Message + type: string + type: + title: Error Type + type: string \ No newline at end of file diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/AI\345\256\271\345\231\250\346\240\210/Compatibility-AI-Infra/plugin.json" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/AI\345\256\271\345\231\250\346\240\210/Compatibility-AI-Infra/plugin.json" new file mode 100644 index 0000000000000000000000000000000000000000..6136093d2313bd85ae2f2244adef96d48dad90bd --- /dev/null +++ "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/AI\345\256\271\345\231\250\346\240\210/Compatibility-AI-Infra/plugin.json" @@ -0,0 +1,6 @@ +{ + "id": "ai_docker_images", + "name": "AI容器镜像", + "description": "该插件接受用户的输入,检查当前支持哪些AI容器,拉取容器,运行容器", + "predefined_question": "查看当前支持哪些AI容器,拉取指定的容器,运行指定的容器" +} \ No newline at end of file diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/AI\345\256\271\345\231\250\346\240\210/\346\217\222\344\273\266\342\200\224AI\345\256\271\345\231\250\346\240\210\351\203\250\347\275\262\346\214\207\345\215\227.md" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/AI\345\256\271\345\231\250\346\240\210/\346\217\222\344\273\266\342\200\224AI\345\256\271\345\231\250\346\240\210\351\203\250\347\275\262\346\214\207\345\215\227.md" new file mode 100644 index 0000000000000000000000000000000000000000..3d8943698907f3d368bac2462fb376eb254a351d --- /dev/null +++ "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/AI\345\256\271\345\231\250\346\240\210/\346\217\222\344\273\266\342\200\224AI\345\256\271\345\231\250\346\240\210\351\203\250\347\275\262\346\214\207\345\215\227.md" @@ -0,0 +1,35 @@ +# AI容器栈部署指南 + +## 准备工作 + ++ 提前安装 [openEuler Copilot System 命令行(智能 Shell)客户端](../../../使用指南/命令行客户端/命令行助手使用指南.md) + ++ 修改 /xxxx/xxxx/values.yaml 文件的 `euler-copilot-tune` 部分,将 `enable` 字段改为 `True` + +```yaml +enable: True +``` + ++ 更新环境 + +```bash +helm upgrade euler-copilot . +``` + ++ 检查 Compatibility-AI-Infra 目录下的 openapi.yaml 中 `servers.url` 字段,确保AI容器服务的启动地址被正确设置 + ++ 获取 `$plugin_dir` 插件文件夹的路径,该变量位于 euler-copilot-helm/chart/euler_copilot/values.yaml 中的 `framework` 模块 + ++ 如果插件目录不存在,需新建该目录 + ++ 将该目录下的 Compatibility-AI-Infra 文件夹放到 `$plugin_dir` 中 + +```bash +cp -r ./Compatibility-AI-Infra $PLUGIN_DIR +``` + ++ 重建 framework pod,重载插件配置 + +```bash +kubectl delete pod framework-xxxx -n 命名空间 +``` diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\257\212\346\226\255/euler-copilot-rca/flows/demarcation.yaml" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\257\212\346\226\255/euler-copilot-rca/flows/demarcation.yaml" new file mode 100644 index 0000000000000000000000000000000000000000..6831bdea203e1ffd360f765e5f85ebdce704a437 --- /dev/null +++ "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\257\212\346\226\255/euler-copilot-rca/flows/demarcation.yaml" @@ -0,0 +1,18 @@ +name: demarcation +description: 该工具的作用为针对已知异常事件进行定界分析。需从上下文中获取start_time(开始时间),end_time(结束时间),container_id(容器ID) +steps: + - name: start + call_type: api + params: + endpoint: POST /demarcation + next: report_gen + - name: report_gen + call_type: llm + params: + system_prompt: 你是一个系统智能助手,擅长分析系统的故障现象,最终生成分析报告。 + user_prompt: | + 您是一个专业的运维人员,擅长分析系统的故障现象,最终生成分析报告。当前异常检测结果为{data}。 + 将root_causes_metric_top3内容输出为表格形式,并为每个根因指标进行标号。 + 整个分析报告应该符合markdown规范 +next_flow: + - detection \ No newline at end of file diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\257\212\346\226\255/euler-copilot-rca/flows/detection.yaml" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\257\212\346\226\255/euler-copilot-rca/flows/detection.yaml" new file mode 100644 index 0000000000000000000000000000000000000000..836c71423d63248cd84fe20593d6f848c9b35363 --- /dev/null +++ "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\257\212\346\226\255/euler-copilot-rca/flows/detection.yaml" @@ -0,0 +1,10 @@ +name: detection +description: 该工具的作用为针对已知容器ID和指标,执行profiling分析任务,得到任务ID。需从上下文中获取container_id(容器ID)和三个metric(指标)的其中一个。 +steps: + - name: start + call_type: api + params: + endpoint: POST /detection + next: end + - name: end + call_type: none diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\257\212\346\226\255/euler-copilot-rca/flows/inspection.yaml" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\257\212\346\226\255/euler-copilot-rca/flows/inspection.yaml" new file mode 100644 index 0000000000000000000000000000000000000000..afaefe31106c5ec2016fb3f030fb363950b62516 --- /dev/null +++ "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\257\212\346\226\255/euler-copilot-rca/flows/inspection.yaml" @@ -0,0 +1,16 @@ +name: inspection +description: 该工具的作用为在指定机器上对容器进行异常事件检测。需从上下文中获取start_time(开始时间),end_time(结束时间),machine_id(机器IP) +steps: + - name: start + call_type: api + params: + endpoint: POST /inspection + next: list2markdown + - name: list2markdown + call_type: llm + params: + user_prompt: | + 您是一个专业的运维人员,擅长分析系统的故障现象,最终生成分析报告。当前的异常检测结果为{data}。请将anomaly_events_times_list的信息,输出为表格形式。整个分析报告请符合markdown规范。 + +next_flow: + - demarcation \ No newline at end of file diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\257\212\346\226\255/euler-copilot-rca/flows/show_profiling.yaml" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\257\212\346\226\255/euler-copilot-rca/flows/show_profiling.yaml" new file mode 100644 index 0000000000000000000000000000000000000000..b82172eb272e6c0679dd32582e18e4ecda7dc2bf --- /dev/null +++ "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\257\212\346\226\255/euler-copilot-rca/flows/show_profiling.yaml" @@ -0,0 +1,36 @@ +name: show_profiling +description: 根据已知的智能诊断任务ID(task_id),获取报告的原始数据。随后根据原始数据,生成详细的报告。 +steps: + - name: start + call_type: api + params: + endpoint: POST /show_profiling + next: report_gen + - name: report_gen + call_type: llm + params: + system_prompt: | + 你是一个数据分析和性能分析的专家,请按以下的模板分析出应用的性能瓶颈: + + 1.分析topStackSelf字段中自身耗时排名前3的函数调用栈,分析结果中应该包含函数的耗时信息、函数调用栈的解释说明。 + 2.分析topStackTotal字段中总耗时排名前3的函数调用栈,分析结果中应该包含函数的耗时信息、函数调用栈的解释说明。 + 3.总结前两步的分析结果,并给出影响应用性能的瓶颈所在,同时给出建议。 + user_prompt: | + 现有定界分析结果:{data} + 上面提供了一个JSON对象,它包含了应用程序的Profiling分析报告。该JSON对象包括如下几个字段: + + - traceEvents:它是一个事件列表,列表中的每一项表示一个事件,每个事件以字典格式存储,事件的主要内容解释如下: + - cat 字段:表示事件的分类,它的值包括 syscall、python_gc、sample、pthread_sync,oncpu。其中,syscall 表示这是一个系统调用事件;python_gc 表示这是一个Python垃圾回收事件;sample表示这是一个cpu调用栈采样事件;oncpu表示这是一个OnCPU事件,它说明了pid字段所代表的进程正在占用cpu。 + - name字段:表示事件的名称; + - pid字段:表示事件的进程ID; + - tid字段:表示事件所在的线程ID; + - ts字段:表示事件发生的开始时间,它是一个时间戳格式,单位是微秒; + - dur字段:表示事件的耗时,单位是微秒; + - sf字段:表示事件的函数调用栈,内容是以分号(;)分隔的函数名列表,分号左边是调用方的函数名,分号右边是被调用的函数名。 + - args字段:表示每个事件特有的信息,内容主要包括:count字段,表示事件发生的计数;thread.name字段,表示事件所在的线程的名称;cpu字段,表示采样的cpu编号。 + - topStackSelf:表示应用程序在执行CPU操作期间,自身耗时排名前10的函数调用栈列表。自身耗时是指函数调用栈自身的耗时。列表中的每一项内容说明如下: + - stack:用字符串表示的一个函数调用栈,内容是以分号(;)分隔的函数名列表,分号左边是调用方的函数名,分号右边是被调用的函数名。 + - self_time:stack表示的函数调用栈的自身耗时,单位是毫秒。 + - topStackTotal:表示应用程序在执行CPU操作期间,总耗时排名前10的函数调用栈列表,总耗时是指函数调用栈累积的耗时,它包含了自身耗时。列表中的每一项内容说明如下: + - stack:用字符串表示的一个函数调用栈,内容是以分号(;)分隔的函数名列表,分号左边是调用方的函数名,分号右边是被调用的函数名。 + - total_time:stack表示的函数调用栈的总耗时,单位是毫秒。 \ No newline at end of file diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\257\212\346\226\255/euler-copilot-rca/openapi.yaml" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\257\212\346\226\255/euler-copilot-rca/openapi.yaml" new file mode 100644 index 0000000000000000000000000000000000000000..9ebf2715d5ff61cd86150cfa9b208c2c48a2afa3 --- /dev/null +++ "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\257\212\346\226\255/euler-copilot-rca/openapi.yaml" @@ -0,0 +1,255 @@ +openapi: 3.0.2 +info: + title: 智能诊断 + version: 1.0.0 +servers: + - url: http://192.168.10.31:20030 +paths: + /inspection: + post: + description: 对指定机器进行异常检测,返回异常事件 + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/InspectionRequestData' + required: true + responses: + '200': + description: Successful Response + content: + application/json: + schema: {} + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + /demarcation: + post: + description: 对指定容器进行异常定界 + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/DemarcationRequestData' + required: true + responses: + '200': + description: Successful Response + content: + application/json: + schema: {} + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + /detection: + post: + description: 根据定界结果指标进行定位 + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/DetectionRequestData' + required: true + responses: + '200': + description: Successful Response + content: + application/json: + schema: {} + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + /show_profiling: + post: + description: 根据任务ID,获取Profiling结果 + requestBody: + content: + application/json: + schema: + type: object + description: 请求数据 + required: + - task_id + properties: + task_id: + type: string + description: 任务ID,为UUID类型 + responses: + '200': + description: Successful Response + content: + application/json: + schema: + $ref: "#/components/schemas/ShowProfilingResponse" + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' +components: + schemas: + HTTPValidationError: + type: object + description: HTTP 校验错误 + properties: + detail: + type: array + items: + $ref: '#/components/schemas/ValidationError' + title: Detail + InspectionRequestData: + type: object + description: 巡检接口入参 + required: + - machine_id + - start_time + - end_time + properties: + machine_id: + description: 机器IP。如果给定的信息没有指定任何机器IP,则默认为“default_0.0.0.0”。 + type: string + title: Machine_ID + default: default_0.0.0.0 + start_time: + description: 根据给定的信息提取出开始时间,如果给定的信息不包含开始时间,开始时间可以设置为当前时间往前推2分钟,最终解析出的时间以'%Y-%m-%d %H:%M:%S'格式输出 + type: string + title: Start_Time + default: '' + end_time: + description: 根据给定的信息提取出结束时间,如果给定的信息不包含结束时间,结束时间可以设置为当前时间,最终解析出的时间以'%Y-%m-%d %H:%M:%S'格式输出 + type: string + title: End_Time + default: '' + DemarcationRequestData: + type: object + description: 定界接口入参 + required: + - start_time + - end_time + - container_id + properties: + start_time: + description: 根据给定的信息提取出开始时间,如果给定的信息不包含开始时间,开始时间可以设置为当前时间往前推2分钟,最终解析出的时间以'%Y-%m-%d %H:%M:%S'格式输出 + type: string + title: Start_Time + default: '' + end_time: + description: 根据给定的信息提取出结束时间,如果给定的信息不包含结束时间,结束时间可以设置为当前时间,最终解析出的时间以'%Y-%m-%d %H:%M:%S'格式输出 + type: string + title: End_Time + default: '' + container_id: + description: 结合问题中指定的具体异常事件,根据给定信息提取容器ID + type: string + title: Container_ID + default: '' + DetectionRequestData: + type: object + description: 定位接口入参 + required: + - container_id + - metric + properties: + container_id: + description: 结合问题中指定的具体指标或者指标号,根据给定信息提取容器ID + type: string + title: Container_ID + default: '' + metric: + description: 结合问题中的具体指标或者指标号,根据给定信息提取具体指标值作为metric + type: string + title: Metric + default: '' + ShowProfilingResponse: + type: object + description: show profiling 的返回结果 + properties: + traceEvents: + type: array + items: + type: object + properties: + cat: + type: string + description: Event category (syscall, python_gc, sample, pthread_sync, oncpu) + name: + type: string + description: Event name + pid: + type: integer + format: int32 + description: Process ID + tid: + type: integer + format: int32 + description: Thread ID + ts: + type: integer + format: int64 + description: Timestamp of the event start in microseconds + dur: + type: integer + format: int32 + description: Duration of the event in microseconds + sf: + type: string + description: Call stack represented as a list of function names separated by semicolons + args: + type: object + additionalProperties: true + description: Additional event-specific information such as count, thread.name, and cpu + topStackSelf: + type: array + items: + type: object + properties: + stack: + type: string + description: Call stack represented as a list of function names separated by semicolons + self_time: + type: number + format: int + description: Exclusive time spent in the call stack in milliseconds + topStackTotal: + type: array + items: + type: object + properties: + stack: + type: string + description: Call stack represented as a list of function names separated by semicolons + total_time: + type: number + format: int + description: Total inclusive time spent in the call stack in milliseconds + ValidationError: + type: object + required: + - loc + - msg + - type + title: ValidationError + properties: + loc: + type: array + items: + anyOf: + - type: string + - type: integer + title: Location + msg: + type: string + title: Message + type: + type: string + title: Error Type \ No newline at end of file diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\257\212\346\226\255/euler-copilot-rca/plugin.json" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\257\212\346\226\255/euler-copilot-rca/plugin.json" new file mode 100644 index 0000000000000000000000000000000000000000..b0ef2fd7aa0c13ad626a01d0fc7a4bf010ab3178 --- /dev/null +++ "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\257\212\346\226\255/euler-copilot-rca/plugin.json" @@ -0,0 +1,5 @@ +{ + "id": "rca", + "name": "智能诊断", + "description": "该插件具备以下功能:巡检,定界,定位" +} \ No newline at end of file diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\257\212\346\226\255/\346\217\222\344\273\266\342\200\224\346\231\272\350\203\275\350\257\212\346\226\255\351\203\250\347\275\262\346\214\207\345\215\227.md" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\257\212\346\226\255/\346\217\222\344\273\266\342\200\224\346\231\272\350\203\275\350\257\212\346\226\255\351\203\250\347\275\262\346\214\207\345\215\227.md" new file mode 100644 index 0000000000000000000000000000000000000000..733fea049b62c54021eca335b769215edd778d8e --- /dev/null +++ "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\257\212\346\226\255/\346\217\222\344\273\266\342\200\224\346\231\272\350\203\275\350\257\212\346\226\255\351\203\250\347\275\262\346\214\207\345\215\227.md" @@ -0,0 +1,189 @@ +# 智能诊断部署指南 + +## 准备工作 + ++ 提前安装 [openEuler Copilot System 命令行(智能 Shell)客户端](../../../使用指南/命令行客户端/命令行助手使用指南.md) + ++ 被诊断机器不能安装 crictl 和 isula,只能有 docker 一个容器管理工具 + ++ 在需要被诊断的机器上安装 gala-gopher 和 gala-anteater + +## 部署 gala-gopher + +### 1. 准备 BTF 文件 + +**如果Linux内核支持 BTF,则不需要准备 BTF 文件。**可以通过以下命令来查看Linux内核是否已经支持 BTF: + +```bash +cat /boot/config-$(uname -r) | grep CONFIG_DEBUG_INFO_BTF +``` + +如果输出结果为`CONFIG_DEBUG_INFO_BTF=y`,则表示内核支持BTF。否则表示内核不支持BTF。 +如果内核不支持BTF,需要手动制作BTF文件。步骤如下: + +1. 获取当前Linux内核版本的 vmlinux 文件 + + vmlinux 文件存放在 `kernel-debuginfo` 包里面,存放路径为 `/usr/lib/debug/lib/modules/$(uname -r)/vmlinux`。 + + 例如,对于 `kernel-debuginfo-5.10.0-136.65.0.145.oe2203sp1.aarch64`,对应的vmlinux路径为`/usr/lib/debug/lib/modules/5.10.0-136.65.0.145.oe2203sp1.aarch64/vmlinux`。 + +2. 制作 BTF 文件 + + 基于获取到 vmlinux 文件来制作 BTF 文件。这一步可以在自己的环境里操作。首先,需要安装相关的依赖包: + + ```bash + # 说明:dwarves 包中包含 pahole 命令,llvm 包中包含 llvm-objcopy 命令 + yum install -y llvm dwarves + ``` + + 执行下面的命令行,生成 BTF 文件。 + + ```bash + kernel_version=4.19.90-2112.8.0.0131.oe1.aarch64 # 说明:这里需要替换成目标内核版本,可通过 uname -r 命令获取 + pahole -J vmlinux + llvm-objcopy --only-section=.BTF --set-section-flags .BTF=alloc,readonly --strip-all vmlinux ${kernel_version}.btf + strip -x ${kernel_version}.btf + ``` + + 生成的 BTF 文件名称为`.btf`格式,其中 ``为目标机器的内核版本,可通过 `uname -r` 命令获取。 + +### 2. 下载 gala-gopher 容器镜像 + +#### 在线下载 + +gala-gopher 容器镜像已归档到 仓库中,可通过如下命令获取。 + +```bash +# 获取 aarch64 架构的镜像 +docker pull hub.oepkgs.net/a-ops/gala-gopher-profiling-aarch64:latest +# 获取 x86_64 架构的镜像 +docker pull hub.oepkgs.net/a-ops/gala-gopher-profiling-x86_64:latest +``` + +#### 离线下载 + +若无法通过在线下载的方式下载容器镜像,可联系我(何秀军 00465007)获取压缩包。 + +拿到压缩包后,放到目标机器上,解压并加载容器镜像,命令行如下: + +```bash +tar -zxvf gala-gopher-profiling-aarch64.tar.gz +docker load < gala-gopher-profiling-aarch64.tar +``` + +### 3. 启动 gala-gopher 容器 + +容器启动命令: + +```shell +docker run -d --name gala-gopher-profiling --privileged --pid=host --network=host -v /:/host -v /etc/localtime:/etc/localtime:ro -v /sys:/sys -v /usr/lib/debug:/usr/lib/debug -v /var/lib/docker:/var/lib/docker -v /tmp/$(uname -r).btf:/opt/gala-gopher/btf/$(uname -r).btf -e GOPHER_HOST_PATH=/host gala-gopher-profiling-aarch64:latest +``` + +启动配置参数说明: + ++ `-v /tmp/$(uname -r).btf:/opt/gala-gopher/btf/$(uname -r).btf` :如果内核支持 BTF,则删除该配置即可。如果内核不支持 BTF,则需要将前面准备好的 BTF 文件拷贝到目标机器上,并将 `/tmp/$(uname -r).btf` 替换为对应的路径。 ++ `gala-gopher-profiling-aarch64-0426` :gala-gopher容器对应的tag,替换成实际下载的tag。 + +探针启动: + ++ `container_id` 为需要观测的容器 id ++ 分别启动 sli 和 container 探针 + +```bash +curl -X PUT http://localhost:9999/sli -d json='{"cmd":{"check_cmd":""},"snoopers":{"container_id":[""]},"params":{"report_period":5},"state":"running"}' +``` + +```bash +curl -X PUT http://localhost:9999/container -d json='{"cmd":{"check_cmd":""},"snoopers":{"container_id":[""]},"params":{"report_period":5},"state":"running"}' +``` + +探针关闭 + +```bash +curl -X PUT http://localhost:9999/sli -d json='{"state": "stopped"}' +``` + +```bash +curl -X PUT http://localhost:9999/container -d json='{"state": "stopped"}' +``` + +## 部署 gala-anteater + +源码部署: + +```bash +# 请指定分支为 930eulercopilot +git clone https://gitee.com/GS-Stephen_Curry/gala-anteater.git +``` + +安装部署请参考 +(请留意python版本导致执行setup.sh install报错) + +镜像部署: + +```bash +docker pull hub.oepkgs.net/a-ops/gala-anteater:2.0.2 +``` + +`/etc/gala-anteater/config/gala-anteater.yaml` 中 Kafka 和 Prometheus 的 `server` 和 `port` 需要按照实际部署修改,`model_topic`、`meta_topic`、`group_id` 自定义 + +```yaml +Kafka: + server: "xxxx" + port: "xxxx" + model_topic: "xxxx" # 自定义,与rca配置中保持一致 + meta_topic: "xxxx" # 自定义,与rca配置中保持一致 + group_id: "xxxx" # 自定义,与rca配置中保持一致 + # auth_type: plaintext/sasl_plaintext, please set "" for no auth + auth_type: "" + username: "" + password: "" + +Prometheus: + server: "xxxx" + port: "xxxx" + steps: "5" +``` + +gala-anteater 中模型的训练依赖于 gala-gopher 采集的数据,因此请保证 gala-gopher 探针正常运行至少24小时,在运行 gala-anteater。 + +## 部署 gala-ops + +每个中间件的大致介绍: + +kafka : 一个数据库中间件, 分布式数据分流作用, 可以配置为当前的管理节点。 + +prometheus:性能监控, 配置需要监控的生产节点 ip list。 + +直接通过yum install安装kafka和prometheus,可参照安装脚本 + +只需要参照其中 kafka 和 prometheus 的安装即可 + +## 部署 euler-copilot-rca + +镜像拉取 + +```bash +docker pull hub.oepkgs.net/a-ops/euler-copilot-rca:0.9.1 +``` + ++ 修改 `config/config.json` 文件,配置 gala-gopher 镜像的 `container_id` 以及 `ip`,Kafka 和 Prometheus 的 `ip` 和 `port`(与上述 gala-anteater 配置保持一致) + +```yaml +"gopher_container_id": "xxxx", # gala-gopher的容器id + "remote_host": "xxxx" # gala-gopher的部署机器ip + }, + "kafka": { + "server": "xxxx", + "port": "xxxx", + "storage_topic": "usad_intermediate_results", + "anteater_result_topic": "xxxx", + "rca_result_topic": "xxxx", + "meta_topic": "xxxx" + }, + "prometheus": { + "server": "xxxx", + "port": "xxxx", + "steps": 5 + }, +``` diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\260\203\344\274\230/euler-copilot-tune/flows/data_collection.yaml" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\260\203\344\274\230/euler-copilot-tune/flows/data_collection.yaml" new file mode 100644 index 0000000000000000000000000000000000000000..d2718f0dd059f3a8a34d02cbc67436c6fc274a28 --- /dev/null +++ "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\260\203\344\274\230/euler-copilot-tune/flows/data_collection.yaml" @@ -0,0 +1,15 @@ +name: data_collection +description: 采集某一指定ip主机的系统性能指标 +steps: + - name: start + call_type: api + params: + endpoint: POST /performance_metric + next: show_data + - name: show_data + call_type: llm + params: + user_prompt: | + 当前采集到系统性能指标为:{data}, 输出内容请符合markdown规范。 +next_flow: + - performance_analysis \ No newline at end of file diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\260\203\344\274\230/euler-copilot-tune/flows/performance_analysis.yaml" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\260\203\344\274\230/euler-copilot-tune/flows/performance_analysis.yaml" new file mode 100644 index 0000000000000000000000000000000000000000..07e2a2ada9c54568be3f3bf13c5b2223e615037a --- /dev/null +++ "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\260\203\344\274\230/euler-copilot-tune/flows/performance_analysis.yaml" @@ -0,0 +1,15 @@ +name: performance_analysis +description: 分析性能指标并生成性能分析报告 +steps: + - name: start + call_type: api + params: + endpoint: POST /performance_report + next: extract_key + - name: extract_key + call_type: extract + params: + keys: + - data.output +next_flow: + - performance_tuning \ No newline at end of file diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\260\203\344\274\230/euler-copilot-tune/flows/performance_tuning.yaml" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\260\203\344\274\230/euler-copilot-tune/flows/performance_tuning.yaml" new file mode 100644 index 0000000000000000000000000000000000000000..e938a0bf1bd83f971c4eaaff2d447a150fcf5560 --- /dev/null +++ "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\260\203\344\274\230/euler-copilot-tune/flows/performance_tuning.yaml" @@ -0,0 +1,13 @@ +name: performance_tuning +description: 基于性能能分析报告,生成操作系统和Mysql应用的性能优化建议,结果以shell脚本的形式返回 +steps: + - name: start + call_type: api + params: + endpoint: POST /optimization_suggestion + next: extract_key + - name: extract_key + call_type: extract + params: + keys: + - data.script \ No newline at end of file diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\260\203\344\274\230/euler-copilot-tune/openapi.yaml" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\260\203\344\274\230/euler-copilot-tune/openapi.yaml" new file mode 100644 index 0000000000000000000000000000000000000000..18ede5a988fdc06c9de09ff0f2b7077554bedbff --- /dev/null +++ "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\260\203\344\274\230/euler-copilot-tune/openapi.yaml" @@ -0,0 +1,147 @@ +openapi: 3.0.2 +info: + title: 智能诊断 + version: 1.0.0 +servers: + - url: http://euler-copilot-tune.euler-copilot.svc.cluster.local:8100 +paths: + /performance_metric: + post: + description: 对指定机器进行性能指标采集,返回指标值 + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/PerformanceMetricRequestData' + required: true + responses: + '200': + description: Successful Response + content: + application/json: + schema: {} + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + /performance_report: + post: + description: 基于采集到的指标,对指定机器进行性能诊断,生成性能分析报告 + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/PerformanceReportRequestData' + required: true + responses: + '200': + description: Successful Response + content: + application/json: + schema: {} + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + /optimization_suggestion: + post: + description: 根据性能分析报告,以及指定的机器应用信息,生成调优建议 + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OptimizationSuggestionRequestData' + required: true + responses: + '200': + description: Successful Response + content: + application/json: + schema: {} + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' +components: + schemas: + HTTPValidationError: + type: object + description: HTTP 校验错误 + properties: + detail: + type: array + items: + $ref: '#/components/schemas/ValidationError' + OptimizationSuggestionRequestData: + type: object + description: 生成优化建议的接口的入参 + required: + - app + - ip + properties: + app: + type: string + description: 应用名称 + default: mysql + enum: + - mysql + - none + ip: + type: string + description: 点分十进制的ipv4地址, 例如192.168.10.43 + example: "192.168.10.43" + PerformanceMetricRequestData: + type: object + description: 性能指标采集的接口的入参 + required: + - app + - ip + properties: + ip: + type: string + description: 点分十进制的ipv4地址, 例如192.168.10.43 + example: "192.168.10.43" + app: + type: string + description: App + default: none + enum: + - mysql + - none + PerformanceReportRequestData: + type: object + description: 生成性能报告接口的入参 + required: + - ip + properties: + ip: + type: string + description: 点分十进制的ipv4地址, 例如192.168.10.43 + example: "192.168.10.43" + ValidationError: + type: object + required: + - loc + - msg + - type + title: ValidationError + properties: + loc: + type: array + items: + anyOf: + - type: string + - type: integer + title: Location + msg: + type: string + title: Message + type: + type: string + title: Error Type \ No newline at end of file diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\260\203\344\274\230/euler-copilot-tune/plugin.json" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\260\203\344\274\230/euler-copilot-tune/plugin.json" new file mode 100644 index 0000000000000000000000000000000000000000..c4b95f57e6169a93dcaf7c08e2d328f5be6bf893 --- /dev/null +++ "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\260\203\344\274\230/euler-copilot-tune/plugin.json" @@ -0,0 +1,6 @@ +{ + "id": "tune", + "name": "智能性能优化", + "description": "该插件具备以下功能:采集系统性能指标,分析系统性能,推荐系统性能优化建议", + "automatic_flow": false +} \ No newline at end of file diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\260\203\344\274\230/\346\217\222\344\273\266\342\200\224\346\231\272\350\203\275\350\260\203\344\274\230\351\203\250\347\275\262\346\214\207\345\215\227.md" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\260\203\344\274\230/\346\217\222\344\273\266\342\200\224\346\231\272\350\203\275\350\260\203\344\274\230\351\203\250\347\275\262\346\214\207\345\215\227.md" new file mode 100644 index 0000000000000000000000000000000000000000..4b6524d60bb3625cf0564d3c1fcf3c4fa1d70bee --- /dev/null +++ "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\217\222\344\273\266\351\203\250\347\275\262\346\214\207\345\215\227/\346\231\272\350\203\275\350\260\203\344\274\230/\346\217\222\344\273\266\342\200\224\346\231\272\350\203\275\350\260\203\344\274\230\351\203\250\347\275\262\346\214\207\345\215\227.md" @@ -0,0 +1,131 @@ +# 智能调优部署指南 + +## 准备工作 + ++ 提前安装 [openEuler Copilot System 命令行(智能 Shell)客户端](../../../使用指南/命令行客户端/命令行助手使用指南.md) + ++ 被调优机器需要为 openEuler 22.03 LTS-SP3 + ++ 在需要被调优的机器上安装依赖 + +```bash +yum install -y sysstat perf +``` + ++ 被调优机器需要开启 SSH 22端口 + +## 编辑配置文件 + +修改values.yaml文件的tune部分,将 `enable` 字段改为 `True` ,并配置大模型设置、 +Embedding模型文件地址、以及需要调优的机器和对应机器上的 mysql 的账号名以及密码 + +```bash +vim /home/euler-copilot-framework/euler-copilot-helm/chart/agents/values.yaml +``` + +```yaml +tune: + # 【必填】是否启用智能调优Agent + enabled: true + # 镜像设置 + image: + # 镜像仓库。留空则使用全局设置。 + registry: "" + # 【必填】镜像名称 + name: euler-copilot-tune + # 【必填】镜像标签 + tag: "0.9.1" + # 拉取策略。留空则使用全局设置。 + imagePullPolicy: "" + # 【必填】容器根目录只读 + readOnly: false + # 性能限制设置 + resources: {} + # Service设置 + service: + # 【必填】Service类型,ClusterIP或NodePort + type: ClusterIP + nodePort: + # 大模型设置 + llm: + # 【必填】模型地址(需要包含v1后缀) + url: + # 【必填】模型名称 + name: "" + # 【必填】模型API Key + key: "" + # 【必填】模型最大Token数 + max_tokens: 8096 + # 【必填】Embedding模型文件地址 + embedding: "" + # 待优化机器信息 + machine: + # 【必填】IP地址 + ip: "" + # 【必填】Root用户密码 + # 注意:必需启用Root用户以密码形式SSH登录 + password: "" + # 待优化应用设置 + mysql: + # 【必填】数据库用户名 + user: "root" + # 【必填】数据库密码 + password: "" +``` + +## 安装智能调优插件 + +```bash +helm install -n euler-copilot agents . +``` + +如果之前有执行过安装,则按下面指令更新插件服务 + +```bash +helm upgrade-n euler-copilot agents . +``` + +如果 framework未重启,则需要重启framework配置 + +```bash +kubectl delete pod framework-deploy-service-bb5b58678-jxzqr -n eulercopilot +``` + +## 测试 + ++ 查看 tune 的 pod 状态 + + ```bash + NAME READY STATUS RESTARTS AGE + authhub-backend-deploy-authhub-64896f5cdc-m497f 2/2 Running 0 16d + authhub-web-deploy-authhub-7c48695966-h8d2p 1/1 Running 0 17d + pgsql-deploy-databases-86b4dc4899-ppltc 1/1 Running 0 17d + redis-deploy-databases-f8866b56-kj9jz 1/1 Running 0 17d + mysql-deploy-databases-57f5f94ccf-sbhzp 2/2 Running 0 17d + framework-deploy-service-bb5b58678-jxzqr 2/2 Running 0 16d + rag-deploy-service-5b7887644c-sm58z 2/2 Running 0 110m + vectorize-deploy-service-57f5f94ccf-sbhzp 2/2 Running 0 17d + web-deploy-service-74fbf7999f-r46rg 1/1 Running 0 2d + tune-deploy-agents-5d46bfdbd4-xph7b 1/1 Running 0 2d + ``` + ++ pod启动失败排查办法 + + 检查 euler-copilot-tune 目录下的 openapi.yaml 中 `servers.url` 字段,确保调优服务的启动地址被正确设置 + + 检查 `$plugin_dir` 插件文件夹的路径是否配置正确,该变量位于 `euler-copilot-helm/chart/euler_copilot/values.yaml` 中的 `framework`模块,如果插件目录不存在,需新建该目录,并需要将该目录下的 euler-copilot-tune 文件夹放到 `$plugin_dir` 中。 + + 检查sglang的地址和key填写是否正确,该变量位于 `vim /home/euler-copilot-framework/euler-copilot-helm/chart/euler_copilot/values.yaml` + + ```yaml + # 用于Function Call的模型 + scheduler: + # 推理框架类型 + backend: sglang + # 模型地址 + url: "" + # 模型 API Key + key: "" + # 数据库设置 + ``` + ++ 命令行客户端使用智能调优 + + 具体使用可参考 [openEuler Copilot System 命令行(智能插件:智能调优)](../../../使用指南/命令行客户端/智能调优.md) diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\227\240\347\275\221\347\273\234\347\216\257\345\242\203\344\270\213\351\203\250\347\275\262\346\214\207\345\215\227.md" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\227\240\347\275\221\347\273\234\347\216\257\345\242\203\344\270\213\351\203\250\347\275\262\346\214\207\345\215\227.md" new file mode 100644 index 0000000000000000000000000000000000000000..4a7712788da73b152ee2de5013fe53cb8dc29bf9 --- /dev/null +++ "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\227\240\347\275\221\347\273\234\347\216\257\345\242\203\344\270\213\351\203\250\347\275\262\346\214\207\345\215\227.md" @@ -0,0 +1,733 @@ +# 无网络环境下部署指南 + +## 介绍 + +openEuler Copilot System 是一款智能问答工具,使用 openEuler Copilot System 可以解决操作系统知识获取的便捷性,并且为OS领域模型赋能开发者及运维人员。作为获取操作系统知识,使能操作系统生产力工具 (如 A-Ops / A-Tune / x2openEuler / EulerMaker / EulerDevOps / StratoVirt / iSulad 等),颠覆传统命令交付方式,由传统命令交付方式向自然语义进化,并结合智能体任务规划能力,降低开发、使用操作系统特性的门槛。 + +### 组件介绍 + +| 组件 | 端口 | 说明 | +| ----------------------------- | --------------- | -------------------- | +| euler-copilot-framework | 8002 (内部端口) | 智能体框架服务 | +| euler-copilot-web | 8080 | 智能体前端界面 | +| euler-copilot-rag | 8005 (内部端口) | 检索增强服务 | +| euler-copilot-vectorize-agent | 8001 (内部端口) | 文本向量化服务 | +| mysql | 3306 (内部端口) | MySQL数据库 | +| redis | 6379 (内部端口) | Redis数据库 | +| postgres | 5432 (内部端口) | 向量数据库 | +| secret_inject | 无 | 配置文件安全复制工具 | + +## 环境要求 + +### 软件要求 + +| 类型 | 版本要求 | 说明 | +|------------| -------------------------------------|--------------------------------------| +| 操作系统 | openEuler 22.03 LTS 及以上版本 | 无 | +| K3s | >= v1.30.2,带有 Traefik Ingress 工具 | K3s 提供轻量级的 Kubernetes 集群,易于部署和管理 | +| Helm | >= v3.15.3 | Helm 是一个 Kubernetes 的包管理工具,其目的是快速安装、升级、卸载 openEuler Copilot System 服务 | +| python | >=3.9.9 | python3.9.9 以上版本为模型的下载和安装提供运行环境 | + +### 硬件要求 + +| 类型 | 硬件要求 | +|----------------| -----------------------------| +| 服务器 | 1台 | +| CPU | 鲲鹏或x86_64,>= 32 cores | +| RAM | >= 64GB | +| 存储 | >= 500 GB | +| GPU | Tesla V100 16GB,4张 | +| NPU | 910ProB、910B | + +注意: + +1. 若无 GPU 或 NPU 资源,建议通过调用 OpenAI 接口的方式来实现功能。(接口样例:) +2. 调用第三方 OpenAI 接口的方式不需要安装高版本的 python (>=3.9.9) +3. 英伟达 GPU 对 Docker 的支持必需要新版本 Docker (>= v25.4.0) + +### 部署视图 + +![部署图](./pictures/部署视图.png) + +## 获取 openEuler Copilot System + +- 从 openEuler Copilot System 的官方Git仓库 [euler-copilot-framework](https://gitee.com/openeuler/euler-copilot-framework) 下载最新的部署仓库 +- 如果您正在使用 Kubernetes,则不需要安装 k3s 工具。 + + ```bash + # 下载目录以 home 为例 + cd /home + ``` + + ```bash + git clone https://gitee.com/openeuler/euler-copilot-framework.git + ``` + +## 环境准备 + +如果您的服务器、硬件、驱动等全部就绪,即可启动环境初始化流程,以下部署步骤在无公网环境执行。 + +### 1. 环境检查 + +环境检查主要是对服务器的主机名、DNS、防火墙设置、磁盘剩余空间大小、网络、检查 SELinux 的设置。 + +- 主机名设置 + 在Shell中运行如下命令: + + ```bash + cat /etc/hostname + echo "主机名" > /etc/hostname + ``` + +- 系统DNS设置:需要给当前主机设置有效的DNS +- 防火墙设置 + + ```bash + # 查看防火墙状态 + systemctl status firewalld + # 查看防火墙列表 + firewall-cmd --list-all + # 关闭防火墙 + systemctl stop firewalld + systemctl disable firewalld + ``` + +- SELinux设置 + + ```bash + # 需要关闭selinux,可以临时关闭或永久关闭 + # 永久关闭SELinux + sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config + # 临时关闭 + setenforce 0 + ``` + +### 2. 文件下载 + +- 模型文件 bge-reranker-large、bge-mixed-model 下载 [模型文件下载链接](https://repo.oepkgs.net/openEuler/rpm/openEuler-22.03-LTS/contrib/EulerCopilot/) + + ```bash + mkdir -p /home/EulerCopilot/models + cd /home/EulerCopilot/models + # 将需要下载的bge文件放置在models目录 + wget https://repo.oepkgs.net/openEuler/rpm/openEuler-22.03-LTS/contrib/EulerCopilot/bge-mixed-model.tar.gz + wget https://repo.oepkgs.net/openEuler/rpm/openEuler-22.03-LTS/contrib/EulerCopilot/bge-reranker-large.tar.gz + ``` + +- 下载分词工具 text2vec-base-chinese-paraphrase [分词工具下载链接](https://repo.oepkgs.net/openEuler/rpm/openEuler-22.03-LTS/contrib/EulerCopilot/) + + ```bash + mkdir -p /home/EulerCopilot/text2vec + cd /home/EulerCopilot/text2vec + wget https://repo.oepkgs.net/openEuler/rpm/openEuler-22.03-LTS/contrib/EulerCopilot/text2vec-base-chinese-paraphrase.tar.gz + ``` + +- 镜像包下载 + - x86或arm架构的EulerCopilot服务的各组件镜像单独提供 + +### 3. 安装部署工具 + +#### 3.1 安装 Docker + +如需要基于 GPU/NPU 部署大模型,需要检查 Docker 版本是否满足>= v25.4.0 ,如不满足,请升级 Docker 版本 + +#### 3.2 安装 K3s 并导入镜像 + +- 安装 SELinux 配置文件 + + ```bash + yum install -y container-selinux selinux-policy-base + # packages里有k3s-selinux-0.1.1-rc1.el7.noarch.rpm的离线包 + rpm -i https://rpm.rancher.io/k3s-selinux-0.1.1-rc1.el7.noarch.rpm + ``` + +- x86 架构安装 k3s + + ```bash + # 在有网络的环境上获取k3s相关包,以v1.30.3+k3s1示例 + wget https://github.com/k3s-io/k3s/releases/download/v1.30.3%2Bk3s1/k3s + wget https://github.com/k3s-io/k3s/releases/download/v1.30.3%2Bk3s1/k3s-airgap-images-amd64.tar.zst + cp k3s /usr/local/bin/ + cd /var/lib/rancher/k3s/agent + mkdir images + cp k3s-airgap-images-arm64.tar.zst /var/lib/rancher/k3s/agent/images + # packages里有k3s-install.sh的离线包 + curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh + INSTALL_K3S_SKIP_DOWNLOAD=true ./k3s-install.sh + export KUBECONFIG=/etc/rancher/k3s/k3s.yaml + ``` + +- arm 架构安装 k3s + + ```bash + # 在有网络的环境上获取k3s相关包,以v1.30.3+k3s1示例 + wget https://github.com/k3s-io/k3s/releases/download/v1.30.3%2Bk3s1/k3s-arm64 + wget https://github.com/k3s-io/k3s/releases/download/v1.30.3%2Bk3s1/k3s-airgap-images-arm64.tar.zst + cp k3s-arm64 /usr/local/bin/k3s + cd /var/lib/rancher/k3s/agent + mkdir images + cp k3s-airgap-images-arm64.tar.zst /var/lib/rancher/k3s/agent/images + # packages里有k3s-install.sh的离线包 + curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh + INSTALL_K3S_SKIP_DOWNLOAD=true ./k3s-install.sh + export KUBECONFIG=/etc/rancher/k3s/k3s.yaml + ``` + +- 导入镜像 + + ```bash + # 导入已下载的镜像文件 + k3s ctr image import $(镜像文件) + ``` + +#### 3.3 安装 Helm 工具 + +- x86_64 架构 + + ```bash + wget https://get.helm.sh/helm-v3.15.0-linux-amd64.tar.gz + tar -xzf helm-v3.15.0-linux-amd64.tar.gz + mv linux-amd64/helm /usr/sbin + rm -rf linux-amd64 + ``` + +- arm64 架构 + + ```bash + wget https://get.helm.sh/helm-v3.15.0-linux-arm64.tar.gz + tar -xzf helm-v3.15.0-linux-arm64.tar.gz + mv linux-arm64/helm /usr/sbin + rm -rf linux-arm64 + ``` + +#### 3.4 大模型准备 + +提供第三方openai接口或基于硬件本都部署大模型,本地部署大模型可参考附录部分。 + +## 安装 + +您的环境现已就绪,接下来即可启动 openEuler Copilot System 的安装流程。 + +- 下载目录以home为例,进入 openEuler Copilot System 仓库的 Helm 配置文件目录 + + ```bash + cd /home/euler-copilot-framework && ll + ``` + + ```bash + total 28 + drwxr-xr-x 3 root root 4096 Aug 28 17:45 docs/ + drwxr-xr-x 5 root root 4096 Aug 28 17:45 euler-copilot-helm/ + ``` + +- 查看euler-copilot-helm的目录 + + ```bash + tree euler-copilot-helm + ``` + + ```bash + euler-copilot-helm/chart + ├── databases + │   ├── Chart.yaml + │   ├── configs + │   ├── templates + │   └── values.yaml + ├── authhub + │   ├── Chart.yaml + │   ├── configs + │   ├── templates + │   └── values.yaml + └── euler_copilot + ├── Chart.yaml + ├── configs + ├── templates + │   ├── NOTES.txt + │   ├── rag + │   ├── vectorize + │   └── web + └── values.yaml + ``` + +### 1. 安装数据库 + +- 编辑 values.yaml + + ```bash + cd euler-copilot-helm/chart/databases + ``` + + 仅需修改镜像tag为对应架构,其余可不进行修改 + + ```bash + vim values.yaml + ``` + +- 创建命名空间 + + ```bash + kubectl create namespace euler-copilot + ``` + + 设置环境变量 + + ```bash + export KUBECONFIG=/etc/rancher/k3s/k3s.yaml + ``` + +- 安装数据库 + + ```bash + helm install -n euler-copilot databases . + ``` + +- 查看 pod 状态 + + ```bash + kubectl -n euler-copilot get pods + ``` + + ```bash + pgsql-deploy-databases-86b4dc4899-ppltc 1/1 Running 0 17d + redis-deploy-databases-f8866b56-kj9jz 1/1 Running 0 17d + mysql-deploy-databases-57f5f94ccf-sbhzp 2/2 Running 0 17d + ``` + +- 若服务器之前部署过 mysql,则可预先清除下 pvc,再部署 databases。 + + ```bash + # 获取pvc + kubectl -n euler-copilot get pvc + ``` + + ```bash + # 删除pvc + kubectl -n euler-copilot delete pvc mysql-pvc + ``` + +### 2. 安装鉴权平台Authhub + +- 编辑 values.yaml + + ```bash + cd euler-copilot-helm/chart/authhub + ``` + + 请结合 YAML 中的注释中的[必填]项进行修改 + + ```bash + vim values.yaml + ``` + + - 注意: + 1. authHub 需要域名,可预先申请域名或在 'C:\Windows\System32\drivers\etc\hosts' 下配置。 + authhub和euler-copilot必须是同一个根域名的两个子域名, 例如authhub.test.com和 + eulercopilot.test.com + 2. 修改tag为对应架构的tag; + +- 安装 AuthHub + + ```bash + helm install -n euler-copilot authhub . + ``` + + AuthHub 默认账号 `administrator`, 密码 `changeme` + +- 查看 pod 状态 + + ```bash + kubectl -n euler-copilot get pods + ``` + + ```bash + NAME READY STATUS RESTARTS AGE + authhub-backend-deploy-authhub-64896f5cdc-m497f 2/2 Running 0 16d + authhub-web-deploy-authhub-7c48695966-h8d2p 1/1 Running 0 17d + pgsql-deploy-databases-86b4dc4899-ppltc 1/1 Running 0 17d + redis-deploy-databases-f8866b56-kj9jz 1/1 Running 0 17d + mysql-deploy-databases-57f5f94ccf-sbhzp 2/2 Running 0 17d + ``` + +- 登录 AuthHub + + AuthHub 的域名以 为例,浏览器输入`https://authhub.test.com`, 登录界面如下图所示: + + ![部署图](./pictures/authhub登录界面.png) + +- 创建应用eulercopilot + + ![部署图](./pictures/创建应用界面.png) + 点击创建应用,输入应用名称、应用主页和应用回调地址(登录后回调地址),参考如下: + - 应用名称:eulercopilot + - 应用主页: + - 应用回调地址: + - 应用创建好后会生成 Client ID 和 Client Secret,将生成的 Client ID 和 Client Secret 配置到应用里,以 eulercopilot 为例,创建应用后在配置文件中添加配置 `euler-copilot-helm/chart/euler_copilot/values.yaml` 中添加配置 + + ![部署图](./pictures/创建应用成功界面.png) + +### 2. 安装 openEuler Copilot System + +- 编辑 values.yaml + + ```bash + cd euler-copilot-helm/chart/euler_copilot + ``` + + 请结合 YAML 中的注释中的[必填]项进行修改 + + ```bash + vim values.yaml + ``` + + - 注意: + 1. 查看系统架构,并修改values.yaml中的tag; + 2. 修改values.yaml中的globals的domain为EulerCopilot域名,并配置大模型的相关信息 + 3. 手动创建`docs_dir`、`plugin_dir`、`models`三个文件挂载目录 + 4. 修改values.yaml中framework章节的web_url和oidc设置 + 5. 如果部署插件,则需要配置用于Function Call的模型,此时必须有GPU环境用于部署sglang,可参考附件 + +- 安装 openEuler Copilot System + + ```bash + helm install -n euler-copilot service . + ``` + +- 查看 Pod 状态 + + ```bash + kubectl -n euler-copilot get pods + ``` + + 镜像拉取过程可能需要大约一分钟的时间,请耐心等待。部署成功后,所有 Pod 的状态应显示为 Running。 + + ```bash + NAME READY STATUS RESTARTS AGE + authhub-backend-deploy-authhub-64896f5cdc-m497f 2/2 Running 0 16d + authhub-web-deploy-authhub-7c48695966-h8d2p 1/1 Running 0 17d + pgsql-deploy-databases-86b4dc4899-ppltc 1/1 Running 0 17d + redis-deploy-databases-f8866b56-kj9jz 1/1 Running 0 17d + mysql-deploy-databases-57f5f94ccf-sbhzp 2/2 Running 0 17d + framework-deploy-service-bb5b58678-jxzqr 2/2 Running 0 16d + rag-deploy-service-5b7887644c-sm58z 2/2 Running 0 110m + vectorize-deploy-service-57f5f94ccf-sbhzp 2/2 Running 0 17d + web-deploy-service-74fbf7999f-r46rg 1/1 Running 0 2d + ``` + + 注意:如果 Pod 状态出现失败,建议按照以下步骤进行排查 +注意:如果 Pod 状态出现失败,建议按照以下步骤进行排查 + + 1. 查看 Kubernetes 集群的事件 (Events),以获取更多关于 Pod 失败的上下文信息 + + ```bash + kubectl -n euler-copilot get events + ``` + + 2. 查看镜像拉取是否成功 + + ```bash + k3s crictl images + ``` + + 3. 检查 RAG 的 Pod 日志,以确定是否有错误信息或异常行为。 + + ```bash + kubectl logs rag-deploy-service-5b7887644c-sm58z -n euler-copilot + ``` + + 4. 验证 Kubernetes 集群的资源状态,检查服务器资源或配额是否足够,资源不足常导致 Pod 镜像服拉取失败。 + + ```bash + df -h + ``` + + 5. 如果未拉取成且镜像大小为0,请检查是否是 k3s 版本未满足要求,低于 v1.30.2 + + ```bash + k3s -v + ``` + + 6. 确认 values.yaml 中 framework 的 OIDC 设置是否正确配置,以确保身份验证和授权功能正常工作。 + + ```bash + vim /home/euler-copilot-framework/euler-copilot-helm/chart/euler_copilot/values.yaml + ``` + +## 验证安装 + +恭喜您,openEuler Copilot System 的部署已完成!现在,您可以开启智能问答的非凡体验之旅了。 +请在浏览器中输入 https://$(host_ip):8080 或 (其中 port 默认值为8080,若更改则需相应调整)访问 openEuler Copilot System 网页,并尝试进行问答体验。 + +![Web 界面](./pictures/WEB界面.png) + +## 安装插件 + +详细信息请参考文档 [插件部署指南](./插件) + +## 构建专有领域智能问答 + +### 1. 构建 openEuler 专业知识领域的智能问答 + + 1. 修改 values.yaml 的 pg 的镜像仓为 `pg-data` + 2. 修改 values.yaml 的 rag 部分的字段 `knowledgebaseID: openEuler_2bb3029f` + 3. 将 `vim euler-copilot-helm/chart/databases/templates/pgsql/pgsql-deployment.yaml` 的 volumes 相关字段注释 + 4. 进入 `cd euler-copilot-helm/chart/databases`,执行更新服务 `helm upgrade -n euler-copilot databases .` + 5. 进入 `cd euler-copilot-helm/chart/euler_copilot`,执行更新服务 `helm upgrade -n euler-copilot service .` + 6. 进入网页端进行 openEuler 专业知识领域的问答 + +### 2. 构建项目专属知识领域智能问答 + +详细信息请参考文档 [本地资产库构建指南](本地资产库构建指南.md) + +## 附录 + +### 大模型准备 + +#### GPU 环境 + +参考以下方式进行部署 + +1. 下载模型文件: + + ```bash + huggingface-cli download --resume-download Qwen/Qwen1.5-14B-Chat --local-dir Qwen1.5-14B-Chat + ``` + +2. 创建终端 control + + ```bash + screen -S control + ``` + + ```bash + python3 -m fastchat.serve.controller + ``` + + - 按 Ctrl A+D 置于后台 + +3. 创建新终端 api + + ```bash + screen -S api + ``` + + ```bash + python3 -m fastchat.serve.openai_api_server --host 0.0.0.0 --port 30000 --api-keys sk-123456 + ``` + + - 按 Ctrl A+D 置于后台 + - 如果当前环境的 Python 版本是 3.12 或者 3.9 可以创建 python3.10 的 conda 虚拟环境 + + ```bash + mkdir -p /root/py310 + ``` + + ```bash + conda create --prefix=/root/py310 python==3.10.14 + ``` + + ```bash + conda activate /root/py310 + ``` + +4. 创建新终端 worker + + ```bash + screen -S worker + ``` + + ```bash + screen -r worker + ``` + + 安装 fastchat 和 vllm + + ```bash + pip install fschat vllm + ``` + + 安装依赖: + + ```bash + pip install fschat[model_worker] + ``` + + ```bash + python3 -m fastchat.serve.vllm_worker --model-path /root/models/Qwen1.5-14B-Chat/ --model-name qwen1.5 --num-gpus 8 --gpu-memory-utilization=0.7 --dtype=half + ``` + + - 按 Ctrl A+D 置于后台 + +5. 按照如下方式配置文件,并更新服务。 + + ```bash + vim euler-copilot-helm/chart/euler_copilot/values.yaml + ``` + + 修改如下部分 + + ```yaml + llm: + # 开源大模型,OpenAI兼容接口 + openai: + url: "http://$(IP):30000" + key: "sk-123456" + model: qwen1.5 + max_tokens: 8192 + ``` + +#### NPU 环境 + +NPU 环境部署可参考链接 [MindIE安装指南](https://www.hiascend.com/document/detail/zh/mindie/10RC2/whatismindie/mindie_what_0001.html) + +## FAQ + +### 1. huggingface 使用报错? + +```text +File "/usr/lib/python3.9/site-packages/urllib3/connection.py", line 186, in _new_conn +raise NewConnectionError( +urllib3.exceptions.eanconectionError: : Failed to establish a new conmection: [Errno 101] Network is unreachable +``` + +- 解决办法 + +```bash +pip3 install -U huggingface_hub +``` + +```bash +export HF_ENDPOINT=https://hf-mirror.com +``` + +### 2. 如何在 RAG 容器中调用获取问答结果的接口? + +- 请先进入到 RAG 对应 Pod + +```bash +curl -k -X POST "http://localhost:8005/kb/get_answer" -H "Content-Type: application/json" -d '{ \ + "question": "", \ + "kb_sn": "default_test", \ + "fetch_source": true }' +``` + +### 3. 执行 `helm upgrade` 报错? + +```text +Error: INSTALLATI0N FAILED: Kubernetes cluster unreachable: Get "http:/localhost:880/version": dial tcp [:1:8089: connect: connection refused +``` + +或者 + +```text +Error: UPGRADE FAILED: Kubernetes cluster unreachable: the server could not find the requested resource +``` + +- 解决办法 + +```bash +export KUBECONFIG=/etc/rancher/k3s/k3s.yaml +``` + +### 4. 无法查看 Pod 日志? + +```text +[root@localhost euler-copilot]# kubectl logs rag-deployservice65c75c48d8-44vcp-n euler-copilotDefaulted container "rag" out of: rag.rag-copy secret (init)Error from server: Get "https://172.21.31.11:10250/containerlogs/euler copilot/rag deploy"service 65c75c48d8-44vcp/rag": Forbidden +``` + +- 解决办法 + 如果设置了代理,需要将本机的网络 IP 从代理中剔除 + +```bash +cat /etc/systemd/system/k3s.service.env +``` + +```text +http_proxy="http://172.21.60.51:3128" +https_proxy="http://172.21.60.51:3128" +no_proxy=172.21.31.10 # 代理中剔除本机IP +``` + +### 5. GPU环境部署大模型时出现无法流式回复? + +在服务执行 curl 大模型失败,但是将 `"stream": true` 改为 `"stream": false`就可以 curl 通? + +```bash +curl http://localhost:30000/v1/chat/completions -H "Content-Type: application/json" -H "Authorization: Bearer sk-123456" -d '{ +"model": "qwen1.5", +"messages": [ +{ +"role": "system", +"content": "你是情感分析专家,你的任务是xxxx" +}, +{ +"role": "user", +"content": "你好" +} +], +"stream": true, +"n": 1, +"max_tokens": 32768 +}' +``` + +- 解决办法: + +```bash +pip install Pydantic=1.10.13 +``` + +### 6. 如何部署sglang? + +```bash +# 1. 激活 Conda 环境, 并激活 Python 3.10 的 Conda 环境。假设你的环境名为 `myenv`: +conda activate myenv + +# 2. 在激活的环境中,安装 sglang[all] 和 flashinfer +pip install sglang[all]==0.3.0 +pip install flashinfer -i https://flashinfer.ai/whl/cu121/torch2.4/ + +# 3. 启动服务器 +python -m sglang.launch_server --served-model-name Qwen2.5-32B --model-path Qwen2.5-32B-Instruct-AWQ --host 0.0.0.0 --port 8001 --api-key sk-12345 --mem-fraction-static 0.5 --tp 8 +``` + +- 验证安装 + +```bash +pip show sglang +pip show flashinfer +``` + +- 注意: + +1. API Key:请确保 `--api-key` 参数中的 API 密钥是正确的 +2. 模型路径: 确保 `--model-path` 参数中的路径是正确的,并且模型文件存在于该路径下。 +3. CUDA 版本:确保你的系统上安装了 CUDA 12.1 和 PyTorch 2.4,因为 `flashinfer` 包依赖于这些特定版本。 +4. 线程池大小:根据你的GPU资源和预期负载调整线程池大小。如果你有 8 个 GPU,那么可以选择 --tp 8 来充分利用这些资源。 + +### 7. 如何 curl embedding? + +```bash +curl -k -X POST http://$IP:8001/embedding \ + -H "Content-Type: application/json" \ + -d '{"texts": ["sample text 1", "sample text 2"]}' +# $IP为vectorize的Embedding的内网地址 +``` + +### 8. 如何生成证书? + +```bash +下载地址: https://github.com/FiloSottile/mkcert/releases +# 1. 下载 mkcert +# x86_64 +wget https://github.com/FiloSottile/mkcert/releases/download/v1.4.4/mkcert-v1.4.4-linux-amd64 +# arm64 +wget https://github.com/FiloSottile/mkcert/releases/download/v1.4.4/mkcert-v1.4.4-linux-arm64 + +# 2. 执行下面的命令生成秘钥 +mkcert -install +# mkcert 可直接接域名或 IP, 生成证书和秘钥 +mkcert example.com + +# 3. 将证书和秘钥拷贝到 /home/euler-copilot-framework_openeuler/euler-copilot-helm/chart_ssl/traefik-secret.yaml 中, 并执行下面命令使其生效。 +kubectl apply -f traefik-secret.yaml +``` diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272\346\214\207\345\215\227.md" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272\346\214\207\345\215\227.md" new file mode 100644 index 0000000000000000000000000000000000000000..32259fdba92e02f572f3269004fea825e0e95413 --- /dev/null +++ "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\346\234\254\345\234\260\350\265\204\344\272\247\345\272\223\346\236\204\345\273\272\346\214\207\345\215\227.md" @@ -0,0 +1,406 @@ +# 本地资产库构建指南 + +- RAG 是一个检索增强的模块,该指南主要是为rag提供命令行的方式进行数据库管理、资产管理、资产库管理和语料资产管理; + 对于数据库管理提供了清空数据库、初始化数据库等功能; + 对于资产管理提供了资产创建、资产查询和资产删除等功能; + 对于资产库管理提供了资产库创建、资产库查询和资产库删除等功能; + 对于语料资产管理提供了语料上传、语料查询和语料删除等功能。 +- 当前指南面向管理员进行编写,对于管理员而言,可以拥有多个资产,一个资产包含多个资产库(不同资产库的使用的向量化模型可以不同),一个资产库对应一个语料资产。 +- 本地语料上传指南是用户构建项目专属语料的指导,当前支持 docx、pdf、markdown、txt 和 xlsx 文件上传,推荐使用 docx 格式上传。 + +## 准备工作 + +- RAG 中关于语料上传目录挂载的配置: + +将本地语料保存到服务器的目录,例如 /home/docs 目录,且将 /home/data 目录权限设置为755 + +```bash +# 设置本地存放文档目录权限为755 +chmod -R 755 /home/docs +``` + +将文件存放的源目录映射至 RAG 容器目标目录,源目录的配置在 中,下面是文件中具体配置映射源目录的配置方法: + +![配置映射源目录](./pictures/本地资产库构建/配置映射源目录.png) + +中间层的配置(链接源目录和目标目录的配置)在 中,下面是文件中具体映射中间层的配置方法: + +![配置映射中间层](./pictures/本地资产库构建/配置映射中间层.png) + +目标目录的配置在 中,下面是文件中具体映射目标目录的配置方法: + +![配置映射目标目录](./pictures/本地资产库构建/配置映射目标目录.png) + +- 更新 Copilot 服务: + + ```bash + root@openeuler:/home/EulerCopilot/euler-copilot-helm/chart# helm upgrade -n euler-copilot service . + # 请注意:service是服务名,可根据实际修改 + ``` + +- 进入到 RAG 容器: + + ```bash + root@openeuler:~# kubectl -n euler-copilot get pods + NAME READY STATUS RESTARTS AGE + framework-deploy-service-bb5b58678-jxzqr 2/2 Running 0 16d + mysql-deploy-service-c7857c7c9-wz9gn 1/1 Running 0 17d + pgsql-deploy-service-86b4dc4899-ppltc 1/1 Running 0 17d + rag-deploy-service-5b7887644c-sm58z 2/2 Running 0 110m + redis-deploy-service-f8866b56-kj9jz 1/1 Running 0 17d + vectorize-deploy-service-57f5f94ccf-sbhzp 2/2 Running 0 17d + web-deploy-service-74fbf7999f-r46rg 1/1 Running 0 2d + # 进入rag pod + root@openeuler:~# kubectl -n euler-copilot exec -it rag-deploy-service-5b7887644c-sm58z -- bash + ``` + +- 设置 PYTHONPATH + + ```bash + # 设置PYTHONPATH + export PYTHONPATH=$(pwd) + ``` + +## 上传语料 + +### 查看脚本帮助信息 + +```bash +python3 scripts/rag_kb_manager.pyc --help +usage: rag_kb_manager.pyc [-h] --method + {init_database_info,init_rag_info,init_database,clear_database,create_kb,del_kb,query_kb,create_kb_asset,del_kb_asset,query_kb_asset,up_corpus,del_corpus,query_corpus,stop_corpus_uploading_job} + [--database_url DATABASE_URL] [--vector_agent_name VECTOR_AGENT_NAME] [--parser_agent_name PARSER_AGENT_NAME] + [--rag_url RAG_URL] [--kb_name KB_NAME] [--kb_asset_name KB_ASSET_NAME] [--corpus_dir CORPUS_DIR] + [--corpus_chunk CORPUS_CHUNK] [--corpus_name CORPUS_NAME] [--up_chunk UP_CHUNK] + [--embedding_model {TEXT2VEC_BASE_CHINESE_PARAPHRASE,BGE_LARGE_ZH,BGE_MIXED_MODEL}] [--vector_dim VECTOR_DIM] + [--num_cores NUM_CORES] + +optional arguments: + -h, --help show this help message and exit + --method {init_database_info,init_rag_info,init_database,clear_database,create_kb,del_kb,query_kb,create_kb_asset,del_kb_asset,query_kb_asset,up_corpus,del_corpus,query_corpus,stop_corpus_uploading_job} + 脚本使用模式,有init_database_info(初始化数据库配置)、init_database(初始化数据库)、clear_database(清除数据库)、create_kb(创建资产)、 + del_kb(删除资产)、query_kb(查询资产)、create_kb_asset(创建资产库)、del_kb_asset(删除资产库)、query_kb_asset(查询 + 资产库)、up_corpus(上传语料,当前支持txt、html、pdf、docx和md格式)、del_corpus(删除语料)、query_corpus(查询语料)和 + stop_corpus_uploading_job(上传语料失败后,停止当前上传任务) + --database_url DATABASE_URL + 语料资产所在数据库的url + --vector_agent_name VECTOR_AGENT_NAME + 向量化插件名称 + --parser_agent_name PARSER_AGENT_NAME + 分词插件名称 + --rag_url RAG_URL rag服务的url + --kb_name KB_NAME 资产名称 + --kb_asset_name KB_ASSET_NAME + 资产库名称 + --corpus_dir CORPUS_DIR + 待上传语料所在路径 + --corpus_chunk CORPUS_CHUNK + 语料切割尺寸 + --corpus_name CORPUS_NAME + 待查询或者待删除语料名 + --up_chunk UP_CHUNK 语料单次上传个数 + --embedding_model {TEXT2VEC_BASE_CHINESE_PARAPHRASE,BGE_LARGE_ZH,BGE_MIXED_MODEL} + 初始化资产时决定使用的嵌入模型 + --vector_dim VECTOR_DIM + 向量化维度 + --num_cores NUM_CORES + 语料处理使用核数 +``` + +### 具体操作 + +以下出现的命令中带**初始化**字段需要在进行资产管理前按指南中出现的相对顺序进行执行,命令中带**可重复**执字段的在后续过程中可以反复执行,命令中带**注意**字段的需谨慎执行。 + +### 步骤1:配置数据库和 RAG 信息 + +- #### 配置数据库信息(初始化) + +```bash +python3 scripts/rag_kb_manager.pyc --method init_database_info --database_url postgresql+psycopg2://postgres:123456@{dabase_url}:{databse_port}/postgres +``` + +**注意:** + +**{dabase_url}**为 k8s 集群内访问 postgres 服务的 url,请根据具体情况修改,一般为 **{postgres_servive_name}-{{ .Release.Name }}.\.svc.cluster.local** 格式,其中 **{postgres_servive_name}** 可以从 找到: + +![k8s集群中postgres服务的名称](./pictures/本地资产库构建/k8s集群中postgres服务的名称.png) + +**{{ .Release.Name }}**和**\** 为部署服务时helm安装应用时指定的 **my-release-name** 以及 **my-namespace**,一条 helm 安装应用的命令如下所示: + +```bash +helm install my-release-name --namespace my-namespace path/to/chart +``` + +**database_port** 的信息可以在 中查看,以下为字段所在位置(一般为5432): + +![postgres服务端口](./pictures/本地资产库构建/postgres服务端口.png) + +数据库信息配置命令执行命令完成之后会在 scripts/config 下出现 database_info.json 文件,文件内容如下: + +```bash +{"database_url": "postgresql+psycopg2://postgres:123456@{dabase_url}:{databse_port}/postgres"} +``` + +下面是命令执行成功的截图: + +![数据库配置信息成功](./pictures/本地资产库构建/数据库配置信息成功.png) + +- #### 配置rag信息(初始化) + +```bash +python3 scripts/rag_kb_manager.pyc --method init_rag_info --rag_url http://{rag_url}:{rag_port} +``` + +**{rag_url}** 为 0.0.0.0,**{rag_port}** 可以从 中获取(一般为8005): + +![rag_port](./pictures/本地资产库构建/rag_port.png) + +数据库信息配置命令执行命令完成之后会在 scripts/config 下出现 rag_info.json 文件,文件内容如下: + +```bash +{"rag_url": "http://{rag_url}:{rag_port}"} +``` + +下面是命令执行成功的截图: + +![rag配置信息成功](./pictures/本地资产库构建/rag配置信息成功.png) + +### 步骤2:初始化数据库 + +- #### 初始化数据库表格 + +```bash +python3 scripts/rag_kb_manager.pyc --method init_database +# 注意: +# 对于特殊关系型数据库可指定插件参数'--vector_agent_name VECTOR_AGENT_NAME'和 '--parser_agent_name PARSER_AGENT_NAME';其中VECTOR_AGENT_NAME默认为vector, PARSER_AGENT_NAME默认为zhparser +``` + +命令执行完成之后可以进入数据库容器查看表格是否创建成功,首先获取命名空间中的所有节点名称: + +```bash +# 获取命名空间中的所有pod节点 +kubectl get pods -n euler-copilot +``` + +结果如下: + +![获取数据库pod名称](./pictures/本地资产库构建/获取数据库pod名称.png) + +使用下面命令进入数据库: + +```bash +kubectl exec -it pgsql-deploy-b4cc79794-qn8zd -n euler-copilot -- bash +``` + +进入容器后使用下面命令进入数据库: + +```bash +root@pgsql-deploy-b4cc79794-qn8zd:/tmp# psql -U postgres +``` + +再使用\dt查看数据库初始化情况,出现下面内容表示数据库初始化成功: + +![数据库初始化](./pictures/本地资产库构建/数据库初始化.png) + +- #### 清空数据库(注意) + + 假设您想清空 RAG 产生的所有数据库数据,可以使用下面命令(**此命令会清空整个数据库,需谨慎操作!**)。 + +```bash +python3 scripts/rag_kb_manager.pyc --method clear_database +# 清空数据库请谨慎操作 +``` + +### 步骤3:创建资产 + + 下列指令若不指定 kb_name,则默认资产名为 default_test(ps:Copilot 不允许存在两个同名的资产): + +- #### 创建资产(可重复) + +```bash +python3 scripts/rag_kb_manager.pyc --method create_kb --kb_name default_test +``` + +创建资产成功会有以下提示: + +![创建资产成功](./pictures/本地资产库构建/创建资产成功.png) + +创建同名资产会有以下提示: + +![重复创建资产失败](./pictures/本地资产库构建/重复创建资产失败.png) + +- #### 删除资产(可重复) + +```bash +python3 scripts/rag_kb_manager.pyc --method del_kb --kb_name default_test +``` + +删除资产成功会出现以下提示(会将资产下的所有资产库和语料资产全部删除): + +![删除资产成功](./pictures/本地资产库构建/删除资产成功.png) + +对于不存在的资产进行删除,会出现以下提示: + +![删除不存在的资产失败](./pictures/本地资产库构建/删除不存在的资产失败.png) + +- #### 查询资产(可重复) + +```bash +python3 scripts/rag_kb_manager.pyc --method query_kb +``` + +查询资产成功会出现下面内容: + +![查询资产](./pictures/本地资产库构建/查询资产.png) + +对于无资产的情况下查询资产会出现以下内容: + +![无资产时查询资产](./pictures/本地资产库构建/无资产时查询资产.png) + +### 步骤4:创建资产库 + +下列指令若不指定资产名(kb_name)和资产库名(kb_asset_name),则默认资产名为 default_test 和资产库名 default_test_asset(ps:Copilot 同一个资产下不允许存在两个同名的资产库): + +- #### 创建资产库(可重复) + +```bash +python3 scripts/rag_kb_manager.pyc --method create_kb_asset --kb_name default_test --kb_asset_name default_test_asset +# 创建属于default_test的资产库 +``` + +对于创建资产库成功会出现以下内容: + +![资产库创建成功](./pictures/本地资产库构建/资产库创建成功.png) + +对于指定不存在的资产库创建资产会出现以下内容: + +![指定不存在的资产创建资产库失败](./pictures/本地资产库构建/指定不存在的资产创建资产库失败.png) + +对于同一个资产下重复创建同名资产库会出现以下内容: + +![创建资产库失败由于统一资产下存在同名资产库](./pictures/本地资产库构建/创建资产库失败由于统一资产下存在同名资产库.png) + +- #### 删除资产库(可重复) + +```bash +python3 scripts/rag_kb_manager.pyc --method del_kb_asset --kb_name default_test --kb_asset_name default_test_asset +``` + +对于删除资产库成功会出现以下内容: + +![资产库删除成功](./pictures/本地资产库构建/资产库删除成功png.png) + +对于删除不存在的资产库失败会出现以下内容: + +![资产下不存在对应资产库](./pictures/本地资产库构建/删除资产库失败,资产下不存在对应资产库.png) + +对于删除不存在的资产下的资产库会出现以下内容: + +![不存在资产](./pictures/本地资产库构建/资产库删除失败,不存在资产.png) + +- #### 查询资产库(可重复) + +```bash +python3 scripts/rag_kb_manager.pyc --method query_kb_asset --kb_name default_test +# 注意:资产是最上层的,资产库属于资产,且不能重名 +``` + +对于查询资产库成功会出现以下内容: + +![资产下查询资产库成功](./pictures/本地资产库构建/资产下查询资产库成功.png) + +对于资产内无资产库的情况下查询资产库会出现以下内容: + +![资产下未查询到资产库](./pictures/本地资产库构建/资产下未查询到资产库.png) + +对于查询不存在的资产下的资产库会出现以下内容: + +![不存在资产](./pictures/本地资产库构建/资产库查询失败,不存在资产.png) + +### 步骤5:上传语料 + +下列指令若不指定资产名(kb_name)和资产库名(kb_asset_name),则默认资产名为 default_test 和资产库名 default_test_asset,对于删除语料命令需要指定完整的语料名称(语料统一为 docx 格式保存在数据库中,可以通过查询语料命令查看已上传的文档名称);对于查询语料命令可以不指定语料名称(corpus_name),此时默认查询所有语料,可以指定部分或者完整的语料名,此时通过模糊搜索匹配数据库内相关的语料名称。 + +- 上传语料 + +```bash +python3 scripts/rag_kb_manager.pyc --method up_corpus --corpus_dir ./scripts/docs/ --kb_name default_test --kb_asset_name default_test_asset +# 注意: +# 1. RAG容器用于存储用户语料的目录路径是'./scripts/docs/'。在执行相关命令前,请确保该目录下已有本地上传的语料。 +# 2. 若语料已上传但查询未果,请检查宿主机上的待向量化语料目录(位于/home/euler-copilot/docs)的权限设置。 +# 为确保无权限问题影响,您可以通过运行chmod 755 /home/euler-copilot/docs命令来赋予该目录最大访问权限。 +``` + +对于语料上传成功会出现以下内容: + +![语料上传成功](./pictures/本地资产库构建/语料上传成功.png) + +对于语料具体的分割和上传情况可以在 logs/app.log 下查看,内容如下: + +![查看文档产生片段总数和上传成功总数](./pictures/本地资产库构建/查看文档产生片段总数和上传成功总数.png) + +- 删除语料 + +```bash +python3 scripts/rag_kb_manager.pyc --method del_corpus --corpus_name abc.docx --kb_name default_test --kb_asset_name default_test_asset +# 上传的文件统一转换为docx +``` + +对于语料删除成功会出现以下内容: + +![删除语料](./pictures/本地资产库构建/删除语料.png) + +对于删除不存在的语料会出现以下内容: + +![语料删除失败](./pictures/本地资产库构建/语料删除失败,未查询到相关语料.png) + +- 查询语料 + +```bash +# 查询指定名称的语料: +python3 scripts/rag_kb_manager.pyc --method query_corpus --corpus_name 语料名.docx +# 查询所有语料: +python3 scripts/rag_kb_manager.pyc --method query_corpus +``` + +对于查询所有语料会出现以下内容: + +![查询全部语料](./pictures/本地资产库构建/查询全部语料.png) + +- 停止上传任务 + +```bash +python3 scripts/rag_kb_manager.pyc --method stop_corpus_uploading_job +``` + +对于某些极端条件下(例如内存受限),上传语料失败,需要执行上面shell命令用于清除语料上传失败的缓存。 + +## 网页端查看语料上传进度 + +您可以灵活设置端口转发规则,通过执行如下命令将容器端口映射到主机上的指定端口,并在任何设备上通过访问 http://<主机IP>:<映射端口>(例如 )来查看语料上传的详细情况。 + +```bash +kubectl port-forward rag-deploy-service-5b7887644c-sm58z 3000:8005 -n euler-copilot --address=0.0.0.0 +# 注意: 3000是主机上的端口,8005是rag的容器端口,可修改映射到主机上的端口 +``` + +## 验证上传后效果 + +上传语料成功之后你可以通过以下命令直接与 RAG 交互,来观察语料是否上传成功。 + +```bash +curl -k -X POST "http://{rag_url}:{rag_port}/kb/get_answer" -H "Content-Type: application/json" -d '{ \ + "question": "question", \ + "kb_sn": "kb_name", \ + "fetch_source": true, \ + "top_k": 3 \ +}' +``` + +- `question`:问题 + +- `kb_sn`:资产库名称 + +- `fetch_source`:是否返回关联片段以及片段来源,`false` 代表不返回,`true` 代表返回 + +- `top_k`:关联语料片段个数,需要大于等于3 diff --git "a/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\347\275\221\347\273\234\347\216\257\345\242\203\344\270\213\351\203\250\347\275\262\346\214\207\345\215\227.md" "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\347\275\221\347\273\234\347\216\257\345\242\203\344\270\213\351\203\250\347\275\262\346\214\207\345\215\227.md" new file mode 100644 index 0000000000000000000000000000000000000000..988ee7c090b6a696fbc439dd1810c50901b14a67 --- /dev/null +++ "b/docs/zh/docs/AI/openEuler_Copilot_System/\351\203\250\347\275\262\346\214\207\345\215\227/\347\275\221\347\273\234\347\216\257\345\242\203\344\270\213\351\203\250\347\275\262\346\214\207\345\215\227.md" @@ -0,0 +1,618 @@ +# 网络环境部署指南 + +## 介绍 + +openEuler Copilot System 是一款智能问答工具,使用 openEuler Copilot System 可以解决操作系统知识获取的便捷性,并且为OS领域模型赋能开发者及运维人员。作为获取操作系统知识,使能操作系统生产力工具 (如 A-Ops / A-Tune / x2openEuler / EulerMaker / EulerDevOps / StratoVirt / iSulad 等),颠覆传统命令交付方式,由传统命令交付方式向自然语义进化,并结合智能体任务规划能力,降低开发、使用操作系统特性的门槛。 + +### 组件介绍 + +| 组件 | 端口 | 说明 | +| ----------------------------- | --------------- | -------------------- | +| euler-copilot-framework | 8002 (内部端口) | 智能体框架服务 | +| euler-copilot-web | 8080 | 智能体前端界面 | +| euler-copilot-rag | 8005 (内部端口) | 检索增强服务 | +| euler-copilot-vectorize-agent | 8001 (内部端口) | 文本向量化服务 | +| mysql | 3306 (内部端口) | MySQL数据库 | +| redis | 6379 (内部端口) | Redis数据库 | +| postgres | 5432 (内部端口) | 向量数据库 | +| secret_inject | 无 | 配置文件安全复制工具 | + +## 环境要求 + +### 软件要求 + +| 类型 | 版本要求 | 说明 | +|------------| -------------------------------------|--------------------------------------| +| 操作系统 | openEuler 22.03 LTS 及以上版本 | 无 | +| K3s | >= v1.30.2,带有 Traefik Ingress 工具 | K3s 提供轻量级的 Kubernetes 集群,易于部署和管理 | +| Helm | >= v3.15.3 | Helm 是一个 Kubernetes 的包管理工具,其目的是快速安装、升级、卸载 openEuler Copilot System 服务 | +| python | >=3.9.9 | python3.9.9 以上版本为模型的下载和安装提供运行环境 | + +### 硬件要求 + +| 类型 | 硬件要求 | +|----------------| -----------------------------| +| 服务器 | 1台 | +| CPU | 鲲鹏或x86_64,>= 32 cores | +| RAM | >= 64GB | +| 存储 | >= 500 GB | +| GPU | Tesla V100 16GB,4张 | +| NPU | 910ProB、910B | + +注意: + +1. 若无 GPU 或 NPU 资源,建议通过调用 OpenAI 接口的方式来实现功能。(接口样例: 参考链接:[API-KEY的获取与配置](https://help.aliyun.com/zh/dashscope/developer-reference/acquisition-and-configuration-of-api-key?spm=a2c4g.11186623.0.0.30e7694eaaxxGa)) +2. 调用第三方 OpenAI 接口的方式不需要安装高版本的 python (>=3.9.9) +3. 英伟达 GPU 对 Docker 的支持必需要新版本 Docker (>= v25.4.0) +4. 如果k8s集群环境,则不需要单独安装k3s,要求version >= 1.28 + +### 部署视图 + +![部署图](./pictures/部署视图.png) + +## 获取 openEuler Copilot System + +- 从 openEuler Copilot System 的官方Git仓库 [euler-copilot-framework](https://gitee.com/openeuler/euler-copilot-framework) 下载最新的部署仓库 +- 如果您正在使用 Kubernetes,则不需要安装 k3s 工具。 + +```bash +# 下载目录以 home 为例 +cd /home +``` + +```bash +git clone https://gitee.com/openeuler/euler-copilot-framework.git +``` + +## 环境准备 + +设备需联网并符合 openEuler Copilot System 的最低软硬件要求。确认服务器、硬件、驱动等准备就绪后,即可开始环境准备工作。为了顺利进行后续操作,请按照指引,先进入我 +们的脚本部署目录,并且按照提供的操作步骤和脚本路径依次执行,以确保初始化成功。 + +```bash +# 进入部署脚本目录 +cd /home/euler-copilot-framework/euler-copilot-helm/scripts && tree +``` + +```bash +. +├── check_env.sh +├── download_file.sh +├── get_log.sh +├── install_tools.sh +└── prepare_docker.sh +``` + +| 序号 | 步骤内容 | 相关指令 | 说明 | +|-------------- |----------|---------------------------------------------|------------------------------------------ | +|1| 环境检查 | `bash check_env.sh` | 主要对服务器的主机名、DNS、防火墙设置、磁盘剩余空间大小、网络、检查SELinux的设置 | +|2| 文件下载 | `bash download_file.sh` | 模型bge-reranker-large、bge-mixed-mode下载 | +|3| 安装部署工具 | `bash install_tools.sh v1.30.2+k3s1 v3.15.3 cn` | 安装helm、k3s工具。注意:cn的使用是使用镜像站,可以去掉不用 | +|4| 大模型准备 | 提供第三方 OpenAI 接口或基于硬件本都部署大模型 | 本地部署大模型可参考附录部分 | + +## 安装 + +您的环境现已就绪,接下来即可启动 openEuler Copilot System 的安装流程。 + +- 下载目录以home为例,进入 openEuler Copilot System 仓库的 Helm 配置文件目录 + + ```bash + cd /home/euler-copilot-framework && ll + ``` + + ```bash + total 28 + drwxr-xr-x 3 root root 4096 Aug 28 17:45 docs/ + drwxr-xr-x 5 root root 4096 Aug 28 17:45 euler-copilot-helm/ + ``` + +- 查看euler-copilot-helm的目录 + + ```bash + tree euler-copilot-helm + ``` + + ```bash + euler-copilot-helm/chart + ├── databases + │   ├── Chart.yaml + │   ├── configs + │   ├── templates + │   └── values.yaml + ├── authhub + │   ├── Chart.yaml + │   ├── configs + │   ├── templates + │   └── values.yaml + └── euler_copilot + ├── Chart.yaml + ├── configs + ├── templates + │   ├── NOTES.txt + │   ├── rag + │   ├── vectorize + │   └── web + └── values.yaml + ``` + +### 1. 安装数据库 + +- 编辑 values.yaml + + ```bash + cd euler-copilot-helm/chart/databases + ``` + + 仅需修改镜像tag为对应架构,其余可不进行修改 + + ```bash + vim values.yaml + ``` + +- 创建命名空间 + + ```bash + kubectl create namespace euler-copilot + ``` + + 设置环境变量 + + ```bash + export KUBECONFIG=/etc/rancher/k3s/k3s.yaml + ``` + +- 安装数据库 + + ```bash + helm install -n euler-copilot databases . + ``` + +- 查看 pod 状态 + + ```bash + kubectl -n euler-copilot get pods + ``` + + ```bash + pgsql-deploy-databases-86b4dc4899-ppltc 1/1 Running 0 17d + redis-deploy-databases-f8866b56-kj9jz 1/1 Running 0 17d + mysql-deploy-databases-57f5f94ccf-sbhzp 2/2 Running 0 17d + ``` + +- 若服务器之前部署过 mysql,则可预先清除下 pvc,再部署 databases。 + + ```bash + # 获取pvc + kubectl -n euler-copilot get pvc + ``` + + ```bash + # 删除pvc + kubectl -n euler-copilot delete pvc mysql-pvc + ``` + +### 2. 安装鉴权平台Authhub + +- 编辑 values.yaml + + ```bash + cd euler-copilot-helm/chart/authhub + ``` + + 请结合 YAML 中的注释中的[必填]项进行修改 + + ```bash + vim values.yaml + ``` + + - 注意: + 1. authHub 需要域名,可预先申请域名或在 'C:\Windows\System32\drivers\etc\hosts' 下配置。 + authhub和euler-copilot必须是同一个根域名的两个子域名, 例如authhub.test.com和 + eulercopilot.test.com + 2. 修改tag为对应架构的tag; + +- 安装 AuthHub + + ```bash + helm install -n euler-copilot authhub . + ``` + + AuthHub 默认账号 `administrator`, 密码 `changeme` + +- 查看 pod 状态 + + ```bash + kubectl -n euler-copilot get pods + ``` + + ```bash + NAME READY STATUS RESTARTS AGE + authhub-backend-deploy-authhub-64896f5cdc-m497f 2/2 Running 0 16d + authhub-web-deploy-authhub-7c48695966-h8d2p 1/1 Running 0 17d + pgsql-deploy-databases-86b4dc4899-ppltc 1/1 Running 0 17d + redis-deploy-databases-f8866b56-kj9jz 1/1 Running 0 17d + mysql-deploy-databases-57f5f94ccf-sbhzp 2/2 Running 0 17d + ``` + +- 登录 AuthHub + + AuthHub 的域名以 为例,浏览器输入`https://authhub.test.com`, 登录界面如下图所示: + + ![部署图](./pictures/authhub登录界面.png) + +- 创建应用eulercopilot + + ![部署图](./pictures/创建应用界面.png) + 点击创建应用,输入应用名称、应用主页和应用回调地址(登录后回调地址),参考如下: + - 应用名称:eulercopilot + - 应用主页: + - 应用回调地址: + - 应用创建好后会生成 Client ID 和 Client Secret,将生成的 Client ID 和 Client Secret 配置到应用里,以 eulercopilot 为例,创建应用后在配置文件中添加配置 `euler-copilot-helm/chart/euler_copilot/values.yaml` 中添加配置 + + ![部署图](./pictures/创建应用成功界面.png) + +### 2. 安装 openEuler Copilot System + +- 编辑 values.yaml + + ```bash + cd euler-copilot-helm/chart/euler_copilot + ``` + + 请结合 YAML 中的注释中的[必填]项进行修改 + + ```bash + vim values.yaml + ``` + + - 注意: + 1. 查看系统架构,并修改values.yaml中的tag; + 2. 修改values.yaml中的globals的domain为EulerCopilot域名,并配置大模型的相关信息 + 3. 手动创建`docs_dir`、`plugin_dir`、`models`三个文件挂载目录 + 4. 修改values.yaml中framework章节的web_url和oidc设置 + 5. 如果部署插件,则需要配置用于Function Call的模型,此时必须有GPU环境用于部署sglang,可参考附件 + +- 安装 openEuler Copilot System + + ```bash + helm install -n euler-copilot service . + ``` + +- 查看 Pod 状态 + + ```bash + kubectl -n euler-copilot get pods + ``` + + 镜像拉取过程可能需要大约一分钟的时间,请耐心等待。部署成功后,所有 Pod 的状态应显示为 Running。 + + ```bash + NAME READY STATUS RESTARTS AGE + authhub-backend-deploy-authhub-64896f5cdc-m497f 2/2 Running 0 16d + authhub-web-deploy-authhub-7c48695966-h8d2p 1/1 Running 0 17d + pgsql-deploy-databases-86b4dc4899-ppltc 1/1 Running 0 17d + redis-deploy-databases-f8866b56-kj9jz 1/1 Running 0 17d + mysql-deploy-databases-57f5f94ccf-sbhzp 2/2 Running 0 17d + framework-deploy-service-bb5b58678-jxzqr 2/2 Running 0 16d + rag-deploy-service-5b7887644c-sm58z 2/2 Running 0 110m + vectorize-deploy-service-57f5f94ccf-sbhzp 2/2 Running 0 17d + web-deploy-service-74fbf7999f-r46rg 1/1 Running 0 2d + ``` + + 注意:如果 Pod 状态出现失败,建议按照以下步骤进行排查 + +注意:如果 Pod 状态出现失败,建议按照以下步骤进行排查 + + 1. 查看 Kubernetes 集群的事件 (Events),以获取更多关于 Pod 失败的上下文信息 + + ```bash + kubectl -n euler-copilot get events + ``` + + 2. 查看镜像拉取是否成功 + + ```bash + k3s crictl images + ``` + + 3. 检查 RAG 的 Pod 日志,以确定是否有错误信息或异常行为。 + + ```bash + kubectl logs rag-deploy-service-5b7887644c-sm58z -n euler-copilot + ``` + + 4. 验证 Kubernetes 集群的资源状态,检查服务器资源或配额是否足够,资源不足常导致 Pod 镜像服拉取失败。 + + ```bash + df -h + ``` + + 5. 如果未拉取成且镜像大小为0,请检查是否是 k3s 版本未满足要求,低于 v1.30.2 + + ```bash + k3s -v + ``` + + 6. 确认 values.yaml 中 framework 的 OIDC 设置是否正确配置,以确保身份验证和授权功能正常工作。 + + ```bash + vim /home/euler-copilot-framework/euler-copilot-helm/chart/euler_copilot/values.yaml + ``` + +## 验证安装 + +恭喜您,openEuler Copilot System 的部署已完成!现在,您可以开启智能问答的非凡体验之旅了。 +请在浏览器中输入 https://$(host_ip):8080 或 (其中 port 默认值为8080,若更改则需相应调整)访问 openEuler Copilot System 网页,并尝试进行问答体验。 + +![Web 界面](./pictures/WEB界面.png) + +## 安装插件 + +详细信息请参考文档 [插件部署指南](./插件) + +## 构建专有领域智能问答 + +### 1. 构建 openEuler 专业知识领域的智能问答 + + 1. 修改 values.yaml 的 pg 的镜像仓为 `pg-data` + 2. 修改 values.yaml 的 rag 部分的字段 `knowledgebaseID: openEuler_2bb3029f` + 3. 将 `vim euler-copilot-helm/chart/databases/templates/pgsql/pgsql-deployment.yaml` 的 volumes 相关字段注释 + 4. 进入 `cd euler-copilot-helm/chart/databases`,执行更新服务 `helm upgrade -n euler-copilot databases .` + 5. 进入 `cd euler-copilot-helm/chart/euler_copilot`,执行更新服务 `helm upgrade -n euler-copilot service .` + 6. 进入网页端进行 openEuler 专业知识领域的问答 + +### 2. 构建项目专属知识领域智能问答 + +详细信息请参考文档 [本地资产库构建指南](本地资产库构建指南.md) + +## 附录 + +### 大模型准备 + +#### GPU 环境 + +参考以下方式进行部署 + +1. 下载模型文件: + + ```bash + huggingface-cli download --resume-download Qwen/Qwen1.5-14B-Chat --local-dir Qwen1.5-14B-Chat + ``` + +2. 创建终端 control + + ```bash + screen -S control + ``` + + ```bash + python3 -m fastchat.serve.controller + ``` + + - 按 Ctrl A+D 置于后台 + +3. 创建新终端 api + + ```bash + screen -S api + ``` + + ```bash + python3 -m fastchat.serve.openai_api_server --host 0.0.0.0 --port 30000 --api-keys sk-123456 + ``` + + - 按 Ctrl A+D 置于后台 + - 如果当前环境的 Python 版本是 3.12 或者 3.9 可以创建 python3.10 的 conda 虚拟环境 + + ```bash + mkdir -p /root/py310 + ``` + + ```bash + conda create --prefix=/root/py310 python==3.10.14 + ``` + + ```bash + conda activate /root/py310 + ``` + +4. 创建新终端 worker + + ```bash + screen -S worker + ``` + + ```bash + screen -r worker + ``` + + 安装 fastchat 和 vllm + + ```bash + pip install fschat vllm + ``` + + 安装依赖: + + ```bash + pip install fschat[model_worker] + ``` + + ```bash + python3 -m fastchat.serve.vllm_worker --model-path /root/models/Qwen1.5-14B-Chat/ --model-name qwen1.5 --num-gpus 8 --gpu-memory-utilization=0.7 --dtype=half + ``` + + - 按 Ctrl A+D 置于后台 + +5. 按照如下方式配置文件,并更新服务。 + + ```bash + vim euler-copilot-helm/chart/euler_copilot/values.yaml + ``` + + 修改如下部分 + + ```yaml + llm: + # 开源大模型,OpenAI兼容接口 + openai: + url: "http://$(IP):30000" + key: "sk-123456" + model: qwen1.5 + max_tokens: 8192 + ``` + +#### NPU 环境 + +NPU 环境部署可参考链接 [MindIE安装指南](https://www.hiascend.com/document/detail/zh/mindie/10RC2/whatismindie/mindie_what_0001.html) + +## FAQ + +### 1. huggingface 使用报错? + +```text +File "/usr/lib/python3.9/site-packages/urllib3/connection.py", line 186, in _new_conn +raise NewConnectionError( +urllib3.exceptions.eanconectionError: : Failed to establish a new conmection: [Errno 101] Network is unreachable +``` + +- 解决办法 + +```bash +pip3 install -U huggingface_hub +``` + +```bash +export HF_ENDPOINT=https://hf-mirror.com +``` + +### 2. 如何在 RAG 容器中调用获取问答结果的接口? + +- 请先进入到 RAG 对应 Pod + +```bash +curl -k -X POST "http://localhost:8005/kb/get_answer" -H "Content-Type: application/json" -d '{ \ + "question": "", \ + "kb_sn": "default_test", \ + "fetch_source": true }' +``` + +### 3. 执行 `helm upgrade` 报错? + +```text +Error: INSTALLATI0N FAILED: Kubernetes cluster unreachable: Get "http:/localhost:880/version": dial tcp [:1:8089: connect: connection refused +``` + +或者 + +```text +Error: UPGRADE FAILED: Kubernetes cluster unreachable: the server could not find the requested resource +``` + +- 解决办法 + +```bash +export KUBECONFIG=/etc/rancher/k3s/k3s.yaml +``` + +### 4. 无法查看 Pod 日志? + +```text +[root@localhost euler-copilot]# kubectl logs rag-deployservice65c75c48d8-44vcp-n euler-copilotDefaulted container "rag" out of: rag.rag-copy secret (init)Error from server: Get "https://172.21.31.11:10250/containerlogs/euler copilot/rag deploy"service 65c75c48d8-44vcp/rag": Forbidden +``` + +- 解决办法 + 如果设置了代理,需要将本机的网络 IP 从代理中剔除 + +```bash +cat /etc/systemd/system/k3s.service.env +``` + +```text +http_proxy="http://172.21.60.51:3128" +https_proxy="http://172.21.60.51:3128" +no_proxy=172.21.31.10 # 代理中剔除本机IP +``` + +### 5. GPU环境部署大模型时出现无法流式回复? + +在服务执行 curl 大模型失败,但是将 `"stream": true` 改为 `"stream": false`就可以 curl 通? + +```bash +curl http://localhost:30000/v1/chat/completions -H "Content-Type: application/json" -H "Authorization: Bearer sk-123456" -d '{ +"model": "qwen1.5", +"messages": [ +{ +"role": "system", +"content": "你是情感分析专家,你的任务是xxxx" +}, +{ +"role": "user", +"content": "你好" +} +], +"stream": true, +"n": 1, +"max_tokens": 32768 +}' +``` + +- 解决办法: + +```bash +pip install Pydantic=1.10.13 +``` + +### 6. 如何部署sglang? + +```bash +# 1. 激活 Conda 环境, 并激活 Python 3.10 的 Conda 环境。假设你的环境名为 `myenv`: +conda activate myenv + +# 2. 在激活的环境中,安装 sglang[all] 和 flashinfer +pip install sglang[all]==0.3.0 +pip install flashinfer -i https://flashinfer.ai/whl/cu121/torch2.4/ + +# 3. 启动服务器 +python -m sglang.launch_server --served-model-name Qwen2.5-32B --model-path Qwen2.5-32B-Instruct-AWQ --host 0.0.0.0 --port 8001 --api-key sk-12345 --mem-fraction-static 0.5 --tp 8 +``` + +- 验证安装 + +```bash +pip show sglang +pip show flashinfer +``` + +- 注意: + +1. API Key:请确保 `--api-key` 参数中的 API 密钥是正确的 +2. 模型路径: 确保 `--model-path` 参数中的路径是正确的,并且模型文件存在于该路径下。 +3. CUDA 版本:确保你的系统上安装了 CUDA 12.1 和 PyTorch 2.4,因为 `flashinfer` 包依赖于这些特定版本。 +4. 线程池大小:根据你的GPU资源和预期负载调整线程池大小。如果你有 8 个 GPU,那么可以选择 --tp 8 来充分利用这些资源。 + +### 7. 如何 curl embedding? + +```bash +curl -k -X POST http://$IP:8001/embedding \ + -H "Content-Type: application/json" \ + -d '{"texts": ["sample text 1", "sample text 2"]}' +# $IP为vectorize的Embedding的内网地址 +``` + +### 8. 如何生成证书? + +```bash +下载地址: https://github.com/FiloSottile/mkcert/releases +# 1. 下载 mkcert +# x86_64 +wget https://github.com/FiloSottile/mkcert/releases/download/v1.4.4/mkcert-v1.4.4-linux-amd64 +# arm64 +wget https://github.com/FiloSottile/mkcert/releases/download/v1.4.4/mkcert-v1.4.4-linux-arm64 +# 2. 执行下面的命令生成秘钥 +mkcert -install +# mkcert 可直接接域名或 IP, 生成证书和秘钥 +mkcert example.com +# 3. 将证书和秘钥拷贝到 `/home/euler-copilot-framework_openeuler/euler-copilot-helm/chart_ssl/traefik-secret.yaml` 中, 并执行下面命令使其生效。 +kubectl apply -f traefik-secret.yaml +``` diff --git "a/docs/zh/docs/AI/pictures/analyze\345\221\275\344\273\244.png" "b/docs/zh/docs/AI/pictures/analyze\345\221\275\344\273\244.png" new file mode 100644 index 0000000000000000000000000000000000000000..1cc921ba038a6a7bde20365c3bcae918ba98eb73 Binary files /dev/null and "b/docs/zh/docs/AI/pictures/analyze\345\221\275\344\273\244.png" differ diff --git "a/docs/zh/docs/AI/pictures/create_pr\345\221\275\344\273\244.png" "b/docs/zh/docs/AI/pictures/create_pr\345\221\275\344\273\244.png" new file mode 100644 index 0000000000000000000000000000000000000000..0225b28f09084750871dac6f707a1dd74fb25e20 Binary files /dev/null and "b/docs/zh/docs/AI/pictures/create_pr\345\221\275\344\273\244.png" differ diff --git "a/docs/zh/docs/AI/pictures/\344\273\243\350\241\250CVE\347\232\204issue.png" "b/docs/zh/docs/AI/pictures/\344\273\243\350\241\250CVE\347\232\204issue.png" new file mode 100644 index 0000000000000000000000000000000000000000..da36c3eb8486d8e9926841c7a9ddb6c7c75d5b22 Binary files /dev/null and "b/docs/zh/docs/AI/pictures/\344\273\243\350\241\250CVE\347\232\204issue.png" differ diff --git "a/docs/zh/docs/AI/\346\231\272\350\203\275\345\214\226\346\274\217\346\264\236\344\277\256\350\241\245\347\224\250\346\210\267\346\214\207\345\215\227.md" "b/docs/zh/docs/AI/\346\231\272\350\203\275\345\214\226\346\274\217\346\264\236\344\277\256\350\241\245\347\224\250\346\210\267\346\214\207\345\215\227.md" new file mode 100644 index 0000000000000000000000000000000000000000..c57a0cd5b00a4b760c0b8ee20da033706d3106cf --- /dev/null +++ "b/docs/zh/docs/AI/\346\231\272\350\203\275\345\214\226\346\274\217\346\264\236\344\277\256\350\241\245\347\224\250\346\210\267\346\214\207\345\215\227.md" @@ -0,0 +1,59 @@ +# openEuler 智能化漏洞修补用户指南 + +## 简介 + +智能化漏洞修补提供了对openEuler的kernel仓库([https://gitee.com/openeuler/kernel](https://gitee.com/openeuler/kernel))进行智能化修补的能力,当前提供了CVE影响范围分析和补丁PR创建的功能。在代表CVE的issue下面评论/analyze和/create_pr命令来执行功能。 + +## 功能入口 + +在src-openEuler的kernel仓库([https://gitee.com/src-openeuler/kernel.git](https://gitee.com/src-openeuler/kernel.git))中,对代表CVE的issue下面进行评论。 + +![CVE截图](pictures/代表CVE的issue.png) + +## /analyze命令 + +`/analyze`命令提供了对CVE影响范围进行分析的能力。通过在issue下面评论`/analyze`,即可自动对当前维护范围内的openEuler版本进行分析,判断每一个openEuler版本是否引入该CVE,是否修复该CVE。 + +![/analyze命令](pictures/analyze命令.png) + +```shell +/analyze命令无参数 +``` + +CVE是否引入存在如下几种情况: + +* 无影响 +* 受影响 + +CVE是否修复存在如下几种情况: + +* 未修复 +* 已修复 + +在评论的最后,会贴上引入补丁链接与修复补丁链接。 + +## /create_pr命令 + +`/create_pr`命令提供了对CVE的补丁进行智能化修复的能力。通过在issue下面评论`/create_pr `,即可自动获得漏洞补丁,并通过创建PR来合入openEuler下的linux仓库([https://gitee.com/openeuler/kernel.git](https://gitee.com/openeuler/kernel.git))中。 +![/create_pr命令](pictures/create_pr命令.png) + +`/create_pr`命令存在参数,包括如下几种情况: + +```shell +# 对OLK-5.10分支创建补丁PR +/create_pr OLK-5.10 + +# 对OLK-5.10、OLK-6.6分支创建PR +/create_pr OLK-5.10 OLK-6.6 + +# 对当前所有的上游分支,包括openEuler-1.0-LTS、OLK-5.10、OLK-6.6三个分支 +/create_pr +``` + +返回结果如下: + +* pr创建成功 +* 没有修复补丁 +* 无法修复,存在冲突 + +如果补丁代码与修复分支存在冲突的话,会提示`无法修复,存在冲突`。该能力将会在后续的版本中进行迭代强化。 diff --git a/docs/zh/docs/Administration/FAQ-54.md b/docs/zh/docs/Administration/FAQ-54.md deleted file mode 100644 index 7ba3fd243d35e33216c36fd4a7ece5765f76634f..0000000000000000000000000000000000000000 --- a/docs/zh/docs/Administration/FAQ-54.md +++ /dev/null @@ -1,408 +0,0 @@ -# FAQ - - - -- [FAQ](#faq) - - [使用systemctl和top命令查询libvirtd服务占用内存不同](#使用systemctl和top命令查询libvirtd服务占用内存不同) - - [设置RAID0卷,参数stripsize设置为4时出错](#设置raid0卷参数stripsize设置为4时出错) - - [使用rpmbuild编译mariadb失败](#使用rpmbuild编译mariadb失败) - - [使用默认配置启动SNTP服务失败](#使用默认配置启动sntp服务失败) - - [安装时出现软件包冲突、文件冲突或缺少软件包导致安装失败](#安装时出现软件包冲突文件冲突或缺少软件包导致安装失败) - - [libiscsi降级失败](#libiscsi降级失败) - - [xfsprogs降级失败](#xfsprogs降级失败) - - [elfutils降级失败](#elfutils降级失败) - - [cpython/Lib发现CVE-2019-9674:Zip炸弹漏洞](#cpythonlib发现cve-2019-9674zip炸弹漏洞) - - [不合理使用glibc正则表达式引起ReDoS攻击](#不合理使用glibc正则表达式引起redos攻击) - - [带参数f执行modprobe或insmod报错](#带参数f执行modprobe或insmod报错) - - - -## 使用systemctl和top命令查询libvirtd服务占用内存不同 - -### 问题描述 - -使用systemctl和systemd-cgtop命令查询libvirtd服务占用内存超1.5G,而使用top命令查询libvirtd服务占用内存仅70M左右。 - -### 原因分析 - -systemd管理的服务(包括systemctl和systemd-cgtop)中显示的内存通过查询CGroup对应的memory.usage\_in\_bytes得到。top是直接统计/proc下内存相关信息计算得出。两者的统计方法不同,不能直接比较。 - -一般来说,业务进程使用的内存主要有以下几种情况: - -- anon\_rss:用户空间的匿名映射页(Anonymous pages in User Mode address spaces),比如调用malloc分配的内存,以及使用MAP\_ANONYMOUS的mmap。当系统内存不够时,内核可以将这部分内存交换出去。 -- file\_rss:用户空间的文件映射页(Mapped pages in User Mode address spaces),包含map file和map tmpfs,前者比如指定文件的mmap,后者比如IPC共享内存。当系统内存不够时,内核可以回收这些页,但回收之前可能需要与文件同步数据。 -- file\_cache:文件缓存(page in page cache of disk file),普通读写(read/write)文件时产生的文件缓存。当系统内存不够时,内核可以回收这些页,但回收之前可能需要与文件同步数据。 -- buffer pages:属于page cache,比如读取块设备文件时的相关缓存。 - -其中anon\_rss和file\_rss属于进程的RSS,file\_cache和buffer pages属于page cache。简单来说: - -top里的RSS = anon\_rss + file\_rss,SHR = file\_rss。 - -CGroup里的memory.usage\_in\_bytes = cache + RSS + swap。 - -由上可知,syestemd相关命令和top命令的内存占用率含义不同,所以查询结果不同。 - -## 设置RAID0卷,参数stripsize设置为4时出错 - -### 问题现象 - -设置RAID0卷,参数stripsize设置为4时出错。 - -### 原因分析 - -64K页表开启只能支持64K场景。 - -### 解决方法 - -不需要修改配置文件,openEuler执行lvcreate命令时,条带化规格支持的stripesize最小值为64KB,将参数stripesize设置为64。 - -## 使用rpmbuild编译mariadb失败 - -### 问题描述 - -如果使用root帐号登录系统,并在该帐号下使用rpmbuild命令编译mariadb源代码,会出现编译失败现象,提示: - -```shell -# echo 'mysql can'\''t run test as root' -mysql can't run test as root -# exit 1 -``` - -### 原因分析 - -mariadb数据库不允许使用root权限的帐号进行测试用例执行,所以会阻止编译过程(编译过程中会自动执行测试用例)。 - -### 解决方案 - -使用vi等文本编辑工具,修改mariadb.spec文件中runtest变量的值。 - -修改前: - -```text -%global runtest 1 -``` - -修改后: - -```text -%global runtest 0 -``` - -该修改关闭了编译阶段执行测试用例的功能,但不会影响编译和编译后的RPM包内容。 - -## 使用默认配置启动SNTP服务失败 - -### 问题现象 - -默认配置情况下SNTP服务启动失败。 - -### 原因分析 - -默认配置中未添加授时服务器域名。 - -### 解决方案 - -修改/etc/sysconfig/sntp文件 ,在文件中添加中国NTP快速授时服务器域名:0.generic.pool.ntp.org。 - -## 安装时出现软件包冲突、文件冲突或缺少软件包导致安装失败 - -### 问题现象 - -安装软件包过程中,可能出现软件包冲突、文件冲突或缺少软件包,从而导致升安装被中断,最终安装失败。软件包冲突、文件冲突和缺少软件包的报错信息分别如下所示。 - -软件包冲突报错信息示例(以 libev-libevent-devel-4.24-11.oe1.aarch64与libevent-devel-2.1.11-2.oe1.aarch64冲突为例): - -```text -package libev-libevent-devel-4.24-11.oe1.aarch64 conflicts with libevent-devel provided by libevent-devel-2.1.11-2.oe1.aarch64 - - cannot install the best candidate for the job - - conflicting requests -``` - -文件冲突报错信息示例(以/usr/bin/containerd文件冲突为例): - -```text -Error: Transaction test error: - file /usr/bin/containerd from install of containerd-1.2.0-101.oe1.aarch64 conflicts with file from package docker-engine-18.09.0-100.aarch64 - file /usr/bin/containerd-shim from install of containerd-1.2.0-101.oe1.aarch64 conflicts with file from package docker-engine-18.09.0-100.aarch64 -``` - -缺少软件包的报错信息示例(以缺失blivet-data软件包为例): - -```text -Error: - Problem: cannot install both blivet-data-1:3.1.1-6.oe1.noarch and blivet-data-1:3.1.1-5.noarch - - package python2-blivet-1:3.1.1-5.noarch requires blivet-data = 1:3.1.1-5, but none of the providers can be installed - - cannot install the best update candidate for package blivet-data-1:3.1.1-5.noarch - - problem with installed package python2-blivet-1:3.1.1-5.noarch(try to add '--allowerasing' to command line to replace conflicting packages or '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages) -``` - -### 原因分析 - -- openEuler提供的软件包中,有些软件包虽然名称不同,但功能相同,导致两个软件包无法同时安装。 -- openEuler提供的软件包中,有些软件包虽然名称不同,但功能相同,导致安装时安装后的文件相同,从而产生了文件冲突。 -- 有些软件包,因在升级安装前被其他软件包所依赖,一旦该软件包升级后,可能导致依赖它的软件包因缺少软件包而不能安装。 - -### 解决方案 - -若为软件包冲突,则按如下步骤进行处理(以问题现象中示例的软件包冲突为例): - -1. 根据安装过程中的软件包冲突报错信息,确定与待安装的 libev-libevent-devel-4.24-11.oe1.aarch64软件包冲突的软件包为libevent-devel-2.1.11-2.oe1.aarch64。 -2. 执行**dnf remove**命令将与待安装软件包冲突的软件包单独卸载。 - - ```shell - # dnf remove libevent-devel-2.1.11-2.oe1.aarch64 - ``` - -3. 重新进行安装操作。 - -若为文件冲突,则按如下步骤进行处理(以问题现象中示例的文件冲突为例): - -1. 根据安装过程中的文件冲突报错信息,确定导致文件冲突的软件包名称为containerd-1.2.0-101.oe1.aarch64和docker-engine-18.09.0-100.aarch64。 -2. 将不需要安装的软件包名称记录下来,以不需要安装docker-engine-18.09.0-100.aarch64为例。 -3. 执行**dnf remove**命令将不需要安装的软件包单独卸载。 - - ```shell - # dnf remove docker-engine-18.09.0-100.aarch64 - ``` - -4. 重新进行安装操作。 - -若为缺少软件包,则按如下步骤进行处理(以问题现象中示例的缺少软件包为例): - -1. 根据升级安装过程中的缺少软件包报错信息,确定待升级的软件包名称blivet-data-1:3.1.1-5.noarch及依赖它的软件包名称python2-blivet-1:3.1.1-5.noarch。 -2. 执行dnf remove命令将依赖待升级包才能安装的软件包单独卸载或在升级软件包时加上\-\-allowerasing参数。 - - 执行**dnf remove**命令将依赖blivet-data-1:3.1.1-5.noarch软件包才能安装的软件包单独卸载。 - - ```shell - # dnf remove python2-blivet-1:3.1.1-5.noarch - ``` - - - 升级软件包时加上\-\-allowerasing参数。 - - ```shell - # yum update blivet-data-1:3.1.1-5.noarch -y --allowerasing - ``` - -3. 重新进行升级操作。 - -### 安装冲突实例 - -- 文件冲突 - - python3-edk2-devel.noarch 与 build.noarch 因文件名重复存在冲突。 - - ```shell - # yum install python3-edk2-devel.noarch build.noarch - ... - Error: Transaction test error: - file /usr/bin/build conflicts between attempted installs of python3-edk2-devel-202002-3.oe1.noarch and build-20191114-324.4.oe1.noarch - ``` - -## libiscsi降级失败 - -### 问题现象 - -libiscsi-1.19.4 版本及以上降级到 libiscsi-1.19.3 及以下版本时失败。 - -```text -Error: -Problem: problem with installed package libiscsi-utils-1.19.0-4.oe1.x86_64 -- package libiscsi-utils-1.19.0-4.oe1.x86_64 requires libiscsi(x86-64) = 1.19.0-4.oe1, but none of the providers can be installed -- cannot install both libiscsi-1.19.0-3.oe1.x86_64 and libiscsi-1.19.0-4.oe1.x86_64 -- cannot install both libiscsi-1.19.0-4.oe1.x86_64 and libiscsi-1.19.0-3.oe1.x86_64 -- conflicting requests -(try to add '--allowerasing' to command line to replace conflicting packages or '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages) -``` - -### 原因分析 - -libiscsi-1.19.3 之前的版本把 iscsi-xxx 等二进制文件打包进了主包 libiscsi,而这些二进制文件引入了不合理的依赖 CUnit, 为了解决这种不合理的依赖,在 libiscsi-1.19.4 版本把这些二进制文件单独拆分出来一个子包 libiscsi-utils,主包弱依赖于子包,产品可以根据自己的需求在做镜像时是否集成该子包;不集成或卸载子包不会影响 libiscsi 主包的功能。 -如果系统中安装了 libiscsi-utils 子包,libiscsi-1.19.4 及以上版本降级到 libiscsi-1.19.3 及以下版本时,由于 libiscsi-1.19.3 及以下版本无法提供对应的 libiscsi-utils,因此 libiscsi-utils 不会降级,但 libiscsi-utils 依赖于降级前的 libiscsi 主包,导致依赖问题无法解决,最终导致降级失败。 - -### 解决方案 - -执行以下命令,卸载 libiscsi-utils 子包,卸载成功后再进行降级操作。 - -```text -yum remove libiscsi-utils -``` - -## xfsprogs降级失败 - -### 问题现象 - -xfsprogs-5.6.0-2 及以上版本降级到 xfsprogs-5.6.0-1 及以下版本时失败。 - -```text -Error: -Problem: problem with installed package xfsprogs-xfs_scrub-5.6.0-2.oe1.x86_64 -- package xfsprogs-xfs_scrub-5.6.0-2.oe1.x86_64 requires xfsprogs = 5.6.0-2.oe1, but none of the providers can be installed -- cannot install both xfsprogs-5.6.0-1.oe1.x86_64 and xfsprogs-5.6.0-2.oe1.x86_64 -- cannot install both xfsprogs-5.6.0-2.oe1.x86_64 and xfsprogs-5.6.0-1.oe1.x86_64 -- conflicting requests -``` - -### 原因分析 - -在 xfsprogs-5.6.0-2 版本中,为了减少 xfsprogs 主包的不合理依赖,同时将实验性质的命令从主包中分来,我们将 xfs_scrub* 命令拆分到单独的 xfsprogs-xfs_scrub 子包中。而 xfsprogs 主包弱依赖于 xfsprogs-xfs_scrub 子包,所以产品可以根据自己的需求在做镜像时是否集成该子包,或者是否卸载该子包。不集成或卸载该子包不会影响 xfsprogs 主包功能。 - -如果系统中安装了 xfsprogs-xfs_scrub 子包,从 xfsprogs-5.6.0-2 及以上版本降级到 xfsprogs-5.6.0-1 及以下版本时,由于 xfsprogs-5.6.0-1 及以下版本无法提供对应的 xfsprogs-xfs_scrub,因此 xfsprogs-xfs_scrub 不会降级,但 xfsprogs-xfs_scrub 依赖于降级前的 xfsprogs 主包,导致依赖问题无法解决,最终导致降级失败。 - -### 解决方案 - -执行以下命令,卸载 xfsprogs-xfs_scrub 子包,卸载成功后再进行降级操作。 - -```shell -# yum remove xfsprogs-xfs_scrub -``` - -## elfutils降级失败 - -### 问题现象 - -elfutils降级缺少依赖,导致无法降级。 - -![](figures/1665628542704.png) - -### 原因分析 - -22.03-LTS、22.03-LTS-Next分支:elfutils-0.185-12 - -master分支:elfutils-0.187-7 - -20.03-LTS-SP1分支:elfutils-0.180-9 - -如上版本,elfutils主包提供的eu-objdump、eu-readelf、eu-nm命令拆分到elfutils-extra子包中。当系统已安装elfutils-extra,且elfutils进行降级时,由于低版本(如上分支版本)无法提供对应的elfutils-extra包,因此elfutils-extra子包不会降级(elfutils-extra依赖于降级前的elfutils包),导致依赖问题无法解决,最终elfutils降级失败。 - -### 解决方案 - -执行以下命令,先卸载elfutils-extra包,再进行降级操作。 - -```shell -# yum remove -y elfutils-extra -``` - -## cpython/Lib发现CVE-2019-9674:Zip炸弹漏洞 - -### 问题现象 - -Python 3.7.2 及以下版本中的 Lib/zipfile.py 允许远程攻击者通过 zip 炸弹制造拒绝服务请求,从而导致资源消耗过大。 - -### 原因分析 - -远程攻击者通过 zip 炸弹导致拒绝服务,影响目标系统业务甚至达到使系统崩溃的结果。zip 炸弹就是一个高压缩比的 zip 文件,它本身可能只有几M或几十M的大小,但是解压缩之后会产生巨大的数据量,产生巨大的资源消耗。 - -### 解决方案 - -在 zipfile 文档中添加告警信息: - -## 不合理使用glibc正则表达式引起ReDoS攻击 - -### 问题现象 - -使用glibc的regcomp/regexec接口编程,或者grep/sed等应用glibc正则表达式的shell命令,不合理的正则表达式或输入会造成ReDoS攻击(CVE-2019-9192/CVE-2018-28796)。 -典型正则表达式pattern为“反向引用”(\1表示)与“*”(匹配零次或多次)、“+”(匹配一次或多次)、“{m,n}”(最小匹配m次,最多匹配n次)的组合,或者配合超长字符串输入,示例如下: - -```shell -# echo D | grep -E "$(printf '(\0|)(\\1\\1)*')"Segmentation fault (core dumped) -# grep -E "$(printf '(|)(\\1\\1)*')" -Segmentation fault (core dumped) -# echo A | sed '/\(\)\(\1\1\)*/p' -Segmentation fault (core dumped) -# time python -c 'print "a"*40000' | grep -E "a{1,32767}" -Segmentation fault (core dumped) -# time python -c 'print "a"*40900' | grep -E "(a)\\1" -Segmentation fault (core dumped) -``` - -### 原因分析 - -使用正则表达式的进程coredump。具体原因为glibc正则表达式的实现为NFA/DFA混合算法,内部原理是使用贪婪算法进行递归查找,目的是尽可能匹配更多的字符串,贪婪算法在处理递归正则表达式时会导致ReDoS。 - -### 解决方案 - -1. 需要对用户做严格的权限控制,减少攻击面。 -2. 用户需保证正则表达式的正确性,不输入无效正则表达式,或者超长字符串配合正则的“引用” “*”等容易触发无限递归的组合。 - - ```shell - # ()(\1\1)* - # "a"*400000 - ``` - -3. 用户程序在检测到进程异常之后,通过重启进程等手段恢复业务,提升程序的可靠性。 - -## 安装卸载httpd-devel和apr-util-devel软件包,其中的依赖包gdbm-devel安装、卸载有报错 - -### 问题现象 - -1. gdbm-devel-1.18.1-1包安装、卸载有报错; -2. 问题1修复后,gdbm和gdbm-devel包更新到1.18.1-2版本,但在安装httpd-devel、apr-util-devel等包(依赖关系中有gdbm-devel软件包)时,默认安装的gdbm-devel还是1.18.1-1旧版本,导致问题报错依然存在。 - -### 原因分析 - -1. gdbm-devel-1.18.1-1包中缺少提供info信息的help软件包,导致单独安装gdbm-devel并不能将help包引入进来,所以出现了如下告警信息。 - - ```text - install-info: 没有那个文件或目录 for /usr/share/info/gdbm.info.gz - ``` - -2. 由于系统默认安装的gdbm主包是1.18.1-1版本,而没有安装gdbm-devel包。依赖gdbm-devel包的相关软件包在安装gdbm-devel包的过程中,仍会匹配gdbm的主包版本,故而依然安装了gdbm-devel的旧版本1.18.1-1,导致警告信息依然存在。 - -### 解决方案 - -1. 单包升级gdbm,安装使用gdbm-1.18.1-2版本相关软件包后,告警信息消失; -2. 在单包升级gdbm后,再进行安装依赖的gdbm-devel软件包安装,让其依赖高版本gdbm软件包,告警信息消失。 - -## 系统reboot后,执行yum/dnf等命令报错,提示rpmdb error - -### 问题现象 - -1. reboot系统,重启后,执行rpm相关命令(yum/dnf)提示: - error: db5 error(-30973) from dbenv->open: BDB0087 DB_RUNRECOVERY: Fatal error, run database recovery - error: cannot open Packages index using db5 - (-30973) - error: cannot open Packages database in /var/lib/rpm - Error: Error: rpmdb open failed - -### 原因分析 - -1. 执行安装升级动作过程中,会对/var/lib/rpm/__db.00*文件进行读写操作,如果在运行中出现强制下电、磁盘空间满或者 ‘kill -9’ 等异常中断操作,会导致对应_db文件损坏,后续执行rpm相关命令(dnf/yum)会发生报错 - -### 解决方案 - -步骤1 执行`kill -9`停止所有正在运行的rpm命令。 -步骤2 执行`rm -rf /var/lib/rpm/__db.00*`删除所有db.00的文件。 -步骤3 执行`rpmdb --rebuilddb`命令,重建rpm db后即可。 - -## 执行 rpmrebuild -d /home/test filesystem对filesystem包rebuild时,rebuild失败 - -### 问题现象 - -执行 rpmrebuild --comment-missing=y --keep-perm -b -d /home/test filesystem-3.16-3.oe1.aarch64对filesystem包rebuild时,rebuild失败. -/usr/lib/rpmrebuild/rpmrebuild.sh:Error:(RpmBuild) Package 'filesystem-3.16-3.oe1.aarch64' build failed. -/usr/lib/rpmrebuild/rpmrebuild.sh:Error: RpmBuild - -### 原因分析 - -软件包在%pretrans -p阶段创建目录,并在%ghost阶段对该目录进行修饰,如果用户在该目录下创建目录或文件,执行rpmrebuild对该包进行打包,发现创建的目录或文件也会打包到该包中。 - -上述问题的根本原因是因为filesystem在%pretrans阶段创建了/proc目录,并在%ghost阶段对该目录进行了修饰,但是该目录在系统运行时会动态的创建一些微量进程,这些进程非目录也非文件,在执行rpmrebuild的时无法对这些进程进行打包,所以rebuild失败。 - -### 解决方案 - -暂时不使用rpmrebuild命令对filesystem进行rebuild。 - -## 带参数f执行modprobe或insmod报错 - -### 问题现象 - -执行`modprobe -f `或`insmod -f .ko.xz`报错,比如`insmod -f xfs.ko.xz`报错:`modprobe: ERROR: could not insert 'xfs': Key was rejected by service`。 - -迄今为止(2022.09.20, kmod v30),该问题尚未被kmod社区修复。Linux v5.17 [b1ae6dc](https://github.com/torvalds/linux/commit/b1ae6dc41eaaa98bb75671e0f3665bfda248c3e7)添加了对压缩内核模块的支持,kmod尚未支持该特性。 - -### 原因分析 - -对于未经压缩的ko,`{modprobe, insmod}`使用`finit_module()`系统调用,而对于压缩的ko,解压由kmod完成,使用`init_module()`系统调用。系统调用`init_module()`无法传入ignore check的flag,导致内核执行路径中`mod_verify_sig()`始终进入,并且`{modprobe, insmod} -f`参数会更改ko有关的校验信息,导致`mod_verify_sig()`校验失败。 - -### 解决方案 - -对压缩了的ko不使用`{insmod, modprobe} -f`。 diff --git a/docs/zh/docs/Administration/figures/ima-modsig.png b/docs/zh/docs/Administration/figures/ima-modsig.png new file mode 100644 index 0000000000000000000000000000000000000000..c3e54e27b6ce30bd21e97908b6168a73f318c117 Binary files /dev/null and b/docs/zh/docs/Administration/figures/ima-modsig.png differ diff --git a/docs/zh/docs/Administration/figures/ima_digest_list_flow.png b/docs/zh/docs/Administration/figures/ima_digest_list_flow.png new file mode 100644 index 0000000000000000000000000000000000000000..2f5c18f97c644069d5d3e6cad82d01ca519418a4 Binary files /dev/null and b/docs/zh/docs/Administration/figures/ima_digest_list_flow.png differ diff --git a/docs/zh/docs/Administration/figures/ima_digest_list_pkg.png b/docs/zh/docs/Administration/figures/ima_digest_list_pkg.png new file mode 100644 index 0000000000000000000000000000000000000000..a93ff611da5cbeec856b5971126e710d91e63567 Binary files /dev/null and b/docs/zh/docs/Administration/figures/ima_digest_list_pkg.png differ diff --git a/docs/zh/docs/Administration/figures/ima_performance.gif b/docs/zh/docs/Administration/figures/ima_performance.gif deleted file mode 100644 index 72fad8a8333f7357c64a160c1d1c174c31201eaa..0000000000000000000000000000000000000000 Binary files a/docs/zh/docs/Administration/figures/ima_performance.gif and /dev/null differ diff --git a/docs/zh/docs/Administration/figures/ima_priv_key.png b/docs/zh/docs/Administration/figures/ima_priv_key.png new file mode 100644 index 0000000000000000000000000000000000000000..1fe6ac6bb01b224e0248603df39aa743ae62966d Binary files /dev/null and b/docs/zh/docs/Administration/figures/ima_priv_key.png differ diff --git a/docs/zh/docs/Administration/figures/ima_rpm.png b/docs/zh/docs/Administration/figures/ima_rpm.png new file mode 100644 index 0000000000000000000000000000000000000000..484e59535b8b0957dfa0618b83764c13d59e3612 Binary files /dev/null and b/docs/zh/docs/Administration/figures/ima_rpm.png differ diff --git a/docs/zh/docs/Administration/figures/ima_secure_boot.png b/docs/zh/docs/Administration/figures/ima_secure_boot.png new file mode 100644 index 0000000000000000000000000000000000000000..656e4cadb8798be2fe634a074e64f15b0f6a6004 Binary files /dev/null and b/docs/zh/docs/Administration/figures/ima_secure_boot.png differ diff --git a/docs/zh/docs/Administration/figures/ima_sig_verify.png b/docs/zh/docs/Administration/figures/ima_sig_verify.png new file mode 100644 index 0000000000000000000000000000000000000000..c2b43abf07ae9bf59f0e913585cf89b1f079ed00 Binary files /dev/null and b/docs/zh/docs/Administration/figures/ima_sig_verify.png differ diff --git a/docs/zh/docs/Administration/figures/ima_tpm.png b/docs/zh/docs/Administration/figures/ima_tpm.png new file mode 100644 index 0000000000000000000000000000000000000000..56fc12820d4dd98c4d6a4db01419d1a72382b0af Binary files /dev/null and b/docs/zh/docs/Administration/figures/ima_tpm.png differ diff --git a/docs/zh/docs/Administration/figures/ima_trusted_measurement.png b/docs/zh/docs/Administration/figures/ima_trusted_measurement.png new file mode 100644 index 0000000000000000000000000000000000000000..79ebc8f8952bc766741482ea023c507b3a2e15a3 Binary files /dev/null and b/docs/zh/docs/Administration/figures/ima_trusted_measurement.png differ diff --git a/docs/zh/docs/Administration/figures/ima_verification.png b/docs/zh/docs/Administration/figures/ima_verification.png deleted file mode 100644 index d022b9d4ea08d4af386c7b76ca28115ad90e5451..0000000000000000000000000000000000000000 Binary files a/docs/zh/docs/Administration/figures/ima_verification.png and /dev/null differ diff --git a/docs/zh/docs/Administration/figures/zh-cn_image_0231563137.png b/docs/zh/docs/Administration/figures/zh-cn_image_0231563137.png new file mode 100644 index 0000000000000000000000000000000000000000..e55ccfd8251c13bbf47f37f94d2111b0c50d26f4 Binary files /dev/null and b/docs/zh/docs/Administration/figures/zh-cn_image_0231563137.png differ diff --git a/docs/zh/docs/Administration/figures/zh-cn_image_0231563138.png b/docs/zh/docs/Administration/figures/zh-cn_image_0231563138.png new file mode 100644 index 0000000000000000000000000000000000000000..ccf7734682d9cde4cf0ea4ef365143109abeadbf Binary files /dev/null and b/docs/zh/docs/Administration/figures/zh-cn_image_0231563138.png differ diff --git "a/docs/zh/docs/Administration/\344\275\277\347\224\250DNF\347\256\241\347\220\206\350\275\257\344\273\266\345\214\205.md" "b/docs/zh/docs/Administration/\344\275\277\347\224\250DNF\347\256\241\347\220\206\350\275\257\344\273\266\345\214\205.md" index e704595388bf9c48f177a6d46e5b74277df9ee26..f8b566d4e7a84cd5e90dcee1c7b26063670dc2ed 100644 --- "a/docs/zh/docs/Administration/\344\275\277\347\224\250DNF\347\256\241\347\220\206\350\275\257\344\273\266\345\214\205.md" +++ "b/docs/zh/docs/Administration/\344\275\277\347\224\250DNF\347\256\241\347\220\206\350\275\257\344\273\266\345\214\205.md" @@ -295,7 +295,7 @@ repository部分允许您定义定制化的openEuler软件源仓库,各个仓 ``` >![](./public_sys-resources/icon-note.gif) **说明:** ->安装RPM包过程中,若出现安装失败,可参考[安装时出现软件包冲突、文件冲突或缺少软件包导致安装失败](./FAQ-54.html#安装时出现软件包冲突文件冲突或缺少软件包导致安装失败)。 +>安装RPM包过程中,若出现安装失败,可参考[安装时出现软件包冲突、文件冲突或缺少软件包导致安装失败](./系统管理常见问题与解决方法.md#安装时出现软件包冲突文件冲突或缺少软件包导致安装失败)。 ### 下载软件包 diff --git "a/docs/zh/docs/Administration/\345\206\205\346\240\270\345\256\214\346\225\264\346\200\247\345\272\246\351\207\217\357\274\210IMA\357\274\211.md" "b/docs/zh/docs/Administration/\345\206\205\346\240\270\345\256\214\346\225\264\346\200\247\345\272\246\351\207\217\357\274\210IMA\357\274\211.md" new file mode 100644 index 0000000000000000000000000000000000000000..98f1afc8b1de1afb58e4a87c3efb79629395dbdc --- /dev/null +++ "b/docs/zh/docs/Administration/\345\206\205\346\240\270\345\256\214\346\225\264\346\200\247\345\272\246\351\207\217\357\274\210IMA\357\274\211.md" @@ -0,0 +1,1140 @@ +# 内核完整性度量(IMA) + +## 概述 + +### IMA介绍 + +IMA,全称 Integrity Measurement Architecture(完整性度量架构),是内核中的一个子系统,能够基于自定义策略对通过`execve()`、`mmap()`和`open()`等系统调用访问的文件进行度量,度量结果可被用于**本地/远程证明**,或者和已有的参考值比较以**控制对文件的访问**。 + +IMA的运行模式主要包含以下两种: + +- 度量(measure):提供了对文件的完整性状态观测功能,访问受保护文件时,会往度量日志(位于内核内存中)增加度量记录。如果系统包含TPM芯片,还可以往TPM芯片PCR寄存器中扩展度量摘要值,以保证度量信息不被篡改。度量场景并不提供对文件访问的控制,它记录的文件信息可传递给上层应用软件,进一步用于远程证明。 +- 评估(appraise):提供了对文件的完整性校验功能,从根本上杜绝了未知的/被篡改的文件的访问。通过哈希、签名、HMAC等密码学技术对文件的内容进行完整性验证,如果验证失败,则不允许任何进程对该文件进行访问。该特性为系统提供了底层韧性设计,在系统被破坏时牺牲一部分功能(被篡改的部分文件),避免攻击造成的影响进一步升级。 + +可以看到,IMA度量模式相当于一个“只记录不干涉”的观察员,IMA评估模式相当于一位严格的保安人员,它的职责是拒绝对所有“人证不一”的文件访问。 + +### EVM介绍 + +EVM,全称 Extended Verification Module(扩展验证模块),是对IMA功能的扩展,在通过IMA实现对于文件内容的完整性保护的基础上,使用EVM可以更进一步地实现对于文件扩展属性(如UID、security.ima 、security.selinux等属性)的保护。 + +### IMA摘要列表介绍 + +IMA Digest Lists(IMA摘要列表)是openEuler对内核原生完整性保护机制的增强,旨在对原生的IMA/EVM机制的以下痛点进行优化: + +**TPM扩展导致文件访问性能下降:** + +IMA度量模式下,每次触发度量都需要访问TPM芯片,TPM属于低速芯片,通常采用几十MHz时钟频率的SPI协议与CPU通信,导致系统调用性能下降: + +![](./figures/ima_tpm.png) + +**非对称运算导致文件访问性能下降:** + +IMA评估模式下,需要使用签名机制保护不可变文件,每次触发文件校验都需要进行签名验证,而非对称运算相对复杂 ,同样导致系统调用性能下降: + +![](./figures/ima_sig_verify.png) + +**复杂的部署方式导致效率和安全性下降:** + +IMA评估模式下,需要通过fix模式进行部署,即系统首先需要进入fix模式进行IMA/EVM扩展属性标记,然后再切换为校验模式启动。同时在受保护的文件升级时,需要重启进入fix模式,完成文件和扩展属性更新。一方面降低了部署效率,另一方面需要在运行环境中访问密钥,降低了安全性: + +![](./figures/ima_priv_key.png) + +IMA摘要列表旨在通过一个哈希列表文件管理一系列文件的基准摘要值,即将若干文件(如一个软件包中的所有可执行文件)的基准摘要值汇总到单个文件中进行管理。基准摘要值可包含文件内容摘要(对应IMA模式)和文件扩展属性摘要(对应EVM模式),这个文件就是IMA摘要列表文件。 + +![](./figures/ima_digest_list_pkg.png) + +开启IMA摘要列表功能后,内核维护一个哈希白名单池,用于存放导入的IMA摘要列表文件中的摘要值,并通过securityfs对外提供IMA摘要列表文件的导入/删除/查询等接口。 + +在度量模式下,导入内核的摘要列表文件需要进行度量和TPM扩展才可添加至白名单池,后续如果度量的目标文件的摘要值和白名单池匹配,则不进行额外的度量日志记录以及TPM扩展;在评估模式下,导入内核的摘要列表文件需要通过签名验证才可添加至白名单池,后续将访问的目标文件的摘要值和白名单池中的摘要值进行匹配即可判断评估结果。 + +![](./figures/ima_digest_list_flow.png) + +相比Linux原生IMA/EVM机制,IMA摘要列表扩展从安全性、性能、易用性三个方面进行了改良,以实现更好的落地效果: + +- 安全性:IMA摘要列表可以随软件包一起发布,软件包安装时同步导入摘要列表,确保了基准值来自于软件发行商(如openEuler社区),避免在运行环境生成基准值的流程,实现了完整的信任链。 +- 性能:IMA摘要列表机制以摘要列表为单位进行度量/校验,降低TPM访问和非对称运算频率为1/n(n为平均单个摘要列表管理的文件哈希数量),可一定程度提升系统调用性能和系统启动性能。 +- 易用性:IMA摘要列表机制可以实现“开箱即用”,即完成系统安装后直接进入评估模式,且允许在评估模式下直接安装/升级软件包,而无需进入fix模式进行文件标记,从而实现快速部署和平滑升级。 + +需要注意的是,IMA摘要列表相比原生IMA/EVM,将度量/评估的基准值在内核内存中进行维护,也引入了一个假设,即内核内存不可被未授权篡改,这就使得IMA摘要列表也依赖于其他安全机制(如内核模块安全启动和内存动态度量等)以保护内核内存的完整性。 + +但无论社区原生IMA机制还是IMA摘要列表扩展,都只是系统安全链中的一环,无法孤立地保证系统的安全性,安全自始至终都是一个构建纵深防御的系统工程。 + +## 接口说明 + +### 内核启动参数说明 + +openEuler IMA/EVM机制提供的内核启动参数及说明如下: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
参数名称取值功能
ima_appraiseenforce-evmIMA评估强制校验模式(EVM开启)
log-evmIMA评估日志模式(EVM开启)
enforceIMA评估强制校验模式
logIMA评估日志模式
off关闭IMA评估
ima_appraise_digest_listdigest基于摘要列表进行IMA+EVM评估(比较文件内容和扩展属性)
digest-nometadata基于摘要列表进行IMA评估(只比较文件内容)
evmx509直接开启基于可移植签名的EVM(无论EVM证书是否加载)
complete启动后不允许通过securityfs接口修改EVM模式
allow_metadata_writes允许修改文件元数据,EVM不做拦截
ima_hashsha256/sha1/...声明IMA度量哈希算法
ima_templateima声明IMA度量模板(d|n)
ima-ng声明IMA度量模板(d-ng|n-ng),默认使用该模板
ima-sig声明IMA度量模板(d-ng|n-ng|sig)
ima_policyexec_tcb度量所有执行、映射方式访问的文件,以及加载的内核模块、固件、内核等文件
tcb在exec_tcb策略的基础上,额外度量以uid=0或euid=0身份访问的文件
secure_boot评估所有加载的内核模块、固件、内核等文件,并指定使用IMA签名模式
appraise_exec_tcb在secure_boot策略的基础上,额外评估所有执行、映射方式访问的文件
appraise_tcb评估访问的所有属主为0的文件
appraise_exec_immutable与appraise_exec_tcb策略配合使用,可执行文件的扩展属性不可变
ima_digest_list_pcr10在PCR 10中扩展基于摘要列表的IMA度量结果,禁用原生IMA度量
11在PCR 11中扩展基于摘要列表的IMA度量结果,禁用原生IMA度量
+11在PCR 11中扩展基于摘要列表的IMA度量结果,在PCR 10中扩展原生IMA度量结果
ima_digest_db_sizenn[M]设置内核摘要列表上限(0M~64M),不做配置的情况下默认为16MB(不做配置指的是不写该参数,但注意不能将值留空,如ima_digest_db_size=)
ima_capacity-1~2147483647设置内核度量日志条数上限,不做配置的情况下默认为100000条,配置-1表示无上限
initramtmpfs在initrd中支持tmpfs,以携带文件扩展属性
+ + +根据用户实际场景诉求,建议采取如下参数组合: + +**1) 原生IMA度量:** + +``` +# 原生IMA度量+自定义策略 +无需配置,默认开启 +# 原生IMA度量+TCB默认策略 +ima_policy="tcb" +``` + +**2) 基于摘要列表的IMA度量:** + +``` +# 摘要列表IMA度量+自定义策略 +ima_digest_list_pcr=11 ima_template=ima-ng initramtmpfs +# 摘要列表IMA度量+默认策略 +ima_digest_list_pcr=11 ima_template=ima-ng ima_policy="exec_tcb" initramtmpfs +``` + +**3) 基于摘要列表的IMA评估,只保护文件内容:** + +``` +# IMA评估+日志模式 +ima_appraise=log ima_appraise_digest_list=digest-nometadata ima_policy="appraise_exec_tcb" initramtmpfs +# IMA评估+强制校验模式 +ima_appraise=enforce ima_appraise_digest_list=digest-nometadata ima_policy="appraise_exec_tcb" initramtmpfs +``` + +**4) 基于摘要列表的IMA评估,保护文件内容和扩展属性:** + +``` +# IMA评估+日志模式 +ima_appraise=log-evm ima_appraise_digest_list=digest ima_policy="appraise_exec_tcb|appraise_exec_immutable" initramtmpfs evm=x509 evm=complete +# IMA评估+强制校验模式 +ima_appraise=enforce-evm ima_appraise_digest_list=digest ima_policy="appraise_exec_tcb|appraise_exec_immutable" initramtmpfs evm=x509 evm=complete +``` + +> ![](./public_sys-resources/icon-note.gif) **说明:** +> +> 以上四种参数都可以单独配置使用,但只有基于摘要列表的度量和评估模式可以组合使用,即2)和3)搭配或2)和4)搭配。 + +### securityfs接口说明 + +openEuler IMA提供的securityfs接口位于`/sys/kernel/security`目录下,接口名及说明如下: + +| 路径 | 权限 | 说明 | +| :----------------------------- | :--- | :-------------------------------------- | +| ima/policy | 600 | IMA策略查询/导入接口 | +| ima/ascii_runtime_measurement | 440 | 查询IMA度量日志,以字符串形式输出 | +| ima/binary_runtime_measurement | 440 | 查询IMA度量日志,以二进制形式输出 | +| ima/runtime_measurement_count | 440 | 查询IMA度量日志条数 | +| ima/violations | 440 | 查询异常IMA度量日志数量 | +| ima/digests_count | 440 | 显示系统哈希表中的总摘要数量(IMA+EVM) | +| ima/digest_list_data | 200 | 摘要列表新增接口 | +| ima/digest_list_data_del | 200 | 摘要列表删除接口 | +| evm | 660 | 查询/设置EVM模式 | + +其中,`/sys/kernel/security/evm` 的接口的取值有以下三种: + +- 0:EVM 未初始化; +- 1:使用 HMAC(对称加密)方式校验扩展属性完整性; +- 2:使用公钥验签(非对称加密)方式校验扩展属性完整性; +- 6:关闭扩展属性完整性校验。 + +### 摘要列表管理工具说明 + +digest-list-tools软件包提供IMA摘要列表文件生成和管理的工具,主要包含如下几个命令行工具: + +#### gen_digest_lists工具 + +用户可通过调用gen_digest_lists命令行工具生成摘要列表。命令参数定义如下: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
参数名称取值功能
-d<path>指定生成摘要列表文件存放的位置,需为有效目录。
-fcompact指定生成摘要列表文件的格式,当前仅支持compact格式。
-i<option arg>:<option value>指定生成摘要列表的目标文件范围,具体参数定义如下。
I:<path>指定需要生成摘要列表的文件绝对路径,如指定目录,则会执行递归生成。
E:<path>指定需要排除的路径或目录。
F:<path>指定路径或目录,为该路径或目录下所有文件生成摘要列表(同时指定e:参数时,忽略e:选项的筛选效果)。
e:仅对可执行文件生成摘要列表。
l:policy从系统SELinux策略匹配文件安全上下文,而不是直接从文件扩展属性中读取安全上下文。
i:当生成metadata类型的摘要列表时,被计算的扩展属性信息包含文件的摘要值(必须指定)。
M:允许显式指定文件的扩展属性信息(需要结合rpmbuild命令使用)。
u:将“L:”参数所指定的列表文件名作为生成摘要列表的文件名(需要结合rpmbuild命令使用)。
L:<path>指定列表文件的路径,列表文件中包含需要生成摘要列表的信息数据(需要结合rpmbuild命令使用)。
-oadd指定生成摘要列表的操作,当前仅支持add操作,即将摘要列表添加到文件中。
-p-1指定将摘要列表写入文件中的位置,当前仅支持指定-1。
-tfile只针对文件内容生成摘要列表。
metadata针对对文件的内容和扩展属性分别生成摘要列表。
-TNA不添加该参数,则生成摘要列表文件,添加该参数则生成TLV摘要列表文件。
-A<path>指定相对根目录,将文件路径截去指定的前缀进行路径匹配和SELinux标签匹配。
-mimmutable指定生成摘要列表文件的modifiers属性,当前仅支持指定immutable。摘要列表在enforce/enforece-evm模式下,摘要列表只能以只读模式打开。
-hNA打印帮助信息。
+ +**参考使用示例:** + +- 场景1:为单个文件生成摘要列表/TLV摘要列表。 + + ``` + gen_digest_lists -t metadata -f compact -i l:policy -o add -p -1 -m immutable -i I:/usr/bin/ls -d ./ -i i: gen_digest_lists -t metadata -f compact -i l:policy -o add -p -1 -m immutable -i I:/usr/bin/ls -d ./ -i i: -T + ``` + +- 场景2: 为单个文件生成摘要列表/TLV摘要列表,并指定相对根目录。 + + ``` + gen_digest_lists -t metadata -f compact -i l:policy -o add -p -1 -m immutable -i I:/usr/bin/ls -A /usr/ -d ./ -i i: gen_digest_lists -t metadata -f compact -i l:policy -o add -p -1 -m immutable -i I:/usr/bin/ls -A /usr/ -d ./ -i i: -T + ``` + +- 场景3:为目录下的文件递归生成摘要列表/TLV摘要列表。 + + ``` + gen_digest_lists -t metadata -f compact -i l:policy -o add -p -1 -m immutable -i I:/usr/bin/ -d ./ -i i: + gen_digest_lists -t metadata -f compact -i l:policy -o add -p -1 -m immutable -i I:/usr/bin/ -d ./ -i i: -T + ``` + +- 场景4:为目录下的可执行文件递归生成摘要列表/TLV摘要列表。 + + ``` + gen_digest_lists -t metadata -f compact -i l:policy -o add -p -1 -m immutable -i I:/usr/bin/ -d ./ -i i: -i e:gen_digest_lists -t metadata -f compact -i l:policy -o add -p -1 -m immutable -i I:/usr/bin/ -d ./ -i i: -i e: -T + ``` + +- 场景5:为目录下的文件递归生成摘要列表/TLV摘要列表,排除部分子目录。 + + ``` + gen_digest_lists -t metadata -f compact -i l:policy -o add -p -1 -m immutable -i I:/usr/ -d ./ -i i: -i E:/usr/bin/gen_digest_lists -t metadata -f compact -i l:policy -o add -p -1 -m immutable -i I:/usr/ -d ./ -i i: -i E:/usr/bin/ -T + ``` + +- 场景6:rpmbuild回调脚本中,通过读取rpmbuild传入的列表文件生成摘要列表。 + + ``` + gen_digest_lists -i M: -t metadata -f compact -d $DIGEST_LIST_DIR -i l:policy \ + -i i: -o add -p -1 -m immutable -i L:$BIN_PKG_FILES -i u: \ + -A $RPM_BUILD_ROOT -i e: \ + -i E:/usr/src \ + -i E:/boot/efi \ + -i F:/lib \ + -i F:/usr/lib \ + -i F:/lib64 \ + -i F:/usr/lib64 \ + -i F:/lib/modules \ + -i F:/usr/lib/modules \ + -i F:/lib/firmware \ + -i F:/usr/lib/firmware + + gen_digest_lists -i M: -t metadata -f compact -d $DIGEST_LIST_DIR.tlv \ + -i l:policy -i i: -o add -p -1 -m immutable -i L:$BIN_PKG_FILES -i u: \ + -T -A $RPM_BUILD_ROOT -i e: \ + -i E:/usr/src \ + -i E:/boot/efi \ + -i F:/lib \ + -i F:/usr/lib \ + -i F:/lib64 \ + -i F:/usr/lib64 \ + -i F:/lib/modules \ + -i F:/usr/lib/modules \ + -i F:/lib/firmware \ + -i F:/usr/lib/firmware + ``` + +#### manage_digest_lists工具 + +manage_digest_lists命令行工具主要用于将二进制格式的TLV摘要列表文件解析转换为可读的文本形式。命令参数定义如下: + +| 参数名称 | 取值 | 功能 | +| -------- | ---------- | ----------------------------------------------------------- | +| -d | \ | 指定TLV摘要列表文件存放的目录。 | +| -f | \ | 指定TLV摘要列表文件名。 | +| -p | dump | 指定操作类型,当前仅支持dump,表示解析打印TLV摘要列表操作。 | +| -v | NA | 打印详细信息。 | +| -h | NA | 打印帮助信息。 | + +**参考使用示例:** + +查看TLV摘要列表信息: + +``` +manage_digest_lists -p dump -d /etc/ima/digest_lists.tlv/ +``` + +## 文件格式说明 + +### IMA策略文件语法说明 + +IMA策略文件为文本文件,一个文件中可包含若干条按照换行符`\n`分隔的规则语句,每条规则语句都必须以 action 关键字代表的**动作**开头,后接**筛选条件**: + +``` + <筛选条件1> [筛选条件2] [筛选条件3]... +``` + +action表示该条策略具体的动作,一条策略只能选一个 action,具体的action见后表(实际书写时**可忽略 action 字样**,例如直接书写 dont_measure,不需要写成 action=dont_measure): + +筛选条件支持如下几种类型: + +- func:表示被度量或评估的文件类型,常和 mask 匹配使用,一条策略只能选一个 func。 + + - FILE_CHECK 只能同 MAY_EXEC、MAY_WRITE、MAY_READ 匹配使用。 + - MODULE_CHECK、MMAP_CHECK、BPRM_CHECK 只能同 MAY_EXEC 匹配使用。 + - 匹配关系以外的组合不会产生效果。 + +- mask:表示文件在做什么操作时将被度量或评估,一条策略只能选一个 mask。 + +- fsmagic:表示文件系统类型的十六进制魔数,定义在 `/usr/include/linux/magic.h` 文件中(默认情况下度量所有文件系统,除非使用 dont_measure/dont_appraise 标记不度量某文件系统)。 + +- fsuuid:表示系统设备 uuid 的 16 位的十六进制字符串。 + +- objtype:表示文件安全类型,一条策略只能选一个文件类型,objtype 相比 func 而言,划分的粒度更细,比如 obj_type=nova_log_t 表示SELinux类型为 nova_log_t 的文件。 + +- uid:表示哪个用户(用用户 id 表示)对文件进行操作,一条策略只能选一个 uid。 + +- fowner:表示文件的属主(用用户 id 表示)是谁,一条策略只能选一个 fowner。 + +关键字的具体取值及说明如下: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
关键字说明
actionmeasure开启IMA度量
dont_measure禁用IMA度量
appraise开启IMA评估
dont_appraise禁用IMA评估
audit开启审计
funcFILE_CHECK将要被打开的文件
MODULE_CHECK将要被装载的内核模块文件
MMAP_CHECK将要被映射到进程内存空间的动态库文件
BRPM_CHECK将要被执行的文件(不含通过 /bin/hash 等程序打开的脚本文件)
POLICY_CHECK将要被导入的IMA策略文件
FIRMWARE_CHECK将要被加载到内存中的固件
DIGEST_LIST_CHECK将要被加载到内核中的摘要列表文件
KEXEC_KERNEL_CHECK将要切换的 kexec 内核
maskMAY_EXEC执行文件
MAY_WRITE写文件
MAY_READ读文件
MAY_APPEND扩展文件属性
fsmagicfsmagic=xxx表示文件系统类型的十六进制魔数
fsuuidfsuuid=xxx表示系统设备 uuid 的 16 位的十六进制字符串
fownerfowner=xxx文件属主的用户 id
uiduid=xxx操作文件的用户 id
obj_typeobj_type=xxx_t表示文件的类型(基于 SELinux 标签)
pcrpcr=选择 TPM 中用于扩展度量值的 PCR(默认为 10)
appraise_typeimasig基于签名进行IMA评估
meta_immutable基于签名进行文件扩展属性的评估(支持摘要列表)
+ +## 使用说明 + +> ![](./public_sys-resources/icon-note.gif) **说明:** +> +> 原生IMA/EVM为Linux开源特性,本章节仅简单介绍基本使用方式,其他资料可参考开源WIKI: +> +> + +### 原生IMA使用说明 + +#### IMA度量模式 + +用户需要配置度量策略,开启IMA度量功能,具体步骤如下: + +**步骤1:** 用户可通过配置启动参数或手动配置的方式,指定度量策略。通过启动参数配置IMA策略的示例如下: + +``` +ima_policy="tcb" +``` + +手动配置IMA策略的示例如下: + +``` +echo "measure func=BPRM_CHECK" > /sys/kernel/security/ima/policy +``` + +**步骤2:** 重启系统,用户可实时检查度量日志获取当前的度量情况: + +``` +cat /sys/kernel/security/ima/ascii_runtime_measurements +``` + +#### IMA评估模式 + +用户需要首先进入fix模式,完成文件的IMA标记后,再开启log或enforce模式。具体步骤如下: + +**步骤1:** 配置启动参数,重启后进入fix模式: + +``` +ima_appraise=fix ima_policy=appraise_tcb +``` + +**步骤2:** 为所有需要评估的文件生成IMA扩展属性: + +对于不可变文件(如二进制程序文件)可以使用签名模式,将文件摘要值的签名写入IMA扩展属性中。举例如下(其中`/path/to/ima.key`指的是和IMA证书匹配的签名私钥): + +``` +find /usr/bin -fstype ext4 -type f -executable -uid 0 -exec evmctl -a sha256 ima_sign --key /path/to/ima.key '{}' \; +``` + +对于可变文件(如数据文件)可以使用哈希模式,将文件的摘要值写入IMA扩展属性中。IMA支持自动标记机制,即在fix模式下仅需触发文件访问,即可自动生成IMA扩展属性: + +``` +find / -fstype ext4 -type f -uid 0 -exec dd if='{}' of=/dev/null count=0 status=none \; +``` + +可通过如下命令检查文件是否被成功标记了IMA扩展属性(security.ima): + +``` +getfattr -m - -d /sbin/init +``` + +**步骤3:** 配置启动参数,修改IMA评估为log或enforce模式后,重启系统: + +``` +ima_appraise=enforce ima_policy=appraise_tcb +``` + +### IMA摘要列表使用说明 + +#### 前置条件 + +IMA摘要列表特性使用前,用户需安装`ima-evm-utils`和`digest-list-tools`软件包: + +``` +yum install ima-evm-utils digest-list-tools +``` + +#### 机制介绍 + +##### 摘要列表文件 + +在安装openEuler发布的RPM包后,默认会在`/etc/ima`目录下生成摘要列表文件。根据文件名的不同,存在如下几种文件: + +**/etc/ima/digest_lists/0-metadata_list-compact-** + +为IMA摘要列表文件,通过`gen_digest_lists`命令生成(生成方法详见[gen_digest_lists工具](#gen_digest_list工具)),该文件为二进制格式,包含header信息以及一连串SHA256哈希值,分别代表合法的文件内容摘要值和文件扩展属性摘要值。该文件被度量或评估后,最终被导入内核,并以该文件中的白名单摘要值为基准进行IMA摘要列表度量或评估。 + +**/etc/ima/digest_lists/0-metadata_list-rpm-** + +为RPM摘要列表文件,**实际为RPM包的头信息**。RPM包安装后,如果IMA摘要列表文件不包含签名,则会把RPM头信息写入该文件中,并将头信息的签名写入`security.ima`扩展属性中。这样通过签名可验证RPM头信息的真实性,由于RPM头信息又包含了摘要列表文件的摘要值,则可实现摘要列表的间接验证。 + +**/etc/ima/digest_lists/0-parser_list-compact-libexec** + +为IMA PARSER摘要列表文件,存放`/usr/libexec/rpm_parser`文件的摘要值。该文件用于实现RPM摘要列表->IMA摘要列表的信任链,内核IMA摘要列表机制会对该文件执行后产生的进程进行特殊校验,如果确定是`rpm_parser`程序,则会信任其导入的所有摘要列表而无需校验签名。 + +**/etc/ima/digest_lists.sig/0-metadata_list-compact-.sig** + +为IMA摘要列表的签名文件,若RPM包中包含此文件,则在RPM包安装阶段,会将该文件的内容写入对应的RPM摘要列表文件的`security.ima`扩展属性,从而在IMA摘要列表导入内核阶段进行签名验证。 + +**/etc/ima/digest_lists.tlv/0-metadata_list-compact_tlv-** + +为TLV摘要列表文件,通常在对目标文件生成IMA摘要列表文件时一并生成,存放目标文件的完整性信息(文件内容摘要值、文件扩展属性等)。该文件的功能是协助用户查询/恢复目标文件的完整性信息。 + +##### 摘要列表文件签名方式 + +在IMA摘要列表评估模式下,IMA摘要列表文件需要经过签名验证才可导入内核,并用于后续的文件白名单匹配。IMA摘要列表文件支持如下几种签名方式: + +**1) IMA扩展属性签名** + +即原生的IMA签名机制,将签名信息按照一定格式,存放在`security.ima`扩展属性中。可通过`evmctl`命令生成并添加: + +``` +evmctl ima_sign --key /path/to/ima.key -a sha256 +``` + +也可添加`-f`参数,将签名信息和头信息存入独立的文件中: + +``` +evmctl ima_sign -f --key /path/to/ima.key -a sha256 +``` + +在开启IMA摘要列表评估模式下,可直接将摘要列表文件路径写入内核接口,实现摘要列表的导入/删除。该过程会自动触发评估,基于`security.ima`扩展属性完成对摘要列表文件内容的签名验证: + +``` +# 导入IMA摘要列表文件 +echo > /sys/kernel/security/ima/digest_list_data +# 删除IMA摘要列表文件 +echo > /sys/kernel/security/ima/digest_list_data_del +``` + +**2) IMA摘要列表追加签名(openEuler 24.03 LTS版本默认)** + +openEuler 24.03 LTS版本开始支持IMA专用签名密钥,并采用CMS签名。由于签名信息包含证书链,可能由于长度超出限制而无法写入文件的`security.ima`扩展属性中,因此采用类似内核模块的追加签名的方式: + + + +其签名机制为: + +1) 将CMS签名信息追加到IMA摘要列表文件末尾; + +2) 填充结构体并添加到签名信息末尾,结构体定义如下: + +``` +struct module_signature { + u8 algo; /* Public-key crypto algorithm [0] */ + u8 hash; /* Digest algorithm [0] */ + u8 id_type; /* Key identifier type [PKEY_ID_PKCS7] */ + u8 signer_len; /* Length of signer's name [0] */ + u8 key_id_len; /* Length of key identifier [0] */ + u8 __pad[3]; + __be32 sig_len; /* Length of signature data */ +}; +``` + +3) 添加魔鬼字符串`"~Module signature appended~\n"` + +此步骤的参考脚本如下: + +``` +#!/bin/bash +DIGEST_FILE=$1 # IMA摘要列表文件路径 +SIG_FILE=$2 # IMA摘要列表签名信息保存路径 +OUT=$3 #完成签名信息添加后的摘要列表文件输出路径 + +cat $DIGEST_FILE $SIG_FILE > $OUT +echo -n -e "\x00\x00\x02\x00\x00\x00\x00\x00" >> $OUT +echo -n -e $(printf "%08x" "$(ls -l $SIG_FILE | awk '{print $5}')") | xxd -r -ps >> $OUT +echo -n "~Module signature appended~" >> $OUT +echo -n -e "\x0a" >> $OUT +``` + +**3) 复用RPM签名(openEuler 22.03 LTS版本默认)** + +openEuler 22.03 LTS版本支持复用RPM签名机制实现IMA摘要列表文件的签名。旨在解决版本无专用IMA签名密钥的问题。用户无需感知该签名流程,当RPM包中含有IMA摘要列表文件,而不包含IMA摘要列表的签名文件时,会自动使用该签名机制。其核心原理是通过RPM包的头信息实现对IMA摘要列表的验证。 + +对于openEuler发布的RPM包,每一个包文件可以包含两部分: + +- **RPM头信息:** 存放RPM包属性字段,如包名、文件摘要值列表等,通过RPM头签名保证其完整性; +- **RPM文件:** 实际安装至系统中的文件,也包括构建阶段生成的IMA摘要列表文件。 + + + +在RPM包安装阶段,如果RPM进程检测到包中的摘要列表文件不包含签名,则在`/etc/ima`目录下创建一个RPM摘要列表文件,将RPM头信息写入文件内容,将RPM头签名写入文件的`security.ima`扩展属性中。后续可通过RPM摘要列表间接实现IMA摘要列表的验证和导入。 + +##### IMA摘要列表导入 + +在开启IMA度量模式下,导入IMA摘要列表文件无需经过签名验证,可直接将路径写入内核接口,实现摘要列表的导入/删除: + +``` +# 导入IMA摘要列表文件 +echo > /sys/kernel/security/ima/digest_list_data +# 删除IMA摘要列表文件 +echo > /sys/kernel/security/ima/digest_list_data_del +``` + +在开启IMA评估模式下,导入摘要列表必须通过签名验证。根据签名方式不同,可分为两种导入方式。 + +**直接导入方式** + +对于已包含签名信息的IMA摘要列表文件(IMA扩展属性签名或IMA摘要列表追加签名),可直接将路径写入内核接口,实现摘要列表的导入/删除。该过程会自动触发评估,基于`security.ima`扩展属性完成对摘要列表文件内容的签名验证: + +``` +# 导入IMA摘要列表文件 +echo > /sys/kernel/security/ima/digest_list_data +# 删除IMA摘要列表文件 +echo > /sys/kernel/security/ima/digest_list_data_del +``` + +**调用`upload_digest_lists`导入方式** + +对于复用RPM签名的IMA摘要列表文件,需要调用`upload_digest_lists`命令实现导入。具体命令如下(注意指定的路径为对应的RPM摘要列表): + +``` +# 导入IMA摘要列表文件 +upload_digest_lists add +# 删除IMA摘要列表文件 +upload_digest_lists del +``` + +该流程相对复杂,需要满足以下前置条件: + +1) 系统已导入openEuler发布的`digest_list_tools`软件包中的摘要列表(包含IMA摘要列表和IMA PARSER摘要列表); + +2) 已配置对应用程序执行的IMA评估策略(BPRM_CHECK策略)。 + +#### 操作指导 + +##### RPM构建自动生成摘要列表 + +openEuler RPM工具链支持`%__brp_digest_list`宏定义,配置格式如下: + +``` +%__brp_digest_list /usr/lib/rpm/brp-digest-list %{buildroot} +``` + +当配置了该宏定义后,当用户调用`rpmbuild`命令进行软件包构建时,在RPM打包阶段会调用`/usr/lib/rpm/brp-digest-list`脚本进行摘要列表的生成和签名等流程。openEuler默认针对可执行程序、动态库、内核模块等关键文件生成摘要列表。用户也可以通过修改脚本,自行配置生成摘要列表的范围和指定签名密钥。如下示例使用用户自定义的签名密钥`/path/to/ima.key`进行摘要列表签名。 + +``` +...... (line 66) +DIGEST_LIST_TLV_PATH="$DIGEST_LIST_DIR.tlv/0-metadata_list-compact_tlv-$(basename $BIN_PKG_FILES)" +[ -f $DIGEST_LIST_TLV_PATH ] || exit 0 + +chmod 644 $DIGEST_LIST_TLV_PATH +echo $DIGEST_LIST_TLV_PATH + +evmctl ima_sign -f --key /path/to/ima.key -a sha256 $DIGEST_LIST_PATH &> /dev/null +chmod 400 $DIGEST_LIST_PATH.sig +mkdir -p $DIGEST_LIST_DIR.sig +mv $DIGEST_LIST_PATH.sig $DIGEST_LIST_DIR.sig +echo $DIGEST_LIST_DIR.sig/0-metadata_list-compact-$(basename $BIN_PKG_FILES).sig +``` + +##### IMA摘要列表度量 + +用户可通过如下功能开启IMA摘要列表度量: + +**步骤1:** 用户需要配置启动参数度量策略,开启IMA度量功能,具体步骤同**原生IMA度量**,不同的是需要单独配置度量所使用的TPM PCR寄存器,启动参数示例如下: + +``` +ima_policy=exec_tcb ima_digest_list_pcr=11 +``` + +**步骤2:** 用户导入IMA摘要列表,以`bash`软件包的摘要列表为例: + +``` +echo /etc/ima/digest_lists/0-metadata_list-compact-bash-5.1.8-6.oe2203sp1.x86_64 > /sys/kernel/security/ima/digest_list_data +``` + +可查询到IMA摘要列表的度量日志: + +``` +cat /sys/kernel/security/ima/ascii_runtime_measurements +``` + +导入IMA摘要列表后,如果后续度量的文件摘要值包含在IMA摘要列表中,则不会额外记录度量日志。 + +##### IMA摘要列表评估 + +###### 默认策略启动场景 + +用户可在启动参数中配置`ima_policy`参数指定IMA默认策略,则在内核启动阶段,IMA初始化完成后立即启用默认策略进行评估。用户可通过如下功能开启IMA摘要列表评估: + +**步骤1:** 执行`dracut`命令将摘要列表文件写入initrd: + +``` +dracut -f -e xattr +``` + +**步骤2:** 配置启动参数和IMA策略,典型的配置如下: + +``` +# 基于摘要列表的IMA评估log/enforce模式,只保护文件内容,配置默认策略为appraise_exec_tcb +ima_appraise=log ima_appraise_digest_list=digest-nometadata ima_policy="appraise_exec_tcb" initramtmpfs module.sig_enforce +ima_appraise=enforce ima_appraise_digest_list=digest-nometadata ima_policy="appraise_exec_tcb" initramtmpfs module.sig_enforce +# 基于摘要列表的IMA评估log/enforce模式,保护文件内容和扩展属性,配置默认策略为appraise_exec_tcb+appraise_exec_immutable +ima_appraise=log-evm ima_appraise_digest_list=digest ima_policy="appraise_exec_tcb|appraise_exec_immutable" initramtmpfs evm=x509 evm=complete module.sig_enforce +ima_appraise=enforce-evm ima_appraise_digest_list=digest ima_policy="appraise_exec_tcb|appraise_exec_immutable" initramtmpfs evm=x509 evm=complete module.sig_enforce +``` + +重启系统即可开启IMA摘要列表评估功能,启动过程中自动完成IMA策略生效和IMA摘要列表文件导入。 + +###### 无默认策略启动场景 + +用户可在启动参数中不配置`ima_policy`参数,代表系统启动阶段无默认策略,IMA评估机制等待用户导入策略后生效启用。 + +**步骤1:** 配置启动参数,典型的配置如下: + +``` +# 基于摘要列表的IMA评估log/enforce模式,只保护文件内容,无默认策略 +ima_appraise=log ima_appraise_digest_list=digest-nometadata initramtmpfs +ima_appraise=enforce ima_appraise_digest_list=digest-nometadata initramtmpfs +# 基于摘要列表的IMA评估log/enforce模式,保护文件内容和扩展属性,无默认策略 +ima_appraise=log-evm ima_appraise_digest_list=digest initramtmpfs evm=x509 evm=complete +ima_appraise=enforce-evm ima_appraise_digest_list=digest initramtmpfs evm=x509 evm=complete +``` + +重启系统,此时由于系统无策略,IMA评估并不生效。 + +**步骤2:** 导入IMA策略,将策略文件的全路径写入内核接口: + +``` +echo /path/to/policy > /sys/kernel/security/ima/policy +``` + +> ![](./public_sys-resources/icon-note.gif) **说明:** +> +> 策略中需要包含一些固定规则,用户可参考如下策略模板: +> +> openEuler 22.03 LTS版本的策略模板如下(复用RPM签名场景): +> +``` +# 不评估securityfs文件系统的访问行为 +dont_appraise fsmagic=0x73636673 +# 其他用户自定义的dont_appraise规则 +...... +# 评估导入的IMA摘要列表文件 +appraise func=DIGEST_LIST_CHECK appraise_type=imasig +# 评估/usr/libexec/rpm_parser进程打开的所有文件 +appraise parser appraise_type=imasig +# 评估执行的应用程序(触发对/usr/libexec/rpm_parser执行的评估,也可以新增其他限制条件,如SELinux标签等) +appraise func=BPRM_CHECK appraise_type=imasig +# 其他用户自定义的appraise规则 +...... +``` +> +> openEuler 24.03 LTS版本的策略模板如下(IMA扩展属性签名或追加签名场景): +> +``` +# 用户自定义的dont_appraise规则 +...... +# 评估导入的IMA摘要列表文件 +appraise func=DIGEST_LIST_CHECK appraise_type=imasig|modsig +# 其他用户自定义的appraise规则 +...... +``` + +**步骤3:** 导入IMA摘要列表文件,对于不同签名方式的摘要列表,需要使用不同的导入方式。 + +openEuler 22.03 LTS的摘要列表导入方式如下(复用RPM签名的IMA摘要列表): + +``` +# 导入digest_list_tools软件包的摘要列表 +echo /etc/ima/digest_lists/0-metadata_list-compact-digest-list-tools-0.3.95-13.x86_64 > /sys/kernel/security/ima/digest_list_data +echo /etc/ima/digest_lists/0-parser_list-compact-libexec > /sys/kernel/security/ima/digest_list_data +# 导入其他的RPM摘要列表 +upload_digest_lists add /etc/ima/digest_lists +# 检查导入的摘要列表条数 +cat /sys/kernel/security/ima/digests_count +``` + +openEuler 24.03 LTS的摘要列表导入方式如下(追加签名的IMA摘要列表): + +``` +find /etc/ima/digest_lists -name "0-metadata_list-compact-*" -exec echo {} > /sys/kernel/security/ima/digest_list_data \; +``` + +##### 软件升级场景 + +开启IMA摘要列表功能后,对于覆盖在IMA保护范围内的文件,在升级更新场景需要同步更新摘要列表。对于openEuler发布的RPM包,在包安装、升级、卸载的同时,将自动完成RPM包中的摘要列表的添加、更新和删除,不需要用户手动操作。对于用户维护的非RPM格式的软件包,则需要手动完成摘要列表的导入。 + +##### 用户证书导入 + +用户可以通过导入自定义证书,从而针对非openEuler发布的软件进行度量或评估。openEuler IMA评估模式支持从如下两种密钥环中获取证书进行签名校验: + +- builtin_trusted_keys密钥环:内核编译时预置的根证书; +- ima密钥环:通过initrd中的/etc/keys/x509_ima.der导入,需要为builtin_trusted_keys密钥环中任意一本证书的子证书。 + +**将根证书导入builtin_trusted_keys密钥环的步骤如下:** + +**步骤1:** 生成根证书,以openssl命令为例: + +``` +echo 'subjectKeyIdentifier=hash' > root.cfg +openssl genrsa -out root.key 4096 +openssl req -new -sha256 -key root.key -out root.csr -subj "/C=AA/ST=BB/O=CC/OU=DD/CN=openeuler test ca" +openssl x509 -req -days 3650 -extfile root.cfg -signkey root.key -in root.csr -out root.crt +openssl x509 -in root.crt -out root.der -outform DER +``` + +**步骤2:** 获取openEuler kernel源码,以最新的OLK-5.10分支为例: + +``` +git clone https://gitee.com/openeuler/kernel.git -b OLK-5.10 +``` + +**步骤3:** 进入源码目录,并将根证书拷贝至目录下: + +``` +cd kernel +cp /path/to/root.der . +``` + +修改config文件的CONFIG_SYSTEM_TRUSTED_KEYS选项: + +``` +CONFIG_SYSTEM_TRUSTED_KEYS="./root.crt" +``` + +**步骤4:** 编译安装内核(步骤略,注意需要为内核模块生成摘要列表)。 + +**步骤5:** 重启后检查证书导入成功: + +``` +keyctl show %:.builtin_trusted_keys +``` + +**将子证书导入ima密钥环的步骤如下,注意需要提前将根证书导入builtin_trusted_keys密钥环:** + +**步骤1:** 基于根证书生成子证书,以openssl命令为例: + +``` +echo 'subjectKeyIdentifier=hash' > ima.cfg +echo 'authorityKeyIdentifier=keyid,issuer' >> ima.cfg +echo 'keyUsage=digitalSignature' >> ima.cfg +openssl genrsa -out ima.key 4096 +openssl req -new -sha256 -key ima.key -out ima.csr -subj "/C=AA/ST=BB/O=CC/OU=DD/CN=openeuler test ima" +openssl x509 -req -sha256 -CAcreateserial -CA root.crt -CAkey root.key -extfile ima.cfg -in ima.csr -out ima.crt +openssl x509 -outform DER -in ima.crt -out x509_ima.der +``` + +**步骤2:** 将IMA证书拷贝到/etc/keys目录下: + +``` +mkdir -p /etc/keys/ +cp x509_ima.der /etc/keys/ +``` + +**步骤3:** 打包initrd,将IMA证书和摘要列表置入initrd镜像中: + +``` +echo 'install_items+=" /etc/keys/x509_ima.der "' >> /etc/dracut.conf +dracut -f -e xattr +``` + +**步骤4:** 重启后检查证书导入成功: + +``` +keyctl show %:.ima +``` + +#### 典型使用场景 + +根据运行模式的不同,IMA摘要列表可应用于可信度量场景和用户态安全启动场景。 + +##### 可信度量场景 + +可信度量场景主要基于IMA摘要列表度量模式,由内核+硬件可信根(如TPM)共同完成对关键文件的度量,再结合远程证明工具链完成对当前系统的文件可信状态的证明: + +![](./figures/ima_trusted_measurement.png) + +**运行阶段** + +- 软件包部署时同步导入摘要列表,IMA对摘要列表进行度量并记录度量日志(同步扩展TPM); + +- 应用程序执行时触发IMA度量,若文件摘要值匹配白名单则忽略,否则记录度量日志(同步扩展TPM) 。 + +**证明阶段(业界通用流程)** + +- 远程证明服务器下发证明请求,客户端回传IMA度量日志以及经过签名的TPM PCR值; + +- 远程证明服务器依次校验PCR(校验签名)、度量日志(PCR回放)、文件度量信息(比对本地基准值)的正确性,上报结果至安全中心; + +- 安全管理中心采取对应操作,如事件通知、节点隔离等。 + +##### 用户态安全启动场景 + +用户态安全启动场景主要基于IMA摘要列表评估模式,与安全启动类似,旨在对执行的应用程序或访问的关键文件执行完整性校验,如果校验失败,则拒绝访问: + +![](./figures/ima_secure_boot.png) + +**运行阶段** + +- 应用部署时导入摘要列表,内核验签通过后,加载摘要值到内核哈希表中作为白名单; +- 应用程序执行时触发IMA校验,计算文件hash值,若与基线值一致,则允许访问,否则记录日志或拒绝访问 。 + +## 附录 + +### 内核编译选项说明 + +原生IMA/EVM提供的编译选项及说明如下: + +| 编译选项 | 功能 | +| :------------------------------- | :------------------------ | +| CONFIG_INTEGRITY | IMA/EVM 总编译开关 | +| CONFIG_INTEGRITY_SIGNATURE | 使能IMA签名校验 | +| CONFIG_INTEGRITY_ASYMMETRIC_KEYS | 使能IMA非对称签名校验 | +| CONFIG_INTEGRITY_TRUSTED_KEYRING | 使能 IMA/EVM 密钥环 | +| CONFIG_INTEGRITY_AUDIT | 编译 IMA audit 审计模块 | +| CONFIG_IMA | IMA 总编译开关 | +| CONFIG_IMA_WRITE_POLICY | 允许在运行阶段更新IMA策略 | +| CONFIG_IMA_MEASURE_PCR_IDX | 允许指定IMA度量 PCR 序号 | +| CONFIG_IMA_LSM_RULES | 允许配置 LSM 规则 | +| CONFIG_IMA_APPRAISE | IMA 评估总编译开关 | +| IMA_APPRAISE_BOOTPARAM | 启用IMA评估启动参数 | +| CONFIG_EVM | EVM 总编译开关 | + +openEuler IMA摘要列表特性提供的编译选项及说明如下(openEuler内核编译默认开启): + +| 编译选项 | 功能 | +| :----------------- | :---------------------- | +| CONFIG_DIGEST_LIST | 开启IMA摘要列表特性开关 | + +### IMA摘要列表根证书说明 + +openEuler 22.03版本使用RPM密钥对IMA摘要列表进行签名,为保证IMA功能开箱可用,openEuler内核编译时默认将RPM根证书(PGP证书)导入内核。当前包含旧版本使用的OBS证书和openEuler 22.03 LTS SP1版本切换的openEuler证书: + +```shell +# cat /proc/keys | grep PGP +1909b4ad I------ 1 perm 1f030000 0 0 asymmetri private OBS b25e7f66: PGP.rsa b25e7f66 [] +2f10cd36 I------ 1 perm 1f030000 0 0 asymmetri openeuler fb37bc6f: PGP.rsa fb37bc6f [] +``` + +由于当前内核不支持导入PGP子公钥,而切换后的openEuler证书采用子密钥签名,因此openEuler内核编译前对证书进行了预处理,抽取子公钥并导入内核,具体处理流程可见内核软件包代码仓内的process_pgp_certs.sh脚本文件: + +openEuler 24.03及之后的版本支持IMA专用证书,详见[证书签名](../CertSignature/签名证书介绍.md)文档相关章节。 + +如果用户不使用IMA摘要列表功能或使用其他密钥实现签名/验签,则可将相关代码移除,自行实现内核根证书配置。 diff --git "a/docs/zh/docs/Administration/\345\212\250\346\200\201\345\256\214\346\225\264\346\200\247\345\272\246\351\207\217\357\274\210DIM\357\274\211.md" "b/docs/zh/docs/Administration/\345\212\250\346\200\201\345\256\214\346\225\264\346\200\247\345\272\246\351\207\217\357\274\210DIM\357\274\211.md" new file mode 100644 index 0000000000000000000000000000000000000000..69fe61f71cbe09520a193652e91c91c28d4aeb01 --- /dev/null +++ "b/docs/zh/docs/Administration/\345\212\250\346\200\201\345\256\214\346\225\264\346\200\247\345\272\246\351\207\217\357\274\210DIM\357\274\211.md" @@ -0,0 +1,732 @@ +# 动态完整性度量(DIM) + +本章节为DIM(Dynamic Integrity Measurement)动态完整性度量的特性介绍以及使用说明。 + +## 背景 + +随着信息产业的不断发展,信息系统所面临的安全风险也日益增长。信息系统中可能运行大量软件,部分软件不可避免地存在漏洞,这些漏洞一旦被攻击者利用,可能会对系统业务造成严重的影响,如数据泄露、服务不可用等。 + +绝大部分的软件攻击,都会伴随着完整性破坏,如恶意进程运行、配置文件篡改、后门植入等。因此业界提出了完整性保护技术,指的是从系统启动开始,对关键数据进行度量和校验,从而保证系统运行达到预期效果。当前业界已广泛使用的完整性保护技术(如安全启动、文件完整性度量等)都无法对进程运行时的内存数据进行保护。如果攻击者利用一些手段修改了进程的代码指令,可能导致进程被劫持或被植入后门,具有攻击性强,隐蔽性高的特点。对于这种攻击手段,业界提出了动态完整性度量技术,即对进程的运行时内存中的关键数据进行度量和保护。 + +## 术语说明 + +静态基线:针对度量目标的二进制文件进行解析所生成的度量基准数据; + +动态基线:针对度量目标执行首次度量的结果; + +度量策略:指定度量目标的配置信息; + +度量日志:存储度量结果的列表,包含度量对象、度量结果等信息。 + +## 特性简介 + +DIM特性通过在程序运行时对内存中的关键数据(如代码段、数据段)进行度量,并将度量结果和基准值进行对比,确定内存数据是否被篡改,从而检测攻击行为,并采取应对措施。 + +### 功能范围 + +- 当前DIM特性支持在ARM64/X86架构系统中运行; +- 当前DIM特性支持对以下关键内存数据执行度量: + - 用户态进程的代码段:对应ELF文件中属性为PT_LOAD、权限为RX的段,对应进程加载后权限为RX的vma区域; + - 内核模块代码段:起始地址为内核模块对应struct module结构体中的core_layout.base,长度为core_layout.text_size; + - 内核代码段:对应\_stext符号至\_etext,跳过可能由于内核static key机制发生变化的地址。 +- 当前DIM特性支持对接以下硬件平台: + - 支持将度量结果扩展至TPM 2.0芯片的PCR寄存器,以实现远程证明服务对接。 + +### 技术限制 + +- 对于用户态进程,仅支持度量文件映射代码段,不支持度量匿名代码段; +- 不支持度量内核热补丁; +- 仅支持主动触发机制,如果两次触发过程中发生了篡改-恢复的行为,会导致无法识别攻击; +- 对于主动修改代码段的场景(如代码段重定位、自修改或热补丁),会被识别为攻击; +- 对于内核、内核模块的度量,以触发动态基线时的度量结果作为度量基准值,静态基线值仅作为一个固定标识; +- 度量目标必须在触发动态基线的时刻就已在内存中加载(如进程运行或内核模块加载),否则后续无法度量; +- 在需要使用TPM芯片的PCR寄存器验证度量日志的场景下,DIM模块不允许卸载,否则会导致度量日志清空,而无法和PCR寄存器匹配; +>![](./public_sys-resources/icon-note.gif) **说明:** +> +>特性启用后,会对系统性能存在一定影响,主要包括以下方面: +> - DIM特性自身加载以及基线数据、度量日志管理会对系统内存造成消耗,具体影响与保护策略配置相关; +> - DIM特性执行度量期间需要进行哈希运算,造成CPU消耗,具体影响与需要度量的数据大小有关; +> - DIM特性执行度量期间需要对部分资源执行上锁或获取信号量操作,可能导致其他并发进程等待。 + +### 规格约束 + +| 规格项 | 值 | +| ------------------------------------------------------------ | ---- | +| 文件大小上限(策略文件、静态基线文件、签名文件、证书文件) | 10MB | +| 同一个度量目标在一次动态基线后多次度量期间最多记录的篡改度量日志条数 | 10条 | +| /etc/dim/policy中度量策略最大可记录数|10000条| + +### 架构说明 + +DIM包含两个软件包dim_tools和dim,分别提供如下组件: + +| 软件包 | 组件 | 说明 | +| --------- | ---------------- | ------------------------------------------------------------ | +| dim_tools | dim_gen_baseline | 用户态组件,静态基线生成工具,用于生成动态度量所需要的基线数据,该基线数据在DIM特性运行时会被导入并作为度量基准值 | +| dim | dim_core | 内核模块,执行核心的动态度量逻辑,包括策略解析、静态基线解析、动态基线建立、度量执行、度量日志记录、TPM芯片扩展操作等,实现对内存关键数据的度量功能 | +| dim | dim_monitor | 内核模块,执行对dim_core的代码段和关键数据的度量保护,一定程度防止由于dim_core遭受攻击导致的DIM功能失效。 | + +整体架构如下图所示: + +![](./figures/dim_architecture.jpg) + +### 关键流程说明 + +dim_core和dim_monitor模块均提供了对内存数据的度量功能,包含两个核心流程: + +- 动态基线流程:dim_core模块读取并解析策略和静态基线文件,然后对目标进程执行代码段度量,度量结果在内存中以动态基线形式存放,最后将动态基线数据和静态基线数据进行对比,并将对比结果记录度量日志;dim_monitor模块对dim_core模块的代码段和关键数据进行度量,作为动态基线并记录度量日志; +- 动态度量流程:dim_core和dim_monitor模块对目标执行度量,并将度量结果与动态基线值进行对比,如果对比不一致,则将结果记录度量日志。 + +### 接口说明 + +#### 文件路径说明 + +| 路径 | 说明 | +| ------------------------------- | ------------------------------------------------------------ | +| /etc/dim/policy | 度量策略文件 | +| /etc/dim/policy.sig | 度量策略签名文件,用于存放策略文件的签名信息,在签名校验功能开启的情况下使用 | +| /etc/dim/digest_list/*.hash | 静态基线文件,用于存放度量的基准值信息 | +| /etc/dim/digest_list/*.hash.sig | 静态基线签名文件,用于存放静态基线文件的签名信息,在签名校验功能开启的情况下使用 | +| /etc/keys/x509_dim.der | 证书文件,用于校验策略文件和静态基线文件的签名信息,在签名校验功能开启的情况下使用 | +| /sys/kernel/security/dim | DIM文件系统目录,DIM内核模块加载后生成,目录下提供对DIM功能进行操作的内核接口 | + +#### 文件格式说明 + +1. 度量策略文件格式说明 + + 文本文件,以UNIX换行符进行分隔,每行代表一条度量策略,当前支持以下几种配置格式: + + 1. 用户态进程代码段度量配置: + + ``` + measure obj=BPRM_TEXT path=<度量目标进程可执行文件或动态库对应二进制文件的绝对路径> + ``` + + 2. 内核模块代码段度量配置: + + ``` + measure obj=MODULE_TEXT name=<内核模块名> + ``` + + 3. 内核度量配置: + + ``` + measure obj=KERNEL_TEXT + ``` + +**参考示例:** + +``` +# cat /etc/dim/policy +measure obj=BPRM_TEXT path=/usr/bin/bash +measure obj=BPRM_TEXT path=/usr/lib64/libc.so.6 +measure obj=MODULE_TEXT name=ext4 +measure obj=KERNEL_TEXT +``` + +2. 静态基线文件格式说明 + + 文本文件,以UNIX换行符进行分隔,每行代表一条静态基线,当前支持以下几种配置格式: + + 1. 用户态进程基线: + + ``` + dim USER sha256:6ae347be2d1ba03bf71d33c888a5c1b95262597fbc8d00ae484040408a605d2b <度量目标进程可执行文件或动态库对应二进制文件的绝对路径> + ``` + + 2. 内核模块基线: + + ``` + dim KERNEL sha256:a18bb578ff0b6043ec5c2b9b4f1c5fa6a70d05f8310a663ba40bb6e898007ac5 <内核release号>/<内核模块名> + ``` + + 3. 内核基线: + + ``` + dim KERNEL sha256:2ce2bc5d65e112ba691c6ab46d622fac1b7dbe45b77106631120dcc5441a3b9a <内核release号> + ``` + +**参考示例:** + +``` +dim USER sha256:6ae347be2d1ba03bf71d33c888a5c1b95262597fbc8d00ae484040408a605d2b /usr/bin/bash +dim USER sha256:bc937f83dee4018f56cc823f5dafd0dfedc7b9872aa4568dc6fbe404594dc4d0 /usr/lib64/libc.so.6 +dim KERNEL sha256:a18bb578ff0b6043ec5c2b9b4f1c5fa6a70d05f8310a663ba40bb6e898007ac5 6.4.0-1.0.1.4.oe2309.x86_64/dim_monitor +dim KERNEL sha256:2ce2bc5d65e112ba691c6ab46d622fac1b7dbe45b77106631120dcc5441a3b9a 6.4.0-1.0.1.4.oe2309.x86_64 +``` + +3. 度量日志格式说明 + + 文本内容,以UNIX换行符进行分隔,每行代表一条度量日志,格式为: + +``` + <度量日志哈希值> <度量算法>:<度量哈希值> <度量对象> <度量日志类型> +``` + +**参考示例:** + + 1. 对bash进程代码段执行度量,度量结果与静态基线一致: + + ``` + 12 0f384a6d24e121daf06532f808df624d5ffc061e20166976e89a7bb24158eb87 sha256:db032449f9e20ba37e0ec4a506d664f24f496bce95f2ed972419397951a3792e /usr/bin.bash [static baseline] + ``` + + 2. 对bash进程代码段执行度量,度量结果与静态基线不一致: + + ``` + 12 0f384a6d24e121daf06532f808df624d5ffc061e20166976e89a7bb24158eb87 sha256:db032449f9e20ba37e0ec4a506d664f24f496bce95f2ed972419397951a3792e /usr/bin.bash [tampered] + ``` + + 3. 对ext4内核模块代码段执行度量,未找到静态基线: + + ``` + 12 0f384a6d24e121daf06532f808df624d5ffc061e20166976e89a7bb24158eb87 sha256:db032449f9e20ba37e0ec4a506d664f24f496bce95f2ed972419397951a3792e ext4 [no static baseline] + ``` + + 4. dim_monitor对dim_core执行度量,记录基线时的度量结果: + + ``` + 12 660d594ba050c3ec9a7cdc8cf226c5213c1e6eec50ba3ff51ff76e4273b3335a sha256:bdab94a05cc9f3ad36d29ebbd14aba8f6fd87c22ae580670d18154b684de366c dim_core.text [dynamic baseline] + 12 28a3cefc364c46caffca71e7c88d42cf3735516dec32796e4883edcf1241a7ea sha256:0dfd9656d6ecdadc8ec054a66e9ff0c746d946d67d932cd1cdb69780ccad6fb2 dim_core.data [dynamic baseline] + ``` + +4. 证书/签名文件格式说明 + +为通用格式,详见[开启签名校验](#开启签名校验)章节。 + +#### 内核模块参数说明 + +1. dim_core模块参数 + +| 参数名 | 参数内容 | 取值范围 | 默认值 | +| -------------------- | ------------------------------------------------------------ | ------------------------ | ------ | +| measure_log_capacity | 度量日志最大条数,当dim_core记录的度量日志数量达到参数设置时,停止记录度量日志 | 100-UINT_MAX(64位系统) | 100000 | +| measure_schedule | 度量完一个进程/模块后调度的时间,单位毫秒,设置为0代表不调度 | 0-1000 | 0 | +| measure_interval | 自动度量周期,单位分钟,设置为0代表不设置自动度量 | 0-525600 | 0 | +| measure_hash | 度量哈希算法 | sha256, sm3 | sha256 | +| measure_pcr | 将度量结果扩展至TPM芯片的PCR寄存器,设置为0代表不扩展(注意需要与芯片实际的PCR编号保持一致) | 0-128 | 0 | +| signature | 是否启用策略文件和签名机制,设置为0代表不启用,设置为1代表启用 | 0, 1 | 0 | + +**使用示例**: + +``` +insmod /path/to/dim_core.ko measure_log_capacity=10000 measure_schedule=10 measure_pcr=12 +modprobe dim_core measure_log_capacity=10000 measure_schedule=10 measure_pcr=12 +``` + +2. dim_monitor模块参数 + +| 参数名 | 参数内容 | 取值范围 | 默认值 | +| -------------------- | ------------------------------------------------------------ | ------------------------ | ------ | +| measure_log_capacity | 度量日志最大条数,当dim_monitor记录的度量日志数量达到参数设置时,停止记录度量日志 | 100-UINT_MAX(64位系统) | 100000 | +| measure_hash | 度量哈希算法 | sha256, sm3 | sha256 | +| measure_pcr | 将度量结果扩展至TPM芯片的PCR寄存器,设置为0代表不扩展 | 0-128 | 0 | + +**使用示例**: + +``` +insmod /path/to/dim_monitor.ko measure_log_capacity=10000 measure_hash=sm3 +modprobe dim_monitor measure_log_capacity=10000 measure_hash=sm3 +``` + +#### 内核接口说明 + +1. dim_core模块接口 + +| 接口名 | 属性 | 功能 | 示例 | +| -------------------------- | ---- | ------------------------------------------------------------ | --------------------------------------------------------- | +| measure | 只写 | 写入字符串1触发动态度量,成功返回0,失败返回错误码 | echo 1 > /sys/kernel/security/dim/measure | +| baseline_init | 只写 | 写入字符串1触发动态基线,成功返回0,失败返回错误码 | echo 1 > /sys/kernel/security/dim/baseline_init | +| ascii_runtime_measurements | 只读 | 读取接口查询度量日志 | cat /sys/kernel/security/dim/ascii_runtime_measurements | +| runtime_status | 只读 | 读取接口返回状态类型信息,失败返回错误码 | cat /sys/kernel/security/dim/runtime_status | +| interval | 读写 | 写入数字字符串设置自动度量周期(范围同measure_interval参数);读取接口查询当前自动度量周期,失败返回错误码 | echo 10 > /sys/kernel/security/dim/interval
cat /sys/kernel/security/dim/interval | + +**dim_core状态类型信息说明:** + +状态信息以如下字段取值: + +- DIM_NO_BASELINE:表示dim_core已加载,但未进行任何操作; +- DIM_BASELINE_RUNNING:表示正在进行动态基线建立; +- DIM_MEASURE_RUNNING:表示正在进行动态度量度量; +- DIM_PROTECTED:表示已完成动态基线建立,处于受保护状态; +- DIM_ERROR:执行动态基线建立或动态度量时发生错误,需要用户解决错误后重新触发动态基线建立或动态度量。 + +2. dim_monitor模块接口 + +| 接口名 | 属性 | 说明 | 示例 | +| ---------------------------------- | ---- | ---------------------------------------------- | ------------------------------------------------------------ | +| monitor_run | 只写 | 写入字符串1触发度量,成功返回0,失败返回错误码 | echo 1 > /sys/kernel/security/dim/monitor_run | +| monitor_baseline | 只写 | 写入字符串1触发基线,成功返回0,失败返回错误码 | echo 1 > /sys/kernel/security/dim/monitor_baseline | +| monitor_ascii_runtime_measurements | 只读 | 读取接口查询度量日志 | cat /sys/kernel/security/dim/monitor_ascii_runtime_measurements | +| monitor_status | 只读 | 读取接口返回状态类型信息,失败返回错误码 | cat /sys/kernel/security/dim/monitor_status | + +**dim_monitor状态类型信息说明:** + +- ready:表示dim_monitior已加载,但未进行任何操作; +- running:表示正在进行动态基线建立或动态度量; +- error:执行动态基线建立或动态度量时发生错误,需要用户解决错误后重新触发动态基线建立或动态度量; +- protected:表示已完成动态基线建立,处于受保护状态。 + +#### 用户态工具接口说明 + +dim_gen_baseline命令行接口,详见: 。 + +## 如何使用 + +### 安装/卸载 + +**前置条件**: + +- OS版本:支持openEuler 23.09及以上版本; +- 内核版本:支持openEuler kernel 5.10/6.4版本。 + +安装dim_tools和dim软件包,以openEuler 23.09版本为例: + +``` +# yum install -y dim_tools dim +``` + +软件包安装完成后,DIM内核组件不会默认加载,可通过如下命令进行加载和卸载: + +``` +# modprobe dim_core 或 insmod /path/to/dim_core.ko +# modprobe dim_monitor 或 insmod /path/to/dim_monitor.ko +# rmmod dim_monitor +# rmmod dim_core +``` + +加载成功后,可以通过如下命令查询: + +``` +# lsmod | grep dim_core +dim_core 77824 1 dim_monitor +# lsmod | grep dim_monitor +dim_monitor 36864 0 +``` + +卸载前需要先卸载ko,再卸载rpm包 + +``` +# rmmod dim_monitor +# rmmod dim_core +# rpm -e dim +``` + +>![](./public_sys-resources/icon-note.gif) **说明:** +> +> dim_monitor必须后于dim_core加载,先于dim_core卸载; +> 也可使用源码编译安装,详见 。 + +### 度量用户态进程代码段 + +**前置条件**: + +- dim_core模块加载成功; + +- 用户需要准备一个常驻的度量目标用户态程序,本小节以程序路径/opt/dim/demo/dim_test_demo为例: + + ``` + # /opt/dim/demo/dim_test_demo & + ``` + +**步骤1**:为度量目标进程对应的二进制文件生成静态基线 + +``` +# mkdir -p /etc/dim/digest_list +# dim_gen_baseline /opt/dim/demo/dim_test_demo -o /etc/dim/digest_list/test.hash +``` + +**步骤2**:配置度量策略 + +``` +# echo "measure obj=BPRM_TEXT path=/opt/dim/demo/dim_test_demo" > /etc/dim/policy +``` + +**步骤3**:触发动态基线建立 + +``` +# echo 1 > /sys/kernel/security/dim/baseline_init +``` + +**步骤4**:查询度量日志 + +``` +# cat /sys/kernel/security/dim/ascii_runtime_measurements +0 e9a79e25f091e03a8b3972b1a0e4ae2ccaed1f5652857fe3b4dc947801a6913e sha256:02e28dff9997e1d81fb806ee5b784fd853eac8812059c4dba7c119c5e5076989 /opt/dim/demo/dim_test_demo [static baseline] +``` + +如上度量日志说明目标进程被成功度量,且度量结果与静态基线一致。 + +**步骤5**:触发动态度量 + +``` +# echo 1 > /sys/kernel/security/dim/measure +``` + +度量完成后可通过**步骤4**查询度量日志,如果度量结果和动态基线阶段的度量结果一致,则度量日志不会更新,否则会新增异常度量日志。如果攻击者尝试篡改目标程序(如采用修改代码重新编译的方式,过程略)并重新启动目标程序: + +``` +# pkill dim_test_demo +# /opt/dim/demo/dim_test_demo & +``` + +再次触发度量并查询度量日志,可以发现有标识为“tampered”的度量日志: + +``` +# echo 1 > /sys/kernel/security/dim/measure +# cat /sys/kernel/security/dim/ascii_runtime_measurements +0 e9a79e25f091e03a8b3972b1a0e4ae2ccaed1f5652857fe3b4dc947801a6913e sha256:02e28dff9997e1d81fb806ee5b784fd853eac8812059c4dba7c119c5e5076989 /opt/dim/demo/dim_test_demo [static baseline] +0 08a2f6f2922ad3d1cf376ae05cf0cc507c2f5a1c605adf445506bc84826531d6 sha256:855ec9a890ff22034f7e13b78c2089e28e8d217491665b39203b50ab47b111c8 /opt/dim/demo/dim_test_demo [tampered] +``` + +### 度量内核模块代码段 + +**前置条件**: + +- dim_core模块加载成功; + +- 用户需要准备一个度量目标内核模块,本小节假设内核模块路径为/opt/dim/demo/dim_test_module.ko,模块名为dim_test_module: + + ``` + # insmod /opt/dim/demo/dim_test_module.ko + ``` + +>![](./public_sys-resources/icon-note.gif) **说明:** +> +>需要保证内核模块的内核编译环境版本号和当前系统内核版本号一致,可以使用如下方法确认: +> +>``` +># modinfo dim_monitor.ko | grep vermagic | grep "$(uname -r)" +>vermagic: 6.4.0-1.0.1.4.oe2309.x86_64 SMP preempt mod_unload modversions +>``` + +即内核模块vermagic信息的第一个字段需要和当前内核版本号完全一致。 + +**步骤1**:为度量目标内核模块生成静态基线 + +``` +# mkdir -p /etc/dim/digest_list +# dim_gen_baseline /opt/dim/demo/dim_test_module.ko -o /etc/dim/digest_list/test.hash +``` + +**步骤2**:配置度量策略 + +``` +# echo "measure obj=MODULE_TEXT name=dim_test_module" > /etc/dim/policy +``` + +**步骤3**:触发动态基线建立 + +``` +# echo 1 > /sys/kernel/security/dim/baseline_init +``` + +**步骤4**:查询度量日志 + +``` +# cat /sys/kernel/security/dim/ascii_runtime_measurements +0 9603a9d5f87851c8eb7d2619f7abbe28cb8a91f9c83f5ea59f036794e23d1558 sha256:9da4bccc7ae1b709deab8f583b244822d52f3552c93f70534932ae21fac931c6 dim_test_module [static baseline] +``` + +如上度量日志说明dim_test_module模块被成功度量,并以当前的度量结果作为后续度量的基准值(此时度量日志中的哈希值不代表实际度量值)。 + +**步骤5**:触发动态度量 + +``` +echo 1 > /sys/kernel/security/dim/measure +``` + +度量完成后可通过**步骤4**查询度量日志,如果度量结果和动态基线阶段的度量结果一致,则度量日志不会更新,否则会新增异常度量日志。如果攻击者尝试篡改内核模块(如采用修改代码重新编译的方式,过程略)并重新加载: + +``` +rmmod dim_test_module +insmod /opt/dim/demo/dim_test_module.ko +``` + +再次触发度量并查询度量日志,可以发现有标识为“tampered”的度量日志: + +``` +# cat /sys/kernel/security/dim/ascii_runtime_measurements +0 9603a9d5f87851c8eb7d2619f7abbe28cb8a91f9c83f5ea59f036794e23d1558 sha256:9da4bccc7ae1b709deab8f583b244822d52f3552c93f70534932ae21fac931c6 dim_test_module [static baseline] +0 6205915fe63a7042788c919d4f0ff04cc5170647d7053a1fe67f6c0943cd1f40 sha256:4cb77370787323140cb572a789703be1a4168359716a01bf745aa05de68a14e3 dim_test_module [tampered] +``` + +### 度量内核代码段 + +**前置条件**: + +- dim_core模块加载成功。 + +**步骤1**:为内核生成静态基线 + +``` +# mkdir -p /etc/dim/digest_list +# dim_gen_baseline -k "$(uname -r)" -o /etc/dim/digest_list/test.hash /boot/vmlinuz-6.4.0-1.0.1.4.oe2309.x86_64 +``` + +>![](./public_sys-resources/icon-note.gif) **说明:** +> +>/boot/vmlinuz-6.4.0-1.0.1.4.oe2309.x86_64文件名不固定。 + +**步骤2**:配置DIM策略 + +``` +# echo "measure obj=KERNEL_TEXT" > /etc/dim/policy +``` + +**步骤3**:触发动态基线建立 + +``` +# echo 1 > /sys/kernel/security/dim/baseline_init +``` + +**步骤4**:查询度量日志 + +``` +# cat /sys/kernel/security/dim/ascii_runtime_measurements +0 ef82c39d767dece1f5c52b31d1e8c7d55541bae68a97542dda61b0c0c01af4d2 sha256:5f1586e95b102cd9b9f7df3585fe13a1306cbd464f2ebe47a51ad34128f5d0af 6.4.0-1.0.1.4.oe2309.x86_64 [static baseline] +``` + +如上度量日志说明内核被成功度量,并以当前的基线结果作为后续度量的基准值(此时度量日志中的哈希值不代表实际度量值)。 + +**步骤5**:触发动态度量 + +``` +# echo 1 > /sys/kernel/security/dim/measure +``` + +度量完成后可通过**步骤4**查询度量日志,如果度量结果和动态基线阶段的度量结果一致,则度量日志不会更新,否则会新增异常度量日志。 + +### 度量dim_core模块 + +**前置条件**: + +- dim_core和dim_monitor模块加载成功; +- 度量策略配置完成。 + +**步骤1**:触发dim_core动态基线 + +``` +# echo 1 > /sys/kernel/security/dim/baseline_init +``` + +**步骤2**:触发dim_monitor动态基线 + +``` +# echo 1 > /sys/kernel/security/dim/monitor_baseline +``` + +**步骤3**:查询dim_monitor度量日志 + +``` +# cat /sys/kernel/security/dim/monitor_ascii_runtime_measurements +0 c1b0d9909ddb00633fc6bbe7e457b46b57e165166b8422e81014bdd3e6862899 sha256:35494ed41109ebc9bf9bf7b1c190b7e890e2f7ce62ca1920397cd2c02a057796 dim_core.text [dynamic baseline] +0 9be7121cd2c215d454db2a8aead36b03d2ed94fad0fbaacfbca83d57a410674f sha256:f35d20aae19ada5e633d2fde6e93133c3b6ae9f494ef354ebe5b162398e4d7fa dim_core.data [dynamic baseline] +``` + +如上度量日志说明dim_core模块被成功度量,并以当前的基线结果作为后续度量的基准值。 +>![](./public_sys-resources/icon-note.gif) **说明:** +> +>若跳过动态基线创建,直接进行度量,日志中会显示tampered。 + +**步骤4**:触发dim_monitor动态度量 + +``` +# echo 1 > /sys/kernel/security/dim/monitor_run +``` + +如果度量结果和动态基线阶段的度量结果一致,则度量日志不会更新,否则会新增异常度量日志。尝试修改策略后重新执触发dim_core动态基线,此时由于度量目标发生变化,dim_core管理的基线数据也会发生变更,从而dim_monitor的度量结果也会发生变化: + +``` +# echo "measure obj=BPRM_TEXT path=/usr/bin/bash" > /etc/dim/policy +# echo 1 > /sys/kernel/security/dim/baseline_init +``` + +再次触发dim_monitor度量并查询度量日志,可以发现有标识为“tampered”的度量日志: + +``` +# echo 1 > /sys/kernel/security/dim/monitor_run +# cat /sys/kernel/security/dim/monitor_ascii_runtime_measurements +0 c1b0d9909ddb00633fc6bbe7e457b46b57e165166b8422e81014bdd3e6862899 sha256:35494ed41109ebc9bf9bf7b1c190b7e890e2f7ce62ca1920397cd2c02a057796 dim_core.text [dynamic baseline] +0 9be7121cd2c215d454db2a8aead36b03d2ed94fad0fbaacfbca83d57a410674f sha256:f35d20aae19ada5e633d2fde6e93133c3b6ae9f494ef354ebe5b162398e4d7fa dim_core.data [dynamic baseline] +0 6a60d78230954aba2e6ea6a6b20a7b803d7adb405acbb49b297c003366cfec0d sha256:449ba11b0bfc6146d4479edea2b691aa37c0c025a733e167fd97e77bbb4b9dab dim_core.data [tampered] +``` + +### 扩展TPM PCR寄存器 + +**前置条件**: + +- 系统已安装TPM 2.0芯片,执行如下命令返回不为空: + + ``` + # ls /dev/tpm* + /dev/tpm0 /dev/tpmrm0 + ``` + +- 系统已安装tpm2-tools软件包,执行如下命令返回不为空: + + ``` + # rpm -qa tpm2-tools + ``` + +- 度量策略和静态基线配置完成。 + +**步骤1**:加载dim_core和dim_monitor模块,并配置扩展度量结果的PCR寄存器编号,这里为dim_core度量结果指定PCR 12,为dim_monitor指定PCR 13 + +``` +# modprobe dim_core measure_pcr=12 +# modprobe dim_monitor measure_pcr=13 +``` + +**步骤2**:触发dim_core和dim_monitor基线 + +``` +# echo 1 > /sys/kernel/security/dim/baseline_init +# echo 1 > /sys/kernel/security/dim/monitor_baseline +``` + +**步骤3**:查看度量日志,每条日志都显示了对应的TPM PCR寄存器编号 + +``` +# cat /sys/kernel/security/dim/ascii_runtime_measurements +12 2649c414d1f9fcac1c8d0df8ae7b1c18b5ea10a162b957839bdb8f8415ec6146 sha256:83110ce600e744982d3676202576d8b94cea016a088f99617767ddbd66da1164 /usr/lib/systemd/systemd [static baseline] +# cat /sys/kernel/security/dim/monitor_ascii_runtime_measurements +13 72ee3061d5a80eb8547cd80c73a80c3a8dc3b3e9f7e5baa10f709350b3058063 sha256:5562ed25fcdf557efe8077e231399bcfbcf0160d726201ac8edf7a2ca7c55ad0 dim_core.text [dynamic baseline] +13 8ba44d557a9855c03bc243a8ba2d553347a52c1a322ea9cf8d3d1e0c8f0e2656 sha256:5279eadc235d80bf66ba652b5d0a2c7afd253ebaf1d03e6e24b87b7f7e94fa02 dim_core.data [dynamic baseline] +``` + +**步骤4**:检查TPM芯片的PCR寄存器,对应的寄存器均已被写入了扩展值 + +``` +# tpm2_pcrread sha256 | grep "12:" + 12: 0xF358AC6F815BB29D53356DA2B4578B4EE26EB9274E553689094208E444D5D9A2 +# tpm2_pcrread sha256 | grep "13:" + 13: 0xBFB9FF69493DEF9C50E52E38B332BDA8DE9C53E90FB96D14CD299E756205F8EA +``` + +### 开启签名校验 + +**前置条件**: + +- 用户准备公钥证书和签名私钥,签名算法需要为RSA,哈希算法为sha256,证书格式需要为DER。也可以采用如下方式生成: + + ``` + # openssl genrsa -out dim.key 4096 + # openssl req -new -sha256 -key dim.key -out dim.csr -subj "/C=AA/ST=BB/O=CC/OU=DD/CN=DIM Test" + # openssl x509 -req -days 3650 -signkey dim.key -in dim.csr -out dim.crt + # openssl x509 -in dim.crt -out dim.der -outform DER + ``` + +- 度量策略配置完成。 + +**步骤1**:将DER格式的证书放置在/etc/keys/x509_dim.der路径 + +``` +# mkdir -p /etc/keys +# cp dim.der /etc/keys/x509_dim.der +``` + +**步骤2**:对策略文件和静态基线文件进行签名,签名文件必须为原文件名直接添加.sig后缀 + +``` +# openssl dgst -sha256 -out /etc/dim/policy.sig -sign dim.key /etc/dim/policy +# openssl dgst -sha256 -out /etc/dim/digest_list/test.hash.sig -sign dim.key /etc/dim/digest_list/test.hash +``` + +**步骤3**:加载dim_core模块,开启签名校验功能 + +``` +modprobe dim_core signature=1 +``` + +此时,策略文件和静态基线文件均需要通过签名校验后才能加载。 +修改策略文件触发基线,会导致基线失败: + +``` +# echo "" >> /etc/dim/policy +# echo 1 > /sys/kernel/security/dim/baseline_init +-bash: echo: write error: Key was rejected by service +``` + +>![](./public_sys-resources/icon-note.gif) **说明:** +> +>如果某个静态基线文件签名校验失败,dim_core会跳过该文件的解析,而不会导致基线失败。 + +### 配置度量算法 + +**前置条件**: + +- 度量策略配置完成。 + +**步骤1**:加载dim_core和dim_monitor模块,并配置度量算法,这里以sm3算法为例 + +``` +# modprobe dim_core measure_hash=sm3 +# modprobe dim_monitor measure_hash=sm3 +``` + +**步骤2**:配置策略并为度量目标程序生成sm3算法的静态基线 + +``` +# echo "measure obj=BPRM_TEXT path=/opt/dim/demo/dim_test_demo" > /etc/dim/policy +# dim_gen_baseline -a sm3 /opt/dim/demo/dim_test_demo -o /etc/dim/digest_list/test.hash +``` + +**步骤3**:触发基线 + +``` +# echo 1 > /sys/kernel/security/dim/baseline_init +# echo 1 > /sys/kernel/security/dim/monitor_baseline +``` + +**步骤4**:查看度量日志,每条日志都显示了对应的哈希算法 + +``` +# cat /sys/kernel/security/dim/ascii_runtime_measurements +0 585a64feea8dd1ec415d4e67c33633b97abb9f88e6732c8a039064351d24eed6 sm3:ca84504c02bef360ec77f3280552c006ce387ebb09b49b316d1a0b7f43039142 /opt/dim/demo/dim_test_demo [static baseline] +# cat /sys/kernel/security/dim/monitor_ascii_runtime_measurements +0 e6a40553499d4cbf0501f32cabcad8d872416ca12855a389215b2509af76e60b sm3:47a1dae98182e9d7fa489671f20c3542e0e154d3ce941440cdd4a1e4eee8f39f dim_core.text [dynamic baseline] +0 2c862bb477b342e9ac7d4dd03b6e6705c19e0835efc15da38aafba110b41b3d1 sm3:a4d31d5f4d5f08458717b520941c2aefa0b72dc8640a33ee30c26a9dab74eae9 dim_core.data [dynamic baseline] +``` + +### 配置自动周期度量 + +**前置条件**: + +- 度量策略配置完成; + +**方式1**:加载dim_core模块,配置定时度量间隔,此处配置为1分钟 + +``` +modprobe dim_core measure_interval=1 +``` + +在模块加载完成后,自动触发动态基线流程,后续每隔1分钟触发一次动态度量。 + +>![](./public_sys-resources/icon-note.gif) **说明:** +> +>此时不能配置dim_core度量自身代码段的度量策略,否则会产生误报。 +>同时需要提前配置/etc/dim/policy,否则指定measure_interval=1加载模块会失败 + +**方式2**:加载dim_core模块后,也可通过内核模块接口配置定时度量间隔,此处配置为1分钟 + +``` +modprobe dim_core +echo 1 > /sys/kernel/security/dim/interval +``` + +此时不会立刻触发度量,1分钟后会触发动态基线或动态度量,后续每隔1分钟触发一次动态度量。 + +### 配置度量调度时间 + +**前置条件**: + +- 度量策略配置完成; + +加载dim_core模块,配置定时度量调度时间,此处配置为10毫秒: + +``` +modprobe dim_core measure_schedule=10 +``` + +触发动态基线或动态度量时,dim_core每度量一个进程,就会调度让出CPU 10毫秒时间。 \ No newline at end of file diff --git "a/docs/zh/docs/Administration/\345\217\257\344\277\241\345\271\263\345\217\260\346\216\247\345\210\266\346\250\241\345\235\227\357\274\210TPCM\357\274\211.md" "b/docs/zh/docs/Administration/\345\217\257\344\277\241\345\271\263\345\217\260\346\216\247\345\210\266\346\250\241\345\235\227\357\274\210TPCM\357\274\211.md" new file mode 100644 index 0000000000000000000000000000000000000000..2cbe00d46cf37245dd331e4bc19c1a2518fc37bb --- /dev/null +++ "b/docs/zh/docs/Administration/\345\217\257\344\277\241\345\271\263\345\217\260\346\216\247\345\210\266\346\250\241\345\235\227\357\274\210TPCM\357\274\211.md" @@ -0,0 +1,39 @@ +# 可信平台控制模块(TPCM) + +## 背景 + +可信计算在近40年的研究过程中,经历了不断的发展和完善,已经成为信息安全的一个重要分支。中国的可信计算技术近年发展迅猛,在可信计算2.0的基础上解决了可信体系与现有体系的融合问题、可信管理问题以及可信开发的简化问题,形成了基于主动免疫体系的可信计算技术--可信计算3.0。相对于可信计算2.0被动调用的外挂式体系结构,可信计算3.0提出了以自主密码为基础、控制芯片为支柱、双融主板为平台、可信软件为核心、可信连接为纽带、策略管控成体系、安全可信保应用的全新的可信体系框架,在网络层面解决可信问题。 + +可信平台控制模块(Trusted Platform Control Module,TPCM)是一种可集成在可信计算平台中,用于建立和保障信任源点的基础核心模块。它作为中国可信计算3.0中的创新点之一和主动免疫机制的核心,实现了对整个平台的主动可控。 + +TPCM可信计算3.0架构为双体系架构,分为防护部件和计算部件,以可信密码模块为基础,通过可信平台控制模块对防护部件和计算部件及组件的固件进行可信度量,可信软件基(Trusted Software Base,TSB)对系统软件及应用软件进行可信度量,同时TPCM管理平台实现对可信度量的验证及可信策略同步和管理。 + + + +## 功能描述 + +如下图所示,整体系统方案由防护部件、计算部件和可信管理中心三部分组成。 + +![](./figures/TPCM.png) + +- 可信管理中心:对可信计算节点的防护策略和基准值进行制定、下发、维护、存储等操作的集中管理平台,可信管理中心由第三方厂商提供。 +- 防护部件:独立于计算部件执行,为可信计算平台提供具有主动度量和主动控制特征的可信计算防护功能,实现运算的同时进行安全防护。防护部件包括可信平台控制模块、可信软件基,以及可信密码模块(Trusted Cryptography Module,TCM)。TPCM是可信计算节点中实现可信防护功能的关键部件,可以采用多种技术途径实现,如板卡、芯片、IP核等,其内部包含中央处理器、存储器等硬件,固件,以及操作系统与可信功能组件等软件,支撑其作为一个独立于计算部件的防护部件组件,并行于计算部件按内置防护策略工作,对计算部件的硬件、固件及软件等需防护的资源进行可信监控,是可信计算节点中的可信根。 + +- 计算部件:主要包括硬件、操作系统和应用层软件。其中操作系统分为引导阶段和运行阶段,在引导阶段openEuler的shim和grub2支持可信度量能力,可实现对shim、grub2以及操作系统内核、initramfs等启动文件的可信度量防护;在运行阶段,openEuler操作系统支持部署可信验证要素代理(由第三方厂商可信华泰提供),它负责将数据发送给TPCM模块,用以实现运行阶段的可信度量防护。 + +其中,TPCM作为可信计算节点中实现可信防护功能的关键部件,需要与TSB、TCM、可信管理中心和可信计算节点的计算部件交互,交互方式如下: + +1. TPCM的硬件、固件与软件为TSB提供运行环境,设置的可信功能组件为TSB按策略库解释要求实现度量、控制、支撑与决策等功能提供支持。 +2. TPCM通过访问TCM获取可信密码功能,完成对防护对象可信验证、度量和保密存储等计算任务,并提供TCM服务部件以支持对TCM的访问。 +3. TPCM通过管理接口连接可信管理中心,实现防护策略管理、可信报告处理等功能。 +4. TPCM通过内置的控制器和I/O端口,经由总线与计算部件的控制器交互,实现对计算部件的主动监控。 +5. 计算部件操作系统中内置的防护代理获取预设的防护对象有关代码和数据提供给TPCM,TPCM将监控信息转发给TSB,由TSB依据策略库进行分析处理。 + +## 约束限制 + +适配服务器:TaiShan 200(型号2280)VF
+适配BMC插卡型号:BC83SMMC + +## 应用场景 + +通过TPCM特性构成一个完整的信任链,保障系统启动以后进入一个可信的计算环境。 \ No newline at end of file diff --git "a/docs/zh/docs/Administration/\345\217\257\344\277\241\350\256\241\347\256\227.md" "b/docs/zh/docs/Administration/\345\217\257\344\277\241\350\256\241\347\256\227.md" index efa7a3e9b4116a7ae673abfb29351cd180dd476c..73d88b12b203a3b58c18f11138f15112e446681d 100644 --- "a/docs/zh/docs/Administration/\345\217\257\344\277\241\350\256\241\347\256\227.md" +++ "b/docs/zh/docs/Administration/\345\217\257\344\277\241\350\256\241\347\256\227.md" @@ -2,8 +2,6 @@ ## 可信计算基础 -### 可信计算 - 不同国际组织对可信(Trusted)做了不同的定义。 1. 可信计算组织(TCG)的定义: @@ -25,1809 +23,3 @@ ![](./figures/trusted_chain.png) 相比于传统安全机制的“头痛医头,脚痛医脚”,发现一个病毒消灭一个病毒,可信计算采用的是白名单机制,即只允许经过认证的内核、内核模块、应用程序等在系统上运行,如果发现程序已发生更改(或本来就是一个未知的程序),就拒绝其执行。 - -## 内核完整性度量(IMA) - -### 概述 - -#### IMA - -IMA,全称 Integrity Measurement Architecture(完整性度量架构),是内核中的一个子系统,能够基于自定义策略对通过 execve()、mmap() 和 open() 系统调用访问的文件进行度量,度量结果可被用于**本地/远程证明**,或者和已有的参考值比较以**控制对文件的访问**。 - -根据 IMA wiki 的定义,内核完整性子系统的功能可以被分为三部分: - -- 度量(measure):检测对文件的意外或恶意修改,无论远程还是本地。 -- 评估(appraise):度量文件并与一个存储在扩展属性中的参考值作比较,控制本地文件完整性。 -- 审计(audit):将度量结果写到系统日志中,用于审计。 - -可以看到,相比于 IMA 度量作为一个“只记录不干涉”的观察员,IMA 评估更像是一位严格的保安人员,它的职责是拒绝对所有“人证不一”的程序的访问。 - -#### EVM - -EVM,全称 Extended Verification Module(扩展验证模块),它的作用就是将系统当中某个文件的安全扩展属性,包括 security.ima 、security.selinux 等合起来计算一个哈希值,然后使用 TPM 中存的密钥或其他可信环境中的密钥对其进行签名,签名之后的值存在 security.evm 中,这个签名后的值是不能被篡改的,如果被篡改,再次访问的时候就会验签失败。 - -总而言之,EVM 的作用就是通过对安全扩展属性计算摘要和签名并将其存储在 security.evm 中,提供对安全扩展属性的离线保护。 - -#### IMA Digest Lists - -IMA Digest Lists(IMA 摘要列表扩展)是 openEuler 对内核原生完整性保护机制的增强,它取代了原生 IMA 机制为文件完整性提供保护。 - -“摘要列表”(digest lists)是一种特殊格式的二进制数据文件,它与 rpm 包一一对应,记录了 rpm 包中受保护文件(即可执行文件和动态库文件)的哈希值。 - -当正确配置启动参数后,内核将维护一个哈希表(对用户空间不可见),并通过 securityfs 对外提供更新哈希表的接口(digest_list_data 和 digest_list_data_del)。摘要列表在构建阶段经过私钥签名,通过接口上传到内核时,需经过内核中的公钥验证。 - -![](./figures/ima_digest_list_update.png) - -在开启 IMA 评估的情况下,每当访问一个可执行文件或动态库文件,就会调用内核中的钩子,计算文件内容和扩展属性的哈希值,并在内核哈希表中进行搜索,如果匹配就允许文件的执行,否则就拒绝访问。 - -![1599719649188](./figures/ima_verification.png) - -相比内核社区原生 IMA 机制,openEuler 内核提供的 IMA 摘要列表扩展从安全性、性能、易用性三个方面进行了改良,助力完整性保护机制在生产环境下落地: - -- **具备完整的信任链,安全性好** - - 原生 IMA 机制要求在现网环境下预先生成并标记文件扩展属性,访问文件时将文件扩展属性作为参考值,信任链不完整。 - - IMA 摘要列表扩展将文件参考摘要值保存在内核空间中,构建阶段通过摘要列表的形式携带在发布的 rpm 包中,安装 rpm 包的同时导入摘要列表并执行验签,确保了参考值来自于软件发行商,实现了完整的信任链。 - -- **惊艳的性能** - - 由于 TPM 芯片是一种低速芯片,因此 PCR 扩展操作成为了 IMA 度量场景的性能瓶颈。摘要列表扩展在确保安全性的前提下,减少了不必要的 PCR 扩展操作,相比原生 IMA 性能提升高达 65%。 - - IMA 评估场景下,摘要列表扩展将签名验证统一移动到启动阶段进行,避免每次访问文件时都执行验签,相比原生 IMA 评估场景提升运行阶段文件访问的性能约 20%。 - -- **快速部署,平滑升级** - - 原生 IMA 机制在初次部署或每次更新软件包时,都需要切换到 fix 模式手动标记文件扩展属性后再重启进入 enforce 模式,才能正常访问安装的程序。 - - 摘要列表扩展可实现安装完成后开箱即用,且允许直接在 enforce 模式下安装或升级 rpm 包,无需重启和手动标记即可使用,实现了用户感知最小化,适合现网环境下的快速部署和平滑升级。 - -需要注意的是,IMA 摘要列表扩展将原生 IMA 的验签过程提前到启动阶段进行,也引入了一个假设,即内核空间的内存无法被篡改,这就使得 IMA 也依赖于其他安全机制(内核模块安全启动和内存动态度量)以保护内核内存的完整性。 - -但无论社区原生 IMA 机制还是 IMA 摘要列表扩展,都只是可信计算信任链中的一环,无法孤立地保证系统的安全性,安全自始至终都是一个构建纵深防御的系统工程。 - -### 约束限制 - -1. 当前 IMA 评估模式仅支持保护系统中的不可变文件(包括可执行文件和动态库文件)。 -2. IMA 提供的是应用层的完整性度量,它的安全性依赖于之前环节的可信。 -3. 当前阶段 IMA 不支持第三方应用摘要列表的导入。 -4. 启动日志中可能存在 `Unable to open file: /etc/keys/x509_ima.der` 字样,该报错来自于开源社区,不影响 IMA 摘要列表特性的使用。 -5. ARM 版本中 IMA 开启日志模式可能存在一些 audit 报错信息,这是由于 modprobe 在摘要列表未导入时加载内核模块所致,不影响正常功能。 - -### 使用场景 - -#### IMA measurement - -IMA 度量的目的是检测对系统文件的意外或恶意修改,度量结果可被用于本地证明或远程证明。 - -如果系统中存在 TPM 芯片,度量结果将被扩展到 TPM 芯片的指定 PCR 寄存器中,由于 PCR 扩展的单向性以及 TPM 芯片的硬件安全性,用户无法修改已被扩展的度量结果,这就确保了度量结果的真实性。 - -IMA 度量的文件范围和触发条件可以由用户通过 IMA 策略自行配置。 - -默认情况下 IMA 不启用,但系统会前往 `/etc/ima/` 路径下寻找 ima-policy 策略文件,如果找到,就会按照策略在启动时度量系统中的文件。如果不想手动编写策略文件,也可以在启动参数中配置 `ima_policy=tcb` 使用默认策略(更多策略参数请参考附录“IMA启动参数”章节)。 - -系统当前加载的 IMA 策略可以在 `/sys/kernel/security/ima/policy` 文件中查看,IMA 度量日志则位于`/sys/kernel/security/ima/ascii_runtime_measurements` 文件中,如下所示: - -```shell -# head /sys/kernel/security/ima/ascii_runtime_measurements -10 ddee6004dc3bd4ee300406cd93181c5a2187b59b ima-ng sha1:9797edf8d0eed36b1cf92547816051c8af4e45ee boot_aggregate -10 180ecafba6fadbece09b057bcd0d55d39f1a8a52 ima-ng sha1:db82919bf7d1849ae9aba01e28e9be012823cf3a /init -10 ac792e08a7cf8de7656003125c7276968d84ea65 ima-ng sha1:f778e2082b08d21bbc59898f4775a75e8f2af4db /bin/bash -10 0a0d9258c151356204aea2498bbca4be34d6bb05 ima-ng sha1:b0ab2e7ebd22c4d17d975de0d881f52dc14359a7 /lib64/ld-2.27.so -10 0d6b1d90350778d58f1302d00e59493e11bc0011 ima-ng sha1:ce8204c948b9fe3ae67b94625ad620420c1dc838 /etc/ld.so.cache -10 d69ac2c1d60d28b2da07c7f0cbd49e31e9cca277 ima-ng sha1:8526466068709356630490ff5196c95a186092b8 /lib64/libreadline.so.7.0 -10 ef3212c12d1fbb94de9534b0bbd9f0c8ea50a77b ima-ng sha1:f80ba92b8a6e390a80a7a3deef8eae921fc8ca4e /lib64/libc-2.27.so -10 f805861177a99c61eabebe21003b3c831ccf288b ima-ng sha1:261a3cd5863de3f2421662ba5b455df09d941168 /lib64/libncurses.so.6.1 -10 52f680881893b28e6f0ce2b132d723a885333500 ima-ng sha1:b953a3fa385e64dfe9927de94c33318d3de56260 /lib64/libnss_files-2.27.so -10 4da8ce3c51a7814d4e38be55a2a990a5ceec8b27 ima-ng sha1:99a9c095c7928ecca8c3a4bc44b06246fc5f49de /etc/passwd -``` - -每一条记录从左到右分别是: - -1. PCR:用于扩展度量结果的 PCR 寄存器,默认是 10,只在系统装了 TPM 芯片的情况下有意义。 -2. 模板哈希值:最终被用于扩展的哈希值,组合了文件内容哈希和文件路径的长度和值。 -3. 模板:扩展度量值的模板,如 ima-ng。 -4. 文件内容哈希值:被度量的文件内容的哈希值。 -5. 文件路径:被度量的文件路径。 - -#### IMA appraisal - -IMA 评估的目的是通过与标准参考值的比较,控制对本地文件的访问。 - -IMA 首先使用安全扩展属性 security.ima 和 security.evm 存储文件完整性度量的参考值: - -- security.ima:存储文件内容的哈希值; -- security.evm:存储文件扩展属性的哈希值签名。 - -访问受保护文件时,将会触发内核中的钩子,依次验证文件扩展属性和内容的完整性: - -1. 使用内核 keyring 中的公钥对文件 security.evm 扩展属性中的签名值验签,与当前文件扩展属性的哈希值比较,如果匹配就证明文件的扩展属性是完整的(包括 security.ima)。 -2. 在文件扩展属性完整的前提下,将文件 security.ima 扩展属性的内容与当前文件内容的摘要值比较,如果匹配就允许对文件的访问。 - -同样,IMA 评估的文件范围和触发条件也可以由用户通过 IMA 策略自行配置。 - -#### IMA Digest Lists - -IMA 摘要列表扩展当前提供对以下三种启动参数组合的支持: - -- IMA measurement 度量模式: - - ```shell - ima_policy=exec_tcb ima_digest_list_pcr=11 - ``` - -- IMA appraisal 日志模式 + IMA measurement 度量模式: - - ```shell - ima_template=ima-sig ima_policy="exec_tcb|appraise_exec_tcb|appraise_exec_immutable" initramtmpfs ima_hash=sha256 ima_appraise=log evm=allow_metadata_writes evm=x509 ima_digest_list_pcr=11 ima_appraise_digest_list=digest - ``` - -- IMA appraisal 强制模式 + IMA measurement 度量模式: - - ```shell - ima_template=ima-sig ima_policy="exec_tcb|appraise_exec_tcb|appraise_exec_immutable" initramtmpfs ima_hash=sha256 ima_appraise=enforce-evm evm=allow_metadata_writes evm=x509 ima_digest_list_pcr=11 ima_appraise_digest_list=digest - ``` - -### 操作指导 - -#### 原生 IMA 场景初次部署 - -第一次启动时,需要在启动参数中配置: - -```shell -ima_appraise=fix ima_policy=appraise_tcb -``` - -`fix` 模式会允许系统在没有参考值的情况下启动,`appraise_tcb` 对应了一种 IMA 策略,具体可参考附录中的“IMA 启动参数”章节。 - -接下来,你需要访问所有需要被校验的文件,从而为它们添加 IMA 扩展属性: - -```shell -# time find / -fstype ext4 -type f -uid 0 -exec dd if='{}' of=/dev/null count=0 status=none \; -``` - -该过程会花费一定时间,请耐心等待。命令执行完成后,你可以从受保护文件的扩展属性中看到参考值已被标记: - -```shell -# getfattr -m - -d /sbin/init -# file: sbin/init -security.ima=0sAXr7Qmun5mkGDS286oZxCpdGEuKT -security.selinux="system_u:object_r:init_exec_t" -``` - -最后,配置以下启动参数并重新启动系统: - -```shell -ima_appraise=enforce ima_policy=appraise_tcb -``` - -#### 摘要列表场景初次部署 - -1. 配置内核参数进入 log 模式。 - - 编辑 `/boot/efi/EFI/openEuler/grub.cfg` 文件,加入以下参数: - - ```shell - ima_template=ima-sig ima_policy="exec_tcb|appraise_exec_tcb|appraise_exec_immutable" initramtmpfs ima_hash=sha256 ima_appraise=log evm=allow_metadata_writes evm=x509 ima_digest_list_pcr=11 ima_appraise_digest_list=digest - ``` - - 使用 `reboot` 重启系统进入 log 模式,该模式下已开启完整性校验,但不会因校验失败而无法启动。 - -2. 安装依赖包。 - - 使用 yum 安装 digest-list-tools 和 ima-evm-utils,确认不低于以下版本: - - ```shell - # yum install digest-list-tools ima-evm-utils - # rpm -qa | grep digest-list-tools - digest-list-tools-0.3.93-1.oe1.x86_64 - # rpm -qa | grep ima-evm-utils - ima-evm-utils-1.2.1-9.oe1.x86_64 - ``` - -3. 执行 `dracut` 重新生成 initrd: - - ```shell - # dracut -f -e xattr - ``` - - 编辑 `/boot/efi/EFI/openEuler/grub.cfg` 文件,将 ima_appraise=log 改为 ima_appraise=enforce-evm: - - ```shell - ima_template=ima-sig ima_policy="exec_tcb|appraise_exec_tcb|appraise_exec_immutable" initramtmpfs ima_hash=sha256 ima_appraise=enforce-evm evm=allow_metadata_writes evm=x509 ima_digest_list_pcr=11 ima_appraise_digest_list=digest - ``` - - 使用 reboot 重启即可完成初次部署。 - -#### 在 OBS 上进行摘要列表构建 - -OBS 全称 Open Build Service,是一种编译系统,最早在 openSUSE 用于软件包的构建,能够支持多架构的分布式编译。 - -进行摘要列表构建之前,首先确保您的工程包含以下 rpm 包,且来自 openEuler: - -- digest-list-tools -- pesign-obs-integration -- selinux-policy -- rpm -- openEuler-rpm-config - -在交付件工程中增加 Project Config: - -```shell -Preinstall: pesign-obs-integration digest-list-tools selinux-policy-targeted -Macros: -%__brp_digest_list /usr/lib/rpm/openEuler/brp-digest-list %{buildroot} -:Macros -``` - -- 在 Preinstall 中新增 digest-list-tools 用于生成摘要列表,pesign-obs-integration 用于生成摘要列表的签名,新增 selinux-policy-targeted 用于确保生成摘要列表时构建环境内 SELinux 标签正确。 -- 在 Macros 中定义宏 %__brp_digest_list,rpm 将在构建阶段通过这个宏执行命令为编译完成的二进制文件生成摘要列表。这个宏可以作为一个开关控制工程中的摘要列表是否生成。 - -配置完成后,OBS 会自动执行全量构建,正常情况下构建完成后,软件包中会新增以下两个文件: - -- /etc/ima/digest_lists/0-metadata_list-compact-[包名]-[版本号] -- /etc/ima/digest_lists.tlv/0-metadata_list-compact_tlv-[包名]-[版本号] - -#### 在 Koji 上进行摘要列表构建 - -Koji 是 Fedora 社区的编译系统,openEuler 社区将在后续支持,敬请期待。 - -### FAQ - -1. 为什么进入 enforce 模式后系统无法启动或启动后命令无法执行/服务不正常? - - enforce 模式下 IMA 会对文件访问做控制,如果访问文件的内容或扩展属性不完整,就会被拒绝访问,当影响启动的关键命令无法执行时,就会造成系统无法启动。 - - 请确认是否存在以下问题: - - - **摘要列表是否被加入到 initrd 中?** - - 初次部署时是否执行了 dracut 命令将摘要列表加入内核?如果摘要列表没有加入 initrd,启动阶段就无法导入摘要列表,从而导致启动失败。 - - - **是否使用官方提供的 rpm 包?** - - 如果使用的是非 openEuler 官方提供的 rpm 包,rpm 包可能没有携带摘要列表,或者对摘要列表签名的私钥与内核中的验签公钥不匹配,从而导致摘要列表没有被导入内核。 - - 如果原因还不明确,可以进入 log 模式启动,从错误日志中寻找原因: - - ```shell - # dmesg | grep appraise - ``` - -2. 为什么 enforce 模式下没有对系统文件做访问控制? - - 系统没有按照预期对文件执行访问控制,首先查看启动参数中的 IMA 策略是否已被正确配置: - - ```shell - # cat /proc/cmdline - ...ima_policy=exec_tcb|appraise_exec_tcb|appraise_exec_immutable... - ``` - - 其次查看当前内核中 IMA 策略是否已生效: - - ```shell - # cat /sys/kernel/security/ima/policy - ``` - - 如果 policy 文件是空的,证明策略没有设置成功,系统也就不会进行访问控制。 - -3. 初次部署完成后,安装/升级/卸载软件包后还需要手动执行 dracut 生成 initrd 吗? - - 不需要。rpm 包提供的 digest_list.so 插件能够在 rpm 包粒度提供摘要列表的自动更新,可以实现用户对摘要列表的无感知。 - -### 附录 - -#### IMA securityfs 接口说明 - -原生 IMA 提供的 securityfs 接口如下: - -> 注:以下接口路径都位于 `/sys/kernel/security/` 目录下。 - -| 路径 | 权限 | 说明 | -| ------------------------------ | ---- | ---------------------------------------- | -| ima/policy | 600 | IMA 策略接口 | -| ima/ascii_runtime_measurement | 440 | ascii 码形式表示的 IMA 度量结果 | -| ima/binary_runtime_measurement | 440 | 二进制形式表示的 IMA 度量结果 | -| ima/runtime_measurement_count | 440 | 度量结果数量统计 | -| ima/violations | 440 | IMA 度量结果冲突数 | -| evm | 660 | EVM 模式,即校验文件扩展属性完整性的方式 | - -其中,`/sys/kernel/security/evm` 的取值有以下三种: - -- 0:EVM 未初始化; -- 1:使用 HMAC(对称加密)方式校验扩展属性完整性; -- 2:使用公钥验签(非对称加密)方式校验扩展属性完整性; -- 6:关闭扩展属性完整性校验(openEuler 使用此方式)。 - -IMA 摘要列表扩展额外提供的 securityfs 接口如下: - -| 路径 | 权限 | 说明 | -| ------------------------ | ---- | --------------------------------------- | -| ima/digests_count | 440 | 显示系统哈希表中的总摘要数量(IMA+EVM) | -| ima/digest_list_data | 200 | 摘要列表新增接口 | -| ima/digest_list_data_del | 200 | 摘要列表删除接口 | - -#### IMA 策略语法 - -每条 IMA 策略语句都必须以 action 关键字代表的**动作**开头,后接**筛选条件**: - -- action:表示该条策略具体的动作,一条策略只能选一个 action。 - - > 注:实际书写时**可忽略 action 字样**,直接书写 dont_measure,不需要写成 action=dont_measure。 - -- func:表示被度量或鉴定的文件类型,常和 mask 匹配使用,一条策略只能选一个 func。 - - - FILE_CHECK 只能同 MAY_EXEC、MAY_WRITE、MAY_READ 匹配使用。 - - MODULE_CHECK、MMAP_CHECK、BPRM_CHECK 只能同 MAY_EXEC 匹配使用。 - - 匹配关系以外的组合不会产生效果。 - -- mask:表示文件在做什么操作时将被度量或鉴定,一条策略只能选一个 mask。 - -- fsmagic:表示文件系统类型的十六进制魔数,定义在 `/usr/include/linux/magic.h` 文件中。 - - > 注:默认情况下度量所有文件系统,除非使用 dont_measure/dont_appraise 标记不度量某文件系统。 - -- fsuuid:表示系统设备 uuid 的 16 位的十六进制字符串。 - -- objtype:表示文件类型,一条策略只能选一个文件类型。 - - > 注:objtype 相比 func 而言,划分的粒度更细,比如 obj_type=nova_log_t 表示 nova log 类型的文件。 - -- uid:表示哪个用户(用用户 id 表示)对文件进行操作,一条策略只能选一个 uid。 - -- fowner:表示文件的属主(用用户 id 表示)是谁,一条策略只能选一个 fowner。 - -关键字的具体取值及说明如下: - -| 关键字 | 值 | 说明 | -| ------ | ---------- | --------- | -| action | measure | 开启 IMA 度量 | -| | dont_measure | 禁用 IMA 度量 | -| | appraise | 开启 IMA 评估 | -| | dont_appraise | 禁用 IMA 评估 | -| | audit | 开启审计 | -| func | FILE_CHECK | 将要被打开的文件 | -| | MODULE_CHECK | 将要被装载的内核模块文件 | -| | MMAP_CHECK | 将要被映射到进程内存空间的动态库文件 | -| | BRPM_CHECK | 将要被执行的文件(不含通过 `/bin/hash` 等程序打开的脚本文件) | -| | POLICY_CHECK | 将要被作为补充 IMA 策略装载的文件 | -| | FIRMWARE_CHECK | 将要被加载到内存中的固件 | -| | DIGEST_LIST_CHECK | 将要被加载到内核中的摘要列表文件 | -| | KEXEC_KERNEL_CHECK | 将要切换的 kexec 内核 | -| mask | MAY_EXEC | 执行文件 | -| | MAY_WRITE | 写文件。不建议使用,受限于 echo、vim 等开源机制(修改本质是新建临时文件再重命名),并不是每次修改都会触发 MAY_WRITE 的 IMA 度量。 | -| | MAY_READ | 读文件 | -| | MAY_APPEND | 扩展文件属性 | -| fsmagic | fsmagic=xxx | 表示文件系统类型的十六进制魔数 | -| fsuuid | fsuuid=xxx | 表示系统设备 uuid 的 16 位的十六进制字符串 | -| fowner | fowner=xxx | 文件属主的用户 id | -| uid | uid=xxx | 操作文件的用户 id | -| obj_type | obj_type=xxx_t | 表示文件的类型(基于 SELinux 标签) | -| pcr | pcr=\ | 选择 TPM 中用于扩展度量值的 PCR(默认为 10) | -| appraise_type | imasig | 基于签名进行 IMA 评估 | -| | meta_immutable | 基于签名进行文件扩展属性的评估(支持摘要列表) | - -> 注:PATH_CHECK 等同于 FILE_CHECK,FILE_MMAP 等同于 MMAP_CHECK,不在本表提及。 - -#### IMA 原生启动参数 - -原生 IMA 的内核启动参数列表如下: - -| 参数名称 | 取值 | 功能 | -| ---------------- | ------------ | ------------------- | -| ima_appraise | off | 关闭 IMA 评估模式,在访问文件时不进行完整性校验,也不为文件生成新的参考值。 | -| | enforce | 开启 IMA 评估强制模式,在访问文件时进行完整性校验,即计算文件摘要值并与参考值比对,如果比对失败就拒绝对文件的访问。IMA 会为新文件生成新的参考值。 | -| | fix | 开启 IMA 修复模式,在该模式下允许更新受保护文件的参考值。 | -| | log | 开启 IMA 评估日志模式,在访问文件时进行完整性校验,但即使校验失败也允许执行命令,只进行日志记录。 | -| ima_policy | tcb | 度量所有文件执行、动态库映射、内核模块导入以及设备驱动加载,此外,root 用户读文件的行为也会被度量。 | -| | appraise_tcb | 对所有 root 属主的文件进行评估。 | -| | secure_boot | 对所有内核模块导入、硬件驱动加载、kexec 内核切换以及 IMA 策略进行评估,前提是这些文件都具有 IMA 签名, | -| ima_tcb | 无 | 等价于 ima_policy=tcb | -| ima_appraise_tcb | 无 | 等价于 ima_policy=appraise_tcb | -| ima_hash | sha1/md5/... | IMA 摘要算法,默认为 sha1 | -| ima_template | ima | IMA 度量扩展模板 | -| | ima-ng | IMA 度量扩展模板 | -| | ima-sig | IMA 度量扩展模板 | -| integrity_audit | 0 | 基础完整性审计信息(默认) | -| | 1 | 额外完整性审计信息 | - -> 注:ima_policy 参数可以同时指定多个值,例如 ima_policy=tcb|appraise_tcb,启动后系统的 IMA 策略就是这两种参数对应的策略的总和。 - -启动参数 `ima_policy=tcb` 对应的 IMA 策略为: - -```shell -# PROC_SUPER_MAGIC = 0x9fa0 -dont_measure fsmagic=0x9fa0 -# SYSFS_MAGIC = 0x62656572 -dont_measure fsmagic=0x62656572 -# DEBUGFS_MAGIC = 0x64626720 -dont_measure fsmagic=0x64626720 -# TMPFS_MAGIC = 0x01021994 -dont_measure fsmagic=0x1021994 -# DEVPTS_SUPER_MAGIC=0x1cd1 -dont_measure fsmagic=0x1cd1 -# BINFMTFS_MAGIC=0x42494e4d -dont_measure fsmagic=0x42494e4d -# SECURITYFS_MAGIC=0x73636673 -dont_measure fsmagic=0x73636673 -# SELINUX_MAGIC=0xf97cff8c -dont_measure fsmagic=0xf97cff8c -# SMACK_MAGIC=0x43415d53 -dont_measure fsmagic=0x43415d53 -# CGROUP_SUPER_MAGIC=0x27e0eb -dont_measure fsmagic=0x27e0eb -# CGROUP2_SUPER_MAGIC=0x63677270 -dont_measure fsmagic=0x63677270 -# NSFS_MAGIC=0x6e736673 -dont_measure fsmagic=0x6e736673 -measure func=MMAP_CHECK mask=MAY_EXEC -measure func=BPRM_CHECK mask=MAY_EXEC -measure func=FILE_CHECK mask=MAY_READ uid=0 -measure func=MODULE_CHECK -measure func=FIRMWARE_CHECK -``` - -启动参数 `ima_policy=tcb_appraise` 对应的 IMA 策略为: - -```shell -# PROC_SUPER_MAGIC = 0x9fa0 -dont_appraise fsmagic=0x9fa0 -# SYSFS_MAGIC = 0x62656572 -dont_appraise fsmagic=0x62656572 -# DEBUGFS_MAGIC = 0x64626720 -dont_appraise fsmagic=0x64626720 -# TMPFS_MAGIC = 0x01021994 -dont_appraise fsmagic=0x1021994 -# RAMFS_MAGIC -dont_appraise fsmagic=0x858458f6 -# DEVPTS_SUPER_MAGIC=0x1cd1 -dont_appraise fsmagic=0x1cd1 -# BINFMTFS_MAGIC=0x42494e4d -dont_appraise fsmagic=0x42494e4d -# SECURITYFS_MAGIC=0x73636673 -dont_appraise fsmagic=0x73636673 -# SELINUX_MAGIC=0xf97cff8c -dont_appraise fsmagic=0xf97cff8c -# SMACK_MAGIC=0x43415d53 -dont_appraise fsmagic=0x43415d53 -# NSFS_MAGIC=0x6e736673 -dont_appraise fsmagic=0x6e736673 -# CGROUP_SUPER_MAGIC=0x27e0eb -dont_appraise fsmagic=0x27e0eb -# CGROUP2_SUPER_MAGIC=0x63677270 -dont_appraise fsmagic=0x63677270 -appraise fowner=0 -``` - -启动参数 `ima_policy=secure_boot` 对应的 IMA 策略为: - -```shell -appraise func=MODULE_CHECK appraise_type=imasig -appraise func=FIRMWARE_CHECK appraise_type=imasig -appraise func=KEXEC_KERNEL_CHECK appraise_type=imasig -appraise func=POLICY_CHECK appraise_type=imasig -``` - -#### IMA 摘要列表启动参数 - -IMA 摘要列表特性额外引入的内核启动参数如下: - -| 参数名称 | 取值 | 功能 | -| -------------- | -------------- | -------------------------- | -| integrity | 0 | IMA 特性总开关关闭(默认) | -| | 1 | IMA 特性总开关打开 | -| ima_appraise | off | 关闭 IMA 评估模式 | -| | enforce-evm | IMA 评估强制模式,在访问文件时进行完整性校验并进行访问控制 | -| ima_appraise_digest_list | digest | 当 EVM 被禁用时,使用摘要列表进行 IMA appraise,摘要列表同时保护文件内容和扩展属性 | -| | digest-nometadata | 在EVM摘要值不存在的情况下,仅基于IMA摘要值进行完整性校验(不保护文件扩展属性) | -| evm | fix | 允许任何对扩展属性的修改(即使修改会导致扩展属性完整性校验失败) | -| | ignore | 只有在扩展属性不存在或不正确的情况下才允许修改 | -| ima_policy | exec_tcb | IMA 度量策略,详见下文策略说明。 | -| | appraise_exec_tcb | IMA 评估策略,详见下文策略说明。 | -| | appraise_exec_immutable | IMA 评估策略,详见下文策略说明。 | -| ima_digest_list_pcr | 11 | 使用 PCR 11 替代 PCR 10,仅使用摘要列表进行度量 | -| | +11 | 依然保留 PCR 10 的度量,在有TPM芯片时也往TPM芯片写度量结果 | -| initramtmpfs | 无 | 添加对 tmpfs 的支持 | - -启动参数 `ima_policy=exec_tcb` 对应的 IMA 策略为: - -```shell -dont_measure fsmagic=0x9fa0 -dont_measure fsmagic=0x62656572 -dont_measure fsmagic=0x64626720 -dont_measure fsmagic=0x1cd1 -dont_measure fsmagic=0x42494e4d -dont_measure fsmagic=0x73636673 -dont_measure fsmagic=0xf97cff8c -dont_measure fsmagic=0x43415d53 -dont_measure fsmagic=0x27e0eb -dont_measure fsmagic=0x63677270 -dont_measure fsmagic=0x6e736673 -measure func=MMAP_CHECK mask=MAY_EXEC -measure func=BPRM_CHECK mask=MAY_EXEC -measure func=MODULE_CHECK -measure func=FIRMWARE_CHECK -measure func=POLICY_CHECK -measure func=DIGEST_LIST_CHECK -measure parser -``` - -启动参数 `ima_policy=appraise_exec_tcb` 对应的 IMA 策略为: - -```shell -appraise func=MODULE_CHECK appraise_type=imasig -appraise func=FIRMWARE_CHECK appraise_type=imasig -appraise func=KEXEC_KERNEL_CHECK appraise_type=imasig -appraise func=POLICY_CHECK appraise_type=imasig -appraise func=DIGEST_LIST_CHECK appraise_type=imasig -dont_appraise fsmagic=0x9fa0 -dont_appraise fsmagic=0x62656572 -dont_appraise fsmagic=0x64626720 -dont_appraise fsmagic=0x858458f6 -dont_appraise fsmagic=0x1cd1 -dont_appraise fsmagic=0x42494e4d -dont_appraise fsmagic=0x73636673 -dont_appraise fsmagic=0xf97cff8c -dont_appraise fsmagic=0x43415d53 -dont_appraise fsmagic=0x6e736673 -dont_appraise fsmagic=0x27e0eb -dont_appraise fsmagic=0x63677270 -``` - -启动参数 `ima_policy=appraise_exec_immutable` 对应的 IMA 策略为: - -```shell -appraise func=BPRM_CHECK appraise_type=imasig appraise_type=meta_immutable -appraise func=MMAP_CHECK -appraise parser appraise_type=imasig -``` - -#### IMA 内核编译选项详解 - -原生 IMA 提供的编译选项如下: - -| 编译选项 | 功能 | -| -------------------------------- | --------------------------- | -| CONFIG_INTEGRITY | IMA/EVM 总编译开关 | -| CONFIG_INTEGRITY_SIGNATURE | 使能 IMA 签名校验 | -| CONFIG_INTEGRITY_ASYMMETRIC_KEYS | 使能 IMA 非对称签名校验 | -| CONFIG_INTEGRITY_TRUSTED_KEYRING | 使能 IMA/EVM 密钥环 | -| CONFIG_INTEGRITY_AUDIT | 编译 IMA audit 审计模块 | -| CONFIG_IMA | IMA 总编译开关 | -| CONFIG_IMA_WRITE_POLICY | 允许在运行阶段更新 IMA 策略 | -| CONFIG_IMA_MEASURE_PCR_IDX | 允许指定 IMA 度量 PCR 序号 | -| CONFIG_IMA_LSM_RULES | 允许配置 LSM 规则 | -| CONFIG_IMA_APPRAISE | IMA 评估总编译开关 | -| IMA_APPRAISE_BOOTPARAM | 启用 IMA 评估启动参数 | -| CONFIG_EVM | EVM 总编译开关 | - -IMA 摘要列表扩展额外提供的编译选项如下: - -| 编译选项 | 功能 | -| ------------------ | ------------------------- | -| CONFIG_DIGEST_LIST | 开启 IMA 摘要列表特性开关 | - -#### IMA 性能参考数据 - -下图对比了不开启 IMA、开启原生 IMA、开启 IMA 摘要列表特性时的性能: - -![img](./figures/ima_performance.gif) - -#### IMA 对kdump服务的影响 - -开启IMA enforce模式,在策略中配置kexec系统调用校验时,可能导致kdump启动失败。 - -```shell -appraise func=KEXEC_KERNEL_CHECK appraise_type=imasig -``` - -kdump启动失败原因:由于开启IMA后,需要对文件执行完整性校验,因此限制kdump加载内核映像文件时需使用kexec_file_load系统调用。可通过修改/etc/sysconfig/kdump配置文件的KDUMP_FILE_LOAD开启kexec_file_load系统调用。 - -```shell -KDUMP_FILE_LOAD="on" -``` - -同时,kexec_file_load系统调用自身也会执行文件的签名校验,因此要求被加载的内核映像文件必须包含正确的安全启动签名,而且当前内核中必须包含对应的验签证书。 - -#### IMA 根证书配置 - -当前openEuler使用RPM密钥对IMA摘要列表进行签名,为保证IMA功能开箱可用,openEuler内核编译时默认将RPM根证书(PGP证书)导入内核。当前共包含两本PGP证书,分别为旧版本使用的OBS证书和openEuler 22.03 LTS SP1版本切换的openEuler证书: - -```shell -# cat /proc/keys | grep PGP -1909b4ad I------ 1 perm 1f030000 0 0 asymmetri private OBS b25e7f66: PGP.rsa b25e7f66 [] -2f10cd36 I------ 1 perm 1f030000 0 0 asymmetri openeuler fb37bc6f: PGP.rsa fb37bc6f [] -``` - -由于当前内核不支持导入PGP子公钥,而切换后的openEuler证书采用子密钥签名,因此openEuler内核编译前对证书进行了预处理,抽取子公钥并导入内核,具体处理流程可见内核软件包代码仓内的process_pgp_certs.sh脚本文件: - -如果用户不使用IMA摘要列表功能或使用其他密钥实现签名/验签,则可将相关代码移除,自行实现内核根证书配置。 - -## DIM动态完整性度量 - -本章节为DIM(Dynamic Integrity Measurement)动态完整性度量的特性介绍以及使用说明。 - -### 背景 - -随着信息产业的不断发展,信息系统所面临的安全风险也日益增长。信息系统中可能运行大量软件,部分软件不可避免地存在漏洞,这些漏洞一旦被攻击者利用,可能会对系统业务造成严重的影响,如数据泄露、服务不可用等。 - -绝大部分的软件攻击,都会伴随着完整性破坏,如恶意进程运行、配置文件篡改、后门植入等。因此业界提出了完整性保护技术,指的是从系统启动开始,对关键数据进行度量和校验,从而保证系统运行达到预期效果。当前业界已广泛使用的完整性保护技术(如安全启动、文件完整性度量等)都无法对进程运行时的内存数据进行保护。如果攻击者利用一些手段修改了进程的代码指令,可能导致进程被劫持或被植入后门,具有攻击性强,隐蔽性高的特点。对于这种攻击手段,业界提出了动态完整性度量技术,即对进程的运行时内存中的关键数据进行度量和保护。 - -### 术语说明 - -静态基线:针对度量目标的二进制文件进行解析所生成的度量基准数据; - -动态基线:针对度量目标执行首次度量的结果; - -度量策略:指定度量目标的配置信息; - -度量日志:存储度量结果的列表,包含度量对象、度量结果等信息。 - -### 特性简介 - -DIM特性通过在程序运行时对内存中的关键数据(如代码段、数据段)进行度量,并将度量结果和基准值进行对比,确定内存数据是否被篡改,从而检测攻击行为,并采取应对措施。 - -#### 功能范围 - -- 当前DIM特性支持在ARM64/X86架构系统中运行; -- 当前DIM特性支持对以下关键内存数据执行度量: - - 用户态进程的代码段:对应ELF文件中属性为PT_LOAD、权限为RX的段,对应进程加载后权限为RX的vma区域; - - 内核模块代码段:起始地址为内核模块对应struct module结构体中的core_layout.base,长度为core_layout.text_size; - - 内核代码段:对应\_stext符号至\_etext,跳过可能由于内核static key机制发生变化的地址。 -- 当前DIM特性支持对接以下硬件平台: - - 支持将度量结果扩展至TPM 2.0芯片的PCR寄存器,以实现远程证明服务对接。 - -#### 技术限制 - -- 对于用户态进程,仅支持度量文件映射代码段,不支持度量匿名代码段; -- 不支持度量内核热补丁; -- 仅支持主动触发机制,如果两次触发过程中发生了篡改-恢复的行为,会导致无法识别攻击; -- 对于主动修改代码段的场景(如代码段重定位、自修改或热补丁),会被识别为攻击; -- 对于内核、内核模块的度量,以触发动态基线时的度量结果作为度量基准值,静态基线值仅作为一个固定标识; -- 度量目标必须在触发动态基线的时刻就已在内存中加载(如进程运行或内核模块加载),否则后续无法度量; -- 在需要使用TPM芯片的PCR寄存器验证度量日志的场景下,DIM模块不允许卸载,否则会导致度量日志清空,而无法和PCR寄存器匹配; ->![](./public_sys-resources/icon-note.gif) **说明:** -> ->特性启用后,会对系统性能存在一定影响,主要包括以下方面: -> - DIM特性自身加载以及基线数据、度量日志管理会对系统内存造成消耗,具体影响与保护策略配置相关; -> - DIM特性执行度量期间需要进行哈希运算,造成CPU消耗,具体影响与需要度量的数据大小有关; -> - DIM特性执行度量期间需要对部分资源执行上锁或获取信号量操作,可能导致其他并发进程等待。 - -#### 规格约束 - -| 规格项 | 值 | -| ------------------------------------------------------------ | ---- | -| 文件大小上限(策略文件、静态基线文件、签名文件、证书文件) | 10MB | -| 同一个度量目标在一次动态基线后多次度量期间最多记录的篡改度量日志条数 | 10条 | -| /etc/dim/policy中度量策略最大可记录数|10000条| - -#### 架构说明 - -DIM包含两个软件包dim_tools和dim,分别提供如下组件: - -| 软件包 | 组件 | 说明 | -| --------- | ---------------- | ------------------------------------------------------------ | -| dim_tools | dim_gen_baseline | 用户态组件,静态基线生成工具,用于生成动态度量所需要的基线数据,该基线数据在DIM特性运行时会被导入并作为度量基准值 | -| dim | dim_core | 内核模块,执行核心的动态度量逻辑,包括策略解析、静态基线解析、动态基线建立、度量执行、度量日志记录、TPM芯片扩展操作等,实现对内存关键数据的度量功能 | -| dim | dim_monitor | 内核模块,执行对dim_core的代码段和关键数据的度量保护,一定程度防止由于dim_core遭受攻击导致的DIM功能失效。 | - -整体架构如下图所示: - -![](./figures/dim_architecture.jpg) - -#### 关键流程说明 - -dim_core和dim_monitor模块均提供了对内存数据的度量功能,包含两个核心流程: - -- 动态基线流程:dim_core模块读取并解析策略和静态基线文件,然后对目标进程执行代码段度量,度量结果在内存中以动态基线形式存放,最后将动态基线数据和静态基线数据进行对比,并将对比结果记录度量日志;dim_monitor模块对dim_core模块的代码段和关键数据进行度量,作为动态基线并记录度量日志; -- 动态度量流程:dim_core和dim_monitor模块对目标执行度量,并将度量结果与动态基线值进行对比,如果对比不一致,则将结果记录度量日志。 - -#### 接口说明 - -##### 文件路径说明 - -| 路径 | 说明 | -| ------------------------------- | ------------------------------------------------------------ | -| /etc/dim/policy | 度量策略文件 | -| /etc/dim/policy.sig | 度量策略签名文件,用于存放策略文件的签名信息,在签名校验功能开启的情况下使用 | -| /etc/dim/digest_list/*.hash | 静态基线文件,用于存放度量的基准值信息 | -| /etc/dim/digest_list/*.hash.sig | 静态基线签名文件,用于存放静态基线文件的签名信息,在签名校验功能开启的情况下使用 | -| /etc/keys/x509_dim.der | 证书文件,用于校验策略文件和静态基线文件的签名信息,在签名校验功能开启的情况下使用 | -| /sys/kernel/security/dim | DIM文件系统目录,DIM内核模块加载后生成,目录下提供对DIM功能进行操作的内核接口 | - -##### 文件格式说明 - -1. 度量策略文件格式说明 - - 文本文件,以UNIX换行符进行分隔,每行代表一条度量策略,当前支持以下几种配置格式: - - 1. 用户态进程代码段度量配置: - - ``` - measure obj=BPRM_TEXT path=<度量目标进程可执行文件或动态库对应二进制文件的绝对路径> - ``` - - 2. 内核模块代码段度量配置: - - ``` - measure obj=MODULE_TEXT name=<内核模块名> - ``` - - 3. 内核度量配置: - - ``` - measure obj=KERNEL_TEXT - ``` - -**参考示例:** - -``` -# cat /etc/dim/policy -measure obj=BPRM_TEXT path=/usr/bin/bash -measure obj=BPRM_TEXT path=/usr/lib64/libc.so.6 -measure obj=MODULE_TEXT name=ext4 -measure obj=KERNEL_TEXT -``` - -2. 静态基线文件格式说明 - - 文本文件,以UNIX换行符进行分隔,每行代表一条静态基线,当前支持以下几种配置格式: - - 1. 用户态进程基线: - - ``` - dim USER sha256:6ae347be2d1ba03bf71d33c888a5c1b95262597fbc8d00ae484040408a605d2b <度量目标进程可执行文件或动态库对应二进制文件的绝对路径> - ``` - - 2. 内核模块基线: - - ``` - dim KERNEL sha256:a18bb578ff0b6043ec5c2b9b4f1c5fa6a70d05f8310a663ba40bb6e898007ac5 <内核release号>/<内核模块名> - ``` - - 3. 内核基线: - - ``` - dim KERNEL sha256:2ce2bc5d65e112ba691c6ab46d622fac1b7dbe45b77106631120dcc5441a3b9a <内核release号> - ``` - -**参考示例:** - -``` -dim USER sha256:6ae347be2d1ba03bf71d33c888a5c1b95262597fbc8d00ae484040408a605d2b /usr/bin/bash -dim USER sha256:bc937f83dee4018f56cc823f5dafd0dfedc7b9872aa4568dc6fbe404594dc4d0 /usr/lib64/libc.so.6 -dim KERNEL sha256:a18bb578ff0b6043ec5c2b9b4f1c5fa6a70d05f8310a663ba40bb6e898007ac5 6.4.0-1.0.1.4.oe2309.x86_64/dim_monitor -dim KERNEL sha256:2ce2bc5d65e112ba691c6ab46d622fac1b7dbe45b77106631120dcc5441a3b9a 6.4.0-1.0.1.4.oe2309.x86_64 -``` - -3. 度量日志格式说明 - - 文本内容,以UNIX换行符进行分隔,每行代表一条度量日志,格式为: - -``` - <度量日志哈希值> <度量算法>:<度量哈希值> <度量对象> <度量日志类型> -``` - -**参考示例:** - - 1. 对bash进程代码段执行度量,度量结果与静态基线一致: - - ``` - 12 0f384a6d24e121daf06532f808df624d5ffc061e20166976e89a7bb24158eb87 sha256:db032449f9e20ba37e0ec4a506d664f24f496bce95f2ed972419397951a3792e /usr/bin.bash [static baseline] - ``` - - 2. 对bash进程代码段执行度量,度量结果与静态基线不一致: - - ``` - 12 0f384a6d24e121daf06532f808df624d5ffc061e20166976e89a7bb24158eb87 sha256:db032449f9e20ba37e0ec4a506d664f24f496bce95f2ed972419397951a3792e /usr/bin.bash [tampered] - ``` - - 3. 对ext4内核模块代码段执行度量,未找到静态基线: - - ``` - 12 0f384a6d24e121daf06532f808df624d5ffc061e20166976e89a7bb24158eb87 sha256:db032449f9e20ba37e0ec4a506d664f24f496bce95f2ed972419397951a3792e ext4 [no static baseline] - ``` - - 4. dim_monitor对dim_core执行度量,记录基线时的度量结果: - - ``` - 12 660d594ba050c3ec9a7cdc8cf226c5213c1e6eec50ba3ff51ff76e4273b3335a sha256:bdab94a05cc9f3ad36d29ebbd14aba8f6fd87c22ae580670d18154b684de366c dim_core.text [dynamic baseline] - 12 28a3cefc364c46caffca71e7c88d42cf3735516dec32796e4883edcf1241a7ea sha256:0dfd9656d6ecdadc8ec054a66e9ff0c746d946d67d932cd1cdb69780ccad6fb2 dim_core.data [dynamic baseline] - ``` - -4. 证书/签名文件格式说明 - -为通用格式,详见[开启签名校验](#开启签名校验)章节。 - -##### 内核模块参数说明 - -1. dim_core模块参数 - -| 参数名 | 参数内容 | 取值范围 | 默认值 | -| -------------------- | ------------------------------------------------------------ | ------------------------ | ------ | -| measure_log_capacity | 度量日志最大条数,当dim_core记录的度量日志数量达到参数设置时,停止记录度量日志 | 100-UINT_MAX(64位系统) | 100000 | -| measure_schedule | 度量完一个进程/模块后调度的时间,单位毫秒,设置为0代表不调度 | 0-1000 | 0 | -| measure_interval | 自动度量周期,单位分钟,设置为0代表不设置自动度量 | 0-525600 | 0 | -| measure_hash | 度量哈希算法 | sha256, sm3 | sha256 | -| measure_pcr | 将度量结果扩展至TPM芯片的PCR寄存器,设置为0代表不扩展(注意需要与芯片实际的PCR编号保持一致) | 0-128 | 0 | -| signature | 是否启用策略文件和签名机制,设置为0代表不启用,设置为1代表启用 | 0, 1 | 0 | - -**使用示例**: - -``` -insmod /path/to/dim_core.ko measure_log_capacity=10000 measure_schedule=10 measure_pcr=12 -modprobe dim_core measure_log_capacity=10000 measure_schedule=10 measure_pcr=12 -``` - -2. dim_monitor模块参数 - -| 参数名 | 参数内容 | 取值范围 | 默认值 | -| -------------------- | ------------------------------------------------------------ | ------------------------ | ------ | -| measure_log_capacity | 度量日志最大条数,当dim_monitor记录的度量日志数量达到参数设置时,停止记录度量日志 | 100-UINT_MAX(64位系统) | 100000 | -| measure_hash | 度量哈希算法 | sha256, sm3 | sha256 | -| measure_pcr | 将度量结果扩展至TPM芯片的PCR寄存器,设置为0代表不扩展 | 0-128 | 0 | - -**使用示例**: - -``` -insmod /path/to/dim_monitor.ko measure_log_capacity=10000 measure_hash=sm3 -modprobe dim_monitor measure_log_capacity=10000 measure_hash=sm3 -``` - -##### 内核接口说明 - -1. dim_core模块接口 - -| 接口名 | 属性 | 功能 | 示例 | -| -------------------------- | ---- | ------------------------------------------------------------ | --------------------------------------------------------- | -| measure | 只写 | 写入字符串1触发动态度量,成功返回0,失败返回错误码 | echo 1 > /sys/kernel/security/dim/measure | -| baseline_init | 只写 | 写入字符串1触发动态基线,成功返回0,失败返回错误码 | echo 1 > /sys/kernel/security/dim/baseline_init | -| ascii_runtime_measurements | 只读 | 读取接口查询度量日志 | cat /sys/kernel/security/dim/ascii_runtime_measurements | -| runtime_status | 只读 | 读取接口返回状态类型信息,失败返回错误码 | cat /sys/kernel/security/dim/runtime_status | -| interval | 读写 | 写入数字字符串设置自动度量周期(范围同measure_interval参数);读取接口查询当前自动度量周期,失败返回错误码 | echo 10 > /sys/kernel/security/dim/interval
cat /sys/kernel/security/dim/interval | - -**dim_core状态类型信息说明:** - -状态信息以如下字段取值: - -- DIM_NO_BASELINE:表示dim_core已加载,但未进行任何操作; -- DIM_BASELINE_RUNNING:表示正在进行动态基线建立; -- DIM_MEASURE_RUNNING:表示正在进行动态度量度量; -- DIM_PROTECTED:表示已完成动态基线建立,处于受保护状态; -- DIM_ERROR:执行动态基线建立或动态度量时发生错误,需要用户解决错误后重新触发动态基线建立或动态度量。 - -2. dim_monitor模块接口 - -| 接口名 | 属性 | 说明 | 示例 | -| ---------------------------------- | ---- | ---------------------------------------------- | ------------------------------------------------------------ | -| monitor_run | 只写 | 写入字符串1触发度量,成功返回0,失败返回错误码 | echo 1 > /sys/kernel/security/dim/monitor_run | -| monitor_baseline | 只写 | 写入字符串1触发基线,成功返回0,失败返回错误码 | echo 1 > /sys/kernel/security/dim/monitor_baseline | -| monitor_ascii_runtime_measurements | 只读 | 读取接口查询度量日志 | cat /sys/kernel/security/dim/monitor_ascii_runtime_measurements | -| monitor_status | 只读 | 读取接口返回状态类型信息,失败返回错误码 | cat /sys/kernel/security/dim/monitor_status | - -**dim_monitor状态类型信息说明:** - -- ready:表示dim_monitior已加载,但未进行任何操作; -- running:表示正在进行动态基线建立或动态度量; -- error:执行动态基线建立或动态度量时发生错误,需要用户解决错误后重新触发动态基线建立或动态度量; -- protected:表示已完成动态基线建立,处于受保护状态。 - -##### 用户态工具接口说明 - -dim_gen_baseline命令行接口,详见: 。 - -### 如何使用 - -#### 安装/卸载 - -**前置条件**: - -- OS版本:支持openEuler 23.09及以上版本; -- 内核版本:支持openEuler kernel 5.10/6.4版本。 - -安装dim_tools和dim软件包,以openEuler 23.09版本为例: - -``` -# yum install -y dim_tools dim -``` - -软件包安装完成后,DIM内核组件不会默认加载,可通过如下命令进行加载和卸载: - -``` -# modprobe dim_core 或 insmod /path/to/dim_core.ko -# modprobe dim_monitor 或 insmod /path/to/dim_monitor.ko -# rmmod dim_monitor -# rmmod dim_core -``` - -加载成功后,可以通过如下命令查询: - -``` -# lsmod | grep dim_core -dim_core 77824 1 dim_monitor -# lsmod | grep dim_monitor -dim_monitor 36864 0 -``` - -卸载前需要先卸载ko,再卸载rpm包 - -``` -# rmmod dim_monitor -# rmmod dim_core -# rpm -e dim -``` - ->![](./public_sys-resources/icon-note.gif) **说明:** -> -> dim_monitor必须后于dim_core加载,先于dim_core卸载; -> 也可使用源码编译安装,详见 。 - -#### 度量用户态进程代码段 - -**前置条件**: - -- dim_core模块加载成功; - -- 用户需要准备一个常驻的度量目标用户态程序,本小节以程序路径/opt/dim/demo/dim_test_demo为例: - - ``` - # /opt/dim/demo/dim_test_demo & - ``` - -**步骤1**:为度量目标进程对应的二进制文件生成静态基线 - -``` -# mkdir -p /etc/dim/digest_list -# dim_gen_baseline /opt/dim/demo/dim_test_demo -o /etc/dim/digest_list/test.hash -``` - -**步骤2**:配置度量策略 - -``` -# echo "measure obj=BPRM_TEXT path=/opt/dim/demo/dim_test_demo" > /etc/dim/policy -``` - -**步骤3**:触发动态基线建立 - -``` -# echo 1 > /sys/kernel/security/dim/baseline_init -``` - -**步骤4**:查询度量日志 - -``` -# cat /sys/kernel/security/dim/ascii_runtime_measurements -0 e9a79e25f091e03a8b3972b1a0e4ae2ccaed1f5652857fe3b4dc947801a6913e sha256:02e28dff9997e1d81fb806ee5b784fd853eac8812059c4dba7c119c5e5076989 /opt/dim/demo/dim_test_demo [static baseline] -``` - -如上度量日志说明目标进程被成功度量,且度量结果与静态基线一致。 - -**步骤5**:触发动态度量 - -``` -# echo 1 > /sys/kernel/security/dim/measure -``` - -度量完成后可通过**步骤4**查询度量日志,如果度量结果和动态基线阶段的度量结果一致,则度量日志不会更新,否则会新增异常度量日志。如果攻击者尝试篡改目标程序(如采用修改代码重新编译的方式,过程略)并重新启动目标程序: - -``` -# pkill dim_test_demo -# /opt/dim/demo/dim_test_demo & -``` - -再次触发度量并查询度量日志,可以发现有标识为“tampered”的度量日志: - -``` -# echo 1 > /sys/kernel/security/dim/measure -# cat /sys/kernel/security/dim/ascii_runtime_measurements -0 e9a79e25f091e03a8b3972b1a0e4ae2ccaed1f5652857fe3b4dc947801a6913e sha256:02e28dff9997e1d81fb806ee5b784fd853eac8812059c4dba7c119c5e5076989 /opt/dim/demo/dim_test_demo [static baseline] -0 08a2f6f2922ad3d1cf376ae05cf0cc507c2f5a1c605adf445506bc84826531d6 sha256:855ec9a890ff22034f7e13b78c2089e28e8d217491665b39203b50ab47b111c8 /opt/dim/demo/dim_test_demo [tampered] -``` - -#### 度量内核模块代码段 - -**前置条件**: - -- dim_core模块加载成功; - -- 用户需要准备一个度量目标内核模块,本小节假设内核模块路径为/opt/dim/demo/dim_test_module.ko,模块名为dim_test_module: - - ``` - # insmod /opt/dim/demo/dim_test_module.ko - ``` - ->![](./public_sys-resources/icon-note.gif) **说明:** -> ->需要保证内核模块的内核编译环境版本号和当前系统内核版本号一致,可以使用如下方法确认: -> ->``` -># modinfo dim_monitor.ko | grep vermagic | grep "$(uname -r)" ->vermagic: 6.4.0-1.0.1.4.oe2309.x86_64 SMP preempt mod_unload modversions ->``` - -即内核模块vermagic信息的第一个字段需要和当前内核版本号完全一致。 - -**步骤1**:为度量目标内核模块生成静态基线 - -``` -# mkdir -p /etc/dim/digest_list -# dim_gen_baseline /opt/dim/demo/dim_test_module.ko -o /etc/dim/digest_list/test.hash -``` - -**步骤2**:配置度量策略 - -``` -# echo "measure obj=MODULE_TEXT name=dim_test_module" > /etc/dim/policy -``` - -**步骤3**:触发动态基线建立 - -``` -# echo 1 > /sys/kernel/security/dim/baseline_init -``` - -**步骤4**:查询度量日志 - -``` -# cat /sys/kernel/security/dim/ascii_runtime_measurements -0 9603a9d5f87851c8eb7d2619f7abbe28cb8a91f9c83f5ea59f036794e23d1558 sha256:9da4bccc7ae1b709deab8f583b244822d52f3552c93f70534932ae21fac931c6 dim_test_module [static baseline] -``` - -如上度量日志说明dim_test_module模块被成功度量,并以当前的度量结果作为后续度量的基准值(此时度量日志中的哈希值不代表实际度量值)。 - -**步骤5**:触发动态度量 - -``` -echo 1 > /sys/kernel/security/dim/measure -``` - -度量完成后可通过**步骤4**查询度量日志,如果度量结果和动态基线阶段的度量结果一致,则度量日志不会更新,否则会新增异常度量日志。如果攻击者尝试篡改内核模块(如采用修改代码重新编译的方式,过程略)并重新加载: - -``` -rmmod dim_test_module -insmod /opt/dim/demo/dim_test_module.ko -``` - -再次触发度量并查询度量日志,可以发现有标识为“tampered”的度量日志: - -``` -# cat /sys/kernel/security/dim/ascii_runtime_measurements -0 9603a9d5f87851c8eb7d2619f7abbe28cb8a91f9c83f5ea59f036794e23d1558 sha256:9da4bccc7ae1b709deab8f583b244822d52f3552c93f70534932ae21fac931c6 dim_test_module [static baseline] -0 6205915fe63a7042788c919d4f0ff04cc5170647d7053a1fe67f6c0943cd1f40 sha256:4cb77370787323140cb572a789703be1a4168359716a01bf745aa05de68a14e3 dim_test_module [tampered] -``` - -#### 度量内核代码段 - -**前置条件**: - -- dim_core模块加载成功。 - -**步骤1**:为内核生成静态基线 - -``` -# mkdir -p /etc/dim/digest_list -# dim_gen_baseline -k "$(uname -r)" -o /etc/dim/digest_list/test.hash /boot/vmlinuz-6.4.0-1.0.1.4.oe2309.x86_64 -``` - ->![](./public_sys-resources/icon-note.gif) **说明:** -> ->/boot/vmlinuz-6.4.0-1.0.1.4.oe2309.x86_64文件名不固定。 - -**步骤2**:配置DIM策略 - -``` -# echo "measure obj=KERNEL_TEXT" > /etc/dim/policy -``` - -**步骤3**:触发动态基线建立 - -``` -# echo 1 > /sys/kernel/security/dim/baseline_init -``` - -**步骤4**:查询度量日志 - -``` -# cat /sys/kernel/security/dim/ascii_runtime_measurements -0 ef82c39d767dece1f5c52b31d1e8c7d55541bae68a97542dda61b0c0c01af4d2 sha256:5f1586e95b102cd9b9f7df3585fe13a1306cbd464f2ebe47a51ad34128f5d0af 6.4.0-1.0.1.4.oe2309.x86_64 [static baseline] -``` - -如上度量日志说明内核被成功度量,并以当前的基线结果作为后续度量的基准值(此时度量日志中的哈希值不代表实际度量值)。 - -**步骤5**:触发动态度量 - -``` -# echo 1 > /sys/kernel/security/dim/measure -``` - -度量完成后可通过**步骤4**查询度量日志,如果度量结果和动态基线阶段的度量结果一致,则度量日志不会更新,否则会新增异常度量日志。 - -#### 度量dim_core模块 - -**前置条件**: - -- dim_core和dim_monitor模块加载成功; -- 度量策略配置完成。 - -**步骤1**:触发dim_core动态基线 - -``` -# echo 1 > /sys/kernel/security/dim/baseline_init -``` - -**步骤2**:触发dim_monitor动态基线 - -``` -# echo 1 > /sys/kernel/security/dim/monitor_baseline -``` - -**步骤3**:查询dim_monitor度量日志 - -``` -# cat /sys/kernel/security/dim/monitor_ascii_runtime_measurements -0 c1b0d9909ddb00633fc6bbe7e457b46b57e165166b8422e81014bdd3e6862899 sha256:35494ed41109ebc9bf9bf7b1c190b7e890e2f7ce62ca1920397cd2c02a057796 dim_core.text [dynamic baseline] -0 9be7121cd2c215d454db2a8aead36b03d2ed94fad0fbaacfbca83d57a410674f sha256:f35d20aae19ada5e633d2fde6e93133c3b6ae9f494ef354ebe5b162398e4d7fa dim_core.data [dynamic baseline] -``` - -如上度量日志说明dim_core模块被成功度量,并以当前的基线结果作为后续度量的基准值。 ->![](./public_sys-resources/icon-note.gif) **说明:** -> ->若跳过动态基线创建,直接进行度量,日志中会显示tampered。 - -**步骤4**:触发dim_monitor动态度量 - -``` -# echo 1 > /sys/kernel/security/dim/monitor_run -``` - -如果度量结果和动态基线阶段的度量结果一致,则度量日志不会更新,否则会新增异常度量日志。尝试修改策略后重新执触发dim_core动态基线,此时由于度量目标发生变化,dim_core管理的基线数据也会发生变更,从而dim_monitor的度量结果也会发生变化: - -``` -# echo "measure obj=BPRM_TEXT path=/usr/bin/bash" > /etc/dim/policy -# echo 1 > /sys/kernel/security/dim/baseline_init -``` - -再次触发dim_monitor度量并查询度量日志,可以发现有标识为“tampered”的度量日志: - -``` -# echo 1 > /sys/kernel/security/dim/monitor_run -# cat /sys/kernel/security/dim/monitor_ascii_runtime_measurements -0 c1b0d9909ddb00633fc6bbe7e457b46b57e165166b8422e81014bdd3e6862899 sha256:35494ed41109ebc9bf9bf7b1c190b7e890e2f7ce62ca1920397cd2c02a057796 dim_core.text [dynamic baseline] -0 9be7121cd2c215d454db2a8aead36b03d2ed94fad0fbaacfbca83d57a410674f sha256:f35d20aae19ada5e633d2fde6e93133c3b6ae9f494ef354ebe5b162398e4d7fa dim_core.data [dynamic baseline] -0 6a60d78230954aba2e6ea6a6b20a7b803d7adb405acbb49b297c003366cfec0d sha256:449ba11b0bfc6146d4479edea2b691aa37c0c025a733e167fd97e77bbb4b9dab dim_core.data [tampered] -``` - -#### 扩展TPM PCR寄存器 - -**前置条件**: - -- 系统已安装TPM 2.0芯片,执行如下命令返回不为空: - - ``` - # ls /dev/tpm* - /dev/tpm0 /dev/tpmrm0 - ``` - -- 系统已安装tpm2-tools软件包,执行如下命令返回不为空: - - ``` - # rpm -qa tpm2-tools - ``` - -- 度量策略和静态基线配置完成。 - -**步骤1**:加载dim_core和dim_monitor模块,并配置扩展度量结果的PCR寄存器编号,这里为dim_core度量结果指定PCR 12,为dim_monitor指定PCR 13 - -``` -# modprobe dim_core measure_pcr=12 -# modprobe dim_monitor measure_pcr=13 -``` - -**步骤2**:触发dim_core和dim_monitor基线 - -``` -# echo 1 > /sys/kernel/security/dim/baseline_init -# echo 1 > /sys/kernel/security/dim/monitor_baseline -``` - -**步骤3**:查看度量日志,每条日志都显示了对应的TPM PCR寄存器编号 - -``` -# cat /sys/kernel/security/dim/ascii_runtime_measurements -12 2649c414d1f9fcac1c8d0df8ae7b1c18b5ea10a162b957839bdb8f8415ec6146 sha256:83110ce600e744982d3676202576d8b94cea016a088f99617767ddbd66da1164 /usr/lib/systemd/systemd [static baseline] -# cat /sys/kernel/security/dim/monitor_ascii_runtime_measurements -13 72ee3061d5a80eb8547cd80c73a80c3a8dc3b3e9f7e5baa10f709350b3058063 sha256:5562ed25fcdf557efe8077e231399bcfbcf0160d726201ac8edf7a2ca7c55ad0 dim_core.text [dynamic baseline] -13 8ba44d557a9855c03bc243a8ba2d553347a52c1a322ea9cf8d3d1e0c8f0e2656 sha256:5279eadc235d80bf66ba652b5d0a2c7afd253ebaf1d03e6e24b87b7f7e94fa02 dim_core.data [dynamic baseline] -``` - -**步骤4**:检查TPM芯片的PCR寄存器,对应的寄存器均已被写入了扩展值 - -``` -# tpm2_pcrread sha256 | grep "12:" - 12: 0xF358AC6F815BB29D53356DA2B4578B4EE26EB9274E553689094208E444D5D9A2 -# tpm2_pcrread sha256 | grep "13:" - 13: 0xBFB9FF69493DEF9C50E52E38B332BDA8DE9C53E90FB96D14CD299E756205F8EA -``` - -#### 开启签名校验 - -**前置条件**: - -- 用户准备公钥证书和签名私钥,签名算法需要为RSA,哈希算法为sha256,证书格式需要为DER。也可以采用如下方式生成: - - ``` - # openssl genrsa -out dim.key 4096 - # openssl req -new -sha256 -key dim.key -out dim.csr -subj "/C=AA/ST=BB/O=CC/OU=DD/CN=DIM Test" - # openssl x509 -req -days 3650 -signkey dim.key -in dim.csr -out dim.crt - # openssl x509 -in dim.crt -out dim.der -outform DER - ``` - -- 度量策略配置完成。 - -**步骤1**:将DER格式的证书放置在/etc/keys/x509_dim.der路径 - -``` -# mkdir -p /etc/keys -# cp dim.der /etc/keys/x509_dim.der -``` - -**步骤2**:对策略文件和静态基线文件进行签名,签名文件必须为原文件名直接添加.sig后缀 - -``` -# openssl dgst -sha256 -out /etc/dim/policy.sig -sign dim.key /etc/dim/policy -# openssl dgst -sha256 -out /etc/dim/digest_list/test.hash.sig -sign dim.key /etc/dim/digest_list/test.hash -``` - -**步骤3**:加载dim_core模块,开启签名校验功能 - -``` -modprobe dim_core signature=1 -``` - -此时,策略文件和静态基线文件均需要通过签名校验后才能加载。 -修改策略文件触发基线,会导致基线失败: - -``` -# echo "" >> /etc/dim/policy -# echo 1 > /sys/kernel/security/dim/baseline_init --bash: echo: write error: Key was rejected by service -``` - ->![](./public_sys-resources/icon-note.gif) **说明:** -> ->如果某个静态基线文件签名校验失败,dim_core会跳过该文件的解析,而不会导致基线失败。 - -#### 配置度量算法 - -**前置条件**: - -- 度量策略配置完成。 - -**步骤1**:加载dim_core和dim_monitor模块,并配置度量算法,这里以sm3算法为例 - -``` -# modprobe dim_core measure_hash=sm3 -# modprobe dim_monitor measure_hash=sm3 -``` - -**步骤2**:配置策略并为度量目标程序生成sm3算法的静态基线 - -``` -# echo "measure obj=BPRM_TEXT path=/opt/dim/demo/dim_test_demo" > /etc/dim/policy -# dim_gen_baseline -a sm3 /opt/dim/demo/dim_test_demo -o /etc/dim/digest_list/test.hash -``` - -**步骤3**:触发基线 - -``` -# echo 1 > /sys/kernel/security/dim/baseline_init -# echo 1 > /sys/kernel/security/dim/monitor_baseline -``` - -**步骤4**:查看度量日志,每条日志都显示了对应的哈希算法 - -``` -# cat /sys/kernel/security/dim/ascii_runtime_measurements -0 585a64feea8dd1ec415d4e67c33633b97abb9f88e6732c8a039064351d24eed6 sm3:ca84504c02bef360ec77f3280552c006ce387ebb09b49b316d1a0b7f43039142 /opt/dim/demo/dim_test_demo [static baseline] -# cat /sys/kernel/security/dim/monitor_ascii_runtime_measurements -0 e6a40553499d4cbf0501f32cabcad8d872416ca12855a389215b2509af76e60b sm3:47a1dae98182e9d7fa489671f20c3542e0e154d3ce941440cdd4a1e4eee8f39f dim_core.text [dynamic baseline] -0 2c862bb477b342e9ac7d4dd03b6e6705c19e0835efc15da38aafba110b41b3d1 sm3:a4d31d5f4d5f08458717b520941c2aefa0b72dc8640a33ee30c26a9dab74eae9 dim_core.data [dynamic baseline] -``` - -#### 配置自动周期度量 - -**前置条件**: - -- 度量策略配置完成; - -**方式1**:加载dim_core模块,配置定时度量间隔,此处配置为1分钟 - -``` -modprobe dim_core measure_interval=1 -``` - -在模块加载完成后,自动触发动态基线流程,后续每隔1分钟触发一次动态度量。 - ->![](./public_sys-resources/icon-note.gif) **说明:** -> ->此时不能配置dim_core度量自身代码段的度量策略,否则会产生误报。 ->同时需要提前配置/etc/dim/policy,否则指定measure_interval=1加载模块会失败 - -**方式2**:加载dim_core模块后,也可通过内核模块接口配置定时度量间隔,此处配置为1分钟 - -``` -modprobe dim_core -echo 1 > /sys/kernel/security/dim/interval -``` - -此时不会立刻触发度量,1分钟后会触发动态基线或动态度量,后续每隔1分钟触发一次动态度量。 - -#### 配置度量调度时间 - -**前置条件**: - -- 度量策略配置完成; - -加载dim_core模块,配置定时度量调度时间,此处配置为10毫秒: - -``` -modprobe dim_core measure_schedule=10 -``` - -触发动态基线或动态度量时,dim_core每度量一个进程,就会调度让出CPU 10毫秒时间。 - - -## 远程证明(鲲鹏安全库) - -### 介绍 - -本项目开发运行在鲲鹏处理器上的基础安全软件组件,前期主要聚焦在远程证明等可信计算相关领域,使能社区安全开发者。 - -### 软件架构 - -在未使能TEE的平台上,本项目可提供平台远程证明特性,其软件架构如下图所示: - -![img](./figures/RA-arch-1.png) - -在已使能TEE的平台上,本项目可提供TEE远程证明特性,其软件架构如下图所示: - -![img](./figures/RA-arch-2.png) - -### 安装配置 - -1. 使用yum安装程序的rpm包,命令如下: - - ```shell - # yum install kunpengsecl-ras kunpengsecl-rac kunpengsecl-rahub kunpengsecl-qcaserver kunpengsecl-attester kunpengsecl-tas kunpengsecl-devel - ``` - -2. 准备数据库环境:进入 `/usr/share/attestation/ras` 目录,执行 `prepare-database-env.sh` 脚本进行自动化的数据库环境配置。 - -3. 程序运行时依赖的配置文件有三个路径,分别为:当前路径 `./config.yaml` ,家路径 `${HOME}/.config/attestation/ras(rac)(rahub)(qcaserver)(attester)(tas)/config.yaml` ,以及系统路径 `/etc/attestation/ras(rac)(rahub)(qcaserver)(attester)(tas)/config.yaml` 。 - -4. (可选)如果需要创建家目录配置文件,可在安装好rpm包后,执行位于 `/usr/share/attestation/ras(rac)(rahub)(qcaserver)(attester)(tas)` 下的脚本 `prepare-ras(rac)(hub)(qca)(attester)(tas)conf-env.sh` 从而完成家目录配置文件的部署。 - -### 相关参数 - -#### RAS启动参数 - -命令行输入 `ras` 即可启动RAS程序。请注意,在当前目录下需要提供**ECDSA**公钥并命名为 `ecdsakey.pub` 。相关参数如下: - -```shell - -H --https http/https模式开关,默认为https(true),false=http - -h --hport https模式下RAS监听的restful api端口 - -p, --port string RAS监听的client api端口 - -r, --rest string http模式下RAS监听的restful api端口 - -T, --token 生成一个测试用的验证码并退出 - -v, --verbose 打印更详细的RAS运行时日志信息 - -V, --version 打印RAS版本并退出 -``` - -#### RAC启动参数 - -命令行输入 `sudo raagent` 即可启动RAC程序,请注意,物理TPM模块的开启需要sudo权限。相关参数如下: - -```shell - -s, --server string 指定待连接的RAS服务端口 - -t, --test 以测试模式启动 - -v, --verbose 打印更详细的RAC运行时日志信息 - -V, --version 打印RAC版本并退出 - -i, --imalog 指定ima文件路径 - -b, --bioslog 指定bios文件路径 - -T, --tatest 以TA测试模式启动 -``` - -**注意:** ->1.若要使用TEE远程证明特性,需要以非TA测试模式启动RAC,并将待证明TA的uuid、是否使用TCB、mem_hash和img_hash按序放入RAC执行路径下的**talist**文件内。同时预装由TEE团队提供的**libqca.so**库和**libteec.so**库。**talist**文件格式如下: -> ->```text ->e08f7eca-e875-440e-9ab0-5f381136c600 false ccd5160c6461e19214c0d8787281a1e3c4048850352abe45ce86e12dd3df9fde 46d5019b0a7ffbb87ad71ea629ebd6f568140c95d7b452011acfa2f9daf61c7a ->``` -> ->2.若不使用TEE远程证明特性,则需要将 `${DESTDIR}/usr/share/attestation/qcaserver` 目录下的libqca.so库和libteec.so库复制到 `/usr/lib` 或 `/usr/lib64` 目录,并以TA测试模式启动RAC。 - -#### QCA启动参数 - -命令行输入 `${DESTDIR}/usr/bin/qcaserver` 即可启动QCA程序,请注意,这里必须要使用qcaserver的完整路径以正常启动QTA,同时需要使QTA中的CA路径参数与该路径保持相同。相关参数如下: - -```shell - -C, --scenario int 设置程序的应用场景,默认为no_as场景(0),1=as_no_daa场景,2=as_with_daa场景 - -S, --server string 指定开放的服务器地址/端口 -``` - -#### ATTESTER启动参数 - -命令行输入 `attester` 即可启动ATTESTER程序。相关参数如下: - -```shell - -B, --basevalue string 设置基准值文件读取路径 - -M, --mspolicy int 设置度量策略,默认为-1,需要手动指定。1=仅比对img-hash值,2=仅比对hash值,3=同时比对img-hash和hash两个值 - -S, --server string 指定待连接的服务器地址 - -U, --uuid int 指定待验证的可信应用 - -V, --version 打印程序版本并退出 - -T, --test 读取固定的nonce值以匹配目前硬编码的可信报告 -``` - -#### TAS启动参数 - -命令行输入 `tas` 即可启动TAS程序。相关参数如下: - -```shell - -T, --token 生成一个测试用的验证码并退出 -``` - -**注意:** ->1.若要启用TAS服务,需要先为TAS配置好私钥。可以按如下命令修改家目录下的配置文件: -> ->```shell -># cd ${HOME}/.config/attestation/tas -># vim config.yaml -> # 如下DAA_GRP_KEY_SK_X和DAA_GRP_KEY_SK_Y的值仅用于测试,正常使用前请务必更新其内容以保证安全。 ->tasconfig: -> port: 127.0.0.1:40008 -> rest: 127.0.0.1:40009 -> akskeycertfile: ./ascert.crt -> aksprivkeyfile: ./aspriv.key -> huaweiitcafile: ./Huawei IT Product CA.pem -> DAA_GRP_KEY_SK_X: 65a9bf91ac8832379ff04dd2c6def16d48a56be244f6e19274e97881a776543c65a9bf91ac8832379ff04dd2c6def16d48a56be244f6e19274e97881a776543c -> DAA_GRP_KEY_SK_Y: 126f74258bb0ceca2ae7522c51825f980549ec1ef24f81d189d17e38f1773b56126f74258bb0ceca2ae7522c51825f980549ec1ef24f81d189d17e38f1773b56 ->``` -> ->之后再输入`tas`启动TAS程序。 -> ->2.在有TAS环境中,为提高QCA配置证书的效率,并非每一次启动都需要访问TAS以生成相应证书,而是通过证书的本地化存储,即读取QCA侧 `config.yaml` 中配置的证书路径,通过 `func hasAKCert(s int) bool` 函数检查是否已有TAS签发的证书保存于本地,若成功读取证书,则无需访问TAS,若读取证书失败,则需要访问TAS,并将TAS返回的证书保存于本地。 - -### 接口定义 - -#### RAS接口 - -为了便于管理员对目标服务器、RAS以及目标服务器上部署的TEE中的用户 TA 进行管理,本程序设计了以下接口可供调用: - -| 接口 | 方法 | -| --------------------------------- | --------------------------- | -| / | GET | -| /{id} | GET、POST、DELETE | -| /{from}/{to} | GET | -| /{id}/reports | GET | -| /{id}/reports/{reportid} | GET、DELETE | -| /{id}/basevalues | GET | -| /{id}/newbasevalue | POST | -| /{id}/basevalues/{basevalueid} | GET、POST、DELETE | -| /{id}/ta/{tauuid}/status | GET | -| /{id}/ta/{tauuid}/tabasevalues | GET | -| /{id}/ta/{tauuid}/tabasevalues/{tabasevalueid} | GET、POST、DELETE | -| /{id}/ta/{tauuid}/newtabasevalue | POST | -| /{id}/ta/{tauuid}/tareports | GET | -| /{id}/ta/{tauuid}/tareports/{tareportid} | GET、POST、DELETE | -| /{id}/basevalues/{basevalueid} | GET、DELETE | -| /version | GET | -| /config | GET、POST | -| /{id}/container/status | GET | -| /{id}/device/status | GET | - -上述接口的具体用法分别介绍如下。 - -若需要查询所有服务器的信息,可以使用`"/"`接口。 - -```shell -# curl -X GET -H "Content-Type: application/json" http://localhost:40002/ -``` - -*** -若需要查询目标服务器的详细信息,可以使用`"/{id}"`接口的`GET`方法,其中{id}是RAS为目标服务器分配的唯一标识号。 - -```shell -# curl -X GET -H "Content-Type: application/json" http://localhost:40002/1 -``` - -*** -若需要修改目标服务器的信息,可以使用`"/{id}"`接口的`POST`方法,其中$AUTHTOKEN是事先使用`ras -T`自动生成的身份验证码。 - -```go -type clientInfo struct { - Registered *bool `json:"registered"` // 目标服务器注册状态 - IsAutoUpdate *bool `json:"isautoupdate"`// 目标服务器基准值更新策略 -} -``` - -```shell -# curl -X POST -H "Authorization: $AUTHTOKEN" -H "Content-Type: application/json" http://localhost:40002/1 -d '{"registered":false, "isautoupdate":false}' -``` - -*** -若需要删除目标服务器,可以使用`"/{id}"`接口的`DELETE`方法。 -**注意:** ->使用该方法并非删除目标服务器的所有信息,而是把目标服务器的注册状态置为`false`! - -```shell -# curl -X DELETE -H "Authorization: $AUTHTOKEN" -H "Content-Type: application/json" http://localhost:40002/1 -``` - -*** -若需要查询指定范围内的所有服务器信息,可以使用`"/{from}/{to}"`接口的`GET`方法。 - -```shell -# curl -X GET -H "Content-Type: application/json" http://localhost:40002/1/9 -``` - -*** -若需要查询目标服务器的所有可信报告,可以使用`"/{id}/reports"`接口的`GET`方法。 - -```shell -# curl -X GET -H "Content-Type: application/json" http://localhost:40002/1/reports -``` - -*** -若需要查询目标服务器指定可信报告的详细信息,可以使用`"/{id}/reports/{reportid}"`接口的`GET`方法,其中{reportid}是RAS为目标服务器指定可信报告分配的唯一标识号。 - -```shell -# curl -X GET -H "Content-Type: application/json" http://localhost:40002/1/reports/1 -``` - -*** -若需要删除目标服务器指定可信报告,可以使用`"/{id}/reports/{reportid}"`接口的`DELETE`方法。 -**注意:** ->使用该方法将删除指定可信报告的所有信息,将无法再通过接口对该报告进行查询! - -```shell -# curl -X DELETE -H "Authorization: $AUTHTOKEN" -H "Content-Type: application/json" http://localhost:40002/1/reports/1 -``` - -*** -若需要查询目标服务器的所有基准值,可以使用`"/{id}/basevalues"`接口的`GET`方法。 - -```shell -# curl -X GET -H "Content-Type: application/json" http://localhost:40002/1/basevalues -``` - -*** -若需要给目标服务器新增一条基准值信息,可以使用`"/{id}/newbasevalue"`接口的`POST`方法。 - -```go -type baseValueJson struct { - BaseType string `json:"basetype"` // 基准值类型 - Uuid string `json:"uuid"` // 容器或设备的标识号 - Name string `json:"name"` // 基准值名称 - Enabled bool `json:"enabled"` // 基准值是否可用 - Pcr string `json:"pcr"` // PCR值 - Bios string `json:"bios"` // BIOS值 - Ima string `json:"ima"` // IMA值 - IsNewGroup bool `json:"isnewgroup"` // 是否为一组新的基准值 -} -``` - -```shell -# curl -X POST -H "Authorization: $AUTHTOKEN" -H "Content-Type: application/json" http://localhost:40002/1/newbasevalue -d '{"name":"test", "basetype":"host", "enabled":true, "pcr":"testpcr", "bios":"testbios", "ima":"testima", "isnewgroup":true}' -``` - -*** -若需要查询目标服务器指定基准值的详细信息,可以使用`"/{id}/basevalues/{basevalueid}"`接口的`GET`方法,其中{basevalueid}是RAS为目标服务器指定基准值分配的唯一标识号。 - -```shell -# curl -X GET -H "Content-Type: application/json" http://localhost:40002/1/basevalues/1 -``` - -*** -若需要修改目标服务器指定基准值的可用状态,可以使用`"/{id}/basevalues/{basevalueid}"`接口的`POST`方法。 - -```shell -# curl -X POST -H "Content-type: application/json" -H "Authorization: $AUTHTOKEN" http://localhost:40002/1/basevalues/1 -d '{"enabled":true}' -``` - -*** -若需要删除目标服务器指定基准值,可以使用`"/{id}/basevalues/{basevalueid}"`接口的`DELETE`方法。 -**注意:** ->使用该方法将删除指定基准值的所有信息,将无法再通过接口对该基准值进行查询! - -```shell -# curl -X DELETE -H "Authorization: $AUTHTOKEN" -H "Content-Type: application/json" http://localhost:40002/1/basevalues/1 -``` - -*** -若需要查询目标服务器上特定用户 TA 的可信状态,可以使用`"/{id}/ta/{tauuid}/status"`接口的GET方法。其中{id}是RAS为目标服务器分配的唯一标识号,{tauuid}是特定用户 TA 的身份标识号。 - -```shell -# curl -X GET -H "Content-type: application/json" -H "Authorization: $AUTHTOKEN" http://localhost:40002/1/ta/test/status -``` - -*** -若需要查询目标服务器上特定用户 TA 的所有基准值信息,可以使用`"/{id}/ta/{tauuid}/tabasevalues"`接口的GET方法。 - -```shell -# curl -X GET -H "Content-type: application/json" http://localhost:40002/1/ta/test/tabasevalues -``` - -*** -若需要查询目标服务器上特定用户 TA 的指定基准值的详细信息,可以使用`"/{id}/ta/{tauuid}/tabasevalues/{tabasevalueid}"`接口的GET方法。其中{tabasevalueid}是RAS为目标服务器上特定用户 TA 的指定基准值分配的唯一标识号。 - -```shell -# curl -X GET -H "Content-type: application/json" http://localhost:40002/1/ta/test/tabasevalues/1 -``` - -*** -若需要修改目标服务器上特定用户 TA 的指定基准值的可用状态,可以使用`"/{id}/ta/{tauuid}/tabasevalues/{tabasevalueid}"`接口的`POST`方法。 - -```shell -# curl -X POST -H "Content-type: application/json" -H "Authorization: $AUTHTOKEN" http://localhost:40002/1/ta/test/tabasevalues/1 --data '{"enabled":true}' -``` - -*** -若需要删除目标服务器上特定用户 TA 的指定基准值,可以使用`"/{id}/ta/{tauuid}/tabasevalues/{tabasevalueid}"`接口的`DELETE`方法。 -**注意:** ->使用该方法将删除指定基准值的所有信息,将无法再通过接口对该基准值进行查询! - -```shell -# curl -X DELETE -H "Content-type: application/json" -H "Authorization: $AUTHTOKEN" -k http://localhost:40002/1/ta/test/tabasevalues/1 -``` - -*** -若需要给目标服务器上特定用户 TA 新增一条基准值信息,可以使用`"/{id}/ta/{tauuid}/newtabasevalue"`接口的`POST`方法。 - -```go -type tabaseValueJson struct { - Uuid string `json:"uuid"` // 用户 TA 的标识号 - Name string `json:"name"` // 基准值名称 - Enabled bool `json:"enabled"` // 基准值是否可用 - Valueinfo string `json:"valueinfo"` // 镜像哈希值和内存哈希值 -} -``` - -```shell -# curl -X POST -H "Content-Type: application/json" -H "Authorization: $AUTHTOKEN" -k http://localhost:40002/1/ta/test/newtabasevalue -d '{"uuid":"test", "name":"testname", "enabled":true, "valueinfo":"test info"}' -``` - -*** -若需要查询目标服务器上特定用户 TA 的所有可信报告,可以使用`"/{id}/ta/{tauuid}/tareports"`接口的`GET`方法。 - -```shell -# curl -X GET -H "Content-type: application/json" http://localhost:40002/1/ta/test/tareports -``` - -*** -若需要查询目标服务器上特定用户 TA 的指定可信报告的详细信息,可以使用`"/{id}/ta/{tauuid}/tareports/{tareportid}"`接口的`GET`方法,其中{tareportid}是RAS为目标服务器上特定用户 TA 的指定可信报告分配的唯一标识号。 - -```shell -# curl -X GET -H "Content-type: application/json" http://localhost:40002/1/ta/test/tareports/2 -``` - -*** -若需要删除目标服务器上特定用户 TA 的指定可信报告,可以使用`"/{id}/ta/{tauuid}/tareports/{tareportid}"`接口的`DELETE`方法。 -**注意:** ->使用该方法将删除指定可信报告的所有信息,将无法再通过接口对该报告进行查询! - -```shell -# curl -X DELETE -H "Content-type: application/json" http://localhost:40002/1/ta/test/tareports/2 -``` - -*** -若需要获取本程序的版本信息,可以使用`"/version"`接口的`GET`方法。 - -```shell -# curl -X GET -H "Content-Type: application/json" http://localhost:40002/version -``` - -*** -若需要查询目标服务器/RAS/数据库的配置信息,可以使用`"/config"`接口的`GET`方法。 - -```shell -# curl -X GET -H "Content-Type: application/json" http://localhost:40002/config -``` - -*** -若需要修改目标服务器/RAS/数据库的配置信息,可以使用`"/config"`接口的`POST`方法。 - -```go -type cfgRecord struct { - // 目标服务器配置 - HBDuration string `json:"hbduration" form:"hbduration"` - TrustDuration string `json:"trustduration" form:"trustduration"` - DigestAlgorithm string `json:"digestalgorithm" form:"digestalgorithm"` - // RAS配置 - MgrStrategy string `json:"mgrstrategy" form:"mgrstrategy"` - ExtractRules string `json:"extractrules" form:"extractrules"` - IsAllupdate *bool `json:"isallupdate" form:"isallupdate"` - LogTestMode *bool `json:"logtestmode" form:"logtestmode"` -} -``` - -```shell -# curl -X POST -H "Authorization: $AUTHTOKEN" -H "Content-Type: application/json" http://localhost:40002/config -d '{"hbduration":"5s","trustduration":"20s","DigestAlgorithm":"sha256"}' -``` - -#### TAS接口 - -为了便于管理员对TAS服务的远程控制,本程序设计了以下接口可供调用: - -| 接口 | 方法 | -| --------------------| ------------------| -| /config | GET、POST | - -若需要查询TAS的配置信息,可使用`"/config"`接口的`GET`方法: - -```shell -# curl -X GET -H "Content-Type: application/json" http://localhost:40009/config -``` - -*** -若需要修改TAS的配置信息,可使用`"/config"`接口的`POST`方法: - -```shell -curl -X POST -H "Content-Type: application/json" -H "Authorization: $AUTHTOKEN" http://localhost:40009/config -d '{"basevalue":"testvalue"}' -``` - -**注意:** ->TAS的配置信息读取与修改目前仅支持基准值 - -### FAQ - -1. RAS安装后,为什么无法启动? - - >因为在当前RAS的设计逻辑中,程序启动后需要从当前目录查找一份名为 `ecdsakey.pub` 的文件进行读取并作为之后访问该程序的身份验证码,若当前目录没有该文件,则RAS启动会报错。 - >>解决方法一:运行 `ras -T` 生成测试用token后会生成 `ecdsakey.pub` 。 - >>解决方法二:自行部署oauth2认证服务后,将对应JWT token生成方对应的验证公钥保存为 `ecdsakey.pub` 。 - -2. 为什么RAS启动后,通过restapi无法访问? - - >因为RAS默认以https模式启动,您需要向RAS提供合法的证书才能正常访问,而http模式下启动的RAS则不需要提供证书。 - - - -## 可信平台控制模块(TPCM) - -### 背景 - -可信计算在近40年的研究过程中,经历了不断的发展和完善,已经成为信息安全的一个重要分支。中国的可信计算技术近年发展迅猛,在可信计算2.0的基础上解决了可信体系与现有体系的融合问题、可信管理问题以及可信开发的简化问题,形成了基于主动免疫体系的可信计算技术--可信计算3.0。相对于可信计算2.0被动调用的外挂式体系结构,可信计算3.0提出了以自主密码为基础、控制芯片为支柱、双融主板为平台、可信软件为核心、可信连接为纽带、策略管控成体系、安全可信保应用的全新的可信体系框架,在网络层面解决可信问题。 - -可信平台控制模块(Trusted Platform Control Module,TPCM)是一种可集成在可信计算平台中,用于建立和保障信任源点的基础核心模块。它作为中国可信计算3.0中的创新点之一和主动免疫机制的核心,实现了对整个平台的主动可控。 - -TPCM可信计算3.0架构为双体系架构,分为防护部件和计算部件,以可信密码模块为基础,通过可信平台控制模块对防护部件和计算部件及组件的固件进行可信度量,可信软件基(Trusted Software Base,TSB)对系统软件及应用软件进行可信度量,同时TPCM管理平台实现对可信度量的验证及可信策略同步和管理。 - - - -### 功能描述 - -如下图所示,整体系统方案由防护部件、计算部件和可信管理中心三部分组成。 - -![](./figures/TPCM.png) - -- 可信管理中心:对可信计算节点的防护策略和基准值进行制定、下发、维护、存储等操作的集中管理平台,可信管理中心由第三方厂商提供。 -- 防护部件:独立于计算部件执行,为可信计算平台提供具有主动度量和主动控制特征的可信计算防护功能,实现运算的同时进行安全防护。防护部件包括可信平台控制模块、可信软件基,以及可信密码模块(Trusted Cryptography Module,TCM)。TPCM是可信计算节点中实现可信防护功能的关键部件,可以采用多种技术途径实现,如板卡、芯片、IP核等,其内部包含中央处理器、存储器等硬件,固件,以及操作系统与可信功能组件等软件,支撑其作为一个独立于计算部件的防护部件组件,并行于计算部件按内置防护策略工作,对计算部件的硬件、固件及软件等需防护的资源进行可信监控,是可信计算节点中的可信根。 - -- 计算部件:主要包括硬件、操作系统和应用层软件。其中操作系统分为引导阶段和运行阶段,在引导阶段openEuler的shim和grub2支持可信度量能力,可实现对shim、grub2以及操作系统内核、initramfs等启动文件的可信度量防护;在运行阶段,openEuler操作系统支持部署可信验证要素代理(由第三方厂商可信华泰提供),它负责将数据发送给TPCM模块,用以实现运行阶段的可信度量防护。 - -其中,TPCM作为可信计算节点中实现可信防护功能的关键部件,需要与TSB、TCM、可信管理中心和可信计算节点的计算部件交互,交互方式如下: - -1. TPCM的硬件、固件与软件为TSB提供运行环境,设置的可信功能组件为TSB按策略库解释要求实现度量、控制、支撑与决策等功能提供支持。 -2. TPCM通过访问TCM获取可信密码功能,完成对防护对象可信验证、度量和保密存储等计算任务,并提供TCM服务部件以支持对TCM的访问。 -3. TPCM通过管理接口连接可信管理中心,实现防护策略管理、可信报告处理等功能。 -4. TPCM通过内置的控制器和I/O端口,经由总线与计算部件的控制器交互,实现对计算部件的主动监控。 -5. 计算部件操作系统中内置的防护代理获取预设的防护对象有关代码和数据提供给TPCM,TPCM将监控信息转发给TSB,由TSB依据策略库进行分析处理。 - -### 约束限制 - -适配服务器:TaiShan 200(型号2280)VF
-适配BMC插卡型号:BC83SMMC - -### 应用场景 - -通过TPCM特性构成一个完整的信任链,保障系统启动以后进入一个可信的计算环境。 \ No newline at end of file diff --git "a/docs/zh/docs/Administration/\346\220\255\345\273\272repo\346\234\215\345\212\241\345\231\250.md" "b/docs/zh/docs/Administration/\346\220\255\345\273\272repo\346\234\215\345\212\241\345\231\250.md" index 29a1d8a96d3a5d1d44c005c049e7e2f37fa481f2..a00464e11f2cda8b363afe37c13f31da9be093d9 100644 --- "a/docs/zh/docs/Administration/\346\220\255\345\273\272repo\346\234\215\345\212\241\345\231\250.md" +++ "b/docs/zh/docs/Administration/\346\220\255\345\273\272repo\346\234\215\345\212\241\345\231\250.md" @@ -192,6 +192,24 @@ Packages为rpm包所在的目录,repodata为repo源元数据所在的目录, # mkdir -p /usr/share/nginx/uwsgi_temp # mkdir -p /usr/share/nginx/scgi_temp ``` +3. nginx日志转储: + nginx自带日志转储文件:/etc/logrotate.d/nginx,默认每天转储一次,共保留十份转储日志。 + ```shell + #cat /etc/logrotate.d/nginx + /var/log/nginx/*log { + create 0664 nginx root + daily + rotate 10 + missingok + notifempty + compress + sharedscripts + postrotate + /bin/kill -USR1 `cat /run/nginx.pid 2>/dev/null` 2>/dev/null || true + endscript + } + ``` + daily表示每天转储,rotate 10表示保留10份转储日志,用户可以根据自己的需求进行日志转储配置。 ### repo源部署 diff --git "a/docs/zh/docs/Administration/\346\220\255\345\273\272\346\225\260\346\215\256\345\272\223\346\234\215\345\212\241\345\231\250.md" "b/docs/zh/docs/Administration/\346\220\255\345\273\272\346\225\260\346\215\256\345\272\223\346\234\215\345\212\241\345\231\250.md" index c305f5cd18ea9ebdc52e27ee4b259796139f8401..95e60a3973c027ef0a14174fcb8c58afbb3a51e7 100644 --- "a/docs/zh/docs/Administration/\346\220\255\345\273\272\346\225\260\346\215\256\345\272\223\346\234\215\345\212\241\345\231\250.md" +++ "b/docs/zh/docs/Administration/\346\220\255\345\273\272\346\225\260\346\215\256\345\272\223\346\234\215\345\212\241\345\231\250.md" @@ -1,4 +1,5 @@ # 搭建数据库服务器 + - [搭建数据库服务器](#搭建数据库服务器) @@ -20,6 +21,17 @@ - [安装、运行和卸载](#安装运行和卸载-2) - [管理数据库用户](#管理数据库用户-1) - [管理数据库](#管理数据库-2) + - [openGauss服务器](#openGauss服务器) + - [软件介绍](#软件介绍-3) + - [安装](#安装-3) + - [管理数据库角色](#管理数据库角色-1) + - [管理数据库](#管理数据库-3) + - [GreatSQL服务器](#greatsql服务器) + - [软件介绍](#软件介绍-3) + - [配置环境](#配置环境-3) + - [安装、运行和卸载](#安装运行和卸载-3) + - [管理数据库用户](#管理数据库用户-2) + - [管理数据库](#管理数据库-3) @@ -108,7 +120,7 @@ PostgreSQL的架构如[图1](#fig26022387391)所示,主要进程说明如[表1 ### 配置环境 >![](./public_sys-resources/icon-note.gif) **说明:** ->以下环境配置仅为参考示例,具体配置视实际需求做配置 +>以下环境配置仅为参考示例,具体配置视实际需求做配置。 #### 关闭防火墙并取消开机自启动 @@ -118,13 +130,13 @@ PostgreSQL的架构如[图1](#fig26022387391)所示,主要进程说明如[表1 1. 在root权限下停止防火墙。 ```shell - # systemctl stop firewalld + systemctl stop firewalld ``` 2. 在root权限下关闭防火墙。 ```shell - # systemctl disable firewalld + systemctl disable firewalld ``` >![](./public_sys-resources/icon-note.gif) **说明:** @@ -135,7 +147,7 @@ PostgreSQL的架构如[图1](#fig26022387391)所示,主要进程说明如[表1 在root权限下修改配置文件。 ```shell -# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config +sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config ``` #### 创建组和用户 @@ -146,39 +158,39 @@ PostgreSQL的架构如[图1](#fig26022387391)所示,主要进程说明如[表1 1. 在root权限下创建PostgreSQL用户(组)。 ```shell - # groupadd postgres - # useradd -g postgres postgres + groupadd postgres + useradd -g postgres postgres ``` 2. 在root权限下设置postgres用户密码(重复输入密码)。 ```shell - # passwd postgres + passwd postgres ``` #### 搭建数据盘 >![](./public_sys-resources/icon-note.gif) **说明:** ->- 测试极限性能时,建议单独挂载IO性能更优的NVME SSD存储介质创建PostgreSQL测试实例,避免磁盘IO对性能测试结果的影响,本文以单独挂载NVME SSD为例,参考步骤1\~步骤4。 ->- 非性能测试时,在root权限下执行以下命令,创建数据目录即可。然后跳过本小节: -> mkdir /data +> 测试极限性能时,建议单独挂载IO性能更优的NVME SSD存储介质创建PostgreSQL测试实例,避免磁盘IO对性能测试结果的影响,本文以单独挂载NVME SSD为例,参考步骤1\~步骤4。 +> 非性能测试时,在root权限下执行以下命令,创建数据目录即可。然后跳过本小节: +> mkdir /data 1. 在root权限下创建文件系统(以xfs为例,根据实际需求创建文件系统),若磁盘之前已做过文件系统,执行此命令会出现报错,可使用-f参数强制创建文件系统。 ```shell - # mkfs.xfs /dev/nvme0n1 + mkfs.xfs /dev/nvme0n1 ``` 2. 在root权限下创建数据目录。 ```shell - # mkdir /data + mkdir /data ``` 3. 在root权限下挂载磁盘。 ```shell - # mount -o noatime,nobarrier /dev/nvme0n1 /data + mount -o noatime,nobarrier /dev/nvme0n1 /data ``` #### 数据目录授权 @@ -186,36 +198,36 @@ PostgreSQL的架构如[图1](#fig26022387391)所示,主要进程说明如[表1 1. 在root权限下修改目录权限。 ```shell - # chown -R postgres:postgres /data/ + chown -R postgres:postgres /data/ ``` ### 安装、运行和卸载 #### 安装 -1. 配置本地yum源,详细信息请参考[搭建repo服务器](./搭建repo服务器.html)。 +1. 配置本地yum源,详细信息请参考[搭建repo服务器](./搭建repo服务器.md)。 2. 清除缓存。 ```shell - # dnf clean all + dnf clean all ``` 3. 创建缓存。 ```shell - # dnf makecache + dnf makecache ``` 4. 在root权限下安装PostgreSQL服务器。 ```shell - # dnf install postgresql-server + dnf install postgresql-server ``` 5. 查看安装后的rpm包。 ```shell - # rpm -qa | grep postgresql + rpm -qa | grep postgresql ``` #### 运行 @@ -228,13 +240,13 @@ PostgreSQL的架构如[图1](#fig26022387391)所示,主要进程说明如[表1 1. 切换到已创建的PostgreSQL用户。 ```shell - # su - postgres + su - postgres ``` 2. 初始化数据库,其中命令中的/usr/bin是命令initdb所在的目录。 ```shell - # usr/bin/initdb -D /data/ + usr/bin/initdb -D /data/ ``` ##### 启动数据库 @@ -242,13 +254,13 @@ PostgreSQL的架构如[图1](#fig26022387391)所示,主要进程说明如[表1 1. 启动PostgreSQL数据库。 ```shell - # /usr/bin/pg_ctl -D /data/ -l /data/logfile start + /usr/bin/pg_ctl -D /data/ -l /data/logfile start ``` 2. 确认PostgreSQL数据库进程是否正常启动。 ```shell - # ps -ef | grep postgres + ps -ef | grep postgres ``` 命令执行后,打印信息如下图所示,PostgreSQL相关进程已经正常启动了。 @@ -260,7 +272,7 @@ PostgreSQL的架构如[图1](#fig26022387391)所示,主要进程说明如[表1 1. 登录数据库。 ```shell - # /usr/bin/psql -U postgres + /usr/bin/psql -U postgres ``` ![](./figures/login.png) @@ -291,7 +303,7 @@ PostgreSQL的架构如[图1](#fig26022387391)所示,主要进程说明如[表1 1. 停止PostgreSQL数据库。 ```shell - # /usr/bin/pg_ctl -D /data/ -l /data/logfile stop + /usr/bin/pg_ctl -D /data/ -l /data/logfile stop ``` #### 卸载 @@ -299,13 +311,13 @@ PostgreSQL的架构如[图1](#fig26022387391)所示,主要进程说明如[表1 1. 在postgres用户下停止数据库。 ```shell - # /usr/bin/pg_ctl -D /data/ -l /data/logfile stop + /usr/bin/pg_ctl -D /data/ -l /data/logfile stop ``` 2. 在root用户下执行**dnf remove postgresql-server**卸载PostgreSQL数据库。 ```shell - # dnf remove postgresql-server + dnf remove postgresql-server ``` ### 管理数据库角色 @@ -355,7 +367,7 @@ postgres=# CREATE ROLE roleexample2 WITH LOGIN PASSWORD '123456'; 创建角色名为roleexample3的角色。 ```shell -[postgres@localhost ~]# createuser roleexample3 +[postgres@localhost ~]# createuser roleexample3 ``` #### 查看角色 @@ -455,7 +467,7 @@ postgres=# DROP ROLE userexample1; 删除userexample2角色。 ```shell -[postgres@localhost ~]# dropuser userexample2 +[postgres@localhost ~]# dropuser userexample2 ``` #### 角色授权 @@ -773,8 +785,8 @@ psql命令不会自动创建databasename数据库,所以在执行psql恢复数 将db1.sql脚本文件导入到主机为192.168.202.144,端口为3306,postgres用户下newdb数据库中。 ```shell -[postgres@localhost ~]# createdb newdb -[postgres@localhost ~]# psql -h 192.168.202.144 -p 3306 -U postgres -W -d newdb < db1.sql +[postgres@localhost ~]# createdb newdb +[postgres@localhost ~]# psql -h 192.168.202.144 -p 3306 -U postgres -W -d newdb < db1.sql ``` ## Mariadb服务器 @@ -819,13 +831,13 @@ MariaDB的架构如[图2](#fig13492418164520)所示。 1. 在root权限下停止防火墙。 ```shell - # systemctl stop firewalld + systemctl stop firewalld ``` 2. 在root权限下关闭防火墙。 ```shell - # systemctl disable firewalld + systemctl disable firewalld ``` >![](./public_sys-resources/icon-note.gif) **说明:** @@ -836,7 +848,7 @@ MariaDB的架构如[图2](#fig13492418164520)所示。 1. 在root权限下修改配置文件。 ```shell - # sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux + sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux ``` #### 创建组和用户 @@ -847,17 +859,17 @@ MariaDB的架构如[图2](#fig13492418164520)所示。 1. 在root权限下创建MySQL用户(组)。 ```shell - # groupadd mysql + groupadd mysql ``` ```shell - # useradd -g mysql mysql + useradd -g mysql mysql ``` 2. 在root权限下设置MySQL用户密码。 ```shell - # passwd mysql + passwd mysql ``` 重复输入密码(根据实际需求设置密码)。 @@ -865,15 +877,15 @@ MariaDB的架构如[图2](#fig13492418164520)所示。 #### 搭建数据盘 >![](./public_sys-resources/icon-note.gif) **说明:** ->- 进行性能测试时,数据目录使用单独硬盘,需要对硬盘进行格式化并挂载,参考方法一或者方法二。 ->- 非性能测试时,在root权限下执行`mkdir /data`创建数据目录即可。然后跳过本小节。 +> 进行性能测试时,数据目录使用单独硬盘,需要对硬盘进行格式化并挂载,参考方法一或者方法二。 +> 非性能测试时,在root权限下执行`mkdir /data`创建数据目录即可。然后跳过本小节。 ##### 方法一:在root权限下使用fdisk进行磁盘管理 1. 创建分区(以/dev/sdb为例,根据实际情况创建) ```shell - # fdisk /dev/sdb + fdisk /dev/sdb ``` 2. 输入n,按回车确认。 @@ -885,17 +897,17 @@ MariaDB的架构如[图2](#fig13492418164520)所示。 8. 创建文件系统(以xfs为例,根据实际需求创建文件系统) ```shell - # mkfs.xfs /dev/sdb1 + mkfs.xfs /dev/sdb1 ``` 9. 挂载分区到“/data”以供操作系统使用。 ```shell - # mkdir /data + mkdir /data ``` ```shell - # mount /dev/sdb1 /data + mount /dev/sdb1 /data ``` 10. 执行命令“vi /etc/fstab", 编辑“/etc/fstab”使重启后自动挂载数据盘。如下图中,添加最后一行内容。 @@ -909,38 +921,38 @@ MariaDB的架构如[图2](#fig13492418164520)所示。 >![](./public_sys-resources/icon-note.gif) **说明:** >此步骤需要安装镜像中的lvm2相关包,步骤如下: > ->1. 配置本地yum源,详细信息请参考[搭建repo服务器](./搭建repo服务器.html)。如果已经执行,则可跳过此步。 ->2. 在root权限下执行`yum install lvm2`命令安装lvm2。 +> 配置本地yum源,详细信息请参考[搭建repo服务器](./搭建repo服务器.md)。如果已经执行,则可跳过此步。 +> 在root权限下执行`yum install lvm2`命令安装lvm2。 1. 创建物理卷(sdb为硬盘名称,具体名字以实际为准)。 ```shell - # pvcreate /dev/sdb + pvcreate /dev/sdb ``` 2. 创建物理卷组(其中datavg为创建的卷组名称,具体名字以实际规划为准)。 ```shell - # vgcreate datavg /dev/sdb + vgcreate datavg /dev/sdb ``` 3. 创建逻辑卷(其中600G为规划的逻辑卷大小,具体大小以实际情况为准;datalv为创建的逻辑卷的名字,具体名称以实际规划为准。)。 ```shell - # lvcreate -L 600G -n datalv datavg + lvcreate -L 600G -n datalv datavg ``` 4. 创建文件系统。 ```shell - # mkfs.xfs /dev/datavg/datalv + mkfs.xfs /dev/datavg/datalv ``` 5. 创建数据目录并挂载。 ```shell - # mkdir /data - # mount /dev/datavg/datalv /data + mkdir /data + mount /dev/datavg/datalv /data ``` 6. 执行命令**vi /etc/fstab**,编辑“/etc/fstab”使重启后自动挂载数据盘。如下图中,添加最后一行内容。 @@ -954,39 +966,39 @@ MariaDB的架构如[图2](#fig13492418164520)所示。 1. 在已创建的数据目录 **/data** 基础上,使用root权限继续创建进程所需的相关目录并授权MySQL用户(组)。 ```shell - # mkdir -p /data/mariadb - # cd /data/mariadb - # mkdir data tmp run log - # chown -R mysql:mysql /data + mkdir -p /data/mariadb + cd /data/mariadb + mkdir data tmp run log + chown -R mysql:mysql /data ``` ### 安装、运行和卸载 #### 安装 -1. 配置本地yum源,详细信息请参考[搭建repo服务器](./搭建repo服务器.html)。 +1. 配置本地yum源,详细信息请参考[搭建repo服务器](./搭建repo服务器.md)。 2. 清除缓存。 ```shell - # dnf clean all + dnf clean all ``` 3. 创建缓存。 ```shell - # dnf makecache + dnf makecache ``` 4. 在root权限下安装mariadb服务器。 ```shell - # dnf install mariadb-server + dnf install mariadb-server ``` 5. 查看安装后的rpm包。 ```shell - # rpm -qa | grep mariadb + rpm -qa | grep mariadb ``` #### 运行 @@ -994,13 +1006,13 @@ MariaDB的架构如[图2](#fig13492418164520)所示。 1. 在root权限下开启mariadb服务器。 ```shell - # systemctl start mariadb + systemctl start mariadb ``` 2. 在root权限下初始化数据库。 ```shell - # /usr/bin/mysql_secure_installation + /usr/bin/mysql_secure_installation ``` 命令执行过程中需要输入数据库的root设置的密码,若没有密码则直接按“Enter”。然后根据提示及实际情况进行设置。 @@ -1008,7 +1020,7 @@ MariaDB的架构如[图2](#fig13492418164520)所示。 3. 登录数据库。 ```shell - # mysql -u root -p + mysql -u root -p ``` 命令执行后提示输入密码。密码为[2](#li197143190587)中设置的密码。 @@ -1021,14 +1033,14 @@ MariaDB的架构如[图2](#fig13492418164520)所示。 1. 在root权限下关闭数据库进程。 ```shell - # ps -ef | grep mysql - # kill -9 进程ID + ps -ef | grep mysql + kill -9 进程ID ``` 2. 在root权限下执行**dnf remove mariadb-server**命令卸载mariadb。 ```shell - # dnf remove mariadb-server + dnf remove mariadb-server ``` ### 管理数据库用户 @@ -1363,31 +1375,31 @@ mysqldump [options] -all-databases > outputfile 备份主机为192.168.202.144,端口为3306,root用户下的所有数据库到alldb.sql中。 ```shell -# mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 --all-databases > alldb.sql +mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 --all-databases > alldb.sql ``` 备份主机为192.168.202.144,端口为3306,root用户下的db1数据库到db1.sql中。 ```shell -# mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 --databases db1 > db1.sql +mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 --databases db1 > db1.sql ``` 备份主机为192.168.202.144,端口为3306,root用户下的db1数据库的tb1表到db1tb1.sql中。 ```shell -# mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 db1 tb1 > db1tb1.sql +mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 db1 tb1 > db1tb1.sql ``` 只备份主机为192.168.202.144,端口为3306,root用户下的db1数据库的表结构到db1.sql中。 ```shell -# mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 -d db1 > db1.sql +mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 -d db1 > db1.sql ``` 只备份主机为192.168.202.144,端口为3306,root用户下的db1数据库的数据到db1.sql中。 ```shell -# mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 -t db1 > db1.sql +mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 -t db1 > db1.sql ``` #### 恢复数据库 @@ -1440,13 +1452,13 @@ MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言。 1. 在root权限下停止防火墙。 ```shell - # systemctl stop firewalld + systemctl stop firewalld ``` 2. 在root权限下关闭防火墙。 ```shell - # systemctl disable firewalld + systemctl disable firewalld ``` >![](./public_sys-resources/icon-note.gif) **说明:** @@ -1457,7 +1469,7 @@ MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言。 1. 在root权限下修改配置文件。 ```shell - # sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux + sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux ``` #### 创建组和用户 @@ -1468,17 +1480,17 @@ MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言。 1. 在root权限下创建MySQL用户(组)。 ```shell - # groupadd mysql + groupadd mysql ``` ```shell - # useradd -g mysql mysql + useradd -g mysql mysql ``` 2. 在root权限下设置MySQL用户密码。 ```shell - # passwd mysql + passwd mysql ``` 重复输入密码(根据实际需求设置密码)。 @@ -1487,14 +1499,14 @@ MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言。 >![](./public_sys-resources/icon-note.gif) **说明:** >- 进行性能测试时,数据目录使用单独硬盘,需要对硬盘进行格式化并挂载,参考方法一或者方法二。 ->- 非性能测试时,在root权限下执行`mkdir /data`创建数据目录即可。然后跳过本小节: +>- 非性能测试时,在root权限下执行`mkdir /data`创建数据目录即可。然后跳过本小节: ##### 方法一:在root权限下使用fdisk进行磁盘管理 1. 创建分区(以/dev/sdb为例,根据实际情况创建) ```shell - # fdisk /dev/sdb + fdisk /dev/sdb ``` 2. 输入n,按回车确认。 @@ -1506,17 +1518,17 @@ MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言。 8. 创建文件系统(以xfs为例,根据实际需求创建文件系统) ```shell - # mkfs.xfs /dev/sdb1 + mkfs.xfs /dev/sdb1 ``` 9. 挂载分区到“/data”以供操作系统使用。 ```shell - # mkdir /data + mkdir /data ``` ```shell - # mount /dev/sdb1 /data + mount /dev/sdb1 /data ``` 10. 执行命令“vi /etc/fstab", 编辑“/etc/fstab”使重启后自动挂载数据盘。如下图中,添加最后一行内容。 @@ -1529,41 +1541,41 @@ MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言。 >![](./public_sys-resources/icon-note.gif) **说明:** >此步骤需要安装镜像中的lvm2相关包,步骤如下: ->1. 配置本地yum源,详细信息请参考[搭建repo服务器](./搭建repo服务器.html)。如果已经执行,则可跳过此步。 ->2. 执行`yum install lvm2`安装lvm2。 +> 配置本地yum源,详细信息请参考[搭建repo服务器](./搭建repo服务器.md)。如果已经执行,则可跳过此步。 +> 执行`yum install lvm2`安装lvm2。 1. 创建物理卷(sdb为硬盘名称,具体名字以实际为准)。 ```shell - #pvcreate /dev/sdb + pvcreate /dev/sdb ``` 2. 创建物理卷组(其中datavg为创建的卷组名称,具体名字以实际规划为准)。 ```shell - #vgcreate datavg /dev/sdb + vgcreate datavg /dev/sdb ``` 3. 创建逻辑卷(其中600G为规划的逻辑卷大小,具体大小以实际情况为准;datalv为创建的逻辑卷的名字,具体名称以实际规划为准。)。 ```shell - #lvcreate -L 600G -n datalv datavg + lvcreate -L 600G -n datalv datavg ``` 4. 创建文件系统。 ```shell - #mkfs.xfs /dev/datavg/datalv + mkfs.xfs /dev/datavg/datalv ``` 5. 创建数据目录并挂载。 ```shell - #mkdir /data + mkdir /data ``` ```shell - #mount /dev/datavg/datalv /data + mount /dev/datavg/datalv /data ``` 6. 执行命令**vi /etc/fstab**,编辑“/etc/fstab”使重启后自动挂载数据盘。如下图中,添加最后一行内容。 @@ -1577,39 +1589,39 @@ MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言。 1. 在已创建的数据目录 **/data** 基础上,使用root权限继续创建进程所需的相关目录并授权MySQL用户(组)。 ```shell - # mkdir -p /data/mysql - # cd /data/mysql - # mkdir data tmp run log - # chown -R mysql:mysql /data + mkdir -p /data/mysql + cd /data/mysql + mkdir data tmp run log + chown -R mysql:mysql /data ``` ### 安装、运行和卸载 #### 安装 -1. 配置本地yum源,详细信息请参考[搭建repo服务器](./搭建repo服务器.html)章节。 +1. 配置本地yum源,详细信息请参考[搭建repo服务器](./搭建repo服务器.md)章节。 2. 清除缓存。 ```shell - # dnf clean all + dnf clean all ``` 3. 创建缓存。 ```shell - # dnf makecache + dnf makecache ``` 4. 在root权限下安装MySQL服务器。 ```shell - # dnf install mysql-server + dnf install mysql-server ``` 5. 查看安装后的rpm包。 ```shell - # rpm -qa | grep mysql-server + rpm -qa | grep mysql-server ``` #### 运行 @@ -1618,7 +1630,7 @@ MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言。 1. 在root权限下创建my.cnf文件,其中文件路径(包括软件安装路径basedir、数据路径datadir等)根据实际情况修改。 ```shell - # vi /etc/my.cnf + vi /etc/my.cnf ``` 编辑my.cnf内容如下: @@ -1646,7 +1658,7 @@ MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言。 2. 确保my.cnf配置文件修改正确。 ```shell - # cat /etc/my.cnf + cat /etc/my.cnf ``` ![](./figures/zh-cn_image_0231563132.png) @@ -1657,14 +1669,14 @@ MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言。 3. 在root权限下修改/etc/my.cnf文件的组和用户为mysql:mysql ```shell - # chown mysql:mysql /etc/my.cnf + chown mysql:mysql /etc/my.cnf ``` 2. 配置环境变量。 1. 安装完成后,在root权限下将MySQL二进制文件路径到PATH。 ```shell - # echo export PATH=$PATH:/usr/local/mysql/bin >> /etc/profile + echo export PATH=$PATH:/usr/local/mysql/bin >> /etc/profile ``` >![](./public_sys-resources/icon-caution.gif) **注意:** @@ -1673,13 +1685,13 @@ MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言。 2. 在root权限下使环境变量配置生效。 ```shell - # source /etc/profile + source /etc/profile ``` 3. 在root权限下初始化数据库。 >![](./public_sys-resources/icon-note.gif) **说明:** - >本步骤倒数第2行中有初始密码,请注意保存,登录数据库时需要使用。 + >本步骤倒数第2行中有初始密码,请注意保存,登录数据库时需要使用。 ```shell # mysqld --defaults-file=/etc/my.cnf --initialize @@ -1698,22 +1710,22 @@ MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言。 1. 在root权限下修改文件权限。 ```shell - # chmod 777 /usr/local/mysql/support-files/mysql.server - # chown mysql:mysql /var/log/mysql/* + chmod 777 /usr/local/mysql/support-files/mysql.server + chown mysql:mysql /var/log/mysql/* ``` 2. 在root权限下启动MySQL。 ```shell - # cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql - # chkconfig mysql on + cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql + chkconfig mysql on ``` 以mysql用户启动数据库。 ```shell - # su - mysql - # service mysql start + su - mysql + service mysql start ``` 5. 登录数据库。 @@ -1765,14 +1777,14 @@ MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言。 1. 在root权限下关闭数据库进程。 ```shell - # ps -ef | grep mysql - # kill -9 进程ID + ps -ef | grep mysql + kill -9 进程ID ``` 2. 在root权限下执行**dnf remove mysql**命令卸载MySQL。 ```shell - # dnf remove mysql + dnf remove mysql ``` ### 管理数据库用户 @@ -2104,31 +2116,1232 @@ mysqldump [options] -all-databases > outputfile 备份主机为192.168.202.144,端口为3306,root用户下的所有数据库到alldb.sql中。 ```shell -# mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 --all-databases > alldb.sql +mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 --all-databases > alldb.sql +``` + +备份主机为192.168.202.144,端口为3306,root用户下的db1数据库到db1.sql中。 + +```shell +mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 --databases db1 > db1.sql +``` + +备份主机为192.168.202.144,端口为3306,root用户下的db1数据库的tb1表到db1tb1.sql中。 + +```shell +mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 db1 tb1 > db1tb1.sql +``` + +只备份主机为192.168.202.144,端口为3306,root用户下的db1数据库的表结构到db1.sql中。 + +```shell +mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 -d db1 > db1.sql +``` + +只备份主机为192.168.202.144,端口为3306,root用户下的db1数据库的数据到db1.sql中。 + +```shell +mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 -t db1 > db1.sql +``` + +#### 恢复数据库 + +可以在root权限下使用mysql命令恢复数据库。 + +恢复一个或多个表: + +```shell +mysql -h hostname -P portnumber -u username -ppassword databasename < infile +``` + +其中: + +- hostname:主机名。 +- portnumber:端口号。 +- username:用户名。 +- password:密码。 +- databasename:数据库名。 +- infile:mysqldump命令中的outfile参数。 + +##### 示例 + +恢复数据库。 + +```shell +# mysql -h 192.168.202.144 -P 3306 -uroot -p123456 -t db1 < db1.sql +``` + +## openGauss服务器 + +### 软件介绍 + +openGauss是一款开源关系型数据库管理系统,采用木兰宽松许可证v2发行。openGauss内核深度融合华为在数据库领域多年的经验,结合企业级场景需求,持续构建竞争力特性。 + +### 安装 + +安装指南请参见[《openGauss rpm安装》](https://docs.opengauss.org/zh/docs/latest/docs/InstallationGuide/RPM%E5%AE%89%E8%A3%85.html)。 + +### 管理数据库角色 + +#### 创建角色 + +可以使用CREATE ROLE语句来创建角色,在数据库界面执行。 + +```shell +CREATE ROLE role_name [ [ WITH ] option [ ... ] ] [ ENCRYPTED | UNENCRYPTED ] { PASSWORD | IDENTIFIED BY } { 'password' [EXPIRED] | DISABLE }; +``` + +其中: + +- role_name:角色名。 +- password:登录密码。 +- option为参数选项,常用的有: + - SYSADMIN | NOSYSADMIN:决定一个新角色是否为"系统管理员",具有SYSADMIN属性的角色拥有系统最高权限。缺省为NOSYSADMIN。 + - CREATEDB | NOCREATEDB:定义一个角色是否能创建数据库,若未指定,则默认为NOCREATEDB,即不能创建数据库。 + - CREATEROLE | NOCREATEROLE:决定一个角色是否可以创建新角色,若未指定,则默认为NOCREATEROLE,即不能创建新角色。 + - INHERIT | NOINHERIT:这些子句决定一个角色是否“继承”它所在组的角色的权限。不推荐使用。 + - LOGIN | NOLOGIN:具有LOGIN属性的角色才可以登录数据库。一个拥有LOGIN属性的角色可以认为是一个用户。 + - ENCRYPTED | UNENCRYPTED:控制密码存储在系统表里的口令是否加密。按照产品安全要求,密码必须加密存储,所以,UNENCRYPTED在openGauss中禁止使用。因为系统无法对指定的加密口令字符串进行解密,所以如果目前的口令字符串已经是用SHA256加密的格式,则会继续照此存放,而不管是否声明了ENCRYPTED或UNENCRYPTED。这样就允许在dump/restore的时候重新加载加密的口令。 + - VALID UNTIL:设置角色失效的时间戳。如果省略了该子句,角色无有效结束时间限制。 + - IN ROLE:新角色立即拥有IN ROLE子句中列出的一个或多个现有角色拥有的权限。不推荐使用。 + - ROLE:ROLE子句列出一个或多个现有的角色,它们将自动添加为这个新角色的成员,拥有新角色所有的权限。 + +要使用这条命令,必须拥有 CREATE ROLE 权限或者是系统管理员。 + +##### 示例 + +创建一个角色,名为manager,密码为xxxxxxxxx。 + +```shell +openGauss=# CREATE ROLE manager IDENTIFIED BY 'xxxxxxxxx'; +``` + +创建一个角色,从2015年1月1日开始生效,到2026年1月1日失效。 + +```shell +openGauss=# CREATE ROLE miriam WITH LOGIN PASSWORD 'xxxxxxxxx' VALID BEGIN '2015-01-01' VALID UNTIL '2026-01-01'; +``` + +#### 查看角色 + +可以使用SELECT语句或gsql的元命令du或者du+查看角色。 + +```shell +SELECT * FROM pg_roles; +``` + +```shell +\du +``` + +```shell +\du+ +``` + +##### 示例 + +查看所有角色名包括内置角色。 + +```shell +openGauss=# SELECT rolname from pg_roles; +``` + +查看现有角色不包含内置角色。 + +```shell +openGauss=# \du +``` + +#### 修改角色 + +##### 修改用户名 + +可以使用ALTER ROLE语句修改一个已经存在的角色名。 + +```shell +ALTER ROLE oldrolename RENAME TO newrolename; +``` + +其中: + +- oldrolename:旧的角色名。 +- newrolename:新的角色名。 + +##### 修改用户示例 + +将角色名manager修改为newmanager。 + +```shell +openGauss=# ALTER ROLE manager RENAME TO newmanager; +``` + +##### 修改用户密码 + +可以使用ALTER ROLE语句修改一个角色的登录密码。 + +```shell +ALTER ROLE rolename with PASSWORD 'password' +``` + +其中: + +- rolename:角色名。 +- password:密码。 + +##### 修改角色密码示例 + +将manager的密码修改为xxxxxxxxx。 + +```shell +openGauss=# ALTER ROLE manager with PASSWORD 'xxxxxxxxx'; +``` + +#### 删除角色 + +可以使用DROP ROLE语句来删除角色。在数据库界面执行。 + +```shell +DROP ROLE rolename; +``` + +其中:rolename为角色名。 + +##### 示例 + +删除manager角色。 + +```shell +openGauss=# DROP ROLE manager; +``` + +#### 角色授权 + +可以使用GRANT语句来对角色授权。 + +对角色授予表或视图的操作权限: + +```shell +GRANT { { SELECT | INSERT | UPDATE | DELETE | TRUNCATE | REFERENCES | TRIGGER | ALTER | DROP | COMMENT | INDEX | VACUUM } [, ...] + | ALL [ PRIVILEGES ] } + ON { [ TABLE ] table_name [, ...] + | ALL TABLES IN SCHEMA schema_name [, ...] } + TO { [ GROUP ] role_name | PUBLIC } [, ...] + [ WITH GRANT OPTION ]; +``` + +对角色授予序列的操作权限: + +```shell +GRANT { { SELECT | UPDATE | USAGE | ALTER | DROP | COMMENT } [, ...] + | ALL [ PRIVILEGES ] } + ON { [ [ LARGE ] SEQUENCE ] sequence_name [, ...] + | ALL SEQUENCES IN SCHEMA schema_name [, ...] } + TO { [ GROUP ] role_name | PUBLIC } [, ...] + [ WITH GRANT OPTION ]; +``` + +对角色授予数据库的操作权限: + +```shell +GRANT { { CREATE | CONNECT | TEMPORARY | TEMP | ALTER | DROP | COMMENT } [, ...] + | ALL [ PRIVILEGES ] } + ON DATABASE database_name [, ...] + TO { [ GROUP ] role_name | PUBLIC } [, ...] + [ WITH GRANT OPTION ]; +``` + +对角色授予函数的操作权限: + +```shell +GRANT { { EXECUTE | ALTER | DROP | COMMENT } [, ...] | ALL [ PRIVILEGES ] } + ON { FUNCTION {function_name ( [ {[ argmode ] [ arg_name ] arg_type} [, ...] ] )} [, ...] + | ALL FUNCTIONS IN SCHEMA schema_name [, ...] } + TO { [ GROUP ] role_name | PUBLIC } [, ...] + [ WITH GRANT OPTION ]; +``` + +对角色授予过程语言的操作权限: + +```shell +GRANT { USAGE | ALL [ PRIVILEGES ] } + ON LANGUAGE lang_name [, ...] + TO { [ GROUP ] role_name | PUBLIC } [, ...] + [ WITH GRANT OPTION ]; +``` + +将模式的访问权限赋予指定的角色: + +```shell +GRANT { { CREATE | USAGE | ALTER | DROP | COMMENT } [, ...] | ALL [ PRIVILEGES ] } + ON SCHEMA schema_name [, ...] + TO { [ GROUP ] role_name | PUBLIC } [, ...] + [ WITH GRANT OPTION ]; +``` + +对角色授予表空间的操作权限: + +```shell +GRANT { { CREATE | ALTER | DROP | COMMENT } [, ...] | ALL [ PRIVILEGES ] } + ON TABLESPACE tablespace_name [, ...] + TO { [ GROUP ] role_name | PUBLIC } [, ...] + [ WITH GRANT OPTION ]; +``` + +将角色rolename1的成员关系赋予角色rolename2: + +```shell +GRANT rolename1 [, ...] TO rolename2 [, ...] [ WITH ADMIN OPTION ] +``` + +其中: + +- SELECT、INSERT、UPDATE、DELETE、REFERENCES、TRIGGER、USAGE、CREATE、CONNECT、TEMPORARY、TEMP、EXECUTE、ALL PRIVILEGES:用户的操作权限,ALL PRIVILEGES表示所有的权限。 +- ON字句:用于指定权限授予的对象。 +- tablename:表名。 +- TO字句:用来指定被赋予权限的角色。 +- rolename1、rolename2:角色名。 +- PUBLIC:表示该权限要赋予所有角色,包括那些以后可能创建的用户。 +- WITH GRANT OPTION:被授权的用户也可以将此权限赋予他人,否则就不能授权给他人。这个选项不能赋予PUBLIC。 +- sequence_name:序列名。 +- database_name:数据库名。 +- function_name ( [ {[ argmode ] [ arg_name ] arg_type} [, ...] ] )} [, ...]:函数名及其参数。 +- lang_name:过程语言名。 +- schema_name:模式名。 +- tablespace_name:表空间名。 +- WITH ADMIN OPTION:表示成员随后就可以将角色的成员关系赋予其他角色,以及撤销其他角色的成员关系。 + +##### 示例 + +对manager授予数据库database1的CREATE权限。· + +```shell +openGauss=# GRANT CREATE ON DATABASE database1 TO manager; +``` + +对所有用户授予表table1的所有权限。 + +```shell +openGauss=# GRANT ALL PRIVILEGES ON TABLE table1 TO PUBLIC; +``` + +#### 删除用户权限 + +可以使用REVOKE语句来撤销一个或多个角色的权限。 + +撤销角色对表的操作权限: + +```shell +REVOKE [ GRANT OPTION FOR ] + { { SELECT | INSERT | UPDATE | DELETE | TRUNCATE | REFERENCES | ALTER | DROP | COMMENT | INDEX | VACUUM }[, ...] + | ALL [ PRIVILEGES ] } + ON { [ TABLE ] table_name [, ...] + | ALL TABLES IN SCHEMA schema_name [, ...] } + FROM { [ GROUP ] role_name | PUBLIC } [, ...] + [ CASCADE | RESTRICT ]; +``` + +撤销角色对序列的操作权限: + +```shell +REVOKE [ GRANT OPTION FOR ] + { { SELECT | UPDATE | ALTER | DROP | COMMENT }[, ...] + | ALL [ PRIVILEGES ] } + ON { [ [ LARGE ] SEQUENCE ] sequence_name [, ...] + | ALL SEQUENCES IN SCHEMA schema_name [, ...] } + FROM { [ GROUP ] role_name | PUBLIC } [, ...] + [ CASCADE | RESTRICT ]; +``` + +撤销角色对数据库的操作权限: + +```shell +REVOKE [ GRANT OPTION FOR ] + { { CREATE | CONNECT | TEMPORARY | TEMP | ALTER | DROP | COMMENT } [, ...] + | ALL [ PRIVILEGES ] } + ON DATABASE database_name [, ...] + FROM { [ GROUP ] role_name | PUBLIC } [, ...] + [ CASCADE | RESTRICT ]; +``` + +撤销角色对函数的操作权限: + +```shell +REVOKE [ GRANT OPTION FOR ] + { { EXECUTE | ALTER | DROP | COMMENT } [, ...] | ALL [ PRIVILEGES ] } + ON { FUNCTION {function_name ( [ {[ argmode ] [ arg_name ] arg_type} [, ...] ] )} [, ...] + | ALL FUNCTIONS IN SCHEMA schema_name [, ...] } + FROM { [ GROUP ] role_name | PUBLIC } [, ...] + [ CASCADE | RESTRICT ]; +``` + +撤销角色对过程语言的操作权限: + +```shell +REVOKE [ GRANT OPTION FOR ] + { USAGE | ALL [ PRIVILEGES ] } + ON LANGUAGE lang_name [, ...] + FROM { [ GROUP ] role_name | PUBLIC } [, ...] + [ CASCADE | RESTRICT ]; +``` + +撤销角色对模式的操作权限: + +```shell +REVOKE [ GRANT OPTION FOR ] + { { CREATE | USAGE | ALTER | DROP | COMMENT } [, ...] | ALL [ PRIVILEGES ] } + ON SCHEMA schema_name [, ...] + FROM { [ GROUP ] role_name | PUBLIC } [, ...] + [ CASCADE | RESTRICT ]; + +``` + +撤销角色对表空间的操作权限: + +```shell +REVOKE [ GRANT OPTION FOR ] + { { CREATE | ALTER | DROP | COMMENT } [, ...] | ALL [ PRIVILEGES ] } + ON TABLESPACE tablespace_name [, ...] + FROM { [ GROUP ] role_name | PUBLIC } [, ...] + [ CASCADE | RESTRICT ]; +``` + +删除rolename2的rolename1之间的成员关系: + +```shell +REVOKE [ ADMIN OPTION FOR ] rolename1 [, ...] FROM rolename2 [, ...] [ CASCADE | RESTRICT ] +``` + +其中: + +- GRANT OPTION FOR:表示只是撤销对该权限的授权的权力,而不是撤销该权限本身。 +- SELECT、INSERT、UPDATE、DELETE、REFERENCES、TRIGGER、USAGE、CREATE、CONNECT、TEMPORARY、TEMP、EXECUTE、ALL PRIVILEGES:用户的操作权限,ALL PRIVILEGES表示所有的权限。 +- ON字句:用于指定撤销权限的对象。 +- table_name:表名。 +- FROM字句:用来指定被撤销权限的角色。 +- rolename1、rolename2:角色名。 +- PUBLIC:表示撤销隐含定义的、拥有所有角色的组,但并不意味着所有角色都失去了权限,那些直接得到的权限以及通过一个组得到的权限仍然有效。 +- sequence_name:序列名。 +- CASCADE:撤销所有依赖性权限。 +- RESTRICT:不撤销所有依赖性权限。 +- database_name:数据库名。 +- function_name ( [ {[ argmode ] [ arg_name ] arg_type} [, ...] ] )} [, ...]:函数名及其参数。 +- lang_name:过程语言名。 +- schema_name:模式名。 +- tablespace_name:表空间名。 +- ADMIN OPTION FOR:表示传递的授权不会自动收回。 + +##### 示例 + +对manager授予数据库database1的CREATE权限。 + +```shell +openGauss=# GRANT CREATE ON DATABASE database1 TO manager; +``` + +对所有用户撤销表table1的所有权限。 + +```shell +openGauss=# REVOKE ALL PRIVILEGES ON TABLE table1 FROM PUBLIC; +``` + +### 管理数据库 + +#### 创建数据库 + +可以使用CREATE DATABASE语句来创建数据库。在数据库界面使用。 + +```shell +CREATE DATABASE databasename; +``` + +其中:databasename为数据库名。 + +要使用这条命令,必须拥有CREATEDB权限。 + +##### 示例 + +创建一个数据库database1。 + +```shell +openGauss=# CREATE DATABASE database1; +``` + +#### 选择数据库 + +可以使用\c语句来选择数据库。 + +```shell +\c databasename; +``` + +其中:databasename为数据库名称。 + +##### 示例 + +选择database_example数据库。 + +```shell +openGauss=# \c database_example; +``` + +#### 查看数据库 + +可以使用\l语句来查看数据库。 + +```shell +\l; +``` + +##### 示例 + +查看所有数据库。 + +```shell +openGauss=# \l; +``` + +#### 删除数据库 + +可以使用DROP DATABASE语句来删除数据库。 + +>![](./public_sys-resources/icon-caution.gif) **注意:** +>删除数据库要谨慎操作,一旦删除,数据库中的所有表和数据都会删除。 + +```shell +DROP DATABASE databasename; +``` + +其中:databasename为数据库名称。 + +DROP DATABASE会删除数据库的系统目录项并且删除包含数据的文件目录。 + +DROP DATABASE只能由超级管理员或数据库管理者执行。 + +##### 示例 + +删除databaseexample数据库。 + +```shell +openGauss=# DROP DATABASE databaseexample; +``` + +#### 备份数据库 + +gs_dump支持将数据库信息导出至纯文本格式的SQL脚本文件或其他归档文件中。 + +```shell +gs_dump [OPTION]... [DBNAME] +gs_dump -p port_number postgres -f dump1.sql +``` + +其中: + +- DBNAME前面不需要加短或长选项。DBNAME指定要连接的数据库。 例如: 不需要-d,直接指定DBNAME。 +- dump1.sql:数据库备份的文件。 +- option:gs_dump命令参数选项,多个参数之间可以使用空格分隔。常用的gs_dump命令参数选项如下: + - -F, --format=c|d|t|p:选择输出格式。格式如下: + - p|plain:输出一个文本SQL脚本文件(默认)。 + - c|custom:输出一个自定义格式的归档,并且以目录形式输出,作为gs_restore输入信息。该格式是最灵活的输出格式,因为能手动选择,而且能在恢复过程中将归档项重新排序。该格式默认状态下会被压缩。 + - d|directory:该格式会创建一个目录,该目录包含两类文件,一类是目录文件,另一类是每个表和blob对象对应的数据文件。 + - t|tar:输出一个tar格式的归档形式,作为gs_restore输入信息。tar格式与目录格式兼容;tar格式归档形式在提取过程中会生成一个有效的目录格式归档形式。但是,tar格式不支持压缩且对于单独表有8GB的大小限制。此外,表数据项的相应排序在恢复过程中不能更改. + - -h, --host=HOSTNAME:指定主机名。 + - -p, --port=PORT:指定端口。 + - -U, --username=NAME:指定连接的用户名。 + - -W, --password=PASSWORD:指定用户连接的密码。如果主机的认证策略是trust,则不会对系统管理员进行密码验证,即无需输入-W选项;如果没有-W选项,并且不是系统管理员,“Dump Restore工具”会提示用户输入密码。 + - -w, --no-password:不出现输入密码提示。如果主机要求密码认证并且密码没有通过其它形式给出,则连接尝试将会失败。 该选项在批量工作和不存在用户输入密码的脚本中很有帮助。 + +##### 示例 + +执行gs_dump,导出postgres数据库全量信息,导出的MPPDB_backup.sql文件格式为纯文本格式。 + +```shell +[openGauss@localhost ~]# gs_dump -U omm -W password -f backup/MPPDB_backup.sql -p port postgres -F p +``` + +执行gs_dump,导出postgres数据库全量信息,导出的MPPDB_backup.dmp文件格式为自定义归档格式。 + +```shell +gs_dump -U omm -W password -f backup/MPPDB_backup.dmp -p port postgres -F c +``` + +#### 恢复数据库 + +gs_restore是openGauss提供的针对gs_dump导出数据的导入工具。通过此工具可将由gs_dump生成的导出文件进行导入。 + +```shell +gs_restore [OPTION]... FILE +``` + +其中: + +- FILE没有短选项或长选项。用来指定归档文件所处的位置。 +- 作为前提条件,需输入dbname或-l选项。不允许用户同时输入dbname和-l选项。 +- gs_restore默认是以追加的方式进行数据导入。为避免多次导入造成数据异常,在进行导入时,建议使用“-c” 参数,在重新创建数据库对象前,清理(删除)已存在于将要还原的数据库中的数据库对象。 +- option:通用参数如下: + - -f,--file=FILENAME:指定生成脚本的输出文件,或使用-l时列表的输出文件。 + - -d, --dbname=NAME:连接数据库dbname并直接导入到该数据库中。 + - -h, --host=HOSTNAME:指定主机名。 + - -p, --port=PORT:指定端口。 + - -U, --username=NAME:指定连接的用户名。 + - -W, --password=PASSWORD:指定用户连接的密码。如果主机的认证策略是trust,则不会对系统管理员进行密码验证,即无需输入-W参数;如果没有-W参数,并且不是系统管理员,“gs_restore”会提示用户输入密码。 + +##### 示例 + +执行gs_restore,将导出的MPPDB_backup.dmp文件(自定义归档格式)导入到postgres数据库。 + +```shell +[openGauss@localhost ~]# gs_restore -W password backup/MPPDB_backup.dmp -p port -d postgres +``` + +## GreatSQL服务器 + +### 软件介绍 + +GreatSQL 数据库是开放原子开源基金会旗下捐赠项目,拥有中国信通院可信开源社区+可信开源项目双认证。 + +GreatSQL 数据库是一款 **开源免费** 数据库,可在普通硬件上满足金融级应用场景,具有 **高可用**、**高性能**、**高兼容**、**高安全** 等特性,可作为 MySQL 或 Percona Server for MySQL 的理想可选替换。 + +GreatSQL 致力于保持开源的开放性。GreatSQL 采用 [GPLv2 协议](https://gitee.com/GreatSQL/GreatSQL/blob/master/LICENSE)。 + +GreatSQL 数据库由 [GreatSQL 社区](https://greatsql.cn) 主导负责运营维护,已有[众多社区维护者、爱好者及用户](https://greatsql.cn/docs/community/6-thanks.html)参与,包括提交代码、功能测试验证、发现 Bug 以及文档改进等多方面贡献。 + +### 配置环境 + +>![](./public_sys-resources/icon-note.gif) **说明:** +>以下环境配置仅为参考示例,具体配置视实际需求做配置 + +#### 关闭防火墙并取消开机自启动 + +>![](./public_sys-resources/icon-note.gif) **说明:** +>测试环境下通常会关闭防火墙以避免部分网络因素影响,视实际需求做配置。 + +1. 在root权限下停止防火墙。 + + ```shell + systemctl stop firewalld + ``` + +2. 在root权限下关闭防火墙。 + + ```shell + systemctl disable firewalld + ``` + + >![](./public_sys-resources/icon-note.gif) **说明:** + >执行disable命令关闭防火墙的同时,也取消了开机自启动。 + +#### 修改SELINUX为disabled + +1. 在root权限下修改配置文件。 + + ```shell + sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux + ``` + +#### 创建组和用户 + +>![](./public_sys-resources/icon-note.gif) **说明:** +>服务器环境下,为了系统安全,通常会为进程分配单独的用户,以实现权限隔离。本章节创建的组和用户都是操作系统层面的,不是数据库层面的。 + +在root权限下创建MySQL用户(组)。 + +```shell +groupadd mysql +``` + +```shell +useradd -r -g mysql -s /sbin/nologin mysql +``` + +#### 搭建数据盘 + +>![](./public_sys-resources/icon-note.gif) **说明:** +> 测试极限性能时,建议单独挂载IO性能更优的NVME SSD存储介质创建GreatSQL测试实例,避免磁盘IO对性能测试结果的影响,本文以单独挂载NVME SSD为例,参考步骤1\~步骤4。 +> 非性能测试时,在root权限下执行以下命令,创建数据目录即可。然后跳过本小节: +> mkdir /data + +1. 在root权限下创建文件系统(以xfs为例,根据实际需求创建文件系统),若磁盘之前已做过文件系统,执行此命令会出现报错,可使用-f参数强制创建文件系统。 + + ```shell + mkfs.xfs /dev/nvme0n1 + ``` + +2. 在root权限下创建数据目录。 + + ```shell + mkdir /data + ``` + +3. 在root权限下挂载磁盘。 + + ```shell + mount -o noatime,nobarrier /dev/nvme0n1 /data + ``` + +#### 创建数据库目录 + +在已创建的数据目录 **/data** 基础上,使用root权限继续创建进程所需的相关目录并授权MySQL用户(组)。 + +```shell +mkdir -p /data/GreatSQL +cd /data/GreatSQL +chown -R mysql:mysql /data/GreatSQL +``` + +### 安装、运行和卸载 + +#### 安装 + +>![](./public_sys-resources/icon-caution.gif) **注意:** +> 安装GreatSQL前请先检查是否已先安装了MySQL/Percona Server For MySQL/MariaDB等这些MySQL同态数据库,如果已经安装需要先卸载,否则无法再安装GreatSQL,会产生冲突。 + +1. 配置本地yum源,详细信息请参考[搭建repo服务器](./搭建repo服务器.md)章节。 + +2. 清除缓存。 + + ```shell + dnf clean all + ``` + +3. 创建缓存。 + + ```shell + dnf makecache + ``` + +4. 在root权限下安装MySQL服务器。 + + ```shell + dnf install greatsql-server + ``` + + 如果安装时遇到冲突报错,需要先卸载MySQL/Percona Server For MySQL/MariaDB等MySQL同态数据库。 + +5. 查看安装后的rpm包。 + + ```shell + rpm -qa | grep greatsql-server + ``` + +#### 运行 + +1. 在root权限下修改/etc/my.cnf文件,包括软件安装路径basedir、数据路径datadir、监听端口号port、内存缓冲区innodb_buffer_pool_size等根据实际情况修改。 + + ```shell + vi /etc/my.cnf + ``` + + 编辑/etc/my.cnf内容如下(下面是一个最基本参考): + + ```shell + [client] + datadir = /data/GreatSQL/mysql.sock + + [mysqld] + !includedir /etc/my.cnf.d + user = mysql + datadir = /data/GreatSQL + socket = /data/GreatSQL/mysql.sock + log-error = /data/GreatSQL/mysqld.log + pid-file = /data/GreatSQL/mysqld.pid + slow_query_log = ON + long_query_time = 0.01 + log_slow_verbosity = FULL + log_error_verbosity = 3 + innodb_buffer_pool_size = 1G + innodb_redo_log_capacity = 256M + innodb_io_capacity = 10000 + innodb_io_capacity_max = 20000 + innodb_flush_sync = OFF + ``` + + 如果想要让GreatSQL获得更好的运行状态和性能,可以参考GreatSQL社区提供的[my.cnf配置文件参考模板](https://gitee.com/GreatSQL/GreatSQL-Doc/blob/master/docs/my.cnf-example)。 + +2. 确保my.cnf配置文件修改正确。 + + ```shell + cat /etc/my.cnf + ``` + + ![](./figures/zh-cn_image_0231563137.png) + +3. 在root权限下启动GreatSQL数据库。 + + ```shell + systemctl start mysqld + ``` + + 首次启动会比较慢,可能需要数分钟,因为包含初始化GreatSQL数据库的工作。 + + 待初始化完成后,查看`datadir`配置参数对应的目录下是否已有数据文件,以及相应的日志文件`/data/GreatSQL/mysqld.log`。 + + ```shell + ls -la /data/GreatSQL + ``` + + 查看`/data/GreatSQL/mysqld.log`日志文件,若其中包括“Bootstrapping complete”表示初始化数据库完成,且包含“A temporary password is generated for root@localhost: =dz;kqt8svrF”这样的信息,则其中的“=dz;kqt8svrF”为GreatSQL数据库root账户的初始密码,第一次登入后要立即修改才能继续使用GreatSQL。 + +4. 登录数据库。 + + >![](./public_sys-resources/icon-note.gif) **说明:** + >- 提示输入密码时,请输入[步骤4](#li15634560588)产生的初始密码。 + + ```shell + mysql -uroot -p + ``` + + ![](./figures/zh-cn_image_0231563138.png) + +5. 修改初始化密码 + + 如上面截图所示,首次登录GreatSQL数据库后,需要先修改临时初始密码才能继续后面的操作。 + + ```shell + greatsql [(none)]> \s + ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. + greatsql [(none)]> ALTER USER USER() IDENTIFIED BY 'GreatSQL@202X'; + Query OK, 0 rows affected (0.00 sec) + ``` + +6. 创建一个允许从任何服务器访问的数据库账户GreatSQL,并授权允许该账户对名为test的数据库下所有数据对象的所有操作权限 + + ```shell + -- 在这里指定新账户GreatSQL的密码为"GreatSQL-202X",建议修改成您自己设定成其他密码 + greatsql [(none)]> CREATE USER GreatSQL@'%' IDENTIFIED BY 'GreatSQL-202X'; + Query OK, 0 rows affected (0.00 sec) + + greatsql [(none)]> GRANT ALL ON test.* TO GreatSQL@'%'; + Query OK, 0 rows affected (0.00 sec) + ``` + +7. 创建名为test的新数据库 + + ```shell + greatsql [(none)]> CREATE DATABASE test; + Query OK, 1 row affected (0.00 sec) + ``` + +8. 退出数据库。 + + 执行 `\q` 或者 `exit` 退出数据库。 + + ```shell + greatsql> exit + ``` + +9. 切换新创建的GreatSQL账户登录,并操作数据库 + + ```shell + -- 这里使用上面创建GreatSQL新账户时指定的密码 "GreatSQL-202X",或者修改成您自己设定的密码 + -- 后面指定test是指登录后立即使用test数据库,要带空格,否则会被认为是密码 + mysql -uGreatSQL -p test + Enter password: + ... + + -- 创建新表 + greatsql [test]> CREATE TABLE t1(id INT PRIMARY KEY); + Query OK, 0 rows affected (1.48 sec) + + -- 查看都有哪些数据表 + greatsql [test]> SHOW TABLES; + +----------------+ + | Tables_in_test | + +----------------+ + | t1 | + +----------------+ + 1 row in set (0.00 sec) + + -- 写入测试数据 + greatsql [test]> INSERT INTO t1 SELECT RAND()*1024; + Query OK, 1 row affected (0.34 sec) + Records: 1 Duplicates: 0 Warnings: 0 + + -- 查询数据 + greatsql [test]> SELECT * FROM t1; + +-----+ + | id | + +-----+ + | 565 | + +-----+ + 1 row in set (0.00 sec) + ``` + +这就完成了对GreatSQL数据库的基本操作。 + +更多相关SQL命令/语法详见手册:[SQL Statements](https://dev.mysql.com/doc/refman/8.0/en/sql-statements.html)。 + +更多基于 GreatSQL 的应用开发内容请参考:[应用开发](https://greatsql.cn/docs/12-dev-guide/12-dev-guide.html)。 + +#### 卸载GreatSQL + +1. 在root权限下关闭数据库进程。 + + ```shell + systemctl stop mysqld + ``` + +2. 在root权限下执行**dnf remove -y greatsql-server**命令卸载GreatSQL。 + + ```shell + dnf remove -y greasql-server + ``` + +### 管理数据库用户 + +#### 创建用户 + +可以使用CREATE USER语句来创建一个或多个用户,并设置相应的口令。 + +```shell +CREATE USER 'username'@'hostname' IDENTIFIED BY 'password'; +``` + +其中: + +- username:用户名。 +- host:主机名,即用户连接数据库时所在的主机的名字。若是本地用户可用localhost,若在创建的过程中,未指定主机名,则主机名默认为“%”,表示一组主机。 +- password:用户的登录密码,密码可以为空,如果为空则该用户可以不需要密码登录服务器,但从安全的角度而言,不推荐这种做法。 + +使用CREATE USER语句必须拥有数据库的INSERT权限或全局CREATE USER权限。 + +使用CREATE USER语句创建一个用户帐号后,会在系统自身的数据库的user表中添加一条新记录。若创建的帐户已经存在,则语句执行时会出现错误。 + +新创建的用户拥有的权限很少,只允许进行不需要权限的操作,如使用SHOW语句查询所有存储引擎和字符集的列表等。 + +##### 示例 + +创建密码为"GreatSQL@202X-local",用户名为**GreatSQL_local**的本地用户。 + +```shell +CREATE USER GreatSQL_local@localhost IDENTIFIED BY 'GreatSQL@202X'; +``` + +创建密码为"GreatSQL@202X-remote",用户名为**GreatSQL_remote**,主机名为**192.168.1.100**的用户。 + +```shell +CREATE USER 'GreatSQL_remote'@'192.168.1.100' IDENTIFIED BY 'GreatSQL@202X-remote'; +``` + +#### 查看用户 + +可以使用SHOW GRANTS语句或SELECT语句查看一个或多个用户。 + +查看特定用户: + +```shell +SHOW GRANTS [FOR 'username'@'hostname']; +``` + +```shell +SELECT USER,HOST,PASSWORD FROM mysql.user WHERE USER='username'; +``` + +查看所有用户: + +```shell +SELECT USER,HOST FROM mysql.user; +``` + +其中: + +- username:用户名。 +- hostname:主机名。 + +##### 示例 + +查看userexample1用户。 + +```sql +SHOW GRANTS FOR GreatSQL; ++----------------------------------------------------+ +| Grants for GreatSQL@% | ++----------------------------------------------------+ +| GRANT USAGE ON *.* TO `GreatSQL`@`%` | +| GRANT ALL PRIVILEGES ON `test`.* TO `GreatSQL`@`%` | ++----------------------------------------------------+ +2 rows in set (0.00 sec) +``` + +#### 修改用户 + +##### 修改用户名 + +可以使用RENAME USER语句修改一个或多个已经存在的用户名。 + +```shell +RENAME USER 'oldusername'@'hostname' TO 'newusername'@'hostname'; +``` + +其中: + +- oldusername:旧的用户名。 +- newusername:新的用户名。 +- hostname:主机名。 + +RENAME USER语句用于对原有的帐号进行重命名。若系统中旧帐号不存在或者新帐号已存在,则该语句执行时会出现错误。 + +使用RENAME USER语句,必须拥有数据库的UPDATE权限或全局CREATE USER权限。 + +##### 修改用户示例 + +将用户名userexample1修改为userexapme2,主机名为locahost。 + +```shell +> RENAME USER 'userexample1'@'localhost' TO 'userexample2'@'localhost'; +``` + +##### 修改用户密码 + +可以使用SET PASSWORD语句修改一个用户的登录密码。 + +```shell +SET PASSWORD FOR 'username'@'hostname' = 'newpassword'; +``` + +其中: + +- FOR 'username'@'hostname':FOR字句,可选项,指定欲修改密码的用户名及主机名。 +- 'newpassword':新密码。 + +在SET PASSWORD语句中,若不加上FOR子句,表示修改当前用户的密码。 + +FOR字句中必须以'username'@'hostname'的格式给定,username为帐户的用户名,hostname为帐户的主机名。 + +欲修改密码的帐号必须在系统中存在,否则语句执行时会出现错误。 + +**建议**:更推荐使用`ALTER USER`命令来修改数据库中的账号密码。 + +##### 修改用户密码示例 + +将用户名为GreatSQL_remote的密码修改为"GreatSQL@@202X-remote"。 + +```shell +SET PASSWORD FOR 'GreatSQL_remote'@'192.168.1.100' = 'GreatSQL@@202X-remote'; +``` + +#### 删除用户 + +可以使用DROP USER语句来删除一个或多个用户帐号以及相关的权限。 + +```shell +DROP USER 'username1'@'hostname1' [,'username2'@'hostname2']…; +``` + +>![](./public_sys-resources/icon-caution.gif) **注意:** +>用户的删除不会影响他们之前所创建的表、索引或其他数据库对象,因为数据库并不会记录创建了这些对象的帐号。 + +DROP USER语句可用于删除一个或多个数据库帐号,并删除其原有权限。 + +使用DROP USER语句必须拥有数据库的DELETE权限或全局CREATE USER权限。 + +在DROP USER语句的使用中,若没有明确地给出帐号的主机名,则该主机名默认为“%”。 + +##### 示例 + +删除用户名为userexample的本地用户。 + +```shell +DROP USER 'userexample'@'localhost'; +``` + +#### 用户授权 + +可以使用GRANT语句来对新建用户的授权。 + +```shell +GRANT privileges ON databasename.tablename TO 'username'@'hostname'; +``` + +其中: + +- ON字句:用于指定权限授予的对象和级别。 +- privileges:用户的操作权限,如SELECT,INSERT,UPDATE等,如果要授予所有的权限则使用ALL。 +- databasename:数据库名。 +- tablename:表名。 +- TO字句:用来设定用户密码,以及指定被赋予权限的用户。 +- username:用户名。 +- hostname:主机名。 + +如果要授予该用户对所有数据库和表的相应操作权限则可用\*表示,如\*.\*。 + +如果在TO子句中给系统中存在的用户指定密码,则新密码会将原密码覆盖。 + +如果权限被授予给一个不存在的用户,则会自动执行一条CREATE USER语句来创建这个用户,但同时必须为该用户指定密码。 + +##### 示例 + +对本地用户userexample授予SELECT和INSERT权限。 + +```shell +GRANT SELECT,INSERT ON *.* TO 'userexample'@'localhost'; +``` + +#### 回收用户权限 + +可以使用REVOKE语句来回收一个用户的权限,但此用户不会被删除。 + +```shell +REVOKE privilege ON databasename.tablename FROM 'username'@'hostname'; +``` + +其中REVOKE语句的参数与GRANT语句的参数含义相同。 + +要使用 REVOKE 语句,必须拥有数据库的全局CREATE USER权限或UPDATE权限。 + +##### 示例 + +回收本地用户userexample的INSERT权限。 + +```shell +REVOKE INSERT ON *.* FROM 'userexample'@'localhost'; +``` + +### 管理数据库 + +#### 创建数据库 + +可以使用CREATE DATABASE语句来创建数据库。 + +```shell +CREATE DATABASE databasename; +``` + +其中:databasename为数据库名称,且数据库名称不区分大小写。 + +##### 示例 + +创建数据库名为databaseexample的数据库。 + +```shell +CREATE DATABASE databaseexample; +``` + +#### 查看数据库 + +可以使用SHOW DATABASES语句来查看数据库。 + +```shell +SHOW DATABASES; +``` + +##### 示例 + +查看所有数据库。 + +```shell +SHOW DATABASES; +``` + +#### 选择数据库 + +一般创建表,查询表等操作首先需要选择一个目标数据库。可以使用USE语句来选择数据库。 + +```shell +USE databasename; +``` + +其中:databasename为数据库名称。 + +##### 示例 + +选择databaseexample数据库。 + +```shell +USE databaseexample; +``` + +#### 删除数据库 + +可以使用DROP DATABASE语句来删除数据库。 + +>![](./public_sys-resources/icon-caution.gif) **注意:** +>删除数据库要谨慎操作,一旦删除,数据库中的所有表和数据都会删除。 + +```shell +DROP DATABASE databasename; +``` + +其中:databasename为数据库名称。 + +DROP DATABASE命令用于删除创建过\(已存在\)的数据库,且会删除数据库中的所有表,但数据库的用户权限不会自动删除。 + +要使用DROP DATABASE,您需要数据库的DROP权限。 + +DROP SCHEMA是DROP DATABASE的同义词。 + +##### 示例 + +删除databaseexample数据库。 + +```shell +DROP DATABASE databaseexample; +``` + +#### 备份数据库 + +可以在root权限下使用mysqldump命令备份数据库。 + +备份一个或多个表: + +```shell +mysqldump [options] databasename [tablename ...] > outfile +``` + +备份一个或多个库: + +```shell +mysqldump [options] -databases databasename ... > outfile +``` + +备份所有库: + +```shell +mysqldump [options] -all-databases > outputfile +``` + +其中: + +- databasename:数据库名称。 +- tablename:数据表名称。 +- outfile:数据库备份的文件。 +- options:mysqldump命令参数选项,多个参数之间可以使用空格分隔。常用的mysqldump命令参数选项如下: + - -u, \-\-user= _username_ :指定用户名。 + - -p, \-\-password\[= _password_\]:指定密码,在下面的例子中密码都指定为123456,您需要根据实际情况调整。 + - -P, \-\-port= _portnumber_ :指定端口。 + - -h, \-\-host= _hostname_ :指定主机名。 + - -r, \-\-result-file= _filename_ :将导出结果保存到指定的文件中,等同于“\>”。 + - -t:只备份数据。 + - -d:只备份表结构。 + +##### 示例 + +备份主机为192.168.202.144,端口为3306,root用户下的所有有权限读取的数据库到alldb.sql中。 + +```shell +mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 --all-databases > alldb.sql ``` 备份主机为192.168.202.144,端口为3306,root用户下的db1数据库到db1.sql中。 ```shell -# mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 --databases db1 > db1.sql +mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 --databases db1 > db1.sql ``` 备份主机为192.168.202.144,端口为3306,root用户下的db1数据库的tb1表到db1tb1.sql中。 ```shell -# mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 db1 tb1 > db1tb1.sql +mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 db1 tb1 > db1tb1.sql ``` 只备份主机为192.168.202.144,端口为3306,root用户下的db1数据库的表结构到db1.sql中。 ```shell -# mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 -d db1 > db1.sql +mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 -d db1 > db1.sql ``` 只备份主机为192.168.202.144,端口为3306,root用户下的db1数据库的数据到db1.sql中。 ```shell -# mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 -t db1 > db1.sql +mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 -t db1 > db1.sql ``` #### 恢复数据库 diff --git "a/docs/zh/docs/Administration/\346\237\245\347\234\213\347\263\273\347\273\237\344\277\241\346\201\257.md" "b/docs/zh/docs/Administration/\346\237\245\347\234\213\347\263\273\347\273\237\344\277\241\346\201\257.md" index e35099b2b02326ad921af2cc586443c25a23deab..e52582d12020ca81b006d444ac5c0b522020a177 100644 --- "a/docs/zh/docs/Administration/\346\237\245\347\234\213\347\263\273\347\273\237\344\277\241\346\201\257.md" +++ "b/docs/zh/docs/Administration/\346\237\245\347\234\213\347\263\273\347\273\237\344\277\241\346\201\257.md" @@ -3,7 +3,7 @@ - 查看系统信息,命令如下: ```shell - cat /etc/os-release + $ cat /etc/os-release ``` 例如,命令和输出如下: @@ -23,23 +23,23 @@ 查看CPU信息,命令如下: ```shell - # lscpu + $ lscpu ``` 查看内存信息,命令如下: ```shell - free + $ free ``` 查看磁盘信息,命令如下: ```shell - fdisk -l + $ fdisk -l ``` - 查看系统资源实时信息,命令如下: ```shell - top + $ top ``` diff --git "a/docs/zh/docs/Administration/\350\277\234\347\250\213\350\257\201\346\230\216\357\274\210\351\262\262\351\271\217\345\256\211\345\205\250\345\272\223\357\274\211.md" "b/docs/zh/docs/Administration/\350\277\234\347\250\213\350\257\201\346\230\216\357\274\210\351\262\262\351\271\217\345\256\211\345\205\250\345\272\223\357\274\211.md" new file mode 100644 index 0000000000000000000000000000000000000000..e3ccf7f0e6c364098b8d55b58b43175d78402a1a --- /dev/null +++ "b/docs/zh/docs/Administration/\350\277\234\347\250\213\350\257\201\346\230\216\357\274\210\351\262\262\351\271\217\345\256\211\345\205\250\345\272\223\357\274\211.md" @@ -0,0 +1,400 @@ +# 远程证明(鲲鹏安全库) + +## 介绍 + +本项目开发运行在鲲鹏处理器上的基础安全软件组件,前期主要聚焦在远程证明等可信计算相关领域,使能社区安全开发者。 + +## 软件架构 + +在未使能TEE的平台上,本项目可提供平台远程证明特性,其软件架构如下图所示: + +![img](./figures/RA-arch-1.png) + +在已使能TEE的平台上,本项目可提供TEE远程证明特性,其软件架构如下图所示: + +![img](./figures/RA-arch-2.png) + +## 安装配置 + +1. 使用yum安装程序的rpm包,命令如下: + + ```shell + # yum install kunpengsecl-ras kunpengsecl-rac kunpengsecl-rahub kunpengsecl-qcaserver kunpengsecl-attester kunpengsecl-tas kunpengsecl-devel + ``` + +2. 准备数据库环境:进入 `/usr/share/attestation/ras` 目录,执行 `prepare-database-env.sh` 脚本进行自动化的数据库环境配置。 + +3. 程序运行时依赖的配置文件有三个路径,分别为:当前路径 `./config.yaml` ,家路径 `${HOME}/.config/attestation/ras(rac)(rahub)(qcaserver)(attester)(tas)/config.yaml` ,以及系统路径 `/etc/attestation/ras(rac)(rahub)(qcaserver)(attester)(tas)/config.yaml` 。 + +4. (可选)如果需要创建家目录配置文件,可在安装好rpm包后,执行位于 `/usr/share/attestation/ras(rac)(rahub)(qcaserver)(attester)(tas)` 下的脚本 `prepare-ras(rac)(hub)(qca)(attester)(tas)conf-env.sh` 从而完成家目录配置文件的部署。 + +## 相关参数 + +### RAS启动参数 + +命令行输入 `ras` 即可启动RAS程序。请注意,在当前目录下需要提供**ECDSA**公钥并命名为 `ecdsakey.pub` 。相关参数如下: + +```shell + -H --https http/https模式开关,默认为https(true),false=http + -h --hport https模式下RAS监听的restful api端口 + -p, --port string RAS监听的client api端口 + -r, --rest string http模式下RAS监听的restful api端口 + -T, --token 生成一个测试用的验证码并退出 + -v, --verbose 打印更详细的RAS运行时日志信息 + -V, --version 打印RAS版本并退出 +``` + +### RAC启动参数 + +命令行输入 `sudo raagent` 即可启动RAC程序,请注意,物理TPM模块的开启需要sudo权限。相关参数如下: + +```shell + -s, --server string 指定待连接的RAS服务端口 + -t, --test 以测试模式启动 + -v, --verbose 打印更详细的RAC运行时日志信息 + -V, --version 打印RAC版本并退出 + -i, --imalog 指定ima文件路径 + -b, --bioslog 指定bios文件路径 + -T, --tatest 以TA测试模式启动 +``` + +**注意:** +>1.若要使用TEE远程证明特性,需要以非TA测试模式启动RAC,并将待证明TA的uuid、是否使用TCB、mem_hash和img_hash按序放入RAC执行路径下的**talist**文件内。同时预装由TEE团队提供的**libqca.so**库和**libteec.so**库。**talist**文件格式如下: +> +>```text +>e08f7eca-e875-440e-9ab0-5f381136c600 false ccd5160c6461e19214c0d8787281a1e3c4048850352abe45ce86e12dd3df9fde 46d5019b0a7ffbb87ad71ea629ebd6f568140c95d7b452011acfa2f9daf61c7a +>``` +> +>2.若不使用TEE远程证明特性,则需要将 `/usr/share/attestation/qcaserver` 目录下的libqca.so库和libteec.so库复制到 `/usr/lib` 或 `/usr/lib64` 目录,并以TA测试模式启动RAC。 + +### QCA启动参数 + +命令行输入 `/usr/bin/qcaserver` 即可启动QCA程序,请注意,这里必须要使用qcaserver的完整路径以正常启动QTA,同时需要使QTA中的CA路径参数与该路径保持相同。相关参数如下: + +```shell + -C, --scenario int 设置程序的应用场景,默认为no_as场景(0),1=as_no_daa场景,2=as_with_daa场景 + -S, --server string 指定开放的服务器地址/端口 +``` + +### ATTESTER启动参数 + +命令行输入 `attester` 即可启动ATTESTER程序。相关参数如下: + +```shell + -B, --basevalue string 设置基准值文件读取路径 + -M, --mspolicy int 设置度量策略,默认为-1,需要手动指定。1=仅比对img-hash值,2=仅比对hash值,3=同时比对img-hash和hash两个值 + -S, --server string 指定待连接的服务器地址 + -U, --uuid int 指定待验证的可信应用 + -V, --version 打印程序版本并退出 + -T, --test 读取固定的nonce值以匹配目前硬编码的可信报告 +``` + +### TAS启动参数 + +命令行输入 `tas` 即可启动TAS程序。相关参数如下: + +```shell + -T, --token 生成一个测试用的验证码并退出 +``` + +**注意:** +>1.若要启用TAS服务,需要先为TAS配置好私钥。可以按如下命令修改家目录下的配置文件: +> +>```shell +># cd ${HOME}/.config/attestation/tas +># vim config.yaml +> # 如下DAA_GRP_KEY_SK_X和DAA_GRP_KEY_SK_Y的值仅用于测试,正常使用前请务必更新其内容以保证安全。 +>tasconfig: +> port: 127.0.0.1:40008 +> rest: 127.0.0.1:40009 +> akskeycertfile: ./ascert.crt +> aksprivkeyfile: ./aspriv.key +> huaweiitcafile: ./Huawei IT Product CA.pem +> DAA_GRP_KEY_SK_X: 65a9bf91ac8832379ff04dd2c6def16d48a56be244f6e19274e97881a776543c65a9bf91ac8832379ff04dd2c6def16d48a56be244f6e19274e97881a776543c +> DAA_GRP_KEY_SK_Y: 126f74258bb0ceca2ae7522c51825f980549ec1ef24f81d189d17e38f1773b56126f74258bb0ceca2ae7522c51825f980549ec1ef24f81d189d17e38f1773b56 +>``` +> +>之后再输入`tas`启动TAS程序。 +> +>2.在有TAS环境中,为提高QCA配置证书的效率,并非每一次启动都需要访问TAS以生成相应证书,而是通过证书的本地化存储,即读取QCA侧 `config.yaml` 中配置的证书路径,通过 `func hasAKCert(s int) bool` 函数检查是否已有TAS签发的证书保存于本地,若成功读取证书,则无需访问TAS,若读取证书失败,则需要访问TAS,并将TAS返回的证书保存于本地。 + +## 接口定义 + +### RAS接口 + +为了便于管理员对目标服务器、RAS以及目标服务器上部署的TEE中的用户 TA 进行管理,本程序设计了以下接口可供调用: + +| 接口 | 方法 | +| --------------------------------- | --------------------------- | +| / | GET | +| /{id} | GET、POST、DELETE | +| /{from}/{to} | GET | +| /{id}/reports | GET | +| /{id}/reports/{reportid} | GET、DELETE | +| /{id}/basevalues | GET | +| /{id}/newbasevalue | POST | +| /{id}/basevalues/{basevalueid} | GET、POST、DELETE | +| /{id}/ta/{tauuid}/status | GET | +| /{id}/ta/{tauuid}/tabasevalues | GET | +| /{id}/ta/{tauuid}/tabasevalues/{tabasevalueid} | GET、POST、DELETE | +| /{id}/ta/{tauuid}/newtabasevalue | POST | +| /{id}/ta/{tauuid}/tareports | GET | +| /{id}/ta/{tauuid}/tareports/{tareportid} | GET、POST、DELETE | +| /{id}/basevalues/{basevalueid} | GET、DELETE | +| /version | GET | +| /config | GET、POST | +| /{id}/container/status | GET | +| /{id}/device/status | GET | + +上述接口的具体用法分别介绍如下。 + +若需要查询所有服务器的信息,可以使用`"/"`接口。 + +```shell +# curl -X GET -H "Content-Type: application/json" http://localhost:40002/ +``` + +*** +若需要查询目标服务器的详细信息,可以使用`"/{id}"`接口的`GET`方法,其中{id}是RAS为目标服务器分配的唯一标识号。 + +```shell +# curl -X GET -H "Content-Type: application/json" http://localhost:40002/1 +``` + +*** +若需要修改目标服务器的信息,可以使用`"/{id}"`接口的`POST`方法,其中$AUTHTOKEN是事先使用`ras -T`自动生成的身份验证码。 + +```go +type clientInfo struct { + Registered *bool `json:"registered"` // 目标服务器注册状态 + IsAutoUpdate *bool `json:"isautoupdate"`// 目标服务器基准值更新策略 +} +``` + +```shell +# curl -X POST -H "Authorization: $AUTHTOKEN" -H "Content-Type: application/json" http://localhost:40002/1 -d '{"registered":false, "isautoupdate":false}' +``` + +*** +若需要删除目标服务器,可以使用`"/{id}"`接口的`DELETE`方法。 +**注意:** +>使用该方法并非删除目标服务器的所有信息,而是把目标服务器的注册状态置为`false`! + +```shell +# curl -X DELETE -H "Authorization: $AUTHTOKEN" -H "Content-Type: application/json" http://localhost:40002/1 +``` + +*** +若需要查询指定范围内的所有服务器信息,可以使用`"/{from}/{to}"`接口的`GET`方法。 + +```shell +# curl -X GET -H "Content-Type: application/json" http://localhost:40002/1/9 +``` + +*** +若需要查询目标服务器的所有可信报告,可以使用`"/{id}/reports"`接口的`GET`方法。 + +```shell +# curl -X GET -H "Content-Type: application/json" http://localhost:40002/1/reports +``` + +*** +若需要查询目标服务器指定可信报告的详细信息,可以使用`"/{id}/reports/{reportid}"`接口的`GET`方法,其中{reportid}是RAS为目标服务器指定可信报告分配的唯一标识号。 + +```shell +# curl -X GET -H "Content-Type: application/json" http://localhost:40002/1/reports/1 +``` + +*** +若需要删除目标服务器指定可信报告,可以使用`"/{id}/reports/{reportid}"`接口的`DELETE`方法。 +**注意:** +>使用该方法将删除指定可信报告的所有信息,将无法再通过接口对该报告进行查询! + +```shell +# curl -X DELETE -H "Authorization: $AUTHTOKEN" -H "Content-Type: application/json" http://localhost:40002/1/reports/1 +``` + +*** +若需要查询目标服务器的所有基准值,可以使用`"/{id}/basevalues"`接口的`GET`方法。 + +```shell +# curl -X GET -H "Content-Type: application/json" http://localhost:40002/1/basevalues +``` + +*** +若需要给目标服务器新增一条基准值信息,可以使用`"/{id}/newbasevalue"`接口的`POST`方法。 + +```go +type baseValueJson struct { + BaseType string `json:"basetype"` // 基准值类型 + Uuid string `json:"uuid"` // 容器或设备的标识号 + Name string `json:"name"` // 基准值名称 + Enabled bool `json:"enabled"` // 基准值是否可用 + Pcr string `json:"pcr"` // PCR值 + Bios string `json:"bios"` // BIOS值 + Ima string `json:"ima"` // IMA值 + IsNewGroup bool `json:"isnewgroup"` // 是否为一组新的基准值 +} +``` + +```shell +# curl -X POST -H "Authorization: $AUTHTOKEN" -H "Content-Type: application/json" http://localhost:40002/1/newbasevalue -d '{"name":"test", "basetype":"host", "enabled":true, "pcr":"testpcr", "bios":"testbios", "ima":"testima", "isnewgroup":true}' +``` + +*** +若需要查询目标服务器指定基准值的详细信息,可以使用`"/{id}/basevalues/{basevalueid}"`接口的`GET`方法,其中{basevalueid}是RAS为目标服务器指定基准值分配的唯一标识号。 + +```shell +# curl -X GET -H "Content-Type: application/json" http://localhost:40002/1/basevalues/1 +``` + +*** +若需要修改目标服务器指定基准值的可用状态,可以使用`"/{id}/basevalues/{basevalueid}"`接口的`POST`方法。 + +```shell +# curl -X POST -H "Content-type: application/json" -H "Authorization: $AUTHTOKEN" http://localhost:40002/1/basevalues/1 -d '{"enabled":true}' +``` + +*** +若需要删除目标服务器指定基准值,可以使用`"/{id}/basevalues/{basevalueid}"`接口的`DELETE`方法。 +**注意:** +>使用该方法将删除指定基准值的所有信息,将无法再通过接口对该基准值进行查询! + +```shell +# curl -X DELETE -H "Authorization: $AUTHTOKEN" -H "Content-Type: application/json" http://localhost:40002/1/basevalues/1 +``` + +*** +若需要查询目标服务器上特定用户 TA 的可信状态,可以使用`"/{id}/ta/{tauuid}/status"`接口的GET方法。其中{id}是RAS为目标服务器分配的唯一标识号,{tauuid}是特定用户 TA 的身份标识号。 + +```shell +# curl -X GET -H "Content-type: application/json" -H "Authorization: $AUTHTOKEN" http://localhost:40002/1/ta/test/status +``` + +*** +若需要查询目标服务器上特定用户 TA 的所有基准值信息,可以使用`"/{id}/ta/{tauuid}/tabasevalues"`接口的GET方法。 + +```shell +# curl -X GET -H "Content-type: application/json" http://localhost:40002/1/ta/test/tabasevalues +``` + +*** +若需要查询目标服务器上特定用户 TA 的指定基准值的详细信息,可以使用`"/{id}/ta/{tauuid}/tabasevalues/{tabasevalueid}"`接口的GET方法。其中{tabasevalueid}是RAS为目标服务器上特定用户 TA 的指定基准值分配的唯一标识号。 + +```shell +# curl -X GET -H "Content-type: application/json" http://localhost:40002/1/ta/test/tabasevalues/1 +``` + +*** +若需要修改目标服务器上特定用户 TA 的指定基准值的可用状态,可以使用`"/{id}/ta/{tauuid}/tabasevalues/{tabasevalueid}"`接口的`POST`方法。 + +```shell +# curl -X POST -H "Content-type: application/json" -H "Authorization: $AUTHTOKEN" http://localhost:40002/1/ta/test/tabasevalues/1 --data '{"enabled":true}' +``` + +*** +若需要删除目标服务器上特定用户 TA 的指定基准值,可以使用`"/{id}/ta/{tauuid}/tabasevalues/{tabasevalueid}"`接口的`DELETE`方法。 +**注意:** +>使用该方法将删除指定基准值的所有信息,将无法再通过接口对该基准值进行查询! + +```shell +# curl -X DELETE -H "Content-type: application/json" -H "Authorization: $AUTHTOKEN" -k http://localhost:40002/1/ta/test/tabasevalues/1 +``` + +*** +若需要给目标服务器上特定用户 TA 新增一条基准值信息,可以使用`"/{id}/ta/{tauuid}/newtabasevalue"`接口的`POST`方法。 + +```go +type tabaseValueJson struct { + Uuid string `json:"uuid"` // 用户 TA 的标识号 + Name string `json:"name"` // 基准值名称 + Enabled bool `json:"enabled"` // 基准值是否可用 + Valueinfo string `json:"valueinfo"` // 镜像哈希值和内存哈希值 +} +``` + +```shell +# curl -X POST -H "Content-Type: application/json" -H "Authorization: $AUTHTOKEN" -k http://localhost:40002/1/ta/test/newtabasevalue -d '{"uuid":"test", "name":"testname", "enabled":true, "valueinfo":"test info"}' +``` + +*** +若需要查询目标服务器上特定用户 TA 的所有可信报告,可以使用`"/{id}/ta/{tauuid}/tareports"`接口的`GET`方法。 + +```shell +# curl -X GET -H "Content-type: application/json" http://localhost:40002/1/ta/test/tareports +``` + +*** +若需要查询目标服务器上特定用户 TA 的指定可信报告的详细信息,可以使用`"/{id}/ta/{tauuid}/tareports/{tareportid}"`接口的`GET`方法,其中{tareportid}是RAS为目标服务器上特定用户 TA 的指定可信报告分配的唯一标识号。 + +```shell +# curl -X GET -H "Content-type: application/json" http://localhost:40002/1/ta/test/tareports/2 +``` + +*** +若需要删除目标服务器上特定用户 TA 的指定可信报告,可以使用`"/{id}/ta/{tauuid}/tareports/{tareportid}"`接口的`DELETE`方法。 +**注意:** +>使用该方法将删除指定可信报告的所有信息,将无法再通过接口对该报告进行查询! + +```shell +# curl -X DELETE -H "Content-type: application/json" http://localhost:40002/1/ta/test/tareports/2 +``` + +*** +若需要获取本程序的版本信息,可以使用`"/version"`接口的`GET`方法。 + +```shell +# curl -X GET -H "Content-Type: application/json" http://localhost:40002/version +``` + +*** +若需要查询目标服务器/RAS/数据库的配置信息,可以使用`"/config"`接口的`GET`方法。 + +```shell +# curl -X GET -H "Content-Type: application/json" http://localhost:40002/config +``` + +*** +若需要修改目标服务器/RAS/数据库的配置信息,可以使用`"/config"`接口的`POST`方法。 + +```go +type cfgRecord struct { + // 目标服务器配置 + HBDuration string `json:"hbduration" form:"hbduration"` + TrustDuration string `json:"trustduration" form:"trustduration"` + DigestAlgorithm string `json:"digestalgorithm" form:"digestalgorithm"` + // RAS配置 + MgrStrategy string `json:"mgrstrategy" form:"mgrstrategy"` + ExtractRules string `json:"extractrules" form:"extractrules"` + IsAllupdate *bool `json:"isallupdate" form:"isallupdate"` + LogTestMode *bool `json:"logtestmode" form:"logtestmode"` +} +``` + +```shell +# curl -X POST -H "Authorization: $AUTHTOKEN" -H "Content-Type: application/json" http://localhost:40002/config -d '{"hbduration":"5s","trustduration":"20s","DigestAlgorithm":"sha256"}' +``` + +### TAS接口 + +为了便于管理员对TAS服务的远程控制,本程序设计了以下接口可供调用: + +| 接口 | 方法 | +| --------------------| ------------------| +| /config | GET、POST | + +若需要查询TAS的配置信息,可使用`"/config"`接口的`GET`方法: + +```shell +# curl -X GET -H "Content-Type: application/json" http://localhost:40009/config +``` + +*** +若需要修改TAS的配置信息,可使用`"/config"`接口的`POST`方法: + +```shell +curl -X POST -H "Content-Type: application/json" -H "Authorization: $AUTHTOKEN" http://localhost:40009/config -d '{"basevalue":"testvalue"}' +``` + +**注意:** +>TAS的配置信息读取与修改目前仅支持基准值 diff --git a/docs/zh/docs/ApplicationDev/FAQ.md b/docs/zh/docs/ApplicationDev/FAQ.md deleted file mode 100644 index b997844d819dd62509e039d9483c4305053927ee..0000000000000000000000000000000000000000 --- a/docs/zh/docs/ApplicationDev/FAQ.md +++ /dev/null @@ -1,19 +0,0 @@ -# FAQ - -## 部分依赖java-devel的应用程序自编译失败 - -### 问题描述 - -部分依赖java-devel的应用程序会出现使用rpmbuild命令自编译失败的问题。 - -### 原因分析 - -为了提供更新的openjdk特性和对广大java应用程序的兼容,openEuler同时提供了openjdk-1.8.0、openjdk-11等多个版本的openjdk。部分应用程序在编译时需要依赖java-devel包,安装java-devel包时系统会默认安装更高版本的java-11-openjdk,从而导致这些应用的编译失败。 - -### 解决方法 - -用户需手动使用如下命令安装java-1.8.0-openjdk后再使用rpmbuild命令进行自编译。 - -```shell -# yum install java-1.8.0-openjdk -``` diff --git "a/docs/zh/docs/ApplicationDev/\344\275\277\347\224\250Clang\347\274\226\350\257\221.md" "b/docs/zh/docs/ApplicationDev/\344\275\277\347\224\250Clang\347\274\226\350\257\221.md" index 2d25fd54df82d76231dd303bae176647b60968fb..4549e1759fa3196712ef58b6fcbacf76e0585c70 100644 --- "a/docs/zh/docs/ApplicationDev/\344\275\277\347\224\250Clang\347\274\226\350\257\221.md" +++ "b/docs/zh/docs/ApplicationDev/\344\275\277\347\224\250Clang\347\274\226\350\257\221.md" @@ -1,103 +1,90 @@ # 使用LLVM/Clang编译 本章介绍LLVM/Clang编译的一些基本知识,并通过示例进行实际演示。更多Clang使用方法请通过**clang --help**命令查询。 + - [使用LLVM/Clang编译](#使用llvmclang编译) - [简介](#简介) - - [LLVM/Clang安装](#llvmclang安装) - - [多版本共存支持](#多版本共存支持) - - [示例](#示例) + - [LLVM/Clang多版本安装](#LLVMClang多版本安装) + - [使用示例](#使用示例) + - [手动构建支持](#手动构建支持) ## 简介 -LLVM是一种涵盖多种编程语言和目标处理器的编译器,使用Clang作为C和C++的编译和驱动程序。Clang不仅仅可以将C, C++程序编译为LLVM中间表示的IR,也会调用所有以代码生成为目标的LLVM优化遍,直到生成最终的二进制文件。 +LLVM是一种涵盖多种编程语言和目标处理器的编译器,使用Clang作为C和C++的编译和驱动程序。Clang不仅仅可以将C/C++程序编译为LLVM中间表示的IR,也会调用所有以代码生成为目标的LLVM优化遍,直到生成最终的二进制文件。 -## LLVM/Clang安装 +## LLVM/Clang多版本安装 -openEuler操作系统中通过yum源安装Clang和LLVM软件包。默认安装llvm-12 +在openEuler操作系统中,Clang/LLVM工具链可通过官方yum仓库进行标准化安装。为兼容不同场景对LLVM版本的需求,系统采用主副版本共存机制:默认安装稳定主版本的同时,支持部署更高版本的LLVM。 -```shell -yum install llvm -yum install clang -yum install lld // openEuler yum源中目前没有lld-12版本 -``` +| openEuler版本 | LLVM主版本 | 安装方式 | LLVM副版本 | 安装方式 | +|----------------|------------|--------------------------|---------------|--------------------------------------------------------------------------| +| 22.03 LTS SP3 | LLVM12 | yum install -y clang | LLVM17、LLVM18 | yum install -y llvm-toolset-17
yum install -y llvm-toolset-18| +| 22.03 LTS SP4 | LLVM12 | yum install -y clang | LLVM17、LLVM18 | yum install -y llvm-toolset-17
yum install -y llvm-toolset-18| +| 24.03 LTS | LLVM17 | yum install -y clang | NA | NA | +| 24.03 LTS SP1 | LLVM17 | yum install -y clang | LLVM18 | yum install -y llvm-toolset-18| -验证安装是否成功 +以openEuler 22.03 LTS SP4为例,验证主版本安装是否成功: ```shell clang -v -``` - -若返回结果中包含clang版本信息,说明安装成功。 - -## 多版本共存支持 - -openEuler LLVM/Clang 多版本支持的方式如下: - -```text -yum包名: -llvm{-*} -clang{-*} -lld{-*} -bolt{-*} -例如: -clang15 -llvm15-devel - -安装路径: -/usr/lib64/llvm -例如: -/usr/lib64/llvm15 - -/usr/bin目录下会安装带有-后缀的可执行文件 -例如: -/usr/bin/clang-15 -/usr/bin/lld-15 -``` - -目前支持的LLVM/Clang版本有 -```text -llvm //默认llvm12 -llvm-15 +clang version 12.0.1 (openEuler 12.0.1-6.oe2203sp4 f4a7df2c51fa9eb3679555ef2de92c638ba9f880) +Target: aarch64-unknown-linux-gnu +Thread model: posix +InstalledDir: /usr/bin +Found candidate GCC installation: /usr/bin/../lib/gcc/aarch64-linux-gnu/10.3.1 +Found candidate GCC installation: /usr/lib/gcc/aarch64-linux-gnu/10.3.1 +Selected GCC installation: /usr/bin/../lib/gcc/aarch64-linux-gnu/10.3.1 +Candidate multilib: .;@m64 +Selected multilib: .;@m64 ``` -通过yum安装其他版本 +验证副版本安装是否成功: ```shell -yum install llvm15 -yum install clang15 -yum install lld15 -``` - -验证安装是否成功 +source /opt/openEuler/llvm-toolset-17/enable +clang -v -```shell -clang-15 -v +clang version 17.0.6 ( 17.0.6-4.oe2203sp4) +Target: aarch64-openEuler-linux-gnu +Thread model: posix +InstalledDir: /opt/openEuler/llvm-toolset-17/root/usr/bin +System configuration file directory: /etc/llvm-toolset-17-clang/ +Found candidate GCC installation: /usr/lib/gcc/aarch64-linux-gnu/10.3.1 +Selected GCC installation: /usr/lib/gcc/aarch64-linux-gnu/10.3.1 +Candidate multilib: .;@m64 +Selected multilib: .;@m64 ``` -## 示例 +若返回结果中包含clang版本信息,说明安装成功。 + +## 使用示例 -编译运行C/C++程序 +编译运行C/C++程序: ```shell -clang [command line flags] hello.c -o hello.o +clang [compiler-flags] hello.c -o hello.o ./hello.o ``` ```shell -clang++ [command line flags] hello.cpp -o hello.o +clang++ [compiler-flags] hello.cpp -o hello.o ./hello.o ``` -指定的链接器为LLVM的lld,若不指定它则使用默认的lld。 +指定链接器为LLVM的lld,若不指定则使用默认gcc的ld: ```shell -clang [command line flags] -fuse-ld=lld hello.c -o hello.o +clang [compiler-flags] -fuse-ld=lld hello.c -o hello.o ./hello.o ``` -其他通用信息请参考LLVM的[用户指导](https://llvm.org/docs/UserGuides.html) +## 手动构建支持 + +请参考openEuler [llvm-project源码仓](https://gitee.com/openeuler/llvm-project)。 + +更多信息请参考LLVM的[用户指导](https://llvm.org/docs/UserGuides.html)。 diff --git "a/docs/zh/docs/ApplicationDev/\345\274\200\345\217\221\347\216\257\345\242\203\345\207\206\345\244\207.md" "b/docs/zh/docs/ApplicationDev/\345\274\200\345\217\221\347\216\257\345\242\203\345\207\206\345\244\207.md" index a87ebc87d2d9247c644600d9f14cb9efbcb7e4de..d1e44c845d7d9afdbe9b6e5390bb55cdc3bfdc7f 100644 --- "a/docs/zh/docs/ApplicationDev/\345\274\200\345\217\221\347\216\257\345\242\203\345\207\206\345\244\207.md" +++ "b/docs/zh/docs/ApplicationDev/\345\274\200\345\217\221\347\216\257\345\242\203\345\207\206\345\244\207.md" @@ -38,7 +38,7 @@

硬盘

-

为了获得更好的应用体验,建议不小于120GB)

+

不小于32GB(为了获得更好的应用体验,建议不小于120GB)

支持IDE、SATA、SAS等接口的硬盘。

@@ -94,7 +94,7 @@ 操作系统要求为openEuler操作系统。 -openEuler操作系统具体安装方法请参考[安装指南](./../Installation/Installation.md),其中“软件选择”页面的“已选环境的附加选项”中将“开发工具”勾选。 +openEuler操作系统具体安装方法请参考[安装指南](./../Installation/installation.md),其中“软件选择”页面的“已选环境的附加选项”中将“开发工具”勾选。 ## 配置openEuler yum源 @@ -155,16 +155,16 @@ openEuler操作系统具体安装方法请参考[安装指南](./../Installation 架构分类如下: - - AArch64:AArch64架构的ISO。 - - x86\_64:x86\_64架构的ISO。 - - ARM32:嵌入式的Image。 + - AArch64:AArch64架构的ISO。 + - x86\_64:x86\_64架构的ISO。 + - ARM32:嵌入式的Image。 场景分类如下: - - 服务器:服务器场景的ISO。 - - 边缘计算:边缘计算场景的ISO。 - - 云计算:云计算场景的ISO。 - - 嵌入式:嵌入式的Image(只有选择AArch64或ARM32架构时,才可选该场景)。 + - 服务器:服务器场景的ISO。 + - 边缘计算:边缘计算场景的ISO。 + - 云计算:云计算场景的ISO。 + - 嵌入式:嵌入式的Image(只有选择AArch64或ARM32架构时,才可选该场景)。 6. 单击“AArch64”,选择AArch64架构。 7. 单击“服务器”,选择服务器场景。 @@ -172,9 +172,9 @@ openEuler操作系统具体安装方法请参考[安装指南](./../Installation 9. 单击该ISO对应的完整性校验文件“SHA256”,复制校验值到本地。 10. 登录openEuler操作系统,新建用于存放发布包的目录,如“~/iso”。 - ```shell + ```shell # mkdir ~/iso - ``` + ``` 11. 使用跨平台文件传输工具(如WinSCP)将本地的openEuler发布包上传到openEuler操作系统。 @@ -187,16 +187,16 @@ openEuler操作系统具体安装方法请参考[安装指南](./../Installation 架构分类如下: - - AArch64:AArch64架构的ISO。 - - x86\_64:x86\_64架构的ISO。 - - ARM32:嵌入式的Image。 + - AArch64:AArch64架构的ISO。 + - x86\_64:x86\_64架构的ISO。 + - ARM32:嵌入式的Image。 场景分类如下: - - 服务器:服务器场景的ISO。 - - 边缘计算:边缘计算场景的ISO。 - - 云计算:云计算场景的ISO。 - - 嵌入式:嵌入式的Image(只有选择AArch64或ARM32架构时,才可选该场景)。 + - 服务器:服务器场景的ISO。 + - 边缘计算:边缘计算场景的ISO。 + - 云计算:云计算场景的ISO。 + - 嵌入式:嵌入式的Image(只有选择AArch64或ARM32架构时,才可选该场景)。 6. 单击“AArch64”,选择AArch64架构。 7. 单击“服务器”,选择服务器场景。 diff --git "a/docs/zh/docs/ApplicationDev/\346\236\204\345\273\272RPM\345\214\205.md" "b/docs/zh/docs/ApplicationDev/\346\236\204\345\273\272RPM\345\214\205.md" index 4ce187b00f70213faf086b2675faffe017940141..c65b48d0e8c21aef02ae0fed91a4e2ef36b75784 100644 --- "a/docs/zh/docs/ApplicationDev/\346\236\204\345\273\272RPM\345\214\205.md" +++ "b/docs/zh/docs/ApplicationDev/\346\236\204\345\273\272RPM\345\214\205.md" @@ -197,54 +197,43 @@ rpmbuild命令格式为:rpmbuild \[_option_...\] ```Conf Name: hello Version: 2.10 -Release: 1%{?dist} +Release: 1 Summary: The "Hello World" program from GNU -Summary(zh_CN): GNU "Hello World" 程序 -License: GPLv3+ -URL: http://ftp.gnu.org/gnu/hello -Source0: http://ftp.gnu.org/gnu/hello/%{name}-%{version}.tar.gz +License: GPL-3.0-or-later +URL: https://ftp.gnu.org/gnu/hello +Source0: https://ftp.gnu.org/gnu/hello/%{name}-%{version}.tar.gz BuildRequires: gettext -Requires(post): info -Requires(preun): info %description The "Hello World" program, done with all bells and whistles of a proper FOSS project, including configuration, build, internationalization, help files, etc. -%description -l zh_CN -"Hello World" 程序, 包含 FOSS 项目所需的所有部分, 包括配置, 构建, 国际化, 帮助文件等. - %prep -%setup -q +%autosetup -p1 -n %{name}-%{version} %build %configure -make %{?_smp_mflags} +%make_build %install -make install DESTDIR=%{buildroot} +%make_install %find_lang %{name} -rm -f %{buildroot}/%{_infodir}/dir - -%post -/sbin/install-info %{_infodir}/%{name}.info %{_infodir}/dir || : -%preun -if [ $1 = 0 ] ; then -/sbin/install-info --delete %{_infodir}/%{name}.info %{_infodir}/dir || : -fi +%check +%make_build check %files -f %{name}.lang %doc AUTHORS ChangeLog NEWS README THANKS TODO %license COPYING -%{_mandir}/man1/hello.1.* -%{_infodir}/hello.info.* %{_bindir}/hello +%{_mandir}/man1/hello.1* +%{_infodir}/hello.info* %changelog * Thu Dec 26 2019 Your Name - 2.10-1 - Update to 2.10 + * Sat Dec 3 2016 Your Name - 2.9-1 - Update to 2.9 ``` diff --git a/docs/zh/docs/Autopkg/autopkg.md b/docs/zh/docs/Autopkg/autopkg.md new file mode 100644 index 0000000000000000000000000000000000000000..52b9756ba4be6bdfceb66fbb9de59163593d0450 --- /dev/null +++ b/docs/zh/docs/Autopkg/autopkg.md @@ -0,0 +1,166 @@ +# 概述 + +本软件服务于`openEuler`社区,将`github`等公共平台上的开源代码仓批量加包到`openEuler`平台上,实现软件包依赖自动检测并编译生成二进制文件,替代手工编写与维护,支持`cmake/autotools/meson/maven/python`等多种构建方式,显著提升加包端到端成功率。 + +# 安装与卸载 + +## 1. 安装 + +从源码仓中下载源码。 + +```bash +git clone https://gitee.com/qiu-tangke/autopkg.git -b ${branch} +``` + +切到代码仓目录下,使用`pip`安装软件,仅支持openeuler-22.03-lts及更高版本的openeuler系统(其他版本需自行安装python3.8以上的环境) + +```bash +pip install dist/autopkg-***-py3-none-any.whl +``` + +## 2. 卸载 + +```bash +pip uninstall autopkg +``` + +# 快速入门 + +## 1. 环境准备 + +使用该软件需要在宿主机上运行,并且需要能启动docker容器。 +预制`openEuler`系统的`docker`镜像,方法如下: + +### 方法1 直接下载源码中心仓的autopkg环境镜像 + +```bash +arch=$(uname -m) +if [ "$arch" == "aarch64" ]; then + wget https://cache-openeuler.obs.cn-north-4.myhuaweicloud.com/52f2b17e15ceeefecf5646d7711df7e94691ea1adb11884b926532ae52ab3c22/autopkg-latest_aarch64.tar.xz + docker load < autopkg-latest_aarch64.tar.xz +elif [ "$arch" == "x86_64" ]; then + wget https://cache-openeuler.obs.cn-north-4.myhuaweicloud.com/710a5f18188efc70bfa0119d0b35dcbb62cab911c9eb77b86dc6aebdbbfc69de/autopkg-latest_x86-64.tar.xz + docker load < autopkg-latest_x86-64.tar.xz +else + echo "Error: The system architecture is neither aarch64 nor x86_64, it is $arch." +fi +``` + +### 方法2 逐个使用命令生成镜像(方法1不成功时选择方法2) + +```bash +arch=$(uname -m) +wget "https://repo.huaweicloud.com/openeuler/openEuler-23.03/docker_img/${arch}/openEuler-docker.${arch}.tar.xz" +docker load < "openEuler-docker.${arch}.tar.xz" +docker run -dti --privileged --name=autopkg_working --network=host openEuler-23.03:latest +docker exec -ti ${container_id} bash # 以下命令在容器中执行 +yum install -y git make gcc cmake python3-pip ruby ruby-devel rubygems-devel npm maven automake perl wget curl meson +cat >> /root/phase.sh << EOF +#/usr/bin/env bash + +prep +build +install +EOF +exit # 退出容器 +docker commit ${container_id} > autopkg:latest # 保存容器操作 +docker tag ${new_image_id} autopkg:latest # 操作镜像的名称和标签 +``` + +## 2. 命令行 + +```bash +autopkg --help +-g,--git-url: 输入git仓库地址,形如'https://***.git' +-t,--tar-url: 输入tar包地址 +-d,--dir: 输入本地仓库路径 +-n,--name: 输入包名,仅用于接口请求信息时的输入 +-v,--version: 输入版本,输入name时配合的参数 +-l,--language: 输入语言,输入name时配合的参数 +-o,--output: 设置输出文件的路径 +-b,--build: 是否需要设置日志模式为debug +-c,--config: 设置可直接使用的配置信息 +``` + +## 3. 常用命令: + +### A. 输入本地仓库路径的形式 + +```bash +autopkg -d ${package_dir} -o ${output_path} +``` + +![](./images/dir_test.PNG) + +### B. 输入源码包地址的形式 + +```bash +autopkg -t ${tar_url} -o ${output_path} +``` + +![](./images/tar_url_test.PNG) + +### C. 输入包名且不编译的形式 + +```bash +autopkg -n ${name} -v ${version} -l ${language} -o ${output_path} +``` + +![](./images/name_test.PNG) + +# 输出文件说明 + +软件包编译完成后会生成`package.yaml`,`phase.sh`和`{package_name}.epkg`。不编译的情况下只生成`package.yaml`和`phase.sh`文件,输出路径为--output参数指定的路径,默认为`/tmp/autopkg/output` + +## 1. package.yaml (jekyll为例,ruby编译) + +记录软件包的基本信息参数 + +```yaml +meta: + summary: No detailed summary available + description: | + # [Jekyll](https://jekyllrb.com/) +name: jekyll +version: 4.3.3 +homepage: https://localhost:8080/jekyll-0.0.1.tar.gz +license: MIT +source: + '0': https://localhost:8080/jekyll-0.0.1.tar.gz # 输入本地仓库时,url会采用本地服务模拟的url +release: 0 +buildRequires: +- ruby +- ruby-devel +- rubygems-devel +``` + +## 2. phase.sh (jekyll为例,ruby编译) + +软件包的构建脚本 + +```bash +#!/usr/bin/env bash + +prep() { + cd /root/workspace +} + +build() { + if [ -f *.gemspec ]; then + gem build *.gemspec + fi + mkdir -p usr/ + gem install -V --local --build-root usr --force --document=ri,rdoc *.gem +} + +install() { + rm -rf /opt/buildroot + mkdir /opt/buildroot + cp -r usr/ /opt/buildroot +} +``` + +## 3. ***.epkg + +软件包的安装包 +![](./images/local_epkg.PNG) diff --git a/docs/zh/docs/Autopkg/images/dir_test.PNG b/docs/zh/docs/Autopkg/images/dir_test.PNG new file mode 100644 index 0000000000000000000000000000000000000000..3d223e1c3f7aca150b724746b43a931f77e6c6d9 Binary files /dev/null and b/docs/zh/docs/Autopkg/images/dir_test.PNG differ diff --git a/docs/zh/docs/Autopkg/images/local_epkg.PNG b/docs/zh/docs/Autopkg/images/local_epkg.PNG new file mode 100644 index 0000000000000000000000000000000000000000..7f5ecdf2948a661ab2d513f008ae72758706fe28 Binary files /dev/null and b/docs/zh/docs/Autopkg/images/local_epkg.PNG differ diff --git a/docs/zh/docs/Autopkg/images/name_test.PNG b/docs/zh/docs/Autopkg/images/name_test.PNG new file mode 100644 index 0000000000000000000000000000000000000000..95e5cbfc916919e0996172cd4c55433c55eed4c2 Binary files /dev/null and b/docs/zh/docs/Autopkg/images/name_test.PNG differ diff --git a/docs/zh/docs/Autopkg/images/tar_url_test.PNG b/docs/zh/docs/Autopkg/images/tar_url_test.PNG new file mode 100644 index 0000000000000000000000000000000000000000..80a49875c4eacbe74da42a859d7d9df251533fb8 Binary files /dev/null and b/docs/zh/docs/Autopkg/images/tar_url_test.PNG differ diff --git "a/docs/zh/docs/CPDS/CPDS\344\273\213\347\273\215.md" "b/docs/zh/docs/CPDS/CPDS\344\273\213\347\273\215.md" index 32db5d854b367cd149dcedfbfaa0767146d8d18c..09478e1242efa02be97c3a539a5c5cc7256e14a2 100644 --- "a/docs/zh/docs/CPDS/CPDS\344\273\213\347\273\215.md" +++ "b/docs/zh/docs/CPDS/CPDS\344\273\213\347\273\215.md" @@ -12,7 +12,7 @@ CPDS (Container Problem Detect System) 容器故障检测系统,是由北京 **2. 集群异常检测** -采集各节点原始数据,基于异常规则对采集的原始数据进行异常检测,提取关键信息。同时基于异常规则对采集数据进行异常检测,后将检测结果数据和原始据进行在线上传,并同步进行持久化操作。 +采集各节点原始数据,基于异常规则对采集的原始数据进行异常检测,提取关键信息。同时基于异常规则对采集数据进行异常检测,后将检测结果数据和原始数据进行在线上传,并同步进行持久化操作。 **3. 节点、业务容器故障/亚健康诊断** diff --git "a/docs/zh/docs/CPDS/\345\256\211\350\243\205\344\270\216\351\203\250\347\275\262.md" "b/docs/zh/docs/CPDS/\345\256\211\350\243\205\344\270\216\351\203\250\347\275\262.md" index f088ff39fd1f57aacb19c43622a9160f55e5e465..4f90b7abae414f19a5ffb2826e6efe3424edaa0a 100644 --- "a/docs/zh/docs/CPDS/\345\256\211\350\243\205\344\270\216\351\203\250\347\275\262.md" +++ "b/docs/zh/docs/CPDS/\345\256\211\350\243\205\344\270\216\351\203\250\347\275\262.md" @@ -195,49 +195,49 @@ SELINUX=disabled 1. 启动数据库 -```shell -systemctl start mariadb.service -systemctl enable mariadb.service -``` + ```shell + systemctl start mariadb.service + systemctl enable mariadb.service + ``` 2. 在root权限下初始化数据库 -```shell -/usr/bin/mysql_secure_installation -``` + ```shell + /usr/bin/mysql_secure_installation + ``` -> 命令执行过程中需要输入数据库的root设置的密码,若没有密码则直接按“Enter”。然后根据提示及实际情况进行设置。 + > 命令执行过程中需要输入数据库的root设置的密码,若没有密码则直接按“Enter”。然后根据提示及实际情况进行设置。 3. 设置数据库连接权限 -```shell -mysql -u root -p -``` + ```shell + mysql -u root -p + ``` -命令执行后提示输入密码。密码为2中设置的密码。 + 命令执行后提示输入密码。密码为2中设置的密码。 -```shell -GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION; -``` + ```shell + GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION; + ``` -> 其中username为数据库用户名,password为该用户的密码。 + > 其中username为数据库用户名,password为该用户的密码。 -例如: + 例如: -```shell -mysql -u root -p -Enter password: -Welcome to the MariaDB monitor. Commands end with ; or \g. -Your MariaDB connection id is 5 -Server version: 10.5.16-MariaDB MariaDB Server + ```shell + mysql -u root -p + Enter password: + Welcome to the MariaDB monitor. Commands end with ; or \g. + Your MariaDB connection id is 5 + Server version: 10.5.16-MariaDB MariaDB Server -Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. + Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. -Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. + Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. -MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION; -Query OK, 0 rows affected (0.014 sec) -``` + MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION; + Query OK, 0 rows affected (0.014 sec) + ``` ### 启动服务 diff --git "a/docs/zh/docs/CTinspector/\344\275\277\347\224\250\346\226\271\346\263\225.md" "b/docs/zh/docs/CTinspector/\344\275\277\347\224\250\346\226\271\346\263\225.md" index a774a10b05d943c450851091a0be435ea22ab84e..b8cad292a7c372f5cb1ef083987c3d65aa29cef7 100644 --- "a/docs/zh/docs/CTinspector/\344\275\277\347\224\250\346\226\271\346\263\225.md" +++ "b/docs/zh/docs/CTinspector/\344\275\277\347\224\250\346\226\271\346\263\225.md" @@ -12,9 +12,10 @@ ``` ## 开发应用实例 + 首先需要基于CTinspector框架,调用相应接口开发特定场景的应用。其次将该应用实例编译构建成基于ebpf指令集的二进制ELF文件。以CTinpsector自带的ebpf_example中vm_migrate为例进行说明,vm_migrate调用CTinpsector框架,可以在不同节点之间不断迁移packet VM,可以从上一个节点迁移时的运行位置在下一个节点接着运行。 -``` +``` text # 编写Makefile并设置ebpf指令集 CFLAGS=-O2 -fno-inline -emit-llvm -I/usr/include/ctinspector/ @@ -23,7 +24,7 @@ LINKFLAGS=-march=bpf -filetype=obj all: vm_migrate.o vm_migrate.o: - clang $(CFLAGS) -c migrate.c -o - | llc $(LINKFLAGS) -o vm_migrate.o + clang $(CFLAGS) -c migrate.c -o - | llc $(LINKFLAGS) -o vm_migrate.o clean: rm -f vm_migrate.o @@ -36,6 +37,7 @@ clang -O2 -fno-inline -emit-llvm -I/usr/include/ctinspector/ -c migrate.c -o - | ``` ## 运行应用实例 + Node 1上运行vm_migrate ![](./figures/migrate_node_1.png)   diff --git a/docs/zh/docs/CertSignature/figures/cert-tree.png b/docs/zh/docs/CertSignature/figures/cert-tree.png new file mode 100644 index 0000000000000000000000000000000000000000..cfbea157cb7b7308d668196ca5b0b0386067fd9e Binary files /dev/null and b/docs/zh/docs/CertSignature/figures/cert-tree.png differ diff --git a/docs/zh/docs/CertSignature/figures/mokutil-db.png b/docs/zh/docs/CertSignature/figures/mokutil-db.png new file mode 100644 index 0000000000000000000000000000000000000000..82dbe6e04cafe3e9ac039ba19acd5996d4cf2259 Binary files /dev/null and b/docs/zh/docs/CertSignature/figures/mokutil-db.png differ diff --git a/docs/zh/docs/CertSignature/figures/mokutil-sb-off.png b/docs/zh/docs/CertSignature/figures/mokutil-sb-off.png new file mode 100644 index 0000000000000000000000000000000000000000..f3018c9fd0236e9c2cf560f0da3827ed2a877f6d Binary files /dev/null and b/docs/zh/docs/CertSignature/figures/mokutil-sb-off.png differ diff --git a/docs/zh/docs/CertSignature/figures/mokutil-sb-on.png b/docs/zh/docs/CertSignature/figures/mokutil-sb-on.png new file mode 100644 index 0000000000000000000000000000000000000000..449b6774dc61a601cf884845fbd0be5d314108e1 Binary files /dev/null and b/docs/zh/docs/CertSignature/figures/mokutil-sb-on.png differ diff --git a/docs/zh/docs/CertSignature/figures/mokutil-sb-unsupport.png b/docs/zh/docs/CertSignature/figures/mokutil-sb-unsupport.png new file mode 100644 index 0000000000000000000000000000000000000000..525c72f78b897ffaba0d356406ab9d9e64024d91 Binary files /dev/null and b/docs/zh/docs/CertSignature/figures/mokutil-sb-unsupport.png differ diff --git "a/docs/zh/docs/CertSignature/\345\256\211\345\205\250\345\220\257\345\212\250.md" "b/docs/zh/docs/CertSignature/\345\256\211\345\205\250\345\220\257\345\212\250.md" new file mode 100644 index 0000000000000000000000000000000000000000..d56bc5e732c501d11def45bb8450566e0a9eda5f --- /dev/null +++ "b/docs/zh/docs/CertSignature/\345\256\211\345\205\250\345\220\257\345\212\250.md" @@ -0,0 +1,37 @@ +# 安全启动 + +## 概述 +安全启动(Secure Boot)就是利用公私钥对启动部件进行签名和验证。在启动过程中,前一个部件验证后一个部件的数字签名,如果能验证通过,则运行后一个部件;如果验证不通过,则暂停启动。通过安全启动可以保证系统启动过程中各个部件的完整性,防止没有经过认证的部件被加载运行,从而防止对系统及用户数据产生安全威胁。 +安全启动涉及的验证组件: BIOS->shim->grub->vmlinuz(依次验签通过并加载),其中vmlinuz是内核镜像。 +相关的EFI启动组件由openEuler签名平台采用signcode方式进行签名。公钥证书由BIOS集成到签名数据库DB中,启动过程中BIOS对shim进行验证,shim和grub组件从BIOS的签名数据库DB中获取公钥证书并对下一级组件进行验证。 + +## 背景和解决方案 +前期openEuler版本中,安全启动相关组件没有签名,无法直接使用安全启动功能保障系统组件的完整性。 +从22.03-LTS-SP3版本开始,openEuler使用社区签名平台对OS侧的相关组件进行签名,包括grub和vmlinuz组件,并将社区签名根证书内嵌于shim组件中。 +对于shim组件,为了便于端到端实现安全启动功能,当前使用openEuler社区的签名平台进行签名。后续外部国产CA(如CFCA,中国金融认证中心)正式运营安全启动组件签名服务后,将计划在openEuler的shim模块中集成这些国产CA的签名。 + +## 使用方法 +### openEuler证书获取 +openEuler根证书获取地址:,进入“证书中心”目录下载。 +网页上根证书识别名称为“openEuler Shim Default CA”,default-x509ca.cert。 + +### BIOS侧操作 +将openEuler根证书导入BIOS的db证书库中,并在BIOS中开启安全启动开关,可实现安全启动功能。 +BIOS证书导入方法及安全启动开启方法可参考具体BIOS厂商提供的资料。 + +### OS侧操作 +**查看db数据库中的证书信息**:mokutil –db +![](./figures/mokutil-db.png) +说明:证书信息较多,截图中只显示部分重要信息 +**查看系统安全启动状态**:mokutil --sb +- SecureBoot disabled:安全启动关闭 +![](./figures/mokutil-sb-off.png) +- SecureBoot enabled:安全启动开启 +![](./figures/mokutil-sb-on.png) +- not supported:系统不支持安全启动 +![](./figures/mokutil-sb-unsupport.png) + +## 约束限制 +- **软件限制**:OS系统需要采用UEFI启动 +- **架构限制**:ARM/X86 +- **硬件约束**:需要BIOS支持安全启动相关校验功能 diff --git "a/docs/zh/docs/CertSignature/\346\200\273\344\275\223\346\246\202\350\277\260.md" "b/docs/zh/docs/CertSignature/\346\200\273\344\275\223\346\246\202\350\277\260.md" new file mode 100644 index 0000000000000000000000000000000000000000..80028df2a1176b23b01be0ed3c754846fe32dbea --- /dev/null +++ "b/docs/zh/docs/CertSignature/\346\200\273\344\275\223\346\246\202\350\277\260.md" @@ -0,0 +1,27 @@ +# 认识证书和签名 + +## 概述 +数字签名是保护操作系统完整性的重要技术。通过对系统关键组件添加签名,并在后续的组件启动加载、运行访问等流程中进行签名验证,可以有效检查组件的完整性,避免组件被篡改而导致的安全问题。业界已支持多种系统完整性保护机制,在系统运行的各个阶段对不同类型的组件进行完整性保护,典型的技术机制有: + +- 安全启动; +- 内核模块签名; +- IMA完整性度量架构; +- RPM签名验证。 + +上述完整性保护的安全机制都需要依赖签名(通常需要在组件发布阶段集成),而开源社区普遍存在缺乏签名私钥和证书管理机制,因此社区发布的操作系统发行版通常不提供默认签名,或仅使用构建阶段临时生成的私钥进行签名。往往需要用户或者下游OSV厂商进行二次签名后才可开启这些完整性保护安全机制,增加了安全功能的使用成本并降低了易用性。 + +## 解决方案 +openEuler社区基础设施支持签名服务,通过签名平台统一管理签名私钥和证书,并与EulerMaker构建平台结合,实现在社区发行版的软件包构建过程中对关键文件进行自动签名。当前支持的文件类型有: + +- EFI文件; +- 内核模块文件; +- IMA摘要列表文件; +- RPM软件包。 + +## 约束限制 +openEuler社区的签名服务功能存在如下约束限制: + +- 当前仅支持为openEuler社区官方发布分支进行签名,暂不支持对个人构建分支进行签名; +- 当前仅支持对OS安全启动相关的EFI文件进行签名,包括shim、grub、kernel文件; +- 当前仅支持对kernel软件包提供的内核模块文件进行签名。 + diff --git "a/docs/zh/docs/CertSignature/\347\255\276\345\220\215\350\257\201\344\271\246\344\273\213\347\273\215.md" "b/docs/zh/docs/CertSignature/\347\255\276\345\220\215\350\257\201\344\271\246\344\273\213\347\273\215.md" new file mode 100644 index 0000000000000000000000000000000000000000..2023390d9d33df4bdcc7e5cae5cbe63e6e47c907 --- /dev/null +++ "b/docs/zh/docs/CertSignature/\347\255\276\345\220\215\350\257\201\344\271\246\344\273\213\347\273\215.md" @@ -0,0 +1,47 @@ +# 签名证书介绍 + +openEuler当前支持两种签名机制:openPGP和CMS,分别用于不同的文件类型: + +| 文件类型 | 签名类型 | 签名格式 | +| --------------- | ------------ | -------- | +| EFI文件 | authenticode | CMS | +| 内核模块文件 | modsig | CMS | +| IMA摘要列表文件 | modsig | CMS | +| RPM软件包 | RPM | openPGP | + +## openPGP证书签名 + +openEuler通过openPGP证书实现RPM软件包的签名,签名证书随操作系统镜像发布,用户可通过两种方式获取到当前openEuler版本所使用的证书: + +方法一:通过REPO源下载,以openEuler 24.03 LTS版本为例,可通过如下路径下载: + +``` +https://repo.openeuler.org/openEuler-24.03-LTS/OS/aarch64/RPM-GPG-KEY-openEuler +``` + +方法二:进入系统通过指定路径获取: + +``` +cat /etc/pki/rpm-gpg/RPM-GPG-KEY-openEuler +``` + +## CMS证书签名 + +openEuler签名平台采用三级证书链管理签名的私钥和证书: + +![](./figures/cert-tree.png) + +根据不同等级的证书分别具有不同的有效期,当前规划为: + +| 证书类型 | 有效期 | +| -------- | ------ | +| 根证书 | 30年 | +| 二级证书 | 10年 | +| 三级证书 | 3年 | + +openEuler根证书可通过社区证书中心下载: + +``` +https://www.openeuler.org/zh/security/certificate-center/ +``` + diff --git "a/docs/zh/docs/ClusterDeployment/figures/1.\346\237\245\347\234\213\351\234\200\350\246\201\351\225\234\345\203\217.png" "b/docs/zh/docs/ClusterDeployment/figures/1.\346\237\245\347\234\213\351\234\200\350\246\201\351\225\234\345\203\217.png" new file mode 100644 index 0000000000000000000000000000000000000000..74cdae5726cec83d5d74b0b8bd01694fd388e342 Binary files /dev/null and "b/docs/zh/docs/ClusterDeployment/figures/1.\346\237\245\347\234\213\351\234\200\350\246\201\351\225\234\345\203\217.png" differ diff --git "a/docs/zh/docs/ClusterDeployment/figures/10.\350\207\252\345\256\232\344\271\211\351\241\271\347\233\256\345\220\215\347\247\260.jpg" "b/docs/zh/docs/ClusterDeployment/figures/10.\350\207\252\345\256\232\344\271\211\351\241\271\347\233\256\345\220\215\347\247\260.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..2062c62a6aae63e9700f6ceedf73daea0876eb44 Binary files /dev/null and "b/docs/zh/docs/ClusterDeployment/figures/10.\350\207\252\345\256\232\344\271\211\351\241\271\347\233\256\345\220\215\347\247\260.jpg" differ diff --git "a/docs/zh/docs/ClusterDeployment/figures/11.\350\256\276\347\275\256-cicd-runner.png" "b/docs/zh/docs/ClusterDeployment/figures/11.\350\256\276\347\275\256-cicd-runner.png" new file mode 100644 index 0000000000000000000000000000000000000000..838cf1b6625439e44c7d09162fb71edbe1eaf3d3 Binary files /dev/null and "b/docs/zh/docs/ClusterDeployment/figures/11.\350\256\276\347\275\256-cicd-runner.png" differ diff --git "a/docs/zh/docs/ClusterDeployment/figures/12.\350\256\260\344\270\213runner\345\234\260\345\235\200\344\270\216\344\273\244\347\211\214.jpg" "b/docs/zh/docs/ClusterDeployment/figures/12.\350\256\260\344\270\213runner\345\234\260\345\235\200\344\270\216\344\273\244\347\211\214.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..d3aaaf9ff4b66e4b536bc0afaa33c121bc6b53f6 Binary files /dev/null and "b/docs/zh/docs/ClusterDeployment/figures/12.\350\256\260\344\270\213runner\345\234\260\345\235\200\344\270\216\344\273\244\347\211\214.jpg" differ diff --git "a/docs/zh/docs/ClusterDeployment/figures/13.\346\237\245\347\234\213\350\257\201\344\271\246\351\205\215\347\275\256\346\226\207\344\273\266.png" "b/docs/zh/docs/ClusterDeployment/figures/13.\346\237\245\347\234\213\350\257\201\344\271\246\351\205\215\347\275\256\346\226\207\344\273\266.png" new file mode 100644 index 0000000000000000000000000000000000000000..8e9ce44af5a01670add1b8b2f5a7223a8bd0f35d Binary files /dev/null and "b/docs/zh/docs/ClusterDeployment/figures/13.\346\237\245\347\234\213\350\257\201\344\271\246\351\205\215\347\275\256\346\226\207\344\273\266.png" differ diff --git "a/docs/zh/docs/ClusterDeployment/figures/14.\350\257\201\344\271\246\345\257\274\345\205\245\346\226\207\344\273\266.png" "b/docs/zh/docs/ClusterDeployment/figures/14.\350\257\201\344\271\246\345\257\274\345\205\245\346\226\207\344\273\266.png" new file mode 100644 index 0000000000000000000000000000000000000000..2a1fdb24d6f5c1c9d44cbce08276289adc5c876c Binary files /dev/null and "b/docs/zh/docs/ClusterDeployment/figures/14.\350\257\201\344\271\246\345\257\274\345\205\245\346\226\207\344\273\266.png" differ diff --git "a/docs/zh/docs/ClusterDeployment/figures/15.\346\263\250\345\206\214gitlab-runner.jpg" "b/docs/zh/docs/ClusterDeployment/figures/15.\346\263\250\345\206\214gitlab-runner.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..896f13bdc6411b719283f30d9973973950f27a1c Binary files /dev/null and "b/docs/zh/docs/ClusterDeployment/figures/15.\346\263\250\345\206\214gitlab-runner.jpg" differ diff --git "a/docs/zh/docs/ClusterDeployment/figures/16.web\347\253\257\345\267\262\345\212\240\345\205\245_LI.jpg" "b/docs/zh/docs/ClusterDeployment/figures/16.web\347\253\257\345\267\262\345\212\240\345\205\245_LI.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..fd8ae15ef7bce7120c7ba24b6240b33dbcf610b8 Binary files /dev/null and "b/docs/zh/docs/ClusterDeployment/figures/16.web\347\253\257\345\267\262\345\212\240\345\205\245_LI.jpg" differ diff --git a/docs/zh/docs/ClusterDeployment/figures/17.png b/docs/zh/docs/ClusterDeployment/figures/17.png new file mode 100644 index 0000000000000000000000000000000000000000..86f90a67185f532b362f4710ce8f7615cf40c9e1 Binary files /dev/null and b/docs/zh/docs/ClusterDeployment/figures/17.png differ diff --git "a/docs/zh/docs/ClusterDeployment/figures/18.dns\351\205\215\347\275\256.png" "b/docs/zh/docs/ClusterDeployment/figures/18.dns\351\205\215\347\275\256.png" new file mode 100644 index 0000000000000000000000000000000000000000..46b85396db34577b67679da759b6160ee707dec5 Binary files /dev/null and "b/docs/zh/docs/ClusterDeployment/figures/18.dns\351\205\215\347\275\256.png" differ diff --git "a/docs/zh/docs/ClusterDeployment/figures/19.CICD\347\225\214\351\235\242.png" "b/docs/zh/docs/ClusterDeployment/figures/19.CICD\347\225\214\351\235\242.png" new file mode 100644 index 0000000000000000000000000000000000000000..f8193e005253eb4a6bd036ec8afdf6566f9fd6d2 Binary files /dev/null and "b/docs/zh/docs/ClusterDeployment/figures/19.CICD\347\225\214\351\235\242.png" differ diff --git "a/docs/zh/docs/ClusterDeployment/figures/2.calico\351\205\215\347\275\256.png" "b/docs/zh/docs/ClusterDeployment/figures/2.calico\351\205\215\347\275\256.png" new file mode 100644 index 0000000000000000000000000000000000000000..d656f86d8ce5e110cf240a58e58b05b42aba8c15 Binary files /dev/null and "b/docs/zh/docs/ClusterDeployment/figures/2.calico\351\205\215\347\275\256.png" differ diff --git "a/docs/zh/docs/ClusterDeployment/figures/20.yaml\346\226\207\344\273\266.png" "b/docs/zh/docs/ClusterDeployment/figures/20.yaml\346\226\207\344\273\266.png" new file mode 100644 index 0000000000000000000000000000000000000000..9e7ec858abc2da72c7815a483f3011bf1225ec0f Binary files /dev/null and "b/docs/zh/docs/ClusterDeployment/figures/20.yaml\346\226\207\344\273\266.png" differ diff --git "a/docs/zh/docs/ClusterDeployment/figures/21.\346\265\201\346\260\264\347\272\277\347\212\266\346\200\201.png" "b/docs/zh/docs/ClusterDeployment/figures/21.\346\265\201\346\260\264\347\272\277\347\212\266\346\200\201.png" new file mode 100644 index 0000000000000000000000000000000000000000..fff7063f17fd203390302a6245a8ce4a16cf428e Binary files /dev/null and "b/docs/zh/docs/ClusterDeployment/figures/21.\346\265\201\346\260\264\347\272\277\347\212\266\346\200\201.png" differ diff --git a/docs/zh/docs/ClusterDeployment/figures/3.png b/docs/zh/docs/ClusterDeployment/figures/3.png new file mode 100644 index 0000000000000000000000000000000000000000..7394b5f21821ce8d352c2f935c3ea3e490dc0519 Binary files /dev/null and b/docs/zh/docs/ClusterDeployment/figures/3.png differ diff --git "a/docs/zh/docs/ClusterDeployment/figures/4.gitlab\347\275\221\351\241\265\345\205\245\345\217\243.jpg" "b/docs/zh/docs/ClusterDeployment/figures/4.gitlab\347\275\221\351\241\265\345\205\245\345\217\243.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..d3eb0d59d6dee5051470621a4969651668687789 Binary files /dev/null and "b/docs/zh/docs/ClusterDeployment/figures/4.gitlab\347\275\221\351\241\265\345\205\245\345\217\243.jpg" differ diff --git "a/docs/zh/docs/ClusterDeployment/figures/5.\346\237\245\350\257\242\345\257\206\347\240\201.jpg" "b/docs/zh/docs/ClusterDeployment/figures/5.\346\237\245\350\257\242\345\257\206\347\240\201.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..2e3902815108e9e91a07c382a4aae090b7cc6fe9 Binary files /dev/null and "b/docs/zh/docs/ClusterDeployment/figures/5.\346\237\245\350\257\242\345\257\206\347\240\201.jpg" differ diff --git "a/docs/zh/docs/ClusterDeployment/figures/6.\347\231\273\345\275\225\345\220\216\351\241\265\351\235\242.png" "b/docs/zh/docs/ClusterDeployment/figures/6.\347\231\273\345\275\225\345\220\216\351\241\265\351\235\242.png" new file mode 100644 index 0000000000000000000000000000000000000000..5f4d2c2a9a8bf337263028e859e49499155920b0 Binary files /dev/null and "b/docs/zh/docs/ClusterDeployment/figures/6.\347\231\273\345\275\225\345\220\216\351\241\265\351\235\242.png" differ diff --git "a/docs/zh/docs/ClusterDeployment/figures/7.\351\225\234\345\203\217.png" "b/docs/zh/docs/ClusterDeployment/figures/7.\351\225\234\345\203\217.png" new file mode 100644 index 0000000000000000000000000000000000000000..26c811ae616d2fe86e7b8b75c78ef88aff83616b Binary files /dev/null and "b/docs/zh/docs/ClusterDeployment/figures/7.\351\225\234\345\203\217.png" differ diff --git "a/docs/zh/docs/ClusterDeployment/figures/8.\346\226\260\345\273\272\351\241\271\347\233\256.png" "b/docs/zh/docs/ClusterDeployment/figures/8.\346\226\260\345\273\272\351\241\271\347\233\256.png" new file mode 100644 index 0000000000000000000000000000000000000000..0c56662e6bdedcc78dea32b6e2afada466193096 Binary files /dev/null and "b/docs/zh/docs/ClusterDeployment/figures/8.\346\226\260\345\273\272\351\241\271\347\233\256.png" differ diff --git "a/docs/zh/docs/ClusterDeployment/figures/9.\345\210\233\345\273\272\347\251\272\347\231\275\351\241\271\347\233\256.png" "b/docs/zh/docs/ClusterDeployment/figures/9.\345\210\233\345\273\272\347\251\272\347\231\275\351\241\271\347\233\256.png" new file mode 100644 index 0000000000000000000000000000000000000000..117da11ee289d88b51539e027606cc9da526936a Binary files /dev/null and "b/docs/zh/docs/ClusterDeployment/figures/9.\345\210\233\345\273\272\347\251\272\347\231\275\351\241\271\347\233\256.png" differ diff --git "a/docs/zh/docs/ClusterDeployment/gitlab-runner\351\203\250\347\275\262.md" "b/docs/zh/docs/ClusterDeployment/gitlab-runner\351\203\250\347\275\262.md" new file mode 100644 index 0000000000000000000000000000000000000000..8aec45981ea0d3235431407603918ff579746c0e --- /dev/null +++ "b/docs/zh/docs/ClusterDeployment/gitlab-runner\351\203\250\347\275\262.md" @@ -0,0 +1,193 @@ +# gitlab runner部署及测试 + +## 镜像/软件信息 +安装过程中需要用到的镜像名称如下表,版本号为示例安装时用到的版本,仅供参考。 + +| 镜像 | 版本 | +|------------------------------------|----------| +| gitlab/gitlab-runner | alpine-v14.4.0 | +| gitlab/gitlab-runner-helper | x86_64-54944146 | + +> 如果在无外网环境中搭建,可以从下方链接提前下载对应的镜像。 + 镜像下载地址:dockerhub官网 https://hub.docker.com + +## 使用gitlab-runner.yaml启动runner容器 + +配置gitlab-runner.yaml文件,修改文件中的镜像名,以下为yaml文件的示例参考,请根据实际搭建进行修改。 +``` +vim gitlab-runner.yaml +``` + +``` +apiVersion: apps/v1 +kind: Deployment +metadata: + name: gitlab-runner + namespace: default +spec: + replicas: 1 + selector: + matchLabels: + name: gitlab-runner + template: + metadata: + labels: + name: gitlab-runner + spec: + containers: + - args: + - run + image: gitlab/gitlab-runner:alpine-v14.4.0 + imagePullPolicy: IfNotPresent + name: gitlab-runner + volumeMounts: + - mountPath: /etc/gitlab-runner + name: config + readOnly: false + - mountPath: /etc/ssl/certs + name: cacerts + readOnly: true + restartPolicy: Always + volumes: + - hostPath: + path: /etc/gitlab-runner + name: config + - hostPath: + path: /etc/ssl/key + name: cacerts + +``` + +启动容器: +``` +# kubectl apply -f gitlab-runner.yaml +# kubectl get pod -A -o wide +``` +![镜像](figures/7.%E9%95%9C%E5%83%8F.png) + +## 登录gitlab容器网页-用户证书认证 + +1. 新建项目。 + + ![新建项目](figures/8.%E6%96%B0%E5%BB%BA%E9%A1%B9%E7%9B%AE.png) + +2. 创建空白项目。 + + ![创建空白项目](figures/9.%E5%88%9B%E5%BB%BA%E7%A9%BA%E7%99%BD%E9%A1%B9%E7%9B%AE.png) + +3. 自定义项目名称。 + + ![自定义项目名称](figures/10.%E8%87%AA%E5%AE%9A%E4%B9%89%E9%A1%B9%E7%9B%AE%E5%90%8D%E7%A7%B0.jpg) + +4. 设置--CI/CD--Runner--展开。 + + ![设置-cicd-runner](figures/11.%E8%AE%BE%E7%BD%AE-cicd-runner.png) + +5. 记录注册Runner的地址和令牌。 + + ![记下runner地址与令牌](figures/12.%E8%AE%B0%E4%B8%8Brunner%E5%9C%B0%E5%9D%80%E4%B8%8E%E4%BB%A4%E7%89%8C.jpg) + +6. 导入证书文件。 + + 在master节点上查看并生成证书文件,共三个文件admin.crt、admin.key、ca.crt。 + + - 查看证书信息 + + ``` + # cat /etc/kubernetes/admin.conf + ``` + + ![查看证书配置文件](figures/13.%E6%9F%A5%E7%9C%8B%E8%AF%81%E4%B9%A6%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6.png) + + - 加密生成admin.crt + + ``` + # echo “${client-certificate-data}” | base64 -d > admin.crt + ``` + + - 加密生成admin.key + + ``` + # echo “${client-key-data}” | base64 -d > admin.key + ``` + + - 在manager节点上获取ca的证书 + + ``` + # cp /etc/kubernetes/pki/ca.crt ./ + ``` + +7. 在runner运行的节点处将三个证书文件导入gitlab-runner容器。 + + >**说明** :导入容器需查看gitlab-runner运行在哪个节点上,将三个证书文件拷贝至该节点,然后使用isula cp命令导入。 + + ``` + # isula cp admin.crt [容器id]:存放位置 + # isula cp admin.key [容器id]:存放位置 + # isula cp ca.crt [容器id]:存放位置 + ``` + + 注:isula cp 命令只能一次拷贝一个文件 + + ![证书导入文件](figures/14.%E8%AF%81%E4%B9%A6%E5%AF%BC%E5%85%A5%E6%96%87%E4%BB%B6.png) + + +## 注册gitlab-runner + +进入到runner的容器内进行注册;目前采用交互式注册,注册信息在gitlab上获得,当前配置的 runner服务于项目组,此信息的界面在gitlab-\>项目组(group)-\>设置-\>CI/CD-\>runner中查看。 + +![注册gitlab-runner](figures/15.%E6%B3%A8%E5%86%8Cgitlab-runner.jpg) + +![web端已加入](figures/16.web%E7%AB%AF%E5%B7%B2%E5%8A%A0%E5%85%A5_LI.jpg) + +将准备好的gitlab-runner-helper镜像提前上传至私有镜像仓,进入gitlab-runner容器中,修改配置文件。 + + +``` +# cd /etc/gitlab-runner +# mkdir kubessl +# cp /home/admin.crt /etc/gitlab-runner/kubessl +# cp /home/ca.crt /etc/gitlab-runner/kubessl +# cp /home/admin.key /etc/gitlab-runner/kubessl +# vim /etc/gitlab-runner/config.toml +``` + +![](figures/17.png) + + +## 在manager节点进行如下操作添加gitlab容器的dns记录 + +1. 查看gitlab容器的ip地址。 + + ``` + # kubectl get pods –Aowide + ``` + +2. 添加gitlabip地址到k8s dns配置文件。 + + ``` + # kubectl edit configmaps coredns -n kube-system + ``` +![dns](figures/18.dns%E9%85%8D%E7%BD%AE.png) + +3. 重启coredns服务。 + + ``` + # kubectl scale deployment coredns -n kube-system --replicas=0 + # kubectl scale deployment coredns -n kube-system --replicas=2 + ``` + +## gitlab运行测试 +返回gitlab的web界面,选择CI/CD--编辑器--创建CI/CD流水线。 + +![CICD界面](figures/19.CICD%E7%95%8C%E9%9D%A2.png) +- 编译yaml文件如下: + +![yaml文件](figures/20.yaml%E6%96%87%E4%BB%B6.png) + +- 流水线-查看状态。 + +![流水线状态](figures/21.%E6%B5%81%E6%B0%B4%E7%BA%BF%E7%8A%B6%E6%80%81.png) + + + diff --git "a/docs/zh/docs/ClusterDeployment/gitlab\351\203\250\347\275\262.md" "b/docs/zh/docs/ClusterDeployment/gitlab\351\203\250\347\275\262.md" new file mode 100644 index 0000000000000000000000000000000000000000..b744dfee581b928f2ffe753a0438f23912f78998 --- /dev/null +++ "b/docs/zh/docs/ClusterDeployment/gitlab\351\203\250\347\275\262.md" @@ -0,0 +1,300 @@ +# gitlab部署 + +## 文档说明 +gitlab部署 是场景一(基于gitlab-ci从“0”开始构建欧拉原生开发CICD部署)所需步骤,场景二(欧拉原生开发执行机集群被gitlab-ci纳管)可跳过此步骤进入gitlab-runner部署。 + +## 准备服务器 +需准备1台openEuler机器,建议在openEuler-22.03及以上版本运行。 + +## 启动gitlab + +将需要的yaml文件拷贝至/home目录,并启动对应的pod。 +> **说明**:gitlab相关的yaml文件可从官网获得。 + +以下为yaml文件的示例参考,请根据实际情况进行修改。 + +gitlab-redis.yaml: +``` +apiVersion: apps/v1 +kind: Deployment +metadata: + name: redis + namespace: default + labels: + name: redis +spec: + selector: + matchLabels: + name: redis + template: + metadata: + name: redis + labels: + name: redis + spec: + containers: + - name: redis + image: 10.35.111.11:5000/redis:latest + imagePullPolicy: IfNotPresent + ports: + - name: redis + containerPort: 6379 + volumeMounts: + - mountPath: /var/lib/redis + name: data + livenessProbe: + exec: + command: + - redis-cli + - ping + initialDelaySeconds: 30 + timeoutSeconds: 5 + readinessProbe: + exec: + command: + - redis-cli + - ping + initialDelaySeconds: 5 + timeoutSeconds: 1 + volumes: + - name: data + emptyDir: {} + +--- +apiVersion: v1 +kind: Service +metadata: + name: redis + namespace: default + labels: + name: redis +spec: + ports: + - name: redis + port: 6379 + targetPort: redis + selector: + name: redis + +``` +gitlab-postgresql.yaml: +``` +apiVersion: apps/v1 +kind: Deployment +metadata: + name: postgresql + namespace: default + labels: + name: postgresql +spec: + selector: + matchLabels: + name: postgresql + template: + metadata: + name: postgresql + labels: + name: postgresql + spec: + containers: + - name: postgresql + image: 10.35.111.11:5000/postgres:13.6 + imagePullPolicy: IfNotPresent + env: + - name: POSTGRES_HOST_AUTH_METHOD + value: trust + - name: DB_USER + value: gitlab + - name: DB_PASS + value: passw0rd + - name: DB_NAME + value: gitlab_production + - name: DB_EXTENSION + value: pg_trgm + ports: + - name: postgres + containerPort: 5432 + volumeMounts: + - mountPath: /var/lib/postgresql + name: data + livenessProbe: + exec: + command: + - pg_isready + - -h + - localhost + - -U + - postgres + initialDelaySeconds: 30 + timeoutSeconds: 5 + readinessProbe: + exec: + command: + - pg_isready + - -h + - localhost + - -U + - postgres + initialDelaySeconds: 5 + timeoutSeconds: 1 + volumes: + - name: data + emptyDir: {} + +--- +apiVersion: v1 +kind: Service +metadata: + name: postgresql + namespace: default + labels: + name: postgresql +spec: + ports: + - name: postgres + port: 5432 + targetPort: postgres + selector: + name: postgresql + +``` +gitlab.yaml: +``` +apiVersion: apps/v1 +kind: Deployment +metadata: + name: gitlab + namespace: default + labels: + name: gitlab +spec: + selector: + matchLabels: + name: gitlab + template: + metadata: + name: gitlab + labels: + name: gitlab + spec: + containers: + - name: gitlab + image: 10.35.111.11:5000/yrzr/gitlab-ce-arm64v8:14.3.2-ce.0 + imagePullPolicy: IfNotPresent + env: + - name: TZ + value: Asia/Shanghai + - name: GITLAB_TIMEZONE + value: Beijing + - name: GITLAB_SECRETS_DB_KEY_BASE + value: long-and-random-alpha-numeric-string + - name: GITLAB_SECRETS_SECRET_KEY_BASE + value: long-and-random-alpha-numeric-string + - name: GITLAB_SECRETS_OTP_KEY_BASE + value: long-and-random-alpha-numeric-string + - name: GITLAB_ROOT_PASSWORD + value: admin321 + - name: GITLAB_ROOT_EMAIL + value: 517554016@qq.com + - name: GITLAB_HOST + value: git.qikqiak.com + - name: GITLAB_PORT + value: "80" + - name: GITLAB_SSH_PORT + value: "22" + - name: GITLAB_NOTIFY_ON_BROKEN_BUILDS + value: "true" + - name: GITLAB_NOTIFY_PUSHER + value: "false" + - name: GITLAB_BACKUP_SCHEDULE + value: daily + - name: GITLAB_BACKUP_TIME + value: 01:00 + - name: DB_TYPE + value: postgres + - name: DB_HOST + value: postgresql + - name: DB_PORT + value: "5432" + - name: DB_USER + value: gitlab + - name: DB_PASS + value: passw0rd + - name: DB_NAME + value: gitlab_production + - name: REDIS_HOST + value: redis + - name: REDIS_PORT + value: "6379" + ports: + - name: http + containerPort: 80 + - name: ssh + containerPort: 22 + volumeMounts: + - mountPath: /home/git/data + name: data + livenessProbe: + httpGet: + path: / + port: 80 + initialDelaySeconds: 180 + timeoutSeconds: 5 + readinessProbe: + httpGet: + path: / + port: 80 + initialDelaySeconds: 5 + timeoutSeconds: 1 + volumes: + - name: data + emptyDir: {} + +--- +apiVersion: v1 +kind: Service +metadata: + name: gitlab + namespace: default + labels: + name: gitlab +spec: + ports: + - name: http + port: 80 + targetPort: http + nodePort: 30852 + - name: ssh + port: 22 + nodePort: 32353 + targetPort: ssh + selector: + name: gitlab + type: NodePort +``` +启动相应的容器: +``` +# kubectl apply -f gitlab-redis.yaml +# kubectl apply -f gitlab-postgresql.yaml +# kubectl apply -f gitlab.yaml +``` +可通过命令查看gitlab pod是否搭建完成: +``` +# kubectl get pod -A -owide +``` + +## 登录gitlab +查看是否可以登录gitlab网页,网址为ip地址加设定的端口。 + +![网页入口](figures/4.gitlab%E7%BD%91%E9%A1%B5%E5%85%A5%E5%8F%A3.jpg) +用户名为root,默认密码需进入容器后查看密码文件。 + +``` +# kubectl exec -it gitlab-lab -n default /bin/sh +# cat /etc/gitlab/initial_root_password +``` +![查询密码](figures/5.%E6%9F%A5%E8%AF%A2%E5%AF%86%E7%A0%81.jpg) + +- 登录后界面如图: + +![登录后页面](figures/6.%E7%99%BB%E5%BD%95%E5%90%8E%E9%A1%B5%E9%9D%A2.png) diff --git "a/docs/zh/docs/ClusterDeployment/iSulad+k8s\347\216\257\345\242\203\351\203\250\347\275\262.md" "b/docs/zh/docs/ClusterDeployment/iSulad+k8s\347\216\257\345\242\203\351\203\250\347\275\262.md" new file mode 100644 index 0000000000000000000000000000000000000000..1526f1ebbdf8c201db196eceadcb7c32def05483 --- /dev/null +++ "b/docs/zh/docs/ClusterDeployment/iSulad+k8s\347\216\257\345\242\203\351\203\250\347\275\262.md" @@ -0,0 +1,385 @@ +# K8s+iSulad环境部署 + +## 准备集群服务器 + +需准备至少3台openEuler机器,建议在openEuler-22.03及以上版本运行。下表为示例搭建机器信息,仅供参考。 + +| 主机名 | IP | 系统版本 | 角色 | 组件 | +|-------|-------------|------------------------|----------|-----------| +| lab1 | 197.xxx.xxx.xxx | openEuler 22.03 LTS SP4 | 控制节点 | iSulad/k8s | +| lab2 | 197.xxx.xxx.xxx | openEuler 22.03 LTS SP4 | 工作节点1 | iSulad/k8s | +| lab3 | 197.xxx.xxx.xxx | openEuler 22.03 LTS SP4 | 工作节点2 | iSulad/k8s | + +## 镜像/软件信息 + +安装过程中需要用到的软件及镜像名称如下表,版本号为示例安装时用到的版本,仅供参考。 + +| 软件 | 版本 | +|------------------------------------|----------| +| iSulad | 2.0.17-2 | +| kubernetes-client | 1.20.2-9 | +| kubernetes-kubeadm | 1.20.2-9 | +| kubernetes-kubelet | 1.20.2-9 | + +| 镜像 | 版本 | +|------------------------------------|----------| +| k8s.gcr.io/kube-proxy | v1.20.2 | +| k8s.gcr.io/kube-apiserver | v1.20.2 | +| k8s.gcr.io/kube-controller-manager | v1.20.2 | +| k8s.gcr.io/kube-scheduler | v1.20.2 | +| k8s.gcr.io/etcd | 3.4.13-0 | +| k8s.gcr.io/coredns | 1.7.0 | +| k8s.gcr.io/pause | 3.2 | +| calico/node | v3.14.2 | +| calico/pod2daemon-flexvol | v3.14.2 | +| calico/cni | v3.14.2 | +| calico/kube-controllers | v3.14.2 | + +> 如果在无外网环境中搭建,可以从以下链接提前下载对应的软件包、相关依赖软件包及镜像。
+ 软件包下载地址:[https://repo.openeuler.org/openEuler-22.03-LTS-SP4/ ](https://repo.openeuler.org/openEuler-22.03-LTS-SP4/) + 镜像下载地址:[https://developer.aliyun.com/mirror/](https://developer.aliyun.com/mirror/) + +## 修改host文件 + +1. 修改主机名,以其中一台机器为例。 + + ```shell + # hostnamectl set-hostname lab1 + # sudo -i + ``` + +2. 配置主机名解析,编辑三台服务器的/etc/hosts文件。 + + ```shell + # vim /etc/hosts + ``` + +3. 在hosts文件中添加以下内容(IP+主机名)。 + + ```text + 197.xxx.xxx.xxx lab1 + 197.xxx.xxx.xxx lab2 + 197.xxx.xxx.xxx lab3 + ``` + +## 环境准备 + +1. 关闭防火墙。 + + ```shell + # systemctl stop firewalld + # systemctl disable firewalld + ``` + +2. 禁用selinux。 + + ```shell + # setenforce 0 + ``` + +3. 关闭系统swap。 + + ```shell + # swapoff -a + # sed -ri 's/.*swap.*/#&/' /etc/fstab + ``` + +4. 网络配置,开启相应的转发机制。 + + ```shell + # cat > /etc/sysctl.d/kubernetes.conf <**说明** : 以下所下载的镜像版本均为示例,具体版本号以上条命令返回结果为准,下同。 + + ```shell + # isula pull k8smx/kube-apiserver:v1.20.15 + # isula pull k8smx/kube-controller-manager:v1.20.15 + # isula pull k8smx/kube-scheduler:v1.20.15 + # isula pull k8smx/kube-proxy:v1.20.15 + # isula pull k8smx/pause:3.2 + # isula pull k8smx/coredns:1.7.0 + # isula pull k8smx/etcd:3.4.13-0 + ``` + +3. 修改已下载的镜像标签。 + + ```shell + # isula tag k8smx/kube-apiserver:v1.20.15 k8s.gcr.io/kube-apiserver:v1.20.15 + # isula tag k8smx/kube-controller-manager:v1.20.15 k8s.gcr.io/kube-controller-manager:v1.20.15 + # isula tag k8smx/kube-scheduler:v1.20.15 k8s.gcr.io/kube-scheduler:v1.20.15 + # isula tag k8smx/kube-proxy:v1.20.15 k8s.gcr.io/kube-proxy:v1.20.15 + # isula tag k8smx/pause:3.2 k8s.gcr.io/pause:3.2 + # isula tag k8smx/coredns:1.7.0 k8s.gcr.io/coredns:1.7.0 + # isula tag k8smx/etcd:3.4.13-0 k8s.gcr.io/etcd:3.4.13-0 + ``` + +4. 删除旧镜像。 + + ```shell + # isula rmi k8smx/kube-apiserver:v1.20.15 + # isula rmi k8smx/kube-controller-manager:v1.20.15 + # isula rmi k8smx/kube-scheduler:v1.20.15 + # isula rmi k8smx/kube-proxy:v1.20.15 + # isula rmi k8smx/pause:3.2 + # isula rmi k8smx/coredns:1.7.0 + # isula rmi k8smx/etcd:3.4.13-0 + ``` + +5. 查看已拉取的镜像。 + + ```shell + # isula images + ``` + +## 安装crictl工具 + +```shell +# yum install -y cri-tools +``` + +## 初始化master节点 + +执行如下命令初始化master节点: + +```shell +# kubeadm init --kubernetes-version v1.20.2 --cri-socket=/var/run/isulad.sock --pod-network-cidr=[指定pod分配IP段] + +//以上参数的解释 +kubernetes-version 为当前安装的版本 +cri-socket 指定引擎为isulad +pod-network-cidr 指定pod分配的ip段 +``` + +根据系统提示输入如下命令: + +```shell +# mkdir -p $HOME/.kube +# sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config +# sudo chown $(id -u):$(id -g) $HOME/.kube/config +``` + +初始化成功后,复制最后两行内容,在node节点上执行刚刚复制的命令,将节点加入master集群,如未记录上述命令可通过如下命令生成: + +```shell +# kubeadm token create --print-join-command +``` + +## node节点添加进集群 + +粘贴master上初始化生成的kubeadm join ...命令,并在discovery前添加--cri-socket=/var/run/isulad.sock,执行如下命令: + +```shell +# kubeadm join [IP地址] --token bgyis4.euwkjqb7jwuenwvs --cri-socket=/var/run/isulad.sock --discovery-token-ca-cert-hash sha256:3792f02e136042e2091b245ac71c1b9cdcb97990311f9300e91e1c339e1dfcf6 +``` + +## 安装calico网络插件 + +1. 拉取calico镜像。 + + 需要在master节点配置calico网络插件,同时需要在每个节点中提前拉取需要版本的镜像。 + + ```shell + isula pull calico/node:v3.14.2 + isula pull calico/cni:v3.14.2 + isula pull calico/kube-controllers:v3.14.2 + isula pull calico/pod2daemon-flexvol:v3.14.2 + ``` + +2. 在master节点上获取配置文件。 + + ```shell + wget https://docs.projectcalico.org/v3.14/manifests/calico.yaml + ``` + +3. 修改后创建pod。 + + ```shell + # kubectl apply -f calico.yaml + ``` + + - 如需删除使用如下命令: + + ```shell + # kubectl delete -f calico.yaml + ``` + +4. 查看pod信息。 + + ```shell + # kubectl get pod -A -o wide + ``` + +## 查看master节点node信息 + +使用如下命令可查看节点的详细信息: + +```shell +# kubectl get nodes -o wide +``` + +若需要重置node节点,可使用如下命令: + +```shell +# kubeadm reset +``` \ No newline at end of file diff --git "a/docs/zh/docs/ClusterDeployment/iSulad+k8s\351\233\206\347\276\244\351\203\250\347\275\262\346\214\207\345\215\227.md" "b/docs/zh/docs/ClusterDeployment/iSulad+k8s\351\233\206\347\276\244\351\203\250\347\275\262\346\214\207\345\215\227.md" new file mode 100644 index 0000000000000000000000000000000000000000..447fb635c0407e30989dbc8b4bbaf602136ee3fa --- /dev/null +++ "b/docs/zh/docs/ClusterDeployment/iSulad+k8s\351\233\206\347\276\244\351\203\250\347\275\262\346\214\207\345\215\227.md" @@ -0,0 +1,22 @@ +欧拉原生开发环境集群部署参考实现方案 +=============== + + +本文档介绍在 openEuler 操作系统上,通过 kubeadm 部署 K8S 集群,搭建 K8S+iSulad 的环境,并在该环境上部署 gitlab-runner,指导部署欧拉原生开发环境集群。 + +本文档主要包括以下两个场景内容: + +场景一: 基于 gitlab-ci 从 “0” 开始构建欧拉原生开发CICD部署指导。 +场景二: 欧拉原生开发执行机集群被 gitlab-ci 纳管指导。 + +场景一中需要额外部署gitlab,步骤操作顺序为: +1. K8s+iSulad 环境部署。 +2. gitlab 部署。 +3. gitlab runner 部署和测试。 + +场景二中已有 gitlab-ci 平台,无需额外部署,步骤操作顺序为: +1. K8s+iSulad 环境部署。 +2. gitlab runner 部署和测试。 + + +> **说明**:本文档所有操作均使用root权限执行。 \ No newline at end of file diff --git "a/docs/zh/docs/ClusterDeployment/\346\224\257\346\214\201\345\216\237\347\224\237\345\274\200\345\217\221\347\216\257\345\242\203\346\211\247\350\241\214\346\234\272\351\233\206\347\276\244\351\203\250\347\275\262\346\214\207\345\257\274.md" "b/docs/zh/docs/ClusterDeployment/\346\224\257\346\214\201\345\216\237\347\224\237\345\274\200\345\217\221\347\216\257\345\242\203\346\211\247\350\241\214\346\234\272\351\233\206\347\276\244\351\203\250\347\275\262\346\214\207\345\257\274.md" new file mode 100644 index 0000000000000000000000000000000000000000..7f0acb33d3f754b6aed57a584a20aa6193f2bf14 --- /dev/null +++ "b/docs/zh/docs/ClusterDeployment/\346\224\257\346\214\201\345\216\237\347\224\237\345\274\200\345\217\221\347\216\257\345\242\203\346\211\247\350\241\214\346\234\272\351\233\206\347\276\244\351\203\250\347\275\262\346\214\207\345\257\274.md" @@ -0,0 +1,588 @@ +# 文档说明 + +本文档介绍在 openEuler 操作系统上,通过 kubeadm 部署 K8S 集群,搭建 K8S+iSulad 的环境,并在该环境上部署 gitlab-runner,通过执行流水线用例任务来进行验证测试的步骤。 +本文档主要包括以下两部分的内容: + +1. K8s+iSulad 环境部署。 +2. gitlab runner 部署和测试。 + +> **说明**:本文档所有操作均使用root权限执行。 +> + +# K8s+iSulad环境部署 + +## 准备集群服务器 + +需准备至少3台openEuler机器,建议在openEuler-22.03及以上版本运行。下表为示例搭建机器信息。 + +| 主机名 | IP | 系统版本 | 角色 | 组件 | +|-------|-------------|------------------------|----------|-----------| +| lab1 | 197.xxx.xxx.xxx | openEuler 22.03 LTS SP4 | 控制节点 | iSulad/k8s | +| lab2 | 197.xxx.xxx.xxx | openEuler 22.03 LTS SP4 | 工作节点1 | iSulad/k8s | +| lab3 | 197.xxx.xxx.xxx | openEuler 22.03 LTS SP4 | 工作节点2 | iSulad/k8s | + +## 镜像/软件信息 + +安装过程中需要用到的软件及镜像名称如下表,版本号为示例安装时用到的版本,仅供参考。如果在无公网环境中搭建,需提前下载对应的软件包、相关依赖软件包及镜像。 + +- 软件包下载地址: +- 镜像下载地址:dockerhub官网 + +| 镜像/软件 | 版本 | +|------------------------------------|----------| +| iSulad | 2.0.17-2 | +| kubernetes-client | 1.20.2-9 | +| kubernetes-kubeadm | 1.20.2-9 | +| kubernetes-kubelet | 1.20.2-9 | +| k8s.gcr.io/kube-proxy | v1.20.2 | +| k8s.gcr.io/kube-apiserver | v1.20.2 | +| k8s.gcr.io/kube-controller-manager | v1.20.2 | +| k8s.gcr.io/kube-scheduler | v1.20.2 | +| k8s.gcr.io/etcd | 3.4.13-0 | +| k8s.gcr.io/coredns | 1.7.0 | +| k8s.gcr.io/pause | 3.2 | +| calico/node | v3.14.2 | +| calico/pod2daemon-flexvol | v3.14.2 | +| calico/cni | v3.14.2 | +| calico/kube-controllers | v3.14.2 | +| gitlab/gitlab-runner | alpine-v14.4.0 | +| gitlab/gitlab-runner-helper | x86_64-54944146 | + +## 修改host文件 + +1. 修改主机名,以其中一台机器为例。 + + ``` + # hostnamectl set-hostname lab1 + # sudo -i + ``` + +2. 配置主机名解析,编辑三台服务器的/etc/hosts文件。 + + ``` + # vim /etc/hosts + ``` + +3. 在hosts文件中添加以下内容(IP+主机名) + + ``` + 197.xxx.xxx.xxx lab1 + 197.xxx.xxx.xxx lab2 + 197.xxx.xxx.xxx lab3 + ``` + +## 环境准备 + +1. 关闭防火墙。 + + ``` + # systemctl stop firewalld + # systemctl disable firewalld + ``` + +2. 禁用selinux。 + + ``` + # setenforce 0 + ``` + +3. 关闭系统swap。 + + ``` + # swapoff -a + # sed -ri 's/.*swap.*/#&/' /etc/fstab + ``` + +4. 网络配置,开启相应的转发机制。 + + ``` + # cat > /etc/sysctl.d/kubernetes.conf <**说明** : 以下所下载的镜像版本均为示例,具体版本号以上条命令返回结果为准,下同。 + + ```shell + # isula pull k8simage/kube-apiserver:v1.20.15 + # isula pull k8smx/kube-controller-manager:v1.20.15 + # isula pull k8smx/kube-scheduler:v1.20.15 + # isula pull k8smx/kube-proxy:v1.20.15 + # isula pull k8smx/pause:3.2 + # isula pull k8smx/coredns:1.7.0 + # isula pull k8smx/etcd:3.4.13-0 + ``` + +3. 修改已下载的镜像标签。 + + ```shell + # isula tag k8simage/kube-apiserver:v1.20.15 k8s.gcr.io/kube-apiserver:v1.20.15 + # isula tag k8smx/kube-controller-manager:v1.20.15 k8s.gcr.io/kube-controller-manager:v1.20.15 + # isula tag k8smx/kube-scheduler:v1.20.15 k8s.gcr.io/kube-scheduler:v1.20.15 + # isula tag k8smx/kube-proxy:v1.20.15 k8s.gcr.io/kube-proxy:v1.20.15 + # isula tag k8smx/pause:3.2 k8s.gcr.io/pause:3.2 + # isula tag k8smx/coredns:1.7.0 k8s.gcr.io/coredns:1.7.0 + # isula tag k8smx/etcd:3.4.13-0 k8s.gcr.io/etcd:3.4.13-0 + ``` + +4. 删除旧镜像。 + + ```shell + # isula rmi k8simage/kube-apiserver:v1.20.15 + # isula rmi k8smx/kube-controller-manager:v1.20.15 + # isula rmi k8smx/kube-scheduler:v1.20.15 + # isula rmi k8smx/kube-proxy:v1.20.15 + # isula rmi k8smx/pause:3.2 + # isula rmi k8smx/coredns:1.7.0 + # isula rmi k8smx/etcd:3.4.13-0 + ``` + +5. 查看已拉取的镜像。 + + ```shell + # isula images + ``` + +## 安装crictl工具 + +```shell +# yum install -y cri-tools +``` + +## 初始化master节点 + +执行如下命令初始化master节点: + +```shell +# kubeadm init --kubernetes-version v1.20.2 --cri-socket=/var/run/isulad.sock --pod-network-cidr=[指定pod分配IP段] + +//以上参数的解释 +kubernetes-version 为当前安装的版本 +cri-socket 指定引擎为isulad +pod-network-cidr 指定pod分配的ip段 +``` + +根据系统提示输入如下命令: + +```shell +# mkdir -p $HOME/.kube +# sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config +# sudo chown $(id -u):$(id -g) $HOME/.kube/config +``` + +初始化成功后,复制最后两行内容,在node节点上执行刚刚复制的命令,将节点加入master集群,如未记录上述命令可通过如下命令生成: + +```shell +# kubeadm token create --print-join-command +``` + +## node节点添加进集群 + +粘贴master上初始化生成的kubeadm join ...命令,并在discovery前添加--cri-socket=/var/run/isulad.sock,执行如下命令: + +```shell +# kubeadm join [IP地址] --token bgyis4.euwkjqb7jwuenwvs --cri-socket=/var/run/isulad.sock --discovery-token-ca-cert-hash sha256:3792f02e136042e2091b245ac71c1b9cdcb97990311f9300e91e1c339e1dfcf6 +``` + +## 安装calico网络插件 + +1. 拉取calico镜像。 + + 需要在master节点配置calico网络插件,同时需要在每个节点中提前拉取需要版本的镜像。 + + ```shell + isula pull calico/node:v3.14.2 + isula pull calico/cni:v3.14.2 + isula pull calico/kube-controllers:v3.14.2 + isula pull calico/pod2daemon-flexvol:v3.14.2 + ``` + +2. 在master节点上获取配置文件。 + + ```shell + wget https://docs.projectcalico.org/v3.14/manifests/calico.yaml + ``` + +3. 修改calico.yaml文件。 + + ```shell + # vim calico.yaml + + //修改以下两个参数 + + - name: IP_AUTODERECTION_METHOD + Value: ”can-reach=197.3.10.254” + + - name: CALICO_IPV4POOL_IPIP + Value: ”CrossSubnet” + ``` + + ![](figures/2.calico%E9%85%8D%E7%BD%AE.png) + + - 若POD默认CNI为flannel,在flannel.yaml中添加以下内容,详见下图: + + ``` + --iface=enp4s0 + ``` + + ![](figures/3.png) + +4. 修改后创建pod。 + + ```shell + # kubectl apply -f calico.yaml + ``` + + - 如需删除使用如下命令: + + ```shell + # kubectl delete -f calico.yaml + ``` + +5. 查看pod信息。 + + ```shell + # kubectl get pod -A -o wide + ``` + +## 查看master节点node信息 + +使用如下命令可查看节点的详细信息: + +```shell +# kubectl get nodes -o wide +``` + +若需要重置node节点,可使用如下命令: + +```shell +# kubeadm reset +``` + +# gitlab runner部署及测试 + +## gitlab部署 + +将需要的yaml文件拷贝至/home目录,并启动对应的pod。 +> **说明**:gitlab相关的yaml文件可从官网获得,请选择需要的对应版本下载。 + +```shell +# kubectl apply -f gitlab-redis.yaml +# kubectl apply -f gitlab-postgresql.yaml +# kubectl apply -f gitlab.yaml +``` + +可通过命令查看gitlab pod是否搭建完成。 + +```shell +# kubectl get pod -A -owide +``` + +查看是否可以登录gitlab网页,网址为ip地址加设定的端口。 + +![网页入口](figures/4.gitlab%E7%BD%91%E9%A1%B5%E5%85%A5%E5%8F%A3.jpg) +用户名为root,默认密码需进入容器后查看密码文件。 + +```shell +# kubectl exec -it gitlab-lab -n default /bin/sh +# cat /etc/gitlab/initial_root_password +``` + +![查询密码](figures/5.%E6%9F%A5%E8%AF%A2%E5%AF%86%E7%A0%81.jpg) + +- 登录后界面如图: + +![登录后页面](figures/6.%E7%99%BB%E5%BD%95%E5%90%8E%E9%A1%B5%E9%9D%A2.png) + +## 使用gitlab-runner.yaml启动runner容器 + +修改gitlab-runner.yaml文件,修改文件中的镜像名。 + +```shell +# vim gitlab-runner.yaml +# kubectl apply -f gitlab-runner.yaml +# kubectl get pod -A -o wide +``` + +![镜像](figures/7.%E9%95%9C%E5%83%8F.png) + +## 登录gitlab容器网页-用户证书认证 + +1. 新建项目。 + + ![新建项目](figures/8.%E6%96%B0%E5%BB%BA%E9%A1%B9%E7%9B%AE.png) + +2. 创建空白项目。 + + ![创建空白项目](figures/9.%E5%88%9B%E5%BB%BA%E7%A9%BA%E7%99%BD%E9%A1%B9%E7%9B%AE.png) + +3. 自定义项目名称。 + + ![自定义项目名称](figures/10.%E8%87%AA%E5%AE%9A%E4%B9%89%E9%A1%B9%E7%9B%AE%E5%90%8D%E7%A7%B0.jpg) + +4. 设置--CI/CD--Runner--展开。 + + ![设置-cicd-runner](figures/11.%E8%AE%BE%E7%BD%AE-cicd-runner.png) + +5. 记录注册Runner的地址和令牌。 + + ![记下runner地址与令牌](figures/12.%E8%AE%B0%E4%B8%8Brunner%E5%9C%B0%E5%9D%80%E4%B8%8E%E4%BB%A4%E7%89%8C.jpg) + +6. 导入证书文件。 + + 在master节点上查看并生成证书文件,共三个文件admin.crt、admin.key、ca.crt。 + + - 查看证书信息 + + ```shell + # cat /etc/kubernetes/admin.conf + ``` + + ![查看证书配置文件](figures/13.%E6%9F%A5%E7%9C%8B%E8%AF%81%E4%B9%A6%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6.png) + + - 加密生成admin.crt + + ```shell + # echo “${client-certificate-data}” | base64 -d > admin.crt + ``` + + - 加密生成admin.key + + ```shell + # echo “${client-key-data}” | base64 -d > admin.key + ``` + + - 在manager节点上获取ca的证书 + + ```shell + # cp /etc/kubernetes/pki/ca.crt ./ + ``` + +7. 在runner运行的节点处将三个证书文件导入gitlab-runner容器。 + + >**说明** :导入容器需查看gitlab-runner运行在哪个节点上,将三个证书文件拷贝至该节点,然后使用isula cp命令导入。 + + ```shell + # isula cp admin.crt [容器id]:存放位置 + # isula cp admin.key [容器id]:存放位置 + # isula cp ca.crt [容器id]:存放位置 + ``` + + 注:isula cp 命令只能一次拷贝一个文件 + + ![证书导入文件](figures/14.%E8%AF%81%E4%B9%A6%E5%AF%BC%E5%85%A5%E6%96%87%E4%BB%B6.png) + +## 注册gitlab-runner + +进入到runner的容器内进行注册;目前采用交互式注册,注册信息在gitlab上获得,当前配置的 runner服务于项目组,此信息的界面在gitlab-\>项目组(group)-\>设置-\>CI/CD-\>runner中查看。 + +![注册gitlab-runner](figures/15.%E6%B3%A8%E5%86%8Cgitlab-runner.jpg) + +![web端已加入](figures/16.web%E7%AB%AF%E5%B7%B2%E5%8A%A0%E5%85%A5_LI.jpg) + +将准备好的gitlab-runner-helper镜像提前上传至私有镜像仓,进入gitlab-runner容器中,修改配置文件。 + +```shell +# cd /etc/gitlab-runner +# mkdir kubessl +# cp /home/admin.crt /etc/gitlab-runner/kubessl +# cp /home/ca.crt /etc/gitlab-runner/kubessl +# cp /home/admin.key /etc/gitlab-runner/kubessl +# vim /etc/gitlab-runner/config.toml +``` + +![](figures/17.png) + +## 在manager节点进行如下操作添加gitlab容器的dns记录 + +1. 查看gitlab容器的ip地址 + + ```shell + # kubectl get pods –Aowide + ``` + +2. 添加gitlabip地址到k8s dns配置文件 + + ```shell + # kubectl edit configmaps coredns -n kube-system + ``` + +![dns](figures/18.dns%E9%85%8D%E7%BD%AE.png) + +3. 重启coredns服务 + + ```shell + # kubectl scale deployment coredns -n kube-system --replicas=0 + # kubectl scale deployment coredns -n kube-system --replicas=2 + ``` + +## gitlab运行测试 + +返回gitlab的web界面,选择CI/CD--编辑器--创建新的CI/CD流水线。 + +![CICD界面](figures/19.CICD%E7%95%8C%E9%9D%A2.png) + +- 编译yaml文件如下: + +![yaml文件](figures/20.yaml%E6%96%87%E4%BB%B6.png) + +- 流水线-查看状态。 + +![流水线状态](figures/21.%E6%B5%81%E6%B0%B4%E7%BA%BF%E7%8A%B6%E6%80%81.png) diff --git "a/docs/zh/docs/Container/CRI\346\216\245\345\217\243.md" "b/docs/zh/docs/Container/CRI-v1alpha2\346\216\245\345\217\243.md" similarity index 99% rename from "docs/zh/docs/Container/CRI\346\216\245\345\217\243.md" rename to "docs/zh/docs/Container/CRI-v1alpha2\346\216\245\345\217\243.md" index 0695f784358f8ee6126124e6eb2b0ba6dc03418b..9d1ac2bd92929e7d10ef959c79c1ae0cd8b5fd96 100644 --- "a/docs/zh/docs/Container/CRI\346\216\245\345\217\243.md" +++ "b/docs/zh/docs/Container/CRI-v1alpha2\346\216\245\345\217\243.md" @@ -1,4 +1,4 @@ -# CRI接口 +# CRI V1alpha2 接口 ## 描述 @@ -6,7 +6,7 @@ CRI API 接口是由kubernetes 推出的容器运行时接口,CRI定义了容 因为容器运行时与镜像的生命周期是彼此隔离的,因此需要定义两个服务。该接口使用[Protocol Buffer](https://developers.google.com/protocol-buffers/)定义,基于[gRPC](https://grpc.io/)。 -当前实现CRI版本为v1alpha1版本,官方API描述文件如下: +当前iSulad使用默认CRI版本为v1alpha2版本,官方API描述文件如下: [https://github.com/kubernetes/kubernetes/blob/release-1.14/pkg/kubelet/apis/cri/runtime/v1alpha2/api.proto](https://github.com/kubernetes/kubernetes/blob/release-1.14/pkg/kubelet/apis/cri/runtime/v1alpha2/api.proto), diff --git "a/docs/zh/docs/Container/CRI-v1\346\216\245\345\217\243.md" "b/docs/zh/docs/Container/CRI-v1\346\216\245\345\217\243.md" new file mode 100644 index 0000000000000000000000000000000000000000..55202eb71688de94b726bda2b07be6f86761bca7 --- /dev/null +++ "b/docs/zh/docs/Container/CRI-v1\346\216\245\345\217\243.md" @@ -0,0 +1,312 @@ +# CRI V1接口支持 + +## 概述 + +CRI(Container Runtime Interface, 容器运行时接口)是kublet与容器引擎通信使用的主要协议。 +在K8S 1.25及之前,K8S存在CRI v1alpha2 和 CRI V1两种版本的CRI接口,但从1.26开始,K8S仅提供对于CRI V1的支持。 + +iSulad同时提供对[CRI v1alpha2](./CRI-v1alpha2接口.md)和CRI v1的支持, +对于CRI v1,iSulad支持[CRI v1alpha2](./CRI-v1alpha2接口.md)所述功能, +并提供对CRI V1中所定义新接口和字段的支持。 + +目前iSulad支持的CRI V1版本为1.29,对应官网描述API如下: + +[https://github.com/kubernetes/cri-api/blob/kubernetes-1.29.0/pkg/apis/runtime/v1/api.proto](https://github.com/kubernetes/cri-api/blob/kubernetes-1.29.0/pkg/apis/runtime/v1/api.proto) + +iSulad使用的API描述文件,与官方API略有出入,以本文档描述的接口为准。 + +## 新增字段描述 + +- **CgroupDriver** + + cgroup驱动的enum值列表 + + + + + + + + + + + + + +

参数成员

+

描述

+

SYSTEMD = 0

+

systemd cgroup驱动

+

CGROUPFS = 1

+

cgroupfs驱动

+
+ +- **LinuxRuntimeConfiguration** + + 容器引擎所使用的cgroup驱动 + + + + + + + + + + +

参数成员

+

描述

+

CgroupDriver cgroup_driver

+

容器引擎所使用的cgroup驱动枚举值

+
+ +- **ContainerEventType** + + 容器事件类型枚举值 + + + + + + + + + + + + + + + + + + + +

参数成员

+

描述

+

CONTAINER_CREATED_EVENT = 0

+

容器创建类型

+

CONTAINER_STARTED_EVENT = 1

+

容器启动类型

+

CONTAINER_STOPPED_EVENT = 1

+

容器停止类型

+

CONTAINER_DELETED_EVENT = 1

+

容器删除类型

+
+ +- **SwapUsage** + + 虚拟内存使用情况 + + + + + + + + + + + + + + + + +

参数成员

+

描述

+

int64 timestamp

+

时间戳信息

+

UInt64Value swap_available_bytes

+

可使用虚拟内存字节数

+

UInt64Value swap_usage_bytes

+

已使用虚拟内存字节数

+
+ +## 新增接口描述 + +### RuntimeConfig + +#### 接口原型 + +```text +rpc RuntimeConfig(RuntimeConfigRequest) returns (RuntimeConfigResponse) {} +``` + +#### 接口描述 + +获取cgroup驱动配置 cgroupfs 或 systemd-cgroup + +#### 参数 RuntimeConfigRequest + +无字段 + +#### 返回值 RuntimeConfigResponse + + + + + + + + + +

返回值

+

描述

+

LinuxRuntimeConfiguration linux

+

描述cgroupfs或者systemd-cgroup的CgroupDriver枚举值

+
+ +### GetContainerEvents + +#### 接口原型 + +```text +rpc GetContainerEvents(GetEventsRequest) returns (stream ContainerEventResponse) {} +``` + +#### 接口描述 + +获取Pod生命周期事件流 + +#### 参数 GetEventsRequest + +无字段 + +#### 返回值 ContainerEventResponse + + + + + + + + + + + + + + + + + + + + + +

返回值

+

描述

+

string container_id

+

容器id

+

ContainerEventType container_event_type

+

容器事件类型

+

int64 created_at

+

容器事件产生时间

+

PodSandboxStatus pod_sandbox_status

+

容器所属Pod的status信息

+

repeated ContainerStatus containers_statuses

+

容器所属Pod内所有容器的status信息

+
+ +## 变更描述 + +### CRI V1.29更新变更描述 + +#### [获取cgroup驱动配置](https://github.com/kubernetes/kubernetes/pull/118770) + +`RuntimeConfig` 获取cgroup驱动配置 cgroupfs 或 systemd-cgroup + +#### [GetContainerEvents支持pod生命周期事件](https://github.com/kubernetes/kubernetes/pull/111384) + +`GetContainerEents`,提供对pod生命周期相关事件流 + +`PodSandboxStatus`有相应调整,增加ContainerStatuses提供沙箱内容器status信息 + +#### [ContainerStats虚拟内存信息](https://github.com/kubernetes/kubernetes/pull/118865) + +`ContainerStats`新增虚拟内存使用情况信息: `SwapUsage` + +#### [ContainerStatus reason字段OOMKilled设置](https://github.com/kubernetes/kubernetes/pull/112977) + +ContainerStatus中reason字段在cgroup out-of-memory时应该设置为OOMKilled + +#### [PodSecurityContext.SupplementalGroups描述修改](https://github.com/kubernetes/kubernetes/pull/113047) + +描述修改,优化`PodSecurityContext.SupplementalGroups`的注释,明确容器镜像定义的主UID不在该列表下的行为 + +#### [ExecSync输出限制](https://github.com/kubernetes/kubernetes/pull/110435) + +ExecSync返回值输出小于16MB + +## 使用手册 + +### 配置iSulad支持CRI V1 + +该需求需要iSulad对K8S新版本CRI接口1.29提供支持, + +对于1.25及之前的CRI接口,V1alpha2和V1功能保持一致,1.26及之后新增的特性仅在CRI V1中提供支持。 +此次升级的功能和特性仅在CRI V1中提供支持,因此新增特性均需要按照以下配置使能CRI V1。 + +CRI V1使能: + +iSulad daemon.json中enable-cri-v1设置为true,重启iSulad + +```json +{ + "group": "isula", + "default-runtime": "runc", + ... + "enable-cri-v1": true +} +``` + +若通过源码进行编译安装iSulad需开启ENABLE_CRI_API_V1编译选项 + +```bash +cmake ../ -D ENABLE_CRI_API_V1=ON +``` + +### RuntimeConfig获取cgroup驱动配置 + +#### systemd-cgroup配置 + +iSulad同时提供对systemd和cgroupfs两种cgroup驱动支持, +默认使用cgroupfs作为cgroup驱动,可以通过配置iSulad容器引擎提供对systemd cgroup驱动支持。 +iSulad仅提供底层运行时为runc时systemd-cgroup的支持。通过修改iSulad配置文件daemon.json, +设置systemd-cgroup为true,重启iSulad,则使用systemd cgroup驱动。 + +```json +{ + "group": "isula", + "default-runtime": "runc", + ... + "enable-cri-v1": true, + "systemd-cgroup": true +} +``` + +### GetContainerEvents Pod 生命周期事件生成 + +#### Pod Events配置 + +修改iSulad配置文件daemon.json, +设置enable-pod-events为true,重启iSulad。 + +```json +{ + "group": "isula", + "default-runtime": "runc", + ... + "enable-cri-v1": true, + "enable-pod-events": true +} +``` + +## 使用限制 + +1. 以上新增特性,iSulad仅提供容器运行时设置为runc时的支持。 +2. 由于cgroup oom会同时触发容器cgroup路径删除,若iSulad对oom事件处理发生在 +cgroup路径删除之后,iSulad则无法成功捕捉容器oom事件, +可能导致ContainerStatus中reason字段设置不正确。 +3. iSulad不支持交叉使用不同的cgroup驱动管理容器,启动容器后iSulad的cgroup驱动配置不应该发生变化。 diff --git "a/docs/zh/docs/Container/iSulad\346\224\257\346\214\201CDI.md" "b/docs/zh/docs/Container/iSulad\346\224\257\346\214\201CDI.md" new file mode 100644 index 0000000000000000000000000000000000000000..8621f2cf046d8e872224d6286a5ef7e98d7dd3a3 --- /dev/null +++ "b/docs/zh/docs/Container/iSulad\346\224\257\346\214\201CDI.md" @@ -0,0 +1,107 @@ +# iSulad支持CDI + +## 概述 +CDI(Container Device Interface,容器设备接口)是容器运行时的一种规范,用于支持第三方设备。 + +CDI解决了如下问题: +在Linux上,为了使容器具有设备感知能力,过去只需在该容器中暴露一个设备节点。但是,随着设备和软件变得越来越复杂,供应商希望执行更多的操作,例如: +- 向容器公开设备可能需要公开多个设备节点、从运行时命名空间挂载文件或隐藏procfs条目。 +- 执行容器和设备之间的兼容性检查(例如:检查容器是否可以在指定设备上运行)。 +- 执行特定于运行时的操作(例如:虚拟机与基于Linux容器的运行时)。 +- 执行特定于设备的操作(例如:清理GPU的内存或重新配置FPGA)。 + +在缺乏第三方设备标准的情况下,供应商通常不得不为不同的运行时编写和维护多个插件,甚至直接在运行时中贡献特定于供应商的代码。此外,运行时不统一地暴露插件系统(甚至根本不暴露插件系统),导致在更高级别的抽象(例如Kubernetes设备插件)中重复功能。 + +CDI解决上述问题的方法: +CDI描述了一种允许第三方供应商与设备交互的机制,从而不需要更改容器运行时。 + +使用的机制是一个JSON文件(类似于容器网络接口(CNI)),它允许供应商描述容器运行时应该对容器的OCI规范执行的操作。 + +iSulad目前已支持[CDI v0.6.0](https://github.com/cncf-tags/container-device-interface/blob/v0.6.0/SPEC.md)规范。 + +## 配置iSulad支持CDI +需要对daemon.json做如下配置,然后重启iSulad: +```json +{ + ... + "enable-cri-v1": true, + "cdi-spec-dirs": ["/etc/cdi", "/var/run/cdi"], + "enable-cdi": true +} +``` +其中"cdi-spec-dirs"用于指定CDI specs所在目录,如果不指定则默认为"/etc/cdi", "/var/run/cdi"。 + +## 使用示例: +### CDI specification实例: +具体每个字段含义详见[CDI v0.6.0](https://github.com/cncf-tags/container-device-interface/blob/v0.6.0/SPEC.md) +```bash +$ mkdir /etc/cdi +$ cat > /etc/cdi/vendor.json < ![](./public_sys-resources/icon-note.gif) **说明:** +> +> 安装完成后,需要手工启动isula-build服务。启动请参见[管理服务](isula-build构建工具.md#管理服务)。 + +# 配置与管理服务 + +## 配置服务 + +在安装完 isula-build 软件包之后,systemd 管理服务会以 isula-build 软件包自带的 isula-build 服务端默认配置启动 isula-build 服务。如果 isula-build 服务端的默认配置文件不能满足用户的需求,可以参考如下介绍进行定制化配置。需要注意的是,修改完默认配置之后,需要重启 isula-build 服务端使新配置生效,具体操作可参考下一章节。 + +目前 isula-build 服务端包含如下配置文件: + +* /etc/isula-build/configuration.toml:isula-builder 总体配置文件,用于设置 isula-builder 日志级别、持久化目录和运行时目录、OCI runtime等。其中各参数含义如下: + +| 配置项 | 是否可选 | 配置项含义 | 配置项取值 | +| --------- | -------- | --------------------------------- | ----------------------------------------------- | +| debug | 可选 | 设置是否打开debug日志 | true:打开debug日志
false:关闭debug日志 | +| loglevel | 可选 | 设置日志级别 | debug
info
warn
error | +| run_root | 必选 | 设置运行时数据根目录 | 运行时数据根目录路径,例如/var/run/isula-build/ | +| data_root | 必选 | 设置本地持久化目录 | 本地持久化目录路径,例如/var/lib/isula-build/ | +| runtime | 可选 | 设置runtime种类,目前仅支持runc | runc | +| group | 可选 | 设置本地套接字isula_build.sock文件属组使得加入该组的非特权用户可以操作isula-build | isula | +| experimental | 可选 | 设置是否开启实验特性 | true:开启实验特性;false:关闭实验特性 | + +* /etc/isula-build/storage.toml: 本地持久化存储的配置文件,包含所使用的存储驱动的配置。 + +| 配置项 | 是否可选 | 配置项含义 | +| ------ | -------- | ------------------------------ | +| driver | 可选 | 存储驱动类型,目前支持overlay2 | + + 更多设置可参考 [containers-storage.conf.5](https://github.com/containers/storage/blob/main/docs/containers-storage.conf.5.md)。 + +* /etc/isula-build/registries.toml : 针对各个镜像仓库的配置文件。 + +| 配置项 | 是否可选 | 配置项含义 | +| ------------------- | -------- | ------------------------------------------------------------ | +| registries.search | 可选 | 镜像仓库搜索域,在此list的镜像仓库可以被感知,不在此列的不被感知。 | +| registries.insecure | 可选 | 可访问的不安全镜像仓库地址,在此列表中的镜像仓库将不会通过鉴权,不推荐使用。 | + + 更多设置可参考 [containers-registries.conf.5](https://github.com/containers/image/blob/main/docs/containers-registries.conf.5.md)。 + +* /etc/isula-build/policy.json:镜像pull/push策略文件。当前不支持对其进行配置。 + +> ![](./public_sys-resources/icon-note.gif) **说明:** +> +> * isula-build 支持最大 1MiB 的上述配置文件。 +> * isula-build 不支持将持久化工作目录 dataroot 配置在内存盘上,比如 tmpfs。 +> * isula-build 目前仅支持使用overlay2为底层 graphdriver。 +> * 在设置--group参数前,需保证本地OS已经创建了对应的用户组,且非特权用户已经加入该组。重启isula-builder之后即可使该非特权用户使用isula-build功能。同时,为了保持权限一致性,isula-build的配置文件目录/etc/isula-build的属组也会被设置为--group指定的组。 + +## 管理服务 + +目前 openEuler 采用 systemd 管理软件服务,isula-build 软件包已经自带了 systemd 的服务文件,用户安装完 isula-build 软件包之后,可以直接通过 systemd 工具对它进行服务启停等操作。用户同样可以手动启动 isula-build 服务端软件。需要注意的是,同一个节点上不可以同时启动多个 isula-build 服务端软件。 + +>![](./public_sys-resources/icon-note.gif) **说明:** +> +> 同一个节点上不可以同时启动多个 isula-build 服务端软件。 + +### 通过 systemd 管理(推荐方式) + +用户可以通过如下 systemd 的标准指令控制 isula-build 服务的启动、停止、重启等动作: + +* 启动 isula-build 服务: + + ```sh + sudo systemctl start isula-build.service + ``` + +* 停止 isula-build 服务: + + ```sh + sudo systemctl stop isula-build.service + ``` + +* 重启 isula-build 服务: + + ```sh + sudo systemctl restart isula-build.service + ``` + +isula-build 软件包安装的 systemd 服务文件保存在 `/usr/lib/systemd/system/isula-build.service`。如果用户需要修改 isula-build 服务的 systemd 配置,可以修改该文件,执行如下命令使配置生效,之后再根据上面提到的 systemd 管理指令重启 isula-build 服务 + +```sh +sudo systemctl daemon-reload +``` + +### 直接运行 isula-build 服务端 + +您也可以通过执行 isula-build 服务端命令( isula-builder)的方式启动服务。其中,服务端启动配置,可通过isula-builder命令支持的 flags 设置。isula-build 服务端目前支持的 flags 如下: + +* -D, --debug: 是否开启调测模式。 +* --log-level: 日志级别,支持 “debug”, “info”, “warn” or “error”,默认为 “info”。 +* --dataroot: 本地持久化路径,默认为”/var/lib/isula-build/“。 +* --runroot: 运行时路径,默认为”/var/run/isula-build/“。 +* --storage-driver:底层存储驱动类型。 +* --storage-opt: 底层存储驱动配置。 +* --group: 设置本地套接字isula_build.sock文件属组使得加入该组的非特权用户可以操作isula-build,默认为“isula”。 +* --experimental: 是否开启实验特性,默认为false。 + +>![](./public_sys-resources/icon-note.gif) **说明:** +> +> 当命令行启动参数中传递了与配置文件相同的配置选项时,优先使用命令行参数启动。 + +启动 isula-build 服务。例如指定本地持久化路径/var/lib/isula-build,且不开启调试的参考命令如下: + +```sh +sudo isula-builder --dataroot "/var/lib/isula-build" --debug=false +``` + +# 使用指南 + +## 前提条件 + +isula-build 构建 Dockerfile 内的 RUN 指令时依赖可执行文件 runc ,需要 isula-build 的运行环境上预装好 runc。安装方式视用户使用场景而定,如果用户不需要使用完整的 docker-engine 工具链,则可以仅安装 docker-runc rpm包: + +```sh +sudo yum install -y docker-runc +``` + +如果用户需要使用完整的 docker-engine 工具链,则可以安装 docker-engine rpm包,默认包含可执行文件 runc : + +```sh +sudo yum install -y docker-engine +``` + +>![](./public_sys-resources/icon-note.gif) **说明:** +> +> 用户需保证OCI runtime(runc)可执行文件的安全性,避免被恶意替换。 + +## 总体说明 + +isula-build 客户端提供了一系列命令用于构建和管理容器镜像,当前 isula-build 包含的命令行指令如下: + +* ctr-img,容器镜像管理。ctr-img又包含如下子命令: + * build,根据给定dockerfile构建出容器镜像。 + * images,列出本地容器镜像。 + * import,导入容器基础镜像。 + * load,导入层叠镜像。 + * rm,删除本地容器镜像。 + * save,导出层叠镜像至本地磁盘。 + * tag,给本地容器镜像打tag。 + * pull,拉取镜像到本地。 + * push,推送本地镜像到远程仓库。 +* info,查看isula-build的运行环境和系统信息。 +* login,登录远端容器镜像仓库。 +* logout,退出远端容器镜像仓库。 +* version,查看isula-build和isula-builder的版本号。 +* manifest(实验特性),管理manifest列表。 + +>![](./public_sys-resources/icon-note.gif) **说明:** +> +> * isula-build completion 和 isula-builder completion 命令用于生成bash命令补全脚本。该命令为命令行框架隐式提供,不会显示在help信息中。 +> * isula-build客户端不包含配置文件,当用户需要使用isula-build实验特性时,需要在客户端通过命令`export ISULABUILD_CLI_EXPERIMENTAL=enabled`配置环境变量ISULABUILD_CLI_EXPERIMENTAL来开启实验特性。 + +以下按照上述维度依次详细介绍这些命令行指令的使用。 + +## ctr-img: 容器镜像管理 + +isula-build 将所有容器镜像管理相关命令划分在子命令 `ctr-img` 下,命令原型为: + +```sh +isula-build ctr-img [command] +``` + +### build: 容器镜像构建 + +ctr-img 的子命令 build 用于构建容器镜像,命令原型为: + +```sh +isula-build ctr-img build [flags] +``` + +其中 build 包含如下 flags: + +* --build-arg:string列表,构建过程中需要用到的变量。 +* --build-static:KeyValue值,构建二进制一致性。目前包含如下Key值: + * build-time:string,使用固定时间戳来构建容器镜像;时间戳格式为“YYYY-MM-DD HH-MM-SS”。 +* -f, --filename:string,Dockerfile的路径,不指定则是使用当前路径的Dockerfile文件。 +* --format: string, 设置构建镜像的镜像格式:oci | docker(需开启实验特性选项)。 +* --iidfile:string,输出 image ID 到本地文件。 +* -o, --output:string,镜像导出的方式和路径。 +* --proxy:布尔值,继承主机侧环境的proxy环境变量(默认为true)。 +* --tag:string,设置构建成功的镜像的tag值。 +* --cap-add:string列表,构建过程中RUN指令所需要的权限。 + +**以下为各个 flags 的详解。** + +**\--build-arg** + +从命令行接受参数作为Dockerfile中的参数,用法: + +```sh +$ echo "This is bar file" > bar.txt +$ cat Dockerfile_arg +FROM busybox +ARG foo +ADD ${foo}.txt . +RUN cat ${foo}.txt +$ sudo isula-build ctr-img build --build-arg foo=bar -f Dockerfile_arg +STEP 1: FROM busybox +Getting image source signatures +Copying blob sha256:8f52abd3da461b2c0c11fda7a1b53413f1a92320eb96525ddf92c0b5cde781ad +Copying config sha256:e4db68de4ff27c2adfea0c54bbb73a61a42f5b667c326de4d7d5b19ab71c6a3b +Writing manifest to image destination +Storing signatures +STEP 2: ARG foo +STEP 3: ADD ${foo}.txt . +STEP 4: RUN cat ${foo}.txt +This is bar file +Getting image source signatures +Copying blob sha256:6194458b07fcf01f1483d96cd6c34302ffff7f382bb151a6d023c4e80ba3050a +Copying blob sha256:6bb56e4a46f563b20542171b998cb4556af4745efc9516820eabee7a08b7b869 +Copying config sha256:39b62a3342eed40b41a1bcd9cd455d77466550dfa0f0109af7a708c3e895f9a2 +Writing manifest to image destination +Storing signatures +Build success with image id: 39b62a3342eed40b41a1bcd9cd455d77466550dfa0f0109af7a708c3e895f9a2 +``` + +**\--build-static** + +指定为静态构建,即使用isula-build构建容器镜像时消除所有时间戳和其他构建因素(例如容器ID、hostname等)的差异。最终构建出满足静态要求的容器镜像。 + +在使用isula-build进行容器镜像构建时,假如给 build 子命令一个固定的时间戳,并在限定如下条件的时候: + +* 构建环境前后保持一致。 +* 构建Dockerfile前后保持一致。 +* 构建产生的中间数据前后保持一致。 +* 构建命令相同。 +* 第三方库版本一致。 + +对于容器镜像构建,isula-build支持相同的Dockerfile。如果构建环境相同,则多次构建生成的镜像内容和镜像ID相同。 + +--build-static接受k=v形式的键值对选项,当前支持的选项有: + +* build-time:字符串类型。构建静态镜像的固定时间戳,格式为“YYYY-MM-DD HH-MM-SS”。时间戳影响diff层创建修改时间的文件属性。 + + 使用示例如下: + + ```sh + sudo isula-build ctr-img build -f Dockerfile --build-static='build-time=2020-05-23 10:55:33' . + ``` + + 以此方式,同一环境多次构建出来的容器镜像和镜像ID均会保持一致。 + +**\--format** +开始实验特性后该选项可用,默认为OCI镜像格式。可以手动指定镜像格式进行构建,例如,下面分别为构建OCI镜像格式以及Docker镜像格式镜像的命令。 + + ```sh + export ISULABUILD_CLI_EXPERIMENTAL=enabled; sudo isula-build ctr-img build -f Dockerfile --format oci . + ``` + + ```sh + export ISULABUILD_CLI_EXPERIMENTAL=enabled; sudo isula-build ctr-img build -f Dockerfile --format docker . + ``` + +**\--iidfile** + +将构建的镜像ID输出到文件,用法: + +```sh +isula-build ctr-img build --iidfile filename +``` + +例如,将容器镜像ID输出到testfile的参考命令如下: + + ```sh +sudo isula-build ctr-img build -f Dockerfile_arg --iidfile testfile + ``` + + 查看testfile中的容器镜像ID: + + ```sh +$ cat testfile +76cbeed38a8e716e22b68988a76410eaf83327963c3b29ff648296d5cd15ce7b + ``` + +**\-o, --output** + +目前 -o, --output 支持如下形式: + +* `isulad:image:tag`:将构建成功的镜像直接推送到 iSulad。比如:`-o isulad:busybox:latest`。同时需要注意如下约束: + + * isula-build 和 iSulad 必须在同一个节点上 + * tag必须配置 + * isula-build client端需要将构建成功的镜像暂存成 `/var/tmp/isula-build-tmp-%v.tar` 再导入至 iSulad,用户需要保证 `/var/tmp/` 目录有足够磁盘空间 + +* `docker-daemon:image:tag`:将构建成功的镜像直接推送到 Docker daemon。比如:`-o docker-daemon:busybox:latest`。同时需要注意如下约束: + * isula-build 和 docker 必须在同一个节点上 + * tag必须配置 + +* `docker://registry.example.com/repository:tag`:将构建成功的镜像以Docker镜像格式直接推送到远端镜像仓库。比如:`-o docker://localhost:5000/library/busybox:latest`。 + +* `docker-archive:/:image:tag`:将构建成功的镜像以Docker镜像格式保存至本地。比如:`-o docker-archive:/root/image.tar:busybox:latest`。 + +打开实验特性之后,可以启用相应OCI镜像的构建: + +* `oci://registry.example.com/repository:tag`:将构建成功的镜像以OCI镜像格式直接推送到远端镜像仓库(远程镜像仓库须支持OCI镜像格式)。比如:`-o oci://localhost:5000/library/busybox:latest`。 + +* `oci-archive:/:image:tag`:将构建成功的镜像以OCI镜像的格式保存至本地。比如:`-o oci-archive:/root/image.tar:busybox:latest`。 + +除去各个flags之外,build子命令的命令行最后还会接收一个argument,该argument类型是string,意义为context,即该Dockerfile构建环境的上下文。该参数缺省值为isula-build被执行的当前路径。该路径会影响 .dockerignore 和 Dockerfile的ADD/COPY指令 所检索的路径。 + +**\--proxy** + +选择构建时RUN指令启动的容器是否从环境上继承proxy相关环境变量“http_proxy”,“https_proxy”,“ftp_proxy”,“no_proxy”,“HTTP_PROXY”,“HTTPS_PROXY”,“FTP_PROXY”,“NO_PROXY”,默认为true。 + +当用户在Dockerfile配置proxy相关ARG或ENV,将覆盖所继承的环境变量。 + +注意:若client与daemon不在同一个终端运行,所能继承的环境变量为daemon所在终端的环境变量。 + +**\--tag** + +设置镜像构建成功之后,该镜像在本地磁盘存储时的tag。 + +**\--cap-add** + +添加构建过程中RUN指令所需权限,用法: + +```sh +isula-build ctr-img build --cap-add ${CAP} +``` + +使用举例: + +```sh +sudo isula-build ctr-img build --cap-add CAP_SYS_ADMIN --cap-add CAP_SYS_PTRACE -f Dockerfile +``` + +> ![](./public_sys-resources/icon-note.gif) **说明:** +> +> * isula-build最大支持并发构建100个容器镜像。 +> * isula-build支持Dockerfile最大为1MiB。 +> * isula-build支持 .dockerignore 最大为 1MiB。 +> * 用户需保证Dockerfile文件的权限为仅当前用户可读写,避免别的用户进行篡改。 +> * 构建时,RUN指令会启动容器在容器内进行构建,目前 isula-build 仅支持使用主机网络。 +> * isula-build 导出的镜像压缩格式,目前仅支持tar格式。 +> * isula-build 在每一个镜像构建stage完成后做一次提交,而不是每执行 Dockerfile的一行就提交一次。 +> * isula-build 暂不支持构建缓存。 +> * isula-build 仅在构建RUN指令时会启动构建容器。 +> * 目前不支持docker镜像格式的history功能。 +> * isula-build 的stage name支持以数字开头。 +> * isula-build 的stage name最长可为64个字符。 +> * isula-build 暂不支持对单次Dockerfile的构建进行资源限制。如有资源限制需求,可通过对 isula-builder 服务端配置资源限额的方式进行限制。 +> * isula-build 目前不支持Dockerfile里的ADD指令提供的数据来源是远端url。 +> * isula-build 使用docker-archive以及oci-archive类型导出的本地tar包未经压缩。如有需求,用户可以手动进行压缩。 + +### image: 查看本地持久化构建镜像 + +可通过images命令查看当前本地持久化存储的镜像: + +```sh +$ sudo isula-build ctr-img images +--------------------------------------- ----------- ----------------- ------------------------ ------------ +REPOSITORY TAG IMAGE ID CREATED SIZE +--------------------------------------- ----------- ----------------- ------------------------ ------------ +localhost:5000/library/alpine latest a24bb4013296 2022-01-17 10:02:19 5.85 MB + 39b62a3342ee 2022-01-17 10:01:12 1.45 MB +--------------------------------------- ----------- ----------------- ------------------------ ------------ +``` + +> ![](./public_sys-resources/icon-note.gif) **说明:** +> +> 通过`isula-build ctr-img images`查看的镜像大小与`docker images`的显示上有一定差异。这是因为统计镜像大小时,isula-build是直接计算每层tar包大小之和,而docker是通过解压tar遍历diff目录计算文件大小之和,因此存在统计上的差异。 + +### import: 导入容器基础镜像 + +可以通过`ctr-img import`指令将rootfs形式的tar文件导入到isula-build中。 + +命令原型如下: + +```sh +isula-build ctr-img import [flags] +``` + +使用举例: + +```sh +$ sudo isula-build ctr-img import busybox.tar mybusybox:latest +Getting image source signatures +Copying blob sha256:7b8667757578df68ec57bfc9fb7754801ec87df7de389a24a26a7bf2ebc04d8d +Copying config sha256:173b3cf612f8e1dc34e78772fcf190559533a3b04743287a32d549e3c7d1c1d1 +Writing manifest to image destination +Storing signatures +Import success with image id: "173b3cf612f8e1dc34e78772fcf190559533a3b04743287a32d549e3c7d1c1d1" +$ sudo isula-build ctr-img images +--------------------------------------- ----------- ----------------- ------------------------ ------------ +REPOSITORY TAG IMAGE ID CREATED SIZE +--------------------------------------- ----------- ----------------- ------------------------ ------------ +mybusybox latest 173b3cf612f8 2022-01-12 16:02:31 1.47 MB +--------------------------------------- ----------- ----------------- ------------------------ ------------ +``` + +>![](./public_sys-resources/icon-note.gif) **说明:** +> +> isula-build 支持导入最大1GiB的容器基础镜像。 + +### load: 导入层叠镜像 + +层叠镜像指的是通过 docker save 或 isula-build ctr-img save 等指令,将一个构建完成的镜像保存至本地之后,镜像压缩包内是一层一层 layer.tar 的镜像包。可以通过 ctr-img load 指令将它导入至 isula-build。 + +命令原型如下: + +```sh +isula-build ctr-img load [flags] +``` + +目前支持的 flags 为: + +* -i, --input:本地tar包的路径 + +使用举例如下: + +```sh +$ sudo isula-build ctr-img load -i ubuntu.tar +Getting image source signatures +Copying blob sha256:cf612f747e0fbcc1674f88712b7bc1cd8b91cf0be8f9e9771235169f139d507c +Copying blob sha256:f934e33a54a60630267df295a5c232ceb15b2938ebb0476364192b1537449093 +Copying blob sha256:943edb549a8300092a714190dfe633341c0ffb483784c4fdfe884b9019f6a0b4 +Copying blob sha256:e7ebc6e16708285bee3917ae12bf8d172ee0d7684a7830751ab9a1c070e7a125 +Copying blob sha256:bf6751561805be7d07d66f6acb2a33e99cf0cc0a20f5fd5d94a3c7f8ae55c2a1 +Copying blob sha256:c1bd37d01c89de343d68867518b1155cb297d8e03942066ecb44ae8f46b608a3 +Copying blob sha256:a84e57b779297b72428fc7308e63d13b4df99140f78565be92fc9dbe03fc6e69 +Copying blob sha256:14dd68f4c7e23d6a2363c2320747ab88986dfd43ba0489d139eeac3ac75323b2 +Copying blob sha256:a2092d776649ea2301f60265f378a02405539a2a68093b2612792cc65d00d161 +Copying blob sha256:879119e879f682c04d0784c9ae7bc6f421e206b95d20b32ce1cb8a49bfdef202 +Copying blob sha256:e615448af51b848ecec00caeaffd1e30e8bf5cffd464747d159f80e346b7a150 +Copying blob sha256:f610bd1e9ac6aa9326d61713d552eeefef47d2bd49fc16140aa9bf3db38c30a4 +Copying blob sha256:bfe0a1336d031bf5ff3ce381e354be7b2bf310574cc0cd1949ad94dda020cd27 +Copying blob sha256:f0f15db85788c1260c6aa8ad225823f45c89700781c4c793361ac5fa58d204c7 +Copying config sha256:c07ddb44daa97e9e8d2d68316b296cc9343ab5f3d2babc5e6e03b80cd580478e +Writing manifest to image destination +Storing signatures +Loaded image as c07ddb44daa97e9e8d2d68316b296cc9343ab5f3d2babc5e6e03b80cd580478e +``` + +>![](./public_sys-resources/icon-note.gif) **说明:** +> +> * isula-build 支持导入最大50G的容器层叠镜像。 +> * isula-build 会自动识别容器层叠镜像的格式并进行导入。 + +### rm: 删除本地持久化镜像 + +可通过rm命令删除当前本地持久化存储的镜像。命令原型为: + +```sh +isula-build ctr-img rm IMAGE [IMAGE...] [FLAGS] +``` + +目前支持的 flags 为: + +* -a, --all:删除所有本地持久化存储的镜像。 +* -p, --prune:删除所有没有tag的本地持久化存储的镜像。 + +使用示例如下: + +```sh +$ sudo isula-build ctr-img rm -p +Deleted: sha256:78731c1dde25361f539555edaf8f0b24132085b7cab6ecb90de63d72fa00c01d +Deleted: sha256:eeba1bfe9fca569a894d525ed291bdaef389d28a88c288914c1a9db7261ad12c +``` + +### save: 导出层叠镜像 + +可通过save命令导出层叠镜像到本地磁盘。命令原型如下: + +```sh +isula-build ctr-img save [REPOSITORY:TAG]|imageID -o xx.tar +``` + +目前支持的 flags 为: + +* -f, --format:导出层叠镜像的镜像格式:oci | docker(需开启实验特性选项) +* -o, --output:本地tar包路径 + +以下示例通过 `image/tag` 的形式将镜像进行导出: + +```sh +$ sudo isula-build ctr-img save busybox:latest -o busybox.tar +Getting image source signatures +Copying blob sha256:50644c29ef5a27c9a40c393a73ece2479de78325cae7d762ef3cdc19bf42dd0a +Copying blob sha256:824082a6864774d5527bda0d3c7ebd5ddc349daadf2aa8f5f305b7a2e439806f +Copying blob sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef +Copying config sha256:21c3e96ac411242a0e876af269c0cbe9d071626bdfb7cc79bfa2ddb9f7a82db6 +Writing manifest to image destination +Storing signatures +Save success with image: busybox:latest +``` + +以下示例通过 `ImageID` 的形式将镜像进行导出: + +```sh +$ sudo isula-build ctr-img save 21c3e96ac411 -o busybox.tar +Getting image source signatures +Copying blob sha256:50644c29ef5a27c9a40c393a73ece2479de78325cae7d762ef3cdc19bf42dd0a +Copying blob sha256:824082a6864774d5527bda0d3c7ebd5ddc349daadf2aa8f5f305b7a2e439806f +Copying blob sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef +Copying config sha256:21c3e96ac411242a0e876af269c0cbe9d071626bdfb7cc79bfa2ddb9f7a82db6 +Writing manifest to image destination +Storing signatures +Save success with image: 21c3e96ac411 +``` + +以下示例导出多个镜像到同一个tar包: + +```sh +$ sudo isula-build ctr-img save busybox:latest nginx:latest -o all.tar +Getting image source signatures +Copying blob sha256:eb78099fbf7fdc70c65f286f4edc6659fcda510b3d1cfe1caa6452cc671427bf +Copying blob sha256:29f11c413898c5aad8ed89ad5446e89e439e8cfa217cbb404ef2dbd6e1e8d6a5 +Copying blob sha256:af5bd3938f60ece203cd76358d8bde91968e56491daf3030f6415f103de26820 +Copying config sha256:b8efb18f159bd948486f18bd8940b56fd2298b438229f5bd2bcf4cedcf037448 +Writing manifest to image destination +Storing signatures +Getting image source signatures +Copying blob sha256:e2d6930974a28887b15367769d9666116027c411b7e6c4025f7c850df1e45038 +Copying config sha256:a33de3c85292c9e65681c2e19b8298d12087749b71a504a23c576090891eedd6 +Writing manifest to image destination +Storing signatures +Save success with image: [busybox:latest nginx:latest] +``` + +>![](./public_sys-resources/icon-note.gif) **说明:** +> +> * save 导出的镜像默认格式为未压缩的tar格式,如有需求,用户可以再save之后手动压缩。 +> * 在使用镜像名导出镜像时,需要给出完整的镜像名格式:REPOSITORY:TAG。 + +### tag: 给本地持久化镜像打标签 + +可使用tag命令给本地持久化的容器镜像打tag。命令原型如下: + +```sh +isula-build ctr-img tag / busybox:latest +``` + +使用举例: + +```sh +$ sudo isula-build ctr-img images +--------------------------------------- ----------- ----------------- -------------------------- ------------ +REPOSITORY TAG IMAGE ID CREATED SIZE +--------------------------------------- ----------- ----------------- -------------------------- ------------ +alpine latest a24bb4013296 2020-05-29 21:19:46 5.85 MB +--------------------------------------- ----------- ----------------- -------------------------- ------------ +$ sudo isula-build ctr-img tag a24bb4013296 alpine:v1 +$ sudo isula-build ctr-img images +--------------------------------------- ----------- ----------------- ------------------------ ------------ +REPOSITORY TAG IMAGE ID CREATED SIZE +--------------------------------------- ----------- ----------------- ------------------------ ------------ +alpine latest a24bb4013296 2020-05-29 21:19:46 5.85 MB +alpine v1 a24bb4013296 2020-05-29 21:19:46 5.85 MB +--------------------------------------- ----------- ----------------- ------------------------ ------------ +``` + +### pull: 拉取镜像到本地 + +可通过pull命令拉取远程镜像仓库中的镜像到本地。命令原型如下: + +```sh +isula-build ctr-img pull REPOSITORY[:TAG] +``` + +使用示例: + +```sh +$ sudo isula-build ctr-img pull example-registry/library/alpine:latest +Getting image source signatures +Copying blob sha256:8f52abd3da461b2c0c11fda7a1b53413f1a92320eb96525ddf92c0b5cde781ad +Copying config sha256:e4db68de4ff27c2adfea0c54bbb73a61a42f5b667c326de4d7d5b19ab71c6a3b +Writing manifest to image destination +Storing signatures +Pull success with image: example-registry/library/alpine:latest +``` + +### push: 将本地镜像推送到远程仓库 + +可通过push命令将本地镜像推送到远程仓库。命令原型如下: + +```sh +isula-build ctr-img push REPOSITORY[:TAG] +``` + +目前支持的 flags 为: + +* -f, --format:推送的镜像格式:oci|docker(需开启实验特性选项) + +使用示例: + +```sh +$ sudo isula-build ctr-img push example-registry/library/mybusybox:latest +Getting image source signatures +Copying blob sha256:d2421964bad195c959ba147ad21626ccddc73a4f2638664ad1c07bd9df48a675 +Copying config sha256:f0b02e9d092d905d0d87a8455a1ae3e9bb47b4aa3dc125125ca5cd10d6441c9f +Writing manifest to image destination +Storing signatures +Push success with image: example-registry/library/mybusybox:latest +``` + +>![](./public_sys-resources/icon-note.gif) **说明:** +> +> 推送镜像时,需要先登录对应的镜像仓库 + +## info: 查看运行环境与系统信息 + +可以通过“isula-build info”指令查看 isula-build 目前的运行环境与系统信息。命令原型如下: + +```sh +isula-build info [flags] +``` + +支持如下Flags: + +* -H, --human-readable 布尔值,以常用内存表示格式打印内存信息,使用1000次幂 +* -V, --verbose 布尔值,显示运行时内存占用信息 + +使用示例: + +```sh +$ sudo isula-build info -HV + General: + MemTotal: 7.63 GB + MemFree: 757 MB + SwapTotal: 8.3 GB + SwapFree: 8.25 GB + OCI Runtime: runc + DataRoot: /var/lib/isula-build/ + RunRoot: /var/run/isula-build/ + Builders: 0 + Goroutines: 12 + Store: + Storage Driver: overlay + Backing Filesystem: extfs + Registry: + Search Registries: + oepkgs.net + Insecure Registries: + localhost:5000 + oepkgs.net + Runtime: + MemSys: 68.4 MB + HeapSys: 63.3 MB + HeapAlloc: 7.41 MB + MemHeapInUse: 8.98 MB + MemHeapIdle: 54.4 MB + MemHeapReleased: 52.1 MB +``` + +## login: 登录远端镜像仓库 + +用户可以运行 login 命令来登录远程镜像仓库。命令原型如下: + +```sh + isula-build login SERVER [FLAGS] +``` + +目前支持的flag有: + +```Conf + Flags: + -p, --password-stdin Read password from stdin + -u, --username string Username to access registry +``` + +通过stdin输入密码。以下示例通过通过管道将creds.txt里的密码传给isula-build的stdin进行输入: + +```sh + $ cat creds.txt | sudo isula-build login -u cooper -p mydockerhub.io + Login Succeeded +``` + +通过交互式输入密码: + +```sh + $ sudo isula-build login mydockerhub.io -u cooper + Password: + Login Succeeded +``` + +## logout: 退出远端镜像仓库 + +用户可以运行 logout 命令来登出远程镜像仓库。命令原型如下: + +```sh +isula-build logout [SERVER] [FLAGS] +``` + +目前支持的flag有: + +```sh + Flags: + -a, --all Logout all registries +``` + +使用示例如下: + +```sh +$ sudo isula-build logout -a + Removed authentications +``` + +## version: 版本查询 + +可通过version命令查看当前版本信息: + +```sh +$ sudo isula-build version +Client: + Version: 0.9.6-4 + Go Version: go1.15.7 + Git Commit: 83274e0 + Built: Wed Jan 12 15:32:55 2022 + OS/Arch: linux/amd64 + +Server: + Version: 0.9.6-4 + Go Version: go1.15.7 + Git Commit: 83274e0 + Built: Wed Jan 12 15:32:55 2022 + OS/Arch: linux/amd64 +``` + +## manifest: manifest列表管理 + +manifest列表包含不同系统架构对应的镜像信息,通过使用manifest列表,用户可以在不同的架构中使用相同的manifest(例如openeuler:latest)获取对应架构的镜像,manifest包含create、annotate、inspect和push子命令。 +> ![](./public_sys-resources/icon-note.gif) **说明:** +> +> manifest为实验特性,使用时需开启客户端和服务端的实验选项,方式详见客户端总体说明和配置服务章节。 + +### create: manifest列表创建 + +manifest的子命令create用于创建manifest列表,命令原型为: + +```sh +isula-build manifest create MANIFEST_LIST MANIFEST [MANIFEST...] +``` + +用户可以指定manifest列表的名称以及需要加入到列表中的远程镜像,若不指定任何远程镜像,则会创建一个空的manifest列表。 + +使用示例如下: + +```sh +sudo isula-build manifest create openeuler localhost:5000/openeuler_x86:latest localhost:5000/openeuler_aarch64:latest +``` + +### annotate: manifest列表更新 + +manifest的子命令annotate用于更新manifest列表,命令原型为: + +```sh +isula-build manifest annotate MANIFEST_LIST MANIFEST [flags] +``` + +用户可以指定需要更新的manifest列表以及其中的镜像,通过flags指定需要更新的选项,此命令也可用于添加新的镜像到列表中。 + +其中annotate包含如下flags: + +* --arch: string,重写镜像适用架构 +* --os: string,重写镜像适用系统 +* --os-features: string列表,指定镜像需要的OS特性,很少使用 +* --variant: string,指定列表中记录镜像的变量 + +使用示例如下: + +```sh +sudo isula-build manifest annotate --os linux --arch arm64 openeuler:latest localhost:5000/openeuler_aarch64:latest +``` + +### inspect: manifest列表查询 + +manifest子命令inspect用于查询manifest列表信息,命令原型为: + +```sh +isula-build manifest inspect MANIFEST_LIST +``` + +使用示例如下: + +```sh +$ sudo isula-build manifest inspect openeuler:latest +{ + "schemaVersion": 2, + "mediaType": "application/vnd.docker.distribution.manifest.list.v2+json", + "manifests": [ + { + "mediaType": "application/vnd.docker.distribution.manifest.v2+json", + "size": 527, + "digest": "sha256:bf510723d2cd2d4e3f5ce7e93bf1e52c8fd76831995ac3bd3f90ecc866643aff", + "platform": { + "architecture": "amd64", + "os": "linux" + } + }, + { + "mediaType": "application/vnd.docker.distribution.manifest.v2+json", + "size": 527, + "digest": "sha256:f814888b4bb6149bd39ba8375a1932fb15071b4dbffc7f76c7b602b06abbb820", + "platform": { + "architecture": "arm64", + "os": "linux" + } + } + ] +} +``` + +### push: 将manifest列表推送到远程仓库 + +manifest子命令push用于将manifest列表推送到远程仓库,命令原型为: + +```sh +isula-build manifest push MANIFEST_LIST DESTINATION +``` + +使用示例如下: + +```sh +sudo isula-build manifest push openeuler:latest localhost:5000/openeuler:latest +``` + +# 直接集成容器引擎 + +isula-build可以与iSulad和docker集成,将构建好的容器镜像导入到容器引擎的本地存储中。 + +## 与iSulad集成 + +支持将构建成功的镜像直接导出到iSulad。 + +命令行举例: + +```sh +sudo isula-build ctr-img build -f Dockerfile -o isulad:busybox:2.0 +``` + +通过在-o参数中指定iSulad,将构建好的容器镜像导出到iSulad,可以通过isula images查询: + +```sh +$ sudo isula images +isula images +REPOSITORY TAG IMAGE ID CREATED SIZE +busybox 2.0 2d414a5cad6d 2020-08-01 06:41:36 5.577 MB +``` + +> ![](./public_sys-resources/icon-note.gif) **说明:** +> +> * 要求isula-build和iSulad在同一节点。 +> * 直接导出镜像到iSulad时,isula-build client端需要将构建成功的镜像暂存成 `/var/lib/isula-build/tmp/[buildid]/isula-build-tmp-%v.tar` 再导入至 iSulad,用户需要保证 /var/lib/isula-build/tmp/ 目录有足够磁盘空间;同时如果在导出过程中 isula-build client进程被KILL或Ctrl+C终止,需要依赖用户手动清理 `/var/lib/isula-build/tmp/[buildid]/isula-build-tmp-%v.tar` 文件。 + +## 与Docker集成 + +支持将构建成功的镜像直接导出到Docker daemon。 + +命令行举例: + +```sh +sudo isula-build ctr-img build -f Dockerfile -o docker-daemon:busybox:2.0 +``` + +通过在-o参数中指定docker-daemon,将构建好的容器镜像导出到docker, 可以通过docker images查询。 + +```sh +$ sudo docker images +REPOSITORY TAG IMAGE ID CREATED SIZE +busybox 2.0 2d414a5cad6d 2 months ago 5.22MB +``` + +> ![](./public_sys-resources/icon-note.gif) **说明:** +> +> 要求isula-build和Docker在同一节点。 + +# 使用注意事项 + +本章节主要介绍在使用isula-build构建镜像时相关的约束和限制,以及与docker build的差异。 + +## 约束和限制 + +1. 当导出镜像到[`iSulad`](https://gitee.com/openeuler/iSulad/blob/master/README.md/)时,镜像必须指明tag。 +2. 因为isula-builder运行`RUN`指令时,需要调用系统中的oci 运行时(如`runc`),用户需要保证该运行时的安全性,不受篡改。 +3. `DataRoot`不能设置在内存盘上(tmpfs)。 +4. `Overlay2`是目前isula-builder唯一支持的存储驱动。 +5. `Docker`镜像是目前唯一支持的镜像格式,未来即将支持`oci`格式镜像。 +6. `Dockerfile`文件权限强烈建议设置为**0600**以防止恶意篡改。 +7. `RUN`命令中目前只支持主机侧网络(host network)。 +8. 当导出镜像到本地tar包时,目前只支持保存为`tar`格式。 +9. 当使用`import`功能导入基础镜像时,最大支持**1G**。 + +## 与“docker build”差异 + +`isula-build`兼容[Docker镜像格式规范](https://docs.docker.com/engine/reference/builder/),但仍然和`docker build`存在一些差异: + +1. 支持镜像压缩,即对每个`stage`进行提交而非每一行。 +2. 目前不支持构建缓存。 +3. 只有`RUN`指令会运行容器进行构建。 +4. 目前不支持查询镜像构建历史。 +5. `Stage`名称可以用数字开头。 +6. `Stage`名称最大长度为64。 +7. `ADD`命令不支持远端URL格式。 +8. 暂不支持对单次构建进行资源限额,可采取对isula-builder配置资源限额的方式进行限制。 +9. 统计镜像大小时,isula-build是直接计算每层tar包大小之和,而docker是通过解压tar遍历diff目录计算文件大小之和,因此通过`isula-build ctr-img images`查看的镜像大小与`docker images`的显示上有一定差异。 +10. 操作时的镜像名称需要明确,格式为IMAGE_NAME:IMAGE_TAG。例如 busybox:latest, 其中latest不可省略。 diff --git "a/docs/zh/docs/Container/isula-build\346\236\204\345\273\272\345\267\245\345\205\267.md" "b/docs/zh/docs/Container/isula-build\346\236\204\345\273\272\345\267\245\345\205\267.md" index 9536a5a0ac8d134563ae62edc5aa02db8235db19..cae6ba47cf95eca19b13e452e8234294293f0272 100644 --- "a/docs/zh/docs/Container/isula-build\346\236\204\345\273\272\345\267\245\345\205\267.md" +++ "b/docs/zh/docs/Container/isula-build\346\236\204\345\273\272\345\267\245\345\205\267.md" @@ -1,7 +1,5 @@ # 容器镜像构建 -## 概述 - isula-build是iSula容器团队推出的容器镜像构建工具,支持通过Dockerfile文件快速构建容器镜像。 isula-build采用服务端/客户端模式,其中,isula-build为客户端,提供了一组命令行工具,用于镜像构建及管理等;isula-builder为服务端,用于处理客户端管理请求,作为守护进程常驻后台。 @@ -11,1030 +9,3 @@ isula-build采用服务端/客户端模式,其中,isula-build为客户端, > ![](./public_sys-resources/icon-note.gif) **说明:** > > isula-build当前支持OCI镜像格式([OCI Image Format Specification](https://github.com/opencontainers/image-spec/blob/main/spec.md/))以及Docker镜像格式([Image Manifest Version 2, Schema 2](https://docs.docker.com/registry/spec/manifest-v2-2/))。通过命令`export ISULABUILD_CLI_EXPERIMENTAL=enabled`开启实验特性以支持OCI镜像格式。不开启实验特性时,isula-build默认采用Docker镜像格式;当开启实验特性后,将默认采用OCI镜像格式。 - -## 安装 - -### 环境准备 - -为了确保isula-build成功安装,需满足以下软件硬件要求。 - -* 支持的机器架构:x86_64 和 AArch64 -* 支持的操作系统:openEuler -* 用户具有root权限。 - -#### 安装isula-build - -使用isula-build构建容器镜像,需要先安装以下软件包。 - -##### (推荐)方法一:使用yum安装 - -1. 配置openEuler yum源。 - -2. 使用root权限,登录目标服务器,安装isula-build。 - - ```sh - sudo yum install -y isula-build - ``` - -##### 方法二:使用rpm包安装 - -1. 从openEuler yum源中获取isula-build对应安装包isula-build-*.rpm。例如isula-build-0.9.6-4.oe1.x86_64.rpm。 - -2. 将获取的rpm软件包上传至目标服务器的任一目录,例如 /home/。 - -3. 使用root权限,登录目标服务器,参考如下命令安装isula-build。 - - ```sh - sudo rpm -ivh /home/isula-build-*.rpm - ``` - -> ![](./public_sys-resources/icon-note.gif) **说明:** -> -> 安装完成后,需要手工启动isula-build服务。启动请参见[管理服务](isula-build构建工具.md#管理服务)。 - -## 配置与管理服务 - -### 配置服务 - -在安装完 isula-build 软件包之后,systemd 管理服务会以 isula-build 软件包自带的 isula-build 服务端默认配置启动 isula-build 服务。如果 isula-build 服务端的默认配置文件不能满足用户的需求,可以参考如下介绍进行定制化配置。需要注意的是,修改完默认配置之后,需要重启 isula-build 服务端使新配置生效,具体操作可参考下一章节。 - -目前 isula-build 服务端包含如下配置文件: - -* /etc/isula-build/configuration.toml:isula-builder 总体配置文件,用于设置 isula-builder 日志级别、持久化目录和运行时目录、OCI runtime等。其中各参数含义如下: - -| 配置项 | 是否可选 | 配置项含义 | 配置项取值 | -| --------- | -------- | --------------------------------- | ----------------------------------------------- | -| debug | 可选 | 设置是否打开debug日志 | true:打开debug日志
false:关闭debug日志 | -| loglevel | 可选 | 设置日志级别 | debug
info
warn
error | -| run_root | 必选 | 设置运行时数据根目录 | 运行时数据根目录路径,例如/var/run/isula-build/ | -| data_root | 必选 | 设置本地持久化目录 | 本地持久化目录路径,例如/var/lib/isula-build/ | -| runtime | 可选 | 设置runtime种类,目前仅支持runc | runc | -| group | 可选 | 设置本地套接字isula_build.sock文件属组使得加入该组的非特权用户可以操作isula-build | isula | -| experimental | 可选 | 设置是否开启实验特性 | true:开启实验特性;false:关闭实验特性 | - -* /etc/isula-build/storage.toml: 本地持久化存储的配置文件,包含所使用的存储驱动的配置。 - -| 配置项 | 是否可选 | 配置项含义 | -| ------ | -------- | ------------------------------ | -| driver | 可选 | 存储驱动类型,目前支持overlay2 | - - 更多设置可参考 [containers-storage.conf.5](https://github.com/containers/storage/blob/main/docs/containers-storage.conf.5.md)。 - -* /etc/isula-build/registries.toml : 针对各个镜像仓库的配置文件。 - -| 配置项 | 是否可选 | 配置项含义 | -| ------------------- | -------- | ------------------------------------------------------------ | -| registries.search | 可选 | 镜像仓库搜索域,在此list的镜像仓库可以被感知,不在此列的不被感知。 | -| registries.insecure | 可选 | 可访问的不安全镜像仓库地址,在此列表中的镜像仓库将不会通过鉴权,不推荐使用。 | - - 更多设置可参考 [containers-registries.conf.5](https://github.com/containers/image/blob/main/docs/containers-registries.conf.5.md)。 - -* /etc/isula-build/policy.json:镜像pull/push策略文件。当前不支持对其进行配置。 - -> ![](./public_sys-resources/icon-note.gif) **说明:** -> -> * isula-build 支持最大 1MiB 的上述配置文件。 -> * isula-build 不支持将持久化工作目录 dataroot 配置在内存盘上,比如 tmpfs。 -> * isula-build 目前仅支持使用overlay2为底层 graphdriver。 -> * 在设置--group参数前,需保证本地OS已经创建了对应的用户组,且非特权用户已经加入该组。重启isula-builder之后即可使该非特权用户使用isula-build功能。同时,为了保持权限一致性,isula-build的配置文件目录/etc/isula-build的属组也会被设置为--group指定的组。 - -### 管理服务 - -目前 openEuler 采用 systemd 管理软件服务,isula-build 软件包已经自带了 systemd 的服务文件,用户安装完 isula-build 软件包之后,可以直接通过 systemd 工具对它进行服务启停等操作。用户同样可以手动启动 isula-build 服务端软件。需要注意的是,同一个节点上不可以同时启动多个 isula-build 服务端软件。 - ->![](./public_sys-resources/icon-note.gif) **说明:** -> -> 同一个节点上不可以同时启动多个 isula-build 服务端软件。 - -#### 通过 systemd 管理(推荐方式) - -用户可以通过如下 systemd 的标准指令控制 isula-build 服务的启动、停止、重启等动作: - -* 启动 isula-build 服务: - - ```sh - sudo systemctl start isula-build.service - ``` - -* 停止 isula-build 服务: - - ```sh - sudo systemctl stop isula-build.service - ``` - -* 重启 isula-build 服务: - - ```sh - sudo systemctl restart isula-build.service - ``` - -isula-build 软件包安装的 systemd 服务文件保存在 `/usr/lib/systemd/system/isula-build.service`。如果用户需要修改 isula-build 服务的 systemd 配置,可以修改该文件,执行如下命令使配置生效,之后再根据上面提到的 systemd 管理指令重启 isula-build 服务 - -```sh -sudo systemctl daemon-reload -``` - -#### 直接运行 isula-build 服务端 - -您也可以通过执行 isula-build 服务端命令( isula-builder)的方式启动服务。其中,服务端启动配置,可通过isula-builder命令支持的 flags 设置。isula-build 服务端目前支持的 flags 如下: - -* -D, --debug: 是否开启调测模式。 -* --log-level: 日志级别,支持 “debug”, “info”, “warn” or “error”,默认为 “info”。 -* --dataroot: 本地持久化路径,默认为”/var/lib/isula-build/“。 -* --runroot: 运行时路径,默认为”/var/run/isula-build/“。 -* --storage-driver:底层存储驱动类型。 -* --storage-opt: 底层存储驱动配置。 -* --group: 设置本地套接字isula_build.sock文件属组使得加入该组的非特权用户可以操作isula-build,默认为“isula”。 -* --experimental: 是否开启实验特性,默认为false。 - ->![](./public_sys-resources/icon-note.gif) **说明:** -> -> 当命令行启动参数中传递了与配置文件相同的配置选项时,优先使用命令行参数启动。 - -启动 isula-build 服务。例如指定本地持久化路径/var/lib/isula-build,且不开启调试的参考命令如下: - -```sh -sudo isula-builder --dataroot "/var/lib/isula-build" --debug=false -``` - -## 使用指南 - -### 前提条件 - -isula-build 构建 Dockerfile 内的 RUN 指令时依赖可执行文件 runc ,需要 isula-build 的运行环境上预装好 runc。安装方式视用户使用场景而定,如果用户不需要使用完整的 docker-engine 工具链,则可以仅安装 docker-runc rpm包: - -```sh -sudo yum install -y docker-runc -``` - -如果用户需要使用完整的 docker-engine 工具链,则可以安装 docker-engine rpm包,默认包含可执行文件 runc : - -```sh -sudo yum install -y docker-engine -``` - ->![](./public_sys-resources/icon-note.gif) **说明:** -> -> 用户需保证OCI runtime(runc)可执行文件的安全性,避免被恶意替换。 - -### 总体说明 - -isula-build 客户端提供了一系列命令用于构建和管理容器镜像,当前 isula-build 包含的命令行指令如下: - -* ctr-img,容器镜像管理。ctr-img又包含如下子命令: - * build,根据给定dockerfile构建出容器镜像。 - * images,列出本地容器镜像。 - * import,导入容器基础镜像。 - * load,导入层叠镜像。 - * rm,删除本地容器镜像。 - * save,导出层叠镜像至本地磁盘。 - * tag,给本地容器镜像打tag。 - * pull,拉取镜像到本地。 - * push,推送本地镜像到远程仓库。 -* info,查看isula-build的运行环境和系统信息。 -* login,登录远端容器镜像仓库。 -* logout,退出远端容器镜像仓库。 -* version,查看isula-build和isula-builder的版本号。 -* manifest(实验特性),管理manifest列表。 - ->![](./public_sys-resources/icon-note.gif) **说明:** -> -> * isula-build completion 和 isula-builder completion 命令用于生成bash命令补全脚本。该命令为命令行框架隐式提供,不会显示在help信息中。 -> * isula-build客户端不包含配置文件,当用户需要使用isula-build实验特性时,需要在客户端通过命令`export ISULABUILD_CLI_EXPERIMENTAL=enabled`配置环境变量ISULABUILD_CLI_EXPERIMENTAL来开启实验特性。 - -以下按照上述维度依次详细介绍这些命令行指令的使用。 - -### ctr-img: 容器镜像管理 - -isula-build 将所有容器镜像管理相关命令划分在子命令 `ctr-img` 下,命令原型为: - -```sh -isula-build ctr-img [command] -``` - -#### build: 容器镜像构建 - -ctr-img 的子命令 build 用于构建容器镜像,命令原型为: - -```sh -isula-build ctr-img build [flags] -``` - -其中 build 包含如下 flags: - -* --build-arg:string列表,构建过程中需要用到的变量。 -* --build-static:KeyValue值,构建二进制一致性。目前包含如下Key值: - * build-time:string,使用固定时间戳来构建容器镜像;时间戳格式为“YYYY-MM-DD HH-MM-SS”。 -* -f, --filename:string,Dockerfile的路径,不指定则是使用当前路径的Dockerfile文件。 -* --format: string, 设置构建镜像的镜像格式:oci | docker(需开启实验特性选项)。 -* --iidfile:string,输出 image ID 到本地文件。 -* -o, --output:string,镜像导出的方式和路径。 -* --proxy:布尔值,继承主机侧环境的proxy环境变量(默认为true)。 -* --tag:string,设置构建成功的镜像的tag值。 -* --cap-add:string列表,构建过程中RUN指令所需要的权限。 - -**以下为各个 flags 的详解。** - -**\--build-arg** - -从命令行接受参数作为Dockerfile中的参数,用法: - -```sh -$ echo "This is bar file" > bar.txt -$ cat Dockerfile_arg -FROM busybox -ARG foo -ADD ${foo}.txt . -RUN cat ${foo}.txt -$ sudo isula-build ctr-img build --build-arg foo=bar -f Dockerfile_arg -STEP 1: FROM busybox -Getting image source signatures -Copying blob sha256:8f52abd3da461b2c0c11fda7a1b53413f1a92320eb96525ddf92c0b5cde781ad -Copying config sha256:e4db68de4ff27c2adfea0c54bbb73a61a42f5b667c326de4d7d5b19ab71c6a3b -Writing manifest to image destination -Storing signatures -STEP 2: ARG foo -STEP 3: ADD ${foo}.txt . -STEP 4: RUN cat ${foo}.txt -This is bar file -Getting image source signatures -Copying blob sha256:6194458b07fcf01f1483d96cd6c34302ffff7f382bb151a6d023c4e80ba3050a -Copying blob sha256:6bb56e4a46f563b20542171b998cb4556af4745efc9516820eabee7a08b7b869 -Copying config sha256:39b62a3342eed40b41a1bcd9cd455d77466550dfa0f0109af7a708c3e895f9a2 -Writing manifest to image destination -Storing signatures -Build success with image id: 39b62a3342eed40b41a1bcd9cd455d77466550dfa0f0109af7a708c3e895f9a2 -``` - -**\--build-static** - -指定为静态构建,即使用isula-build构建容器镜像时消除所有时间戳和其他构建因素(例如容器ID、hostname等)的差异。最终构建出满足静态要求的容器镜像。 - -在使用isula-build进行容器镜像构建时,假如给 build 子命令一个固定的时间戳,并在限定如下条件的时候: - -* 构建环境前后保持一致。 -* 构建Dockerfile前后保持一致。 -* 构建产生的中间数据前后保持一致。 -* 构建命令相同。 -* 第三方库版本一致。 - -对于容器镜像构建,isula-build支持相同的Dockerfile。如果构建环境相同,则多次构建生成的镜像内容和镜像ID相同。 - ---build-static接受k=v形式的键值对选项,当前支持的选项有: - -* build-time:字符串类型。构建静态镜像的固定时间戳,格式为“YYYY-MM-DD HH-MM-SS”。时间戳影响diff层创建修改时间的文件属性。 - - 使用示例如下: - - ```sh - sudo isula-build ctr-img build -f Dockerfile --build-static='build-time=2020-05-23 10:55:33' . - ``` - - 以此方式,同一环境多次构建出来的容器镜像和镜像ID均会保持一致。 - -**\--format** -开始实验特性后该选项可用,默认为OCI镜像格式。可以手动指定镜像格式进行构建,例如,下面分别为构建OCI镜像格式以及Docker镜像格式镜像的命令。 - - ```sh - export ISULABUILD_CLI_EXPERIMENTAL=enabled; sudo isula-build ctr-img build -f Dockerfile --format oci . - ``` - - ```sh - export ISULABUILD_CLI_EXPERIMENTAL=enabled; sudo isula-build ctr-img build -f Dockerfile --format docker . - ``` - -**\--iidfile** - -将构建的镜像ID输出到文件,用法: - -```sh -isula-build ctr-img build --iidfile filename -``` - -例如,将容器镜像ID输出到testfile的参考命令如下: - - ```sh -sudo isula-build ctr-img build -f Dockerfile_arg --iidfile testfile - ``` - - 查看testfile中的容器镜像ID: - - ```sh -$ cat testfile -76cbeed38a8e716e22b68988a76410eaf83327963c3b29ff648296d5cd15ce7b - ``` - -**\-o, --output** - -目前 -o, --output 支持如下形式: - -* `isulad:image:tag`:将构建成功的镜像直接推送到 iSulad。比如:`-o isulad:busybox:latest`。同时需要注意如下约束: - - * isula-build 和 iSulad 必须在同一个节点上 - * tag必须配置 - * isula-build client端需要将构建成功的镜像暂存成 `/var/tmp/isula-build-tmp-%v.tar` 再导入至 iSulad,用户需要保证 `/var/tmp/` 目录有足够磁盘空间 - -* `docker-daemon:image:tag`:将构建成功的镜像直接推送到 Docker daemon。比如:`-o docker-daemon:busybox:latest`。同时需要注意如下约束: - * isula-build 和 docker 必须在同一个节点上 - * tag必须配置 - -* `docker://registry.example.com/repository:tag`:将构建成功的镜像以Docker镜像格式直接推送到远端镜像仓库。比如:`-o docker://localhost:5000/library/busybox:latest`。 - -* `docker-archive:/:image:tag`:将构建成功的镜像以Docker镜像格式保存至本地。比如:`-o docker-archive:/root/image.tar:busybox:latest`。 - -打开实验特性之后,可以启用相应OCI镜像的构建: - -* `oci://registry.example.com/repository:tag`:将构建成功的镜像以OCI镜像格式直接推送到远端镜像仓库(远程镜像仓库须支持OCI镜像格式)。比如:`-o oci://localhost:5000/library/busybox:latest`。 - -* `oci-archive:/:image:tag`:将构建成功的镜像以OCI镜像的格式保存至本地。比如:`-o oci-archive:/root/image.tar:busybox:latest`。 - -除去各个flags之外,build子命令的命令行最后还会接收一个argument,该argument类型是string,意义为context,即该Dockerfile构建环境的上下文。该参数缺省值为isula-build被执行的当前路径。该路径会影响 .dockerignore 和 Dockerfile的ADD/COPY指令 所检索的路径。 - -**\--proxy** - -选择构建时RUN指令启动的容器是否从环境上继承proxy相关环境变量“http_proxy”,“https_proxy”,“ftp_proxy”,“no_proxy”,“HTTP_PROXY”,“HTTPS_PROXY”,“FTP_PROXY”,“NO_PROXY”,默认为true。 - -当用户在Dockerfile配置proxy相关ARG或ENV,将覆盖所继承的环境变量。 - -注意:若client与daemon不在同一个终端运行,所能继承的环境变量为daemon所在终端的环境变量。 - -**\--tag** - -设置镜像构建成功之后,该镜像在本地磁盘存储时的tag。 - -**\--cap-add** - -添加构建过程中RUN指令所需权限,用法: - -```sh -isula-build ctr-img build --cap-add ${CAP} -``` - -使用举例: - -```sh -sudo isula-build ctr-img build --cap-add CAP_SYS_ADMIN --cap-add CAP_SYS_PTRACE -f Dockerfile -``` - -> ![](./public_sys-resources/icon-note.gif) **说明:** -> -> * isula-build最大支持并发构建100个容器镜像。 -> * isula-build支持Dockerfile最大为1MiB。 -> * isula-build支持 .dockerignore 最大为 1MiB。 -> * 用户需保证Dockerfile文件的权限为仅当前用户可读写,避免别的用户进行篡改。 -> * 构建时,RUN指令会启动容器在容器内进行构建,目前 isula-build 仅支持使用主机网络。 -> * isula-build 导出的镜像压缩格式,目前仅支持tar格式。 -> * isula-build 在每一个镜像构建stage完成后做一次提交,而不是每执行 Dockerfile的一行就提交一次。 -> * isula-build 暂不支持构建缓存。 -> * isula-build 仅在构建RUN指令时会启动构建容器。 -> * 目前不支持docker镜像格式的history功能。 -> * isula-build 的stage name支持以数字开头。 -> * isula-build 的stage name最长可为64个字符。 -> * isula-build 暂不支持对单次Dockerfile的构建进行资源限制。如有资源限制需求,可通过对 isula-builder 服务端配置资源限额的方式进行限制。 -> * isula-build 目前不支持Dockerfile里的ADD指令提供的数据来源是远端url。 -> * isula-build 使用docker-archive以及oci-archive类型导出的本地tar包未经压缩。如有需求,用户可以手动进行压缩。 - -#### image: 查看本地持久化构建镜像 - -可通过images命令查看当前本地持久化存储的镜像: - -```sh -$ sudo isula-build ctr-img images ---------------------------------------- ----------- ----------------- ------------------------ ------------ -REPOSITORY TAG IMAGE ID CREATED SIZE ---------------------------------------- ----------- ----------------- ------------------------ ------------ -localhost:5000/library/alpine latest a24bb4013296 2022-01-17 10:02:19 5.85 MB - 39b62a3342ee 2022-01-17 10:01:12 1.45 MB ---------------------------------------- ----------- ----------------- ------------------------ ------------ -``` - -> ![](./public_sys-resources/icon-note.gif) **说明:** -> -> 通过`isula-build ctr-img images`查看的镜像大小与`docker images`的显示上有一定差异。这是因为统计镜像大小时,isula-build是直接计算每层tar包大小之和,而docker是通过解压tar遍历diff目录计算文件大小之和,因此存在统计上的差异。 - -#### import: 导入容器基础镜像 - -可以通过`ctr-img import`指令将rootfs形式的tar文件导入到isula-build中。 - -命令原型如下: - -```sh -isula-build ctr-img import [flags] -``` - -使用举例: - -```sh -$ sudo isula-build ctr-img import busybox.tar mybusybox:latest -Getting image source signatures -Copying blob sha256:7b8667757578df68ec57bfc9fb7754801ec87df7de389a24a26a7bf2ebc04d8d -Copying config sha256:173b3cf612f8e1dc34e78772fcf190559533a3b04743287a32d549e3c7d1c1d1 -Writing manifest to image destination -Storing signatures -Import success with image id: "173b3cf612f8e1dc34e78772fcf190559533a3b04743287a32d549e3c7d1c1d1" -$ sudo isula-build ctr-img images ---------------------------------------- ----------- ----------------- ------------------------ ------------ -REPOSITORY TAG IMAGE ID CREATED SIZE ---------------------------------------- ----------- ----------------- ------------------------ ------------ -mybusybox latest 173b3cf612f8 2022-01-12 16:02:31 1.47 MB ---------------------------------------- ----------- ----------------- ------------------------ ------------ -``` - ->![](./public_sys-resources/icon-note.gif) **说明:** -> -> isula-build 支持导入最大1GiB的容器基础镜像。 - -#### load: 导入层叠镜像 - -层叠镜像指的是通过 docker save 或 isula-build ctr-img save 等指令,将一个构建完成的镜像保存至本地之后,镜像压缩包内是一层一层 layer.tar 的镜像包。可以通过 ctr-img load 指令将它导入至 isula-build。 - -命令原型如下: - -```sh -isula-build ctr-img load [flags] -``` - -目前支持的 flags 为: - -* -i, --input:本地tar包的路径 - -使用举例如下: - -```sh -$ sudo isula-build ctr-img load -i ubuntu.tar -Getting image source signatures -Copying blob sha256:cf612f747e0fbcc1674f88712b7bc1cd8b91cf0be8f9e9771235169f139d507c -Copying blob sha256:f934e33a54a60630267df295a5c232ceb15b2938ebb0476364192b1537449093 -Copying blob sha256:943edb549a8300092a714190dfe633341c0ffb483784c4fdfe884b9019f6a0b4 -Copying blob sha256:e7ebc6e16708285bee3917ae12bf8d172ee0d7684a7830751ab9a1c070e7a125 -Copying blob sha256:bf6751561805be7d07d66f6acb2a33e99cf0cc0a20f5fd5d94a3c7f8ae55c2a1 -Copying blob sha256:c1bd37d01c89de343d68867518b1155cb297d8e03942066ecb44ae8f46b608a3 -Copying blob sha256:a84e57b779297b72428fc7308e63d13b4df99140f78565be92fc9dbe03fc6e69 -Copying blob sha256:14dd68f4c7e23d6a2363c2320747ab88986dfd43ba0489d139eeac3ac75323b2 -Copying blob sha256:a2092d776649ea2301f60265f378a02405539a2a68093b2612792cc65d00d161 -Copying blob sha256:879119e879f682c04d0784c9ae7bc6f421e206b95d20b32ce1cb8a49bfdef202 -Copying blob sha256:e615448af51b848ecec00caeaffd1e30e8bf5cffd464747d159f80e346b7a150 -Copying blob sha256:f610bd1e9ac6aa9326d61713d552eeefef47d2bd49fc16140aa9bf3db38c30a4 -Copying blob sha256:bfe0a1336d031bf5ff3ce381e354be7b2bf310574cc0cd1949ad94dda020cd27 -Copying blob sha256:f0f15db85788c1260c6aa8ad225823f45c89700781c4c793361ac5fa58d204c7 -Copying config sha256:c07ddb44daa97e9e8d2d68316b296cc9343ab5f3d2babc5e6e03b80cd580478e -Writing manifest to image destination -Storing signatures -Loaded image as c07ddb44daa97e9e8d2d68316b296cc9343ab5f3d2babc5e6e03b80cd580478e -``` - ->![](./public_sys-resources/icon-note.gif) **说明:** -> -> * isula-build 支持导入最大50G的容器层叠镜像。 -> * isula-build 会自动识别容器层叠镜像的格式并进行导入。 - -#### rm: 删除本地持久化镜像 - -可通过rm命令删除当前本地持久化存储的镜像。命令原型为: - -```sh -isula-build ctr-img rm IMAGE [IMAGE...] [FLAGS] -``` - -目前支持的 flags 为: - -* -a, --all:删除所有本地持久化存储的镜像。 -* -p, --prune:删除所有没有tag的本地持久化存储的镜像。 - -使用示例如下: - -```sh -$ sudo isula-build ctr-img rm -p -Deleted: sha256:78731c1dde25361f539555edaf8f0b24132085b7cab6ecb90de63d72fa00c01d -Deleted: sha256:eeba1bfe9fca569a894d525ed291bdaef389d28a88c288914c1a9db7261ad12c -``` - -#### save: 导出层叠镜像 - -可通过save命令导出层叠镜像到本地磁盘。命令原型如下: - -```sh -isula-build ctr-img save [REPOSITORY:TAG]|imageID -o xx.tar -``` - -目前支持的 flags 为: - -* -f, --format:导出层叠镜像的镜像格式:oci | docker(需开启实验特性选项) -* -o, --output:本地tar包路径 - -以下示例通过 `image/tag` 的形式将镜像进行导出: - -```sh -$ sudo isula-build ctr-img save busybox:latest -o busybox.tar -Getting image source signatures -Copying blob sha256:50644c29ef5a27c9a40c393a73ece2479de78325cae7d762ef3cdc19bf42dd0a -Copying blob sha256:824082a6864774d5527bda0d3c7ebd5ddc349daadf2aa8f5f305b7a2e439806f -Copying blob sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef -Copying config sha256:21c3e96ac411242a0e876af269c0cbe9d071626bdfb7cc79bfa2ddb9f7a82db6 -Writing manifest to image destination -Storing signatures -Save success with image: busybox:latest -``` - -以下示例通过 `ImageID` 的形式将镜像进行导出: - -```sh -$ sudo isula-build ctr-img save 21c3e96ac411 -o busybox.tar -Getting image source signatures -Copying blob sha256:50644c29ef5a27c9a40c393a73ece2479de78325cae7d762ef3cdc19bf42dd0a -Copying blob sha256:824082a6864774d5527bda0d3c7ebd5ddc349daadf2aa8f5f305b7a2e439806f -Copying blob sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef -Copying config sha256:21c3e96ac411242a0e876af269c0cbe9d071626bdfb7cc79bfa2ddb9f7a82db6 -Writing manifest to image destination -Storing signatures -Save success with image: 21c3e96ac411 -``` - -以下示例导出多个镜像到同一个tar包: - -```sh -$ sudo isula-build ctr-img save busybox:latest nginx:latest -o all.tar -Getting image source signatures -Copying blob sha256:eb78099fbf7fdc70c65f286f4edc6659fcda510b3d1cfe1caa6452cc671427bf -Copying blob sha256:29f11c413898c5aad8ed89ad5446e89e439e8cfa217cbb404ef2dbd6e1e8d6a5 -Copying blob sha256:af5bd3938f60ece203cd76358d8bde91968e56491daf3030f6415f103de26820 -Copying config sha256:b8efb18f159bd948486f18bd8940b56fd2298b438229f5bd2bcf4cedcf037448 -Writing manifest to image destination -Storing signatures -Getting image source signatures -Copying blob sha256:e2d6930974a28887b15367769d9666116027c411b7e6c4025f7c850df1e45038 -Copying config sha256:a33de3c85292c9e65681c2e19b8298d12087749b71a504a23c576090891eedd6 -Writing manifest to image destination -Storing signatures -Save success with image: [busybox:latest nginx:latest] -``` - ->![](./public_sys-resources/icon-note.gif) **说明:** -> -> * save 导出的镜像默认格式为未压缩的tar格式,如有需求,用户可以再save之后手动压缩。 -> * 在使用镜像名导出镜像时,需要给出完整的镜像名格式:REPOSITORY:TAG。 - -#### tag: 给本地持久化镜像打标签 - -可使用tag命令给本地持久化的容器镜像打tag。命令原型如下: - -```sh -isula-build ctr-img tag / busybox:latest -``` - -使用举例: - -```sh -$ sudo isula-build ctr-img images ---------------------------------------- ----------- ----------------- -------------------------- ------------ -REPOSITORY TAG IMAGE ID CREATED SIZE ---------------------------------------- ----------- ----------------- -------------------------- ------------ -alpine latest a24bb4013296 2020-05-29 21:19:46 5.85 MB ---------------------------------------- ----------- ----------------- -------------------------- ------------ -$ sudo isula-build ctr-img tag a24bb4013296 alpine:v1 -$ sudo isula-build ctr-img images ---------------------------------------- ----------- ----------------- ------------------------ ------------ -REPOSITORY TAG IMAGE ID CREATED SIZE ---------------------------------------- ----------- ----------------- ------------------------ ------------ -alpine latest a24bb4013296 2020-05-29 21:19:46 5.85 MB -alpine v1 a24bb4013296 2020-05-29 21:19:46 5.85 MB ---------------------------------------- ----------- ----------------- ------------------------ ------------ -``` - -#### pull: 拉取镜像到本地 - -可通过pull命令拉取远程镜像仓库中的镜像到本地。命令原型如下: - -```sh -isula-build ctr-img pull REPOSITORY[:TAG] -``` - -使用示例: - -```sh -$ sudo isula-build ctr-img pull example-registry/library/alpine:latest -Getting image source signatures -Copying blob sha256:8f52abd3da461b2c0c11fda7a1b53413f1a92320eb96525ddf92c0b5cde781ad -Copying config sha256:e4db68de4ff27c2adfea0c54bbb73a61a42f5b667c326de4d7d5b19ab71c6a3b -Writing manifest to image destination -Storing signatures -Pull success with image: example-registry/library/alpine:latest -``` - -#### push: 将本地镜像推送到远程仓库 - -可通过push命令将本地镜像推送到远程仓库。命令原型如下: - -```sh -isula-build ctr-img push REPOSITORY[:TAG] -``` - -目前支持的 flags 为: - -* -f, --format:推送的镜像格式:oci|docker(需开启实验特性选项) - -使用示例: - -```sh -$ sudo isula-build ctr-img push example-registry/library/mybusybox:latest -Getting image source signatures -Copying blob sha256:d2421964bad195c959ba147ad21626ccddc73a4f2638664ad1c07bd9df48a675 -Copying config sha256:f0b02e9d092d905d0d87a8455a1ae3e9bb47b4aa3dc125125ca5cd10d6441c9f -Writing manifest to image destination -Storing signatures -Push success with image: example-registry/library/mybusybox:latest -``` - ->![](./public_sys-resources/icon-note.gif) **说明:** -> -> 推送镜像时,需要先登录对应的镜像仓库 - -### info: 查看运行环境与系统信息 - -可以通过“isula-build info”指令查看 isula-build 目前的运行环境与系统信息。命令原型如下: - -```sh -isula-build info [flags] -``` - -支持如下Flags: - -* -H, --human-readable 布尔值,以常用内存表示格式打印内存信息,使用1000次幂 -* -V, --verbose 布尔值,显示运行时内存占用信息 - -使用示例: - -```sh -$ sudo isula-build info -HV - General: - MemTotal: 7.63 GB - MemFree: 757 MB - SwapTotal: 8.3 GB - SwapFree: 8.25 GB - OCI Runtime: runc - DataRoot: /var/lib/isula-build/ - RunRoot: /var/run/isula-build/ - Builders: 0 - Goroutines: 12 - Store: - Storage Driver: overlay - Backing Filesystem: extfs - Registry: - Search Registries: - oepkgs.net - Insecure Registries: - localhost:5000 - oepkgs.net - Runtime: - MemSys: 68.4 MB - HeapSys: 63.3 MB - HeapAlloc: 7.41 MB - MemHeapInUse: 8.98 MB - MemHeapIdle: 54.4 MB - MemHeapReleased: 52.1 MB -``` - -### login: 登录远端镜像仓库 - -用户可以运行 login 命令来登录远程镜像仓库。命令原型如下: - -```sh - isula-build login SERVER [FLAGS] -``` - -目前支持的flag有: - -```Conf - Flags: - -p, --password-stdin Read password from stdin - -u, --username string Username to access registry -``` - -通过stdin输入密码。以下示例通过通过管道将creds.txt里的密码传给isula-build的stdin进行输入: - -```sh - $ cat creds.txt | sudo isula-build login -u cooper -p mydockerhub.io - Login Succeeded -``` - -通过交互式输入密码: - -```sh - $ sudo isula-build login mydockerhub.io -u cooper - Password: - Login Succeeded -``` - -### logout: 退出远端镜像仓库 - -用户可以运行 logout 命令来登出远程镜像仓库。命令原型如下: - -```sh -isula-build logout [SERVER] [FLAGS] -``` - -目前支持的flag有: - -```sh - Flags: - -a, --all Logout all registries -``` - -使用示例如下: - -```sh -$ sudo isula-build logout -a - Removed authentications -``` - -### version: 版本查询 - -可通过version命令查看当前版本信息: - -```sh -$ sudo isula-build version -Client: - Version: 0.9.6-4 - Go Version: go1.15.7 - Git Commit: 83274e0 - Built: Wed Jan 12 15:32:55 2022 - OS/Arch: linux/amd64 - -Server: - Version: 0.9.6-4 - Go Version: go1.15.7 - Git Commit: 83274e0 - Built: Wed Jan 12 15:32:55 2022 - OS/Arch: linux/amd64 -``` - -### manifest: manifest列表管理 - -manifest列表包含不同系统架构对应的镜像信息,通过使用manifest列表,用户可以在不同的架构中使用相同的manifest(例如openeuler:latest)获取对应架构的镜像,manifest包含create、annotate、inspect和push子命令。 -> ![](./public_sys-resources/icon-note.gif) **说明:** -> -> manifest为实验特性,使用时需开启客户端和服务端的实验选项,方式详见客户端总体说明和配置服务章节。 - -#### create: manifest列表创建 - -manifest的子命令create用于创建manifest列表,命令原型为: - -```sh -isula-build manifest create MANIFEST_LIST MANIFEST [MANIFEST...] -``` - -用户可以指定manifest列表的名称以及需要加入到列表中的远程镜像,若不指定任何远程镜像,则会创建一个空的manifest列表。 - -使用示例如下: - -```sh -sudo isula-build manifest create openeuler localhost:5000/openeuler_x86:latest localhost:5000/openeuler_aarch64:latest -``` - -#### annotate: manifest列表更新 - -manifest的子命令annotate用于更新manifest列表,命令原型为: - -```sh -isula-build manifest annotate MANIFEST_LIST MANIFEST [flags] -``` - -用户可以指定需要更新的manifest列表以及其中的镜像,通过flags指定需要更新的选项,此命令也可用于添加新的镜像到列表中。 - -其中annotate包含如下flags: - -* --arch: string,重写镜像适用架构 -* --os: string,重写镜像适用系统 -* --os-features: string列表,指定镜像需要的OS特性,很少使用 -* --variant: string,指定列表中记录镜像的变量 - -使用示例如下: - -```sh -sudo isula-build manifest annotate --os linux --arch arm64 openeuler:latest localhost:5000/openeuler_aarch64:latest -``` - -#### inspect: manifest列表查询 - -manifest子命令inspect用于查询manifest列表信息,命令原型为: - -```sh -isula-build manifest inspect MANIFEST_LIST -``` - -使用示例如下: - -```sh -$ sudo isula-build manifest inspect openeuler:latest -{ - "schemaVersion": 2, - "mediaType": "application/vnd.docker.distribution.manifest.list.v2+json", - "manifests": [ - { - "mediaType": "application/vnd.docker.distribution.manifest.v2+json", - "size": 527, - "digest": "sha256:bf510723d2cd2d4e3f5ce7e93bf1e52c8fd76831995ac3bd3f90ecc866643aff", - "platform": { - "architecture": "amd64", - "os": "linux" - } - }, - { - "mediaType": "application/vnd.docker.distribution.manifest.v2+json", - "size": 527, - "digest": "sha256:f814888b4bb6149bd39ba8375a1932fb15071b4dbffc7f76c7b602b06abbb820", - "platform": { - "architecture": "arm64", - "os": "linux" - } - } - ] -} -``` - -#### push: 将manifest列表推送到远程仓库 - -manifest子命令push用于将manifest列表推送到远程仓库,命令原型为: - -```sh -isula-build manifest push MANIFEST_LIST DESTINATION -``` - -使用示例如下: - -```sh -sudo isula-build manifest push openeuler:latest localhost:5000/openeuler:latest -``` - -## 直接集成容器引擎 - -isula-build可以与iSulad和docker集成,将构建好的容器镜像导入到容器引擎的本地存储中。 - -### 与iSulad集成 - -支持将构建成功的镜像直接导出到iSulad。 - -命令行举例: - -```sh -sudo isula-build ctr-img build -f Dockerfile -o isulad:busybox:2.0 -``` - -通过在-o参数中指定iSulad,将构建好的容器镜像导出到iSulad,可以通过isula images查询: - -```sh -$ sudo isula images -isula images -REPOSITORY TAG IMAGE ID CREATED SIZE -busybox 2.0 2d414a5cad6d 2020-08-01 06:41:36 5.577 MB -``` - -> ![](./public_sys-resources/icon-note.gif) **说明:** -> -> * 要求isula-build和iSulad在同一节点。 -> * 直接导出镜像到iSulad时,isula-build client端需要将构建成功的镜像暂存成 `/var/lib/isula-build/tmp/[buildid]/isula-build-tmp-%v.tar` 再导入至 iSulad,用户需要保证 /var/lib/isula-build/tmp/ 目录有足够磁盘空间;同时如果在导出过程中 isula-build client进程被KILL或Ctrl+C终止,需要依赖用户手动清理 `/var/lib/isula-build/tmp/[buildid]/isula-build-tmp-%v.tar` 文件。 - -### 与Docker集成 - -支持将构建成功的镜像直接导出到Docker daemon。 - -命令行举例: - -```sh -sudo isula-build ctr-img build -f Dockerfile -o docker-daemon:busybox:2.0 -``` - -通过在-o参数中指定docker-daemon,将构建好的容器镜像导出到docker, 可以通过docker images查询。 - -```sh -$ sudo docker images -REPOSITORY TAG IMAGE ID CREATED SIZE -busybox 2.0 2d414a5cad6d 2 months ago 5.22MB -``` - -> ![](./public_sys-resources/icon-note.gif) **说明:** -> -> 要求isula-build和Docker在同一节点。 - -## 使用注意事项 - -本章节主要介绍在使用isula-build构建镜像时相关的约束和限制,以及与docker build的差异。 - -### 约束和限制 - -1. 当导出镜像到[`iSulad`](https://gitee.com/openeuler/iSulad/blob/master/README.md/)时,镜像必须指明tag。 -2. 因为isula-builder运行`RUN`指令时,需要调用系统中的oci 运行时(如`runc`),用户需要保证该运行时的安全性,不受篡改。 -3. `DataRoot`不能设置在内存盘上(tmpfs)。 -4. `Overlay2`是目前isula-builder唯一支持的存储驱动。 -5. `Docker`镜像是目前唯一支持的镜像格式,未来即将支持`oci`格式镜像。 -6. `Dockerfile`文件权限强烈建议设置为**0600**以防止恶意篡改。 -7. `RUN`命令中目前只支持主机侧网络(host network)。 -8. 当导出镜像到本地tar包时,目前只支持保存为`tar`格式。 -9. 当使用`import`功能导入基础镜像时,最大支持**1G**。 - -### 与“docker build”差异 - -`isula-build`兼容[Docker镜像格式规范](https://docs.docker.com/engine/reference/builder/),但仍然和`docker build`存在一些差异: - -1. 支持镜像压缩,即对每个`stage`进行提交而非每一行。 -2. 目前不支持构建缓存。 -3. 只有`RUN`指令会运行容器进行构建。 -4. 目前不支持查询镜像构建历史。 -5. `Stage`名称可以用数字开头。 -6. `Stage`名称最大长度为64。 -7. `ADD`命令不支持远端URL格式。 -8. 暂不支持对单次构建进行资源限额,可采取对isula-builder配置资源限额的方式进行限制。 -9. 统计镜像大小时,isula-build是直接计算每层tar包大小之和,而docker是通过解压tar遍历diff目录计算文件大小之和,因此通过`isula-build ctr-img images`查看的镜像大小与`docker images`的显示上有一定差异。 -10. 操作时的镜像名称需要明确,格式为IMAGE_NAME:IMAGE_TAG。例如 busybox:latest, 其中latest不可省略。 - -## 附录 - -### 命令行参数说明 - -**表1** ctr-img build 命令参数列表 - -| **命令** | **参数** | **说明** | -| ------------- | -------------- | ------------------------------------------------------------ | -| ctr-img build | --build-arg | string列表,构建过程中需要用到的变量 | -| | --build-static | KV值,构建二进制一致性。目前包含如下K值:- build-time:string,使用固定时间戳来构建容器镜像;时间戳格式为“YYYY-MM-DD HH-MM-SS” | -| | -f, --filename | string,Dockerfile的路径,不指定则是使用当前路径的Dockerfile文件 | -| | --format | string,设置构建镜像的镜像格式:oci|docker(需开启实验特性选项)| -| | --iidfile | string,输出 image ID 到本地文件 | -| | -o, --output | string,镜像导出的方式和路径 | -| | --proxy | 布尔值,继承主机侧环境的proxy环境变量(默认为true) | -| | --tag | string,给构建的镜像添加tag | -| | --cap-add | string列表,构建过程中RUN指令所需要的权限 | - -**表2** ctr-img load 命令参数列表 - -| **命令** | **参数** | **说明** | -| ------------ | ----------- | --------------------------------- | -| ctr-img load | -i, --input | string,需要导入的本地tar包的路径 | - -**表3** ctr-img push 命令参数列表 - -| **命令** | **参数** | **说明** | -| ------------ | ----------- | --------------------------------- | -| ctr-img push | -f, --format | string,推送的镜像格式:oci|docker(需开启实验特性选项)| - -**表4** ctr-img rm 命令参数列表 - -| **命令** | **参数** | **说明** | -| ---------- | ----------- | --------------------------------------------- | -| ctr-img rm | -a, --all | 布尔值,删除所有本地持久化存储的镜像 | -| | -p, --prune | 布尔值,删除所有没有tag的本地持久化存储的镜像 | - -**表5** ctr-img save 命令参数列表 - -| **命令** | **参数** | **说明** | -| ------------ | ------------ | ---------------------------------- | -| ctr-img save | -o, --output | string,镜像导出后在本地的存储路径 | -| | -f, --format | string,导出层叠镜像的镜像格式:oci|docker(需开启实验特性选项)| - -**表6** login 命令参数列表 - -| **命令** | **参数** | **说明** | -| -------- | -------------------- | ------------------------------------------------------- | -| login | -p, --password-stdin | 布尔值,是否通过stdin读入密码;或采用交互式界面输入密码 | -| | -u, --username | string,登录镜像仓库所使用的用户名 | - -**表7** logout 命令参数列表 - -| **命令** | **参数** | **说明** | -| -------- | --------- | ------------------------------------ | -| logout | -a, --all | 布尔值,是否登出所有已登录的镜像仓库 | - -**表8** manifest annotate命令参数列表 - -| **命令** | **说明** | **参数** | -| ----------------- | ------------- | ------------------------------------------ | -| manifest annotate | --arch | string,重写镜像适用架构 | -| | --os | string,重写镜像适用系统 | -| | --os-features | string列表,指定镜像需要的OS特性,很少使用 | -| | --variant | string,指定列表中记录镜像的变量 | - -### 通信矩阵 - -isula-build两个组件进程之间通过unix socket套接字文件进行通信,无端口通信。 - -### 文件与权限 - -* isula-build 所有的操作均需要使用 root 权限。如需使用非特权用户操作,则需要配置--group参数 - -* isula-build 运行涉及文件权限如下表所示: - -| **文件路径** | **文件/文件夹权限** | **说明** | -| ------------------------------------------- | ------------------- | ------------------------------------------------------------ | -| /usr/bin/isula-build | 550 | 命令行工具二进制文件。 | -| /usr/bin/isula-builder | 550 | 服务端isula-builder进程二进制文件。 | -| /usr/lib/systemd/system/isula-build.service | 640 | systemd配置文件,用于管理isula-build服务。 | -| /etc/isula-build | 650 | isula-builder 配置文件根目录 | -| /etc/isula-build/configuration.toml | 600 | isula-builder 总配置文件,包含设置 isula-builder 日志级别、持久化目录和运行时目录、OCI runtime等。 | -| /etc/isula-build/policy.json | 600 | 签名验证策略文件的语法文件。 | -| /etc/isula-build/registries.toml | 600 | 针对各个镜像仓库的配置文件,含可用的镜像仓库列表、镜像仓库黑名单。 | -| /etc/isula-build/storage.toml | 600 | 本地持久化存储的配置文件,包含所使用的存储驱动的配置。 | -| /etc/isula-build/isula-build.pub | 400 | 非对称加密公钥文件 | -| /var/run/isula_build.sock | 660 | 服务端isula-builder的本地套接字。 | -| /var/lib/isula-build | 700 | 本地持久化目录。 | -| /var/run/isula-build | 700 | 本地运行时目录。 | -| /var/lib/isula-build/tmp/[buildid]/isula-build-tmp-*.tar | 644 | 镜像导出至iSulad时的本地暂存目录。 | diff --git "a/docs/zh/docs/Container/isula-build\351\231\204\345\275\225.md" "b/docs/zh/docs/Container/isula-build\351\231\204\345\275\225.md" new file mode 100644 index 0000000000000000000000000000000000000000..35b0fbcc9e4ad33ac420f0706a2c35acdaefa780 --- /dev/null +++ "b/docs/zh/docs/Container/isula-build\351\231\204\345\275\225.md" @@ -0,0 +1,91 @@ +# 附录 + +## 命令行参数说明 + +**表1** ctr-img build 命令参数列表 + +| **命令** | **参数** | **说明** | +| ------------- | -------------- | ------------------------------------------------------------ | +| ctr-img build | --build-arg | string列表,构建过程中需要用到的变量 | +| | --build-static | KV值,构建二进制一致性。目前包含如下K值:- build-time:string,使用固定时间戳来构建容器镜像;时间戳格式为“YYYY-MM-DD HH-MM-SS” | +| | -f, --filename | string,Dockerfile的路径,不指定则是使用当前路径的Dockerfile文件 | +| | --format | string,设置构建镜像的镜像格式:oci|docker(需开启实验特性选项)| +| | --iidfile | string,输出 image ID 到本地文件 | +| | -o, --output | string,镜像导出的方式和路径 | +| | --proxy | 布尔值,继承主机侧环境的proxy环境变量(默认为true) | +| | --tag | string,给构建的镜像添加tag | +| | --cap-add | string列表,构建过程中RUN指令所需要的权限 | + +**表2** ctr-img load 命令参数列表 + +| **命令** | **参数** | **说明** | +| ------------ | ----------- | --------------------------------- | +| ctr-img load | -i, --input | string,需要导入的本地tar包的路径 | + +**表3** ctr-img push 命令参数列表 + +| **命令** | **参数** | **说明** | +| ------------ | ----------- | --------------------------------- | +| ctr-img push | -f, --format | string,推送的镜像格式:oci|docker(需开启实验特性选项)| + +**表4** ctr-img rm 命令参数列表 + +| **命令** | **参数** | **说明** | +| ---------- | ----------- | --------------------------------------------- | +| ctr-img rm | -a, --all | 布尔值,删除所有本地持久化存储的镜像 | +| | -p, --prune | 布尔值,删除所有没有tag的本地持久化存储的镜像 | + +**表5** ctr-img save 命令参数列表 + +| **命令** | **参数** | **说明** | +| ------------ | ------------ | ---------------------------------- | +| ctr-img save | -o, --output | string,镜像导出后在本地的存储路径 | +| | -f, --format | string,导出层叠镜像的镜像格式:oci|docker(需开启实验特性选项)| + +**表6** login 命令参数列表 + +| **命令** | **参数** | **说明** | +| -------- | -------------------- | ------------------------------------------------------- | +| login | -p, --password-stdin | 布尔值,是否通过stdin读入密码;或采用交互式界面输入密码 | +| | -u, --username | string,登录镜像仓库所使用的用户名 | + +**表7** logout 命令参数列表 + +| **命令** | **参数** | **说明** | +| -------- | --------- | ------------------------------------ | +| logout | -a, --all | 布尔值,是否登出所有已登录的镜像仓库 | + +**表8** manifest annotate命令参数列表 + +| **命令** | **说明** | **参数** | +| ----------------- | ------------- | ------------------------------------------ | +| manifest annotate | --arch | string,重写镜像适用架构 | +| | --os | string,重写镜像适用系统 | +| | --os-features | string列表,指定镜像需要的OS特性,很少使用 | +| | --variant | string,指定列表中记录镜像的变量 | + +## 通信矩阵 + +isula-build两个组件进程之间通过unix socket套接字文件进行通信,无端口通信。 + +## 文件与权限 + +* isula-build 所有的操作均需要使用 root 权限。如需使用非特权用户操作,则需要配置--group参数 + +* isula-build 运行涉及文件权限如下表所示: + +| **文件路径** | **文件/文件夹权限** | **说明** | +| ------------------------------------------- | ------------------- | ------------------------------------------------------------ | +| /usr/bin/isula-build | 550 | 命令行工具二进制文件。 | +| /usr/bin/isula-builder | 550 | 服务端isula-builder进程二进制文件。 | +| /usr/lib/systemd/system/isula-build.service | 640 | systemd配置文件,用于管理isula-build服务。 | +| /etc/isula-build | 650 | isula-builder 配置文件根目录 | +| /etc/isula-build/configuration.toml | 600 | isula-builder 总配置文件,包含设置 isula-builder 日志级别、持久化目录和运行时目录、OCI runtime等。 | +| /etc/isula-build/policy.json | 600 | 签名验证策略文件的语法文件。 | +| /etc/isula-build/registries.toml | 600 | 针对各个镜像仓库的配置文件,含可用的镜像仓库列表、镜像仓库黑名单。 | +| /etc/isula-build/storage.toml | 600 | 本地持久化存储的配置文件,包含所使用的存储驱动的配置。 | +| /etc/isula-build/isula-build.pub | 400 | 非对称加密公钥文件 | +| /var/run/isula_build.sock | 660 | 服务端isula-builder的本地套接字。 | +| /var/lib/isula-build | 700 | 本地持久化目录。 | +| /var/run/isula-build | 700 | 本地运行时目录。 | +| /var/lib/isula-build/tmp/[buildid]/isula-build-tmp-*.tar | 644 | 镜像导出至iSulad时的本地暂存目录。 | diff --git a/docs/zh/docs/Container/isulad+kuasar-confidential-containers-deployment-guide.md b/docs/zh/docs/Container/isulad+kuasar-confidential-containers-deployment-guide.md new file mode 100644 index 0000000000000000000000000000000000000000..58d435653d226d85a79e128de3aff5fa2b267a2a --- /dev/null +++ b/docs/zh/docs/Container/isulad+kuasar-confidential-containers-deployment-guide.md @@ -0,0 +1,232 @@ +# isulad+kuasar机密容器部署指南 + +机密容器用于解决云原生场景下的数据安全问题,满足数据合规、数据隐私保护、算法和模型等创新 IP 保护,数据可用但是不可见等使用需求,以及解决云厂商的信任依赖问题。 + +## 环境准备 + +### 物理环境准备 + +为了获取更好的性能体验,kuasar需要运行在裸金属服务器上,**暂不支持kuasar运行在虚拟机内**。 +当前机密虚机只支持基于鲲鹏920新型号处理器环境搭建TEE套件环境使用。服务器目前只支持在aarch64环境上加载TEE License使能TEE套件特性,并通过BIOS配置选项开启TEE特性并设置TEE安全内存大小。 + +### 软件安装 + +```sh +$ yum install iSulad kuasar-cc qemu-system-aarch64 +``` + +#### cni插件安装 + +```sh +$ wget https://github.com/containernetworking/plugins/releases/download/v1.3.0/cni-plugins-linux-arm64-v1.3.0.tgz +$ mkdir -p /opt/cni/bin/ +$ tar -zxvf cni-plugins-linux-arm64-v1.3.0.tgz -C /opt/cni/bin/ +``` + +### 修改容器引擎与容器运行时配置文件 + +#### 修改iSulad 配置文件 + +```sh +vi /etc/isulad/daemon.json + +{ + ... ... + "network-plugin": "cni", + "default-sandboxer": "cc", + "enable-cri-v1": true, + "cri-sandboxers": { + "cc": { + "name": "cc", + "image-type":"remote", + "address": "/run/cc-vmm-sandboxer.sock" + } + }, + "cri-runtimes": { + "cc": "io.containerd.cc.v1" + } + ... ... +} +``` + +cri-sandboxers 和 cri-runtimes指定启动sandbox运行时的相关配置。其他参数可以参考[安装与配置](./安装与配置.md)文档。 + +#### 配置机密容器参数 + +默认情况下kuasar可以使用普通镜像仓库,如果需要使用机密镜像仓库,可以修改/var/lib/kuasar/cc-config.toml中的kernel_params参数,参考下表,以key=value的形式补充需要的参数。 + +|Key|Type|Description| +|---|---|---| +|task.aa_kbc_params|String|远程证明代理的IP和端口。| +|task.aa_kbc_key_provider|String|key provider类型,目前支持"secgear"类型。| +|task.aa_ser_url|String|远程证明密钥托管服务器地址。| +|task.aa_cert|String|远程证明根证书文件路径。| +|task.aa_proto|String|与远程证明服务器通信的协议类型。| +|task.https_proxy|String|拉取镜像时的https代理环境变量。| +|task.no_proxy|String|拉取镜像时不使用代理地址的环境变量。| +|task.enable_signature_verification|bool|安全验证开关控制。| +|task.image_policy|String|`Policy.json`路径。| +|task.image_registry_auth|String|鉴权文件路径。| +|task.simple_signing_sigstore_config|String|用于简单签名的Sigstore配置文件。| + +修改/var/lib/kuasar/cc-config.toml后,重启cc-kuasar-vmm.service后配置生效,用于拉起之后的机密沙箱。 + +值得注意的是,由于机密容器需要在沙箱内拉容器镜像,因此需要重新打包目标镜像网站的CA证书到机密虚机的rootfs镜像,方法示例如下: + +1.在镜像仓服务器:如果是本地镜像仓,需要先将镜像仓证书写入镜像本地仓所在服务器根证书,如果domain.crt文件为镜像仓证书,执行如下命令: + +```sh +$cat domain.crt >> /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem +$cat domain.crt >> /etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt +``` + +2.在机密容器服务器:需要将访问远程镜像仓库所需的证书,打包到机密沙箱镜像:比如当机密容器服务器已经可以成功访问镜像仓服务器时,将机密容器服务器上的证书和镜像仓服务器证书domain.crt都打包到机密沙箱镜像: + +```sh +$ls /var/lib/kuasar/cc-rootfs.img +/var/lib/kuasar/cc-rootfs.img +$mkdir cc-rootfs +$mount /var/lib/kuasar/cc-rootfs.img ./cc-rootfs +$cp -r /etc/pki/ca-trust ./cc-rootfs/etc/pki/ca-trust +$cat domain.crt >> ./cc-rootfs/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem +$cat domain.crt >> ./cc-rootfs/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt +$umount ./cc-rootfs +``` + +如果还需使用远程代理和加密镜像的功能,需要做如下配置: + +1.上传加密镜像到远程镜像服务器时,需要为镜像的manifest添加注解,格式如下: + +```json +"org.opencontainers.image.enc.keys.provider.secgear": "<远程托管的密钥路径的base64编码>" +``` + +2.为远程证明服务节点预置远程证明根证书,如果该证书文件为as_cert.pem,示例步骤如下: + +```sh +$mount /var/lib/kuasar/cc-rootfs.img ./cc-rootfs +$mkdir -p ./cc-rootfs/etc/attestation/attestation-agent +$cp as_cert.pem ./cc-rootfs/etc/attestation/attestation-agent/as_cert.pem +$umount ./cc-rootfs +``` + +3.为远程证明和镜像解密服务配置参数,示例如下: + +```bash +$cat /var/lib/kuasar/cc-config.toml +... ... +kernel_params = "task.aa_kbc_params=127.0.0.1:8088 task.aa_kbc_key_provider=secgear task.aa_ser_url=xx.xx.xx.xx:8080: task.aa_cert=/etc/attestation/attestation-agent/as_cert.pem task.aa_proto=http ... ..." +``` + +当前task.aa_kbc_key_provider只支持"secgear",task.aa_proto只支持"http",默认为"http"。 + +配置完毕上述参数后,重启cc-kuasar-vmm.service后配置生效,用于拉起之后的机密沙箱。 + +### 准备容器配置文件 + +#### 增加cni配置文件 + +```sh +cat /etc/cni/net.d/mynet.conf +{ + "cniVersion":"1.0.0", + "name":"bridge-network", + "type":"bridge", + "bridge":"cni0", + "isGateway":true, + "ipMasq":true, + "ipam":{ + "type":"host-local", + "subnet":"10.244.0.0/16", + "routes":[ + {"dst":"0.0.0.0/0"} + ] + } +} +``` + +#### pod 配置文件 + +```json +cat pod.json +{ + "annotations": { + "cri.sandbox.network.setup.v2": "true" + }, + "hostname": "testhostname", + "log_directory": "/tmp", + "linux": { + "cgroup_parent": "/sys/fs/cgroup", + "security_context": { + "namespace_options": { + "network": 0, + "pid": 0, + "ipc": 0 + }, + "run_as_user": { + "value": 1003 + }, + "readonly_rootfs": true, + "privileged": false + } + }, + "metadata": { + "attempt": 1, + "name": "liuxuPod", + "namespace": "default", + "uid": "2dishd83djaidwnduwk28baaa" + } +} +``` + +#### container 配置文件 + +>[!WARNING]注意 +>如果要使用加密镜像的话,在配置完毕,将`"docker.io/library/busybox-aarch64:latest"`替换为加密镜像的地址,比如:`x.x.x.x:5000/test_encryted_image:latest`。 + +```json +cat local_container.json +{ + "metadata": { + "name": "test-busybox" + }, + "image": { + "image": "docker.io/library/busybox-aarch64:latest" + }, + "command": [ + "top" + ], + "log_path":"console.log", + "linux": { + "security_context": { + "capabilities": {}, + "namespace_options": { + "network": 0, + "pid": 1 + } + } + } +} +``` + +## 启动机密容器 + +重新启动iSulad 和 kuasar进程 + +```sh +$systemctl restart cc-kuasar-vmm.service +$systemctl restart isulad.service +``` + +启动机密容器 + +```sh +$crictl runp --runtime cc pod.json +8d69fee1179c4b0626230c315f48daf5ae75fcd36f080c4547724cc9aa590db9 +$crictl create 8d local_container.json pod.json +e69888c21385facad647e51998c5406092734d73834f9b84842820f8aef9d408 +$crictl start e6 +e6 +``` + +当不再需要容器时,可以分别使用`crictl rm ${container id}` 删除容器,使用`crictl rmp ${sandbox id}`删除沙箱。 diff --git "a/docs/zh/docs/Container/\344\270\272\345\256\211\345\205\250\345\256\271\345\231\250\351\205\215\347\275\256\350\265\204\346\272\220.md" "b/docs/zh/docs/Container/\344\270\272\345\256\211\345\205\250\345\256\271\345\231\250\351\205\215\347\275\256\350\265\204\346\272\220.md" index ce85e9fe218ad510a3c5e5124ebc96b5e5037353..cfa2926eb31cd72223b167bb356e0ff3e256e615 100644 --- "a/docs/zh/docs/Container/\344\270\272\345\256\211\345\205\250\345\256\271\345\231\250\351\205\215\347\275\256\350\265\204\346\272\220.md" +++ "b/docs/zh/docs/Container/\344\270\272\345\256\211\345\205\250\345\256\271\345\231\250\351\205\215\347\275\256\350\265\204\346\272\220.md" @@ -14,8 +14,10 @@ 当启动一个Pod时,同一个Pod中的所有容器默认共享同一个net namespace和ipc namespace。如果同一个Pod中的容器需要共享pid namespace,则可以通过Kubernetes进行配置,Kubernetes 1.11版本该值为默认关闭。 ## 限制资源 + 对资源的限制建议在configuration.toml中进行配置。 常用的字段的有: + - default_vcpus :指定每个SB/VM的默认vCPU数量 - default_maxvcpus :指定每个SB/VM的默认最大vCPU数量 - default_root_ports :指定每个SB/VM的默认Root Ports数量 @@ -24,9 +26,11 @@ - memory_slots :指定每个SB/VM的内存插槽数量,默认为10 ## 热插拔限制内存资源 + 内存热插拔对于容器在部署时内存动态分配来说是一项关键特性。由于安全容器是运行在虚拟机当中的,所以这一项特性需要VMM和guest kernel两方面的支持。目前kata在arm64上默认使用的QEMU和guest kernel都是支持这一特性的。除了VMM和guest kernel,内存热插拔还取决于依赖着固件的ACPI。在x86上,由于ACPI可以隐式地随固件一起启动,所以可以直接用QEMU去启动一个打开了ACPI的虚拟机。不过在arm64上的话,在使用内存热插拔之前就需要手动去安装UEFI ROM。 + ```shell -$ pushd $GOPATH/src/github.com/kata-containers/tests -$ sudo .ci/aarch64/install_rom_aarch64.sh #仅限ubuntu -$ popd +pushd $GOPATH/src/github.com/kata-containers/tests +sudo .ci/aarch64/install_rom_aarch64.sh #仅限ubuntu +popd ``` diff --git "a/docs/zh/docs/Container/\345\256\211\350\243\205\344\270\216\351\205\215\347\275\256.md" "b/docs/zh/docs/Container/\345\256\211\350\243\205\344\270\216\351\205\215\347\275\256.md" index 1f12f24530031cee5faddbe16571daf5a60dfec6..8f36bbb0558592c4c87b505d564ede5a3c4157b2 100644 --- "a/docs/zh/docs/Container/\345\256\211\350\243\205\344\270\216\351\205\215\347\275\256.md" +++ "b/docs/zh/docs/Container/\345\256\211\350\243\205\344\270\216\351\205\215\347\275\256.md" @@ -24,7 +24,7 @@ iSulad可以通过yum或rpm命令两种方式安装,由于yum会自动安装 ``` -- 使用rpm安装iSulad,需要下载iSulad及其所有依赖库的RPM包,然后手动安装。安装单个iSulad的RPM包(依赖包安装方式相同),参考命令如下: +- 使用rpm安装iSulad,需要下载iSulad及其所有依赖的RPM包,然后手动安装。安装单个iSulad的RPM包(依赖包安装方式相同),参考命令如下: ``` # sudo rpm -ihv iSulad-xx.xx.xx-xx.xxx.aarch64.rpm diff --git "a/docs/zh/docs/Container/\345\256\271\345\231\250\350\265\204\346\272\220\347\256\241\347\220\206.md" "b/docs/zh/docs/Container/\345\256\271\345\231\250\350\265\204\346\272\220\347\256\241\347\220\206.md" index d62a945e48387b5569c24ad9015d6257aa771c2a..de0138c0b2314ee7bebb0d179c82d77199f02980 100644 --- "a/docs/zh/docs/Container/\345\256\271\345\231\250\350\265\204\346\272\220\347\256\241\347\220\206.md" +++ "b/docs/zh/docs/Container/\345\256\271\345\231\250\350\265\204\346\272\220\347\256\241\347\220\206.md" @@ -1,6 +1,7 @@ # 容器资源管理 + - [容器资源管理](#容器资源管理) - [描述](#描述) - [资源共享](#资源共享) @@ -11,6 +12,7 @@ - [限制容器内文件句柄数](#限制容器内文件句柄数) - [限制容器内可以创建的进程/线程数](#限制容器内可以创建的进程-线程数) - [配置容器内的ulimit值](#配置容器内的ulimit值) + ## 描述 @@ -27,9 +29,7 @@ cgroup v2来进行资源管理。无论是cgroup v1还是使用cgroup v2对容 容器间或者容器与host之间可以共享namespace信息,包括pid, net, ipc, uts。 >![](./public_sys-resources/icon-note.gif) **说明:** ->当使用与主机共享namespace信息时,即缺少了对应的namespace隔离机制,在容器中可以查询、操作主机上的信息,存在安全 -隐患。比如使用--pid=host共享主机pid namespace时,即可以看到主机上其他进程信息,造成信息泄露,甚至直接kill杀死主机 -进程。请在确保安全的场景下,谨慎使用共享主机host namespace功能。 +>当使用与主机共享namespace信息时,即缺少了对应的namespace隔离机制,在容器中可以查询、操作主机上的信息,存在安全隐患。比如使用--pid=host共享主机pid namespace时,即可以看到主机上其他进程信息,造成信息泄露,甚至直接kill杀死主机进程。请在确保安全的场景下,谨慎使用共享主机host namespace功能。 ### 用法 @@ -93,7 +93,7 @@ create/run时可以指定下列参数。 如果两个容器需要共享同一个pid namespace,在运行容器时,直接加上--pid container: 即可,如: -``` +``` bash isula run -tid --name test_pid busybox sh isula run -tid --name test --pid container:test_pid busybox sh ``` @@ -193,7 +193,7 @@ create/run时可以指定下列参数。 如果需要限制容器只是用特定的cpu,在运行容器时,直接加上--cpuset-cpus number 即可,如: -``` +``` bash isula run -tid --cpuset-cpus 0,2-3 busybox sh ``` @@ -268,7 +268,7 @@ create/run时可以指定下列参数。 如果需要限制容器内内存的上限,在运行容器时,直接加上--memory \[\]即可,如: -``` +``` bash isula run -tid --memory 1G busybox sh ``` @@ -313,13 +313,13 @@ create/run时指定--device-read/write-bps参数。 如果需要限制容器内设备的读写速度,在运行容器时,直接加上--device-write-bps/--device-read-bps :\[\]即可,例如,限制容器busybox内设备/dev/sda的读速度为 1MB 每秒,则命令如下: -``` +``` bash isula run -tid --device-write /dev/sda:1mb busybox sh ``` 限制写速度的命令如下: -``` +``` bash isula run -tid read-bps /dev/sda:1mb busybox sh ``` @@ -333,32 +333,30 @@ isula run -tid read-bps /dev/sda:1mb busybox sh ### 用法 -1. 环境准备 +1. 环境准备 - 文件系统支持Project ID和Project Quota属性,4.19版本内核已经支持,外围包e2fsprogs版本不低于1.43.4-2。 + 文件系统支持Project ID和Project Quota属性,4.19版本内核已经支持,外围包e2fsprogs版本不低于1.43.4-2。 -2. 在容器挂载overlayfs之前,需要对不同容器的upper目录和work目录设置不同的project id,同时设置继承选项,在容器挂载overlayfs之后不允许再修改project id和继承属性。 -3. 配额的设置需要在容器外以特权用户进行。 -4. daemon中增加如下配置 +2. 在容器挂载overlayfs之前,需要对不同容器的upper目录和work目录设置不同的project id,同时设置继承选项,在容器挂载overlayfs之后不允许再修改project id和继承属性。 +3. 配额的设置需要在容器外以特权用户进行。 +4. daemon中增加如下配置 - ``` + ``` bash -s overlay2 --storage-opt overlay2.override_kernel_check=true ``` -5. daemon支持以下选项,用于为容器设置默认的限制, +5. daemon支持以下选项,用于为容器设置默认的限制, --storage-opt overlay2.basesize=128M 指定默认限制的大小,若isula run时也指定 了--storage-opt size选项,则以run时指定来生效,若daemon跟isula run时都不指定大小,则表示不限制。 -6. 需要开启文件系统Project ID和Project Quota属性。 - - 新格式化文件系统并mount +6. 需要开启文件系统Project ID和Project Quota属性。 + - 新格式化文件系统并mount - ``` + ``` bash # mkfs.ext4 -O quota,project /dev/sdb # mount -o prjquota /dev/sdb /var/lib/isulad ``` - - ### 参数 create/run时指定--storage-opt参数。 @@ -390,7 +388,7 @@ create/run时指定--storage-opt参数。 在isula run/create命令行上通过已有参数“--storage-opt size=”来设置限额。其中value是一个正数,单位可以是\[kKmMgGtTpP\]?\[iI\]?\[bB\]?,在不带单位的时候默认单位是字节。 -``` +``` bash # isula run -ti --storage-opt size=10M busybox / # df -h Filesystem Size Used Available Use% Mounted on @@ -427,35 +425,35 @@ overlay 10.0M 10.0M 0 100% / ### 约束 -1. 限额只针对rw层。 +1. 限额只针对rw层。 - overlay2的限额是针对容器的rw层的,镜像的大小不计算在内。 + overlay2的限额是针对容器的rw层的,镜像的大小不计算在内。 -2. 内核支持并使能。 +2. 内核支持并使能。 内核必须支持ext4的project quota功能,并在mkfs的时候要加上-O quota,project,挂载的时候要加上-o prjquota。任何一个不满足,在使用--storage-opt size=时都将报错。 - ``` + ``` bash # isula run -it --storage-opt size=10Mb busybox df -h Error response from daemon: Failed to prepare rootfs with error: time="2019-04-09T05:13:52-04:00" level=fatal msg="error creating read- write layer with ID "a4c0e55e82c55e4ee4b0f4ee07f80cc2261cf31b2c2dfd628fa1fb00db97270f": --storage-opt is supported only for overlay over xfs or ext4 with 'pquota' mount option" ``` -3. 限制额度的说明。 - 1. 限制的额度大于isulad的root所在分区的size时,在容器内用df看到的文件系统的额度是isulad的root所在分区的size,而不是设置的限额。 - 2. --storage-opt size=0代表不限制,且设置值不能小于4096。size的精度为1个字节,如果指定精度含小数个字节,小数部分被忽略,如指定size=0.1实际等同于size=0不限制。(受计算机存储浮点数精度的限制,即0.999999999999999999999999999与1是等价的,具体的9的个数不同计算机可能存在差异,故设置4095.999999999999999999999999999与4096等价,其他情况类似),注意isula inspect显示原始命令行指定形式,如果含小数字节,需自行忽略小数部分。 - 3. 限制的额度过小时,比如--storage-opt size=4k,可能会导致容器无法启动,因为启动容器本身需要创建一些文件。 - 4. 上一次启动isulad时,isulad的root所在分区挂载时加了-o prjquota选项,这次启动时不加,那么上一次启动中创建的带quota的容器的设置值不生效。 - 5. daemon端配额--storage-opt overlay2.basesize,其取值范围与--storage-opt size相同。 +3. 限制额度的说明。 + 1. 限制的额度大于isulad的root所在分区的size时,在容器内用df看到的文件系统的额度是isulad的root所在分区的size,而不是设置的限额。 + 2. --storage-opt size=0代表不限制,且设置值不能小于4096。size的精度为1个字节,如果指定精度含小数个字节,小数部分被忽略,如指定size=0.1实际等同于size=0不限制。(受计算机存储浮点数精度的限制,即0.999999999999999999999999999与1是等价的,具体的9的个数不同计算机可能存在差异,故设置4095.999999999999999999999999999与4096等价,其他情况类似),注意isula inspect显示原始命令行指定形式,如果含小数字节,需自行忽略小数部分。 + 3. 限制的额度过小时,比如--storage-opt size=4k,可能会导致容器无法启动,因为启动容器本身需要创建一些文件。 + 4. 上一次启动isulad时,isulad的root所在分区挂载时加了-o prjquota选项,这次启动时不加,那么上一次启动中创建的带quota的容器的设置值不生效。 + 5. daemon端配额--storage-opt overlay2.basesize,其取值范围与--storage-opt size相同。 -4. 指定storage-opt为4k时,轻量级容器启动与docker有差异 +4. 指定storage-opt为4k时,轻量级容器启动与docker有差异 使用选项 storage-opt size=4k 和镜像 rnd-dockerhub.huawei.com/official/ubuntu-arm64:latest 运行容器。 docker启动失败。 - ``` + ``` bash # docker run -itd --storage-opt size=4k rnd-dockerhub.huawei.com/official/ubuntu-arm64:latest docker: Error response from daemon: symlink /proc/mounts /var/lib/docker/overlay2/e6e12701db1a488636c881b44109a807e187b8db51a50015db34a131294fcf70-init/merged/etc/mtab: disk quota exceeded. See 'docker run --help'. @@ -463,7 +461,7 @@ overlay 10.0M 10.0M 0 100% / 轻量级容器不报错,正常启动 - ``` + ``` bash # isula run -itd --storage-opt size=4k rnd-dockerhub.huawei.com/official/ubuntu-arm64:latest 636480b1fc2cf8ac895f46e77d86439fe2b359a1ff78486ae81c18d089bbd728 # isula ps @@ -477,21 +475,20 @@ overlay 10.0M 10.0M 0 100% / 轻量级容器在启动容器过程中,使用默认配置时,挂载点较少,如/proc,或/sys等路径不存在时,才会创建。用例中的镜像rnd-dockerhub.huawei.com/official/ubuntu-arm64:latest本身含有/proc, /sys等,因此整个启动容器的过程中,都不会有新文件或路径生成,故轻量级容器启动过程不会报错。为验证这一过程,当把镜像替换为rnd-dockerhub.huawei.com/official/busybox-aarch64:latest时,由于该镜像内无/proc存在,轻量级容器启动一样会报错。 - ``` + ``` bash # isula run -itd --storage-opt size=4k rnd-dockerhub.huawei.com/official/busybox-aarch64:latest 8e893ab483310350b8caa3b29eca7cd3c94eae55b48bfc82b350b30b17a0aaf4 Error response from daemon: Start container error: runtime error: 8e893ab483310350b8caa3b29eca7cd3c94eae55b48bfc82b350b30b17a0aaf4:tools/lxc_start.c:main:404 starting container process caused "Failed to setup lxc, please check the config file." ``` -5. 其他说明。 +5. 其他说明。 使用限额功能的isulad切换数据盘时,需要保证被切换的数据盘使用\`prjquota\`选项挂载,且/var/lib/isulad/storage/overlay2目录的挂载方式与/var/lib/isulad相同。 >![](./public_sys-resources/icon-note.gif) **说明:** >切换数据盘时需要保证/var/lib/isulad/storage/overlay2的挂载点被卸载。 - ## 限制容器内文件句柄数 ### 描述 @@ -534,15 +531,15 @@ create/run时指定--files-limit参数。 在运行容器时,直接加上--files-limit n 即可,如: -``` +``` bash isula run -ti --files-limit 1024 busybox bash ``` ### 约束 -1. 使用--files-limit参数传入一个很小的值,如1,可能导致容器启动失败。 +1. 使用--files-limit参数传入一个很小的值,如1,可能导致容器启动失败。 - ``` + ``` bash # isula run -itd --files-limit 1 rnd-dockerhub.huawei.com/official/busybox-aarch64 004858d9f9ef429b624f3d20f8ba12acfbc8a15bb121c4036de4e5745932eff4 Error response from daemon: Start container error: Container is not running:004858d9f9ef429b624f3d20f8ba12acfbc8a15bb121c4036de4e5745932eff4 @@ -550,7 +547,7 @@ isula run -ti --files-limit 1024 busybox bash 而docker会启动成功,其files.limit cgroup值为max。 - ``` + ``` bash # docker run -itd --files-limit 1 rnd-dockerhub.huawei.com/official/busybox-aarch64 ef9694bf4d8e803a1c7de5c17f5d829db409e41a530a245edc2e5367708dbbab # docker exec -it ef96 cat /sys/fs/cgroup/files/files.limit @@ -559,7 +556,6 @@ isula run -ti --files-limit 1024 busybox bash 根因是lxc和runc启动过程的原理不一样,lxc创建cgroup子组后先设置files.limit值,再将容器进程的PID写入该子组的cgroup.procs文件,此时该进程已经打开超过1个句柄,因而写入报错导致启动失败。runc创建cgroup子组后先将容器进程的PID写入该子组的cgroup.procs文件,再设置files.limit值,此时由于该子组内的进程已经打开超过1个句柄,因而写入files.limit不会生效,内核也不会报错,容器启动成功。 - ## 限制容器内可以创建的进程/线程数 ### 描述 @@ -601,7 +597,7 @@ create/run时指定--pids-limit参数。 在运行容器时,直接加上--pids-limit n 即可,如: -``` +``` bash isula run -ti --pids-limit 1024 busybox bash ``` @@ -623,7 +619,7 @@ isula run -ti --pids-limit 1024 busybox bash 通过两种方法配置ulimit -1. isula create/run时使用--ulimit =\[:\]来控制shell执行程序的资源。 +1. isula create/run时使用--ulimit =\[:\]来控制shell执行程序的资源。

参数项

@@ -648,7 +644,7 @@ isula run -ti --pids-limit 1024 busybox bash
-2. 通过daemon端参数或配置文件 +2. 通过daemon端参数或配置文件 详见"(命令行参数说明"与"部署方式"的--default-ulimits相关选项。 @@ -745,16 +741,14 @@ isula run -ti --pids-limit 1024 busybox bash - ### 示例 在容器的创建或者运行时,加上--ulimit =\[:\]即可,如: -``` +``` bash isula create/run -tid --ulimit nofile=1024:2048 busybox sh ``` ### 约束 不能在daemon.json和/etc/sysconfig/iSulad文件(或isulad命令行)中同时配置ulimit限制,否则isulad启动会报错。 - diff --git "a/docs/zh/docs/DevStation/DevStation\345\256\211\350\243\205\346\214\207\345\215\227.md" "b/docs/zh/docs/DevStation/DevStation\345\256\211\350\243\205\346\214\207\345\215\227.md" new file mode 100644 index 0000000000000000000000000000000000000000..c36e82ce87bcf221ef3ad178dbda4d4bde1245c6 --- /dev/null +++ "b/docs/zh/docs/DevStation/DevStation\345\256\211\350\243\205\346\214\207\345\215\227.md" @@ -0,0 +1,5 @@ +# 安装指南 + +本文档主要介绍 openEuler DevStation 安装方法,以指导用户顺利完成 openEuler DevStation 安装。 + +本文档适用于所有使用 openEuler DevStation 的用户,特别是初次使用或想了解 openEuler DevStation 的用户,包括社区开发者、高校师生、系统工程师、管理员及维护人员等。 diff --git a/docs/zh/docs/DevStation/figures/1-createvm.png b/docs/zh/docs/DevStation/figures/1-createvm.png new file mode 100644 index 0000000000000000000000000000000000000000..77a914f27d02915b3c738a00e4affac5983733d8 Binary files /dev/null and b/docs/zh/docs/DevStation/figures/1-createvm.png differ diff --git a/docs/zh/docs/DevStation/figures/1-welcome.jpg b/docs/zh/docs/DevStation/figures/1-welcome.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9c9cd18f596a5adf895e67a558cd99f15bb5b387 Binary files /dev/null and b/docs/zh/docs/DevStation/figures/1-welcome.jpg differ diff --git a/docs/zh/docs/DevStation/figures/10-startinstall.jpg b/docs/zh/docs/DevStation/figures/10-startinstall.jpg new file mode 100644 index 0000000000000000000000000000000000000000..88717541c1a34177c1d7ff6096d0438e2851cfe8 Binary files /dev/null and b/docs/zh/docs/DevStation/figures/10-startinstall.jpg differ diff --git a/docs/zh/docs/DevStation/figures/10-username.png b/docs/zh/docs/DevStation/figures/10-username.png new file mode 100644 index 0000000000000000000000000000000000000000..b1d54f3e1d1da1f509fd0345e4fe510e3a634918 Binary files /dev/null and b/docs/zh/docs/DevStation/figures/10-username.png differ diff --git a/docs/zh/docs/DevStation/figures/11-packages.png b/docs/zh/docs/DevStation/figures/11-packages.png new file mode 100644 index 0000000000000000000000000000000000000000..22bfd691206514b9f31e1d6001de4db9dcd615cb Binary files /dev/null and b/docs/zh/docs/DevStation/figures/11-packages.png differ diff --git a/docs/zh/docs/DevStation/figures/11-summary.png b/docs/zh/docs/DevStation/figures/11-summary.png new file mode 100644 index 0000000000000000000000000000000000000000..d5e8bfdedb842f34cc886e47c2434ce0c025580a Binary files /dev/null and b/docs/zh/docs/DevStation/figures/11-summary.png differ diff --git a/docs/zh/docs/DevStation/figures/12-disk.png b/docs/zh/docs/DevStation/figures/12-disk.png new file mode 100644 index 0000000000000000000000000000000000000000..8cc380b4b66814bb71ee58a6881dad5158bb235c Binary files /dev/null and b/docs/zh/docs/DevStation/figures/12-disk.png differ diff --git a/docs/zh/docs/DevStation/figures/12-installing.jpg b/docs/zh/docs/DevStation/figures/12-installing.jpg new file mode 100644 index 0000000000000000000000000000000000000000..f0379b7a7497d7e35bc6568033bc19198f3a49d5 Binary files /dev/null and b/docs/zh/docs/DevStation/figures/12-installing.jpg differ diff --git a/docs/zh/docs/DevStation/figures/13-grub.png b/docs/zh/docs/DevStation/figures/13-grub.png new file mode 100644 index 0000000000000000000000000000000000000000..93f886dbf53772d4ed44e460b9bdfa1846397ab0 Binary files /dev/null and b/docs/zh/docs/DevStation/figures/13-grub.png differ diff --git a/docs/zh/docs/DevStation/figures/13-install.png b/docs/zh/docs/DevStation/figures/13-install.png new file mode 100644 index 0000000000000000000000000000000000000000..830fddc6927af0f10191b297d1333fc91bdf443b Binary files /dev/null and b/docs/zh/docs/DevStation/figures/13-install.png differ diff --git a/docs/zh/docs/DevStation/figures/14-install-sure.png b/docs/zh/docs/DevStation/figures/14-install-sure.png new file mode 100644 index 0000000000000000000000000000000000000000..7f74989bea5817b392f364ebdd6bc1b79848e717 Binary files /dev/null and b/docs/zh/docs/DevStation/figures/14-install-sure.png differ diff --git a/docs/zh/docs/DevStation/figures/2-create_dialog_box.png b/docs/zh/docs/DevStation/figures/2-create_dialog_box.png new file mode 100644 index 0000000000000000000000000000000000000000..8a7a0351a354d6015dbfec14502bef027cae58cf Binary files /dev/null and b/docs/zh/docs/DevStation/figures/2-create_dialog_box.png differ diff --git a/docs/zh/docs/DevStation/figures/2-timezone.jpg b/docs/zh/docs/DevStation/figures/2-timezone.jpg new file mode 100644 index 0000000000000000000000000000000000000000..ad0313e5e643f5d7d69deef1476b37386ddc8693 Binary files /dev/null and b/docs/zh/docs/DevStation/figures/2-timezone.jpg differ diff --git a/docs/zh/docs/DevStation/figures/3-installation.png b/docs/zh/docs/DevStation/figures/3-installation.png new file mode 100644 index 0000000000000000000000000000000000000000..ccfc0f3d003ede04998bf6006677d067d71e02eb Binary files /dev/null and b/docs/zh/docs/DevStation/figures/3-installation.png differ diff --git a/docs/zh/docs/DevStation/figures/3-username.jpg b/docs/zh/docs/DevStation/figures/3-username.jpg new file mode 100644 index 0000000000000000000000000000000000000000..13120dbbb338f7e04cb5dd452250a68ec413a8a8 Binary files /dev/null and b/docs/zh/docs/DevStation/figures/3-username.jpg differ diff --git a/docs/zh/docs/DevStation/figures/4-packages.png b/docs/zh/docs/DevStation/figures/4-packages.png new file mode 100644 index 0000000000000000000000000000000000000000..e0d92f0f6623f9cf2fd7a0de008e924411b4cf1b Binary files /dev/null and b/docs/zh/docs/DevStation/figures/4-packages.png differ diff --git a/docs/zh/docs/DevStation/figures/5-manifast.jpg b/docs/zh/docs/DevStation/figures/5-manifast.jpg new file mode 100644 index 0000000000000000000000000000000000000000..7e5395cc41b302ab9d93a09d3b33e52cb9d98489 Binary files /dev/null and b/docs/zh/docs/DevStation/figures/5-manifast.jpg differ diff --git a/docs/zh/docs/DevStation/figures/6-fat32.jpg b/docs/zh/docs/DevStation/figures/6-fat32.jpg new file mode 100644 index 0000000000000000000000000000000000000000..b27d813ba49cf0122162f07f130bf1f45d3307f3 Binary files /dev/null and b/docs/zh/docs/DevStation/figures/6-fat32.jpg differ diff --git a/docs/zh/docs/DevStation/figures/7-apps.png b/docs/zh/docs/DevStation/figures/7-apps.png new file mode 100644 index 0000000000000000000000000000000000000000..9cbe689b72b2159f9297c5494b538d7151c790f7 Binary files /dev/null and b/docs/zh/docs/DevStation/figures/7-apps.png differ diff --git a/docs/zh/docs/DevStation/figures/7-bootefi.png b/docs/zh/docs/DevStation/figures/7-bootefi.png new file mode 100644 index 0000000000000000000000000000000000000000..e0bbe0b14abb0f08372ef18cd6d9c9932061b4c7 Binary files /dev/null and b/docs/zh/docs/DevStation/figures/7-bootefi.png differ diff --git a/docs/zh/docs/DevStation/figures/8-devstation.jpg b/docs/zh/docs/DevStation/figures/8-devstation.jpg new file mode 100644 index 0000000000000000000000000000000000000000..36ab625e4a8de71c3f2ee86fe490cea3725c9ddb Binary files /dev/null and b/docs/zh/docs/DevStation/figures/8-devstation.jpg differ diff --git a/docs/zh/docs/DevStation/figures/8-selectlanguage.png b/docs/zh/docs/DevStation/figures/8-selectlanguage.png new file mode 100644 index 0000000000000000000000000000000000000000..637a0e503a1ace735bacff1153f2c3b7f85bdf66 Binary files /dev/null and b/docs/zh/docs/DevStation/figures/8-selectlanguage.png differ diff --git a/docs/zh/docs/DevStation/figures/9-boot.png b/docs/zh/docs/DevStation/figures/9-boot.png new file mode 100644 index 0000000000000000000000000000000000000000..480732f3c2aaae94c69cfab22764d4361879f73e Binary files /dev/null and b/docs/zh/docs/DevStation/figures/9-boot.png differ diff --git a/docs/zh/docs/DevStation/figures/9-timezone.png b/docs/zh/docs/DevStation/figures/9-timezone.png new file mode 100644 index 0000000000000000000000000000000000000000..f8fd638b7a2a0aeb86dbb1bea3463eccea6d282c Binary files /dev/null and b/docs/zh/docs/DevStation/figures/9-timezone.png differ diff --git a/docs/zh/docs/DevStation/figures/compress.png b/docs/zh/docs/DevStation/figures/compress.png new file mode 100644 index 0000000000000000000000000000000000000000..869553e97cd8d63bba6efb3d096a91af26e97c53 Binary files /dev/null and b/docs/zh/docs/DevStation/figures/compress.png differ diff --git a/docs/zh/docs/DevStation/oeDevPlugin/oeDevPlugin.md b/docs/zh/docs/DevStation/oeDevPlugin/oeDevPlugin.md new file mode 100644 index 0000000000000000000000000000000000000000..31cb885279aa7a664a5298d2689606f3f6a20d99 --- /dev/null +++ b/docs/zh/docs/DevStation/oeDevPlugin/oeDevPlugin.md @@ -0,0 +1,9 @@ +# oeDevPlugin 用户指南 + +## 简介 + +oeDevPlugin 提供给用户一个可视化界面来查看用户在Gitee的仓库、issue、pull requests、openeuler和src-openeuler中仓库信息,处理用户pull requests 和issue。本文档主要介绍oeDevPlugin的使用指导。 + +本文档适用于Gitee用户。用户需要具备以下经验或者能力: + +- 具备git以及gitee基础知识 \ No newline at end of file diff --git a/docs/zh/docs/DevStation/oeDevPlugin/pic/PR.png b/docs/zh/docs/DevStation/oeDevPlugin/pic/PR.png new file mode 100644 index 0000000000000000000000000000000000000000..c5b4475974808b34ad6090cf1d4a98c11be600f9 Binary files /dev/null and b/docs/zh/docs/DevStation/oeDevPlugin/pic/PR.png differ diff --git a/docs/zh/docs/DevStation/oeDevPlugin/pic/createPR.png b/docs/zh/docs/DevStation/oeDevPlugin/pic/createPR.png new file mode 100644 index 0000000000000000000000000000000000000000..cfb8b69aac35f9c52c570b20cc92294036044461 Binary files /dev/null and b/docs/zh/docs/DevStation/oeDevPlugin/pic/createPR.png differ diff --git a/docs/zh/docs/DevStation/oeDevPlugin/pic/issue.png b/docs/zh/docs/DevStation/oeDevPlugin/pic/issue.png new file mode 100644 index 0000000000000000000000000000000000000000..da4a4aa58981242f416e44a125892e462f2c3196 Binary files /dev/null and b/docs/zh/docs/DevStation/oeDevPlugin/pic/issue.png differ diff --git a/docs/zh/docs/DevStation/oeDevPlugin/pic/openeuler.png b/docs/zh/docs/DevStation/oeDevPlugin/pic/openeuler.png new file mode 100644 index 0000000000000000000000000000000000000000..dffbad5a3457c0fe81d1763d2e4d15cdcfedd43c Binary files /dev/null and b/docs/zh/docs/DevStation/oeDevPlugin/pic/openeuler.png differ diff --git a/docs/zh/docs/DevStation/oeDevPlugin/pic/repo.png b/docs/zh/docs/DevStation/oeDevPlugin/pic/repo.png new file mode 100644 index 0000000000000000000000000000000000000000..48ceba80d9e86802f5b2345bef88c27642fd589d Binary files /dev/null and b/docs/zh/docs/DevStation/oeDevPlugin/pic/repo.png differ diff --git a/docs/zh/docs/DevStation/oeDevPlugin/pic/src-openeuler.png b/docs/zh/docs/DevStation/oeDevPlugin/pic/src-openeuler.png new file mode 100644 index 0000000000000000000000000000000000000000..8ca82b91b0e7bd027de2e15d3fe87c4b2c1638c2 Binary files /dev/null and b/docs/zh/docs/DevStation/oeDevPlugin/pic/src-openeuler.png differ diff --git "a/docs/zh/docs/DevStation/oeDevPlugin/\344\275\277\347\224\250\346\214\207\345\257\274.md" "b/docs/zh/docs/DevStation/oeDevPlugin/\344\275\277\347\224\250\346\214\207\345\257\274.md" new file mode 100644 index 0000000000000000000000000000000000000000..b07babe9f6030c8a41569cfcb7b0085df992313b --- /dev/null +++ "b/docs/zh/docs/DevStation/oeDevPlugin/\344\275\277\347\224\250\346\214\207\345\257\274.md" @@ -0,0 +1,79 @@ +# 使用指导 + +## 1.前期配置 + +oeDevPlugin 是一款预安装在Devstation中的Vscodium软件中Vscodium插件。在使用前需要在setting-->openEuler目录下做如下配置: + +- Openeuler_vscode_plugin:Target_folder 下载仓库的目标路径,默认为家目录的openeuler_repos文件夹; +- Openeuler_vscode_plugin:Personal_access_token gitee私人令牌,需要配置项目/PR组织权限; + +## 2.展示仓库信息 + +![image-20250329095542163](./pic/repo.png) + +此页面主要用于展示用户在gitee账户上的私人仓库。在此提供如下服务 + +- 克隆仓库(**需先选择分支**) +- 打开仓库链接 +- 打开文件夹 +- 在Vscodium中打开 +- 复制仓库地址 + +## 3.展示issue信息 + +![截图 2025-03-29 09-59-27](./pic/issue.png) + +此页面主要用于展示issue相关信息主要为用户提供处理issue相关服务。在此提供如下服务,主要分为两个条目 + +1、我负责的 + +2、我创建的 + +- 点击跳转到issue的对应repo +- 点击issue条目打开对应issue的web页面 + +## 4.展示PR信息 + +![截图 2025-03-29 10-05-38](./pic/PR.png) + +此页面主要用于展示pull request相关的信息,在查看详细信息前需在图中上半部分中的筛选框选择对应仓库。在此提供如下服务: + +- 修改PR标题(需要有对应仓库的操作权限) +- 合入PR (需要有对应仓库的操作权限) +- 关闭PR (需要有对应仓库的操作权限) +- 打开PR (需要有对应仓库的操作权限) +- 点击跳转到PR对应的repo + +## 5.创建PR + +![截图 2025-03-29 10-14-20](./pic/createPR.png) + +此页面主要用于生成对应PR(需要在目标仓库有对应提交)以下是每个条目的释义。 + +- 目标仓库:需要生成PR的个人仓库 +- 原分支:带有相关修改的提交的分支 +- 目标分支:需要将代码同步到的目标分支 +- title:PR的title,对应gitee web页面上对应的PR的title +- description:PR的描述,对应gitee web页面上对应PR的描述信息 + +## 6.openeuler社区仓库信息 + +![截图 2025-03-29 10-22-24](./pic/openeuler.png) + +![截图 2025-03-29 10-37-26](./pic/src-openeuler.png) + +此页面主要用于展示openeuler社区仓的信息。主要分为两个条目: + +1、openeuler + +2、src-openeuler + +并提供如下服务: + +- 克隆仓库(需先选择分支) +- 打开对应仓库的链接 +- 在文件夹中打开 +- 在VS-CODE中打开 +- 复制仓库地址 +- fork仓库,将仓库fork到个人私仓 +- 在openeuler社区仓页面的基础上src-openeuler仓额外提供本地构建服务,主要是将克隆下来的源代码在本地将其构建成rpm软件包。 diff --git a/docs/zh/docs/DevStation/oeGitExt/oeGitExt.md b/docs/zh/docs/DevStation/oeGitExt/oeGitExt.md new file mode 100644 index 0000000000000000000000000000000000000000..ddeca6dad496acc9fea25ba84926437b1f07c97a --- /dev/null +++ b/docs/zh/docs/DevStation/oeGitExt/oeGitExt.md @@ -0,0 +1,10 @@ +# oeGitExt用户指南 + +## 简介 + +oeGitExt使用命令行的方式查看用户在Gitee的仓库、issue、pull requests、openeuler和src-openeuler中仓库信息,处理用户pull requests和issue。本文档简要介绍oeGitExt安装卸载及使用指导。 + +本文档适用于Gitee用户。用户需要具备如下经验或能力: + +- 具备git及Gitee基础知识 +- 了解Linux命令行的基本使用方法 diff --git "a/docs/zh/docs/DevStation/oeGitExt/\344\275\277\347\224\250\346\214\207\345\257\274.md" "b/docs/zh/docs/DevStation/oeGitExt/\344\275\277\347\224\250\346\214\207\345\257\274.md" new file mode 100644 index 0000000000000000000000000000000000000000..fe95eadb97d421f89356564f03e507f63e13fbfd --- /dev/null +++ "b/docs/zh/docs/DevStation/oeGitExt/\344\275\277\347\224\250\346\214\207\345\257\274.md" @@ -0,0 +1,279 @@ +# 使用指导 + +## 1. 配置gitee私人令牌 + +oeGitExt使用之前,需要配置[gitee私人令牌](https://gitee.com/profile/personal_access_tokens),该令牌需具有user_info、projects、pull_requests和issues权限。 + +```bash +oegitext config -token ${access_token} +``` + +## 2. 显示仓库信息 + +```bash +oegitext show proj -h +``` + +```text +oegitext show proj [-h] [-create] [-p] [-j] [-s {full_name,created,updated,pushd}] [-d {,desc,asc}] [-c COLUMNS] +参数说明: + -h, --help 显示帮助信息 + -create 仅显示我创建的工程 + -p, --pretty 以pretty格式显示结果 + -j, --json 以json格式显示结果 + -s, --sort 排序依据: 创建时间(created),更新时间(updated) + -d, --direction 排序方式,升序(asc),降序(desc) + -c, --columns 仅显示指定列 +``` + +### 显示我的项目 + +```bash +oegitext show proj +# 以pretty格式显示 +oegitext show proj -p +# 仅显示项目的state和url列 +oegitext show proj -c state,url +# 以pretty格式显示 +oegitext show proj -c state,url -p +``` + +### 显示我创建的项目 + +```bash +oegitext show proj -create +# 以pretty格式显示 +oegitext show proj -create -p +# 仅显示项目的state和url列 +oegitext show proj -create -c state,url +``` + +## 3. 显示issue + +```bash +oegitext show issue -h +``` + +```text +oegitext show issue [-h] [-create] [-p] [-j] [-s {created,updated}] [-d {desc,asc}] [-c COLUMNS] +参数说明: + -h, --help 显示帮助信息 + -create 仅显示我创建的issue + -p, --pretty 以pretty格式显示结果 + -j, --json 以json格式显示结果 + -s, --sort 排序依据: 创建时间(created),更新时间(updated) + -d, --direction 排序方式,升序(asc),降序(desc) + -c, --columns 仅显示指定列 +``` + +### 显示我负责的issues + +```bash +oegitext show issue +# 以pretty格式显示 +oegitext show issue -p +# 仅显示state和url列 +oegitext show issue -c state,url +``` + +### 显示我创建的issues + +```bash +oegitext show issue -create +# 以pretty格式显示 +oegitext show issue -create -p +# 仅显示state和url列 +oegitext show issue -create -c state,url +``` + +## 4. Show pull request + +```bash +oegitext show pr -h +``` + +```text +oegitext show pr [-h] [-oe] -name REPO_NAME [-only] [-p] [-j] [-c COLUMNS] +参数说明: + -h, --help 显示帮助信息 + -name pr路径,owner/repo + -only 仅显示我创建的PR + -p, --pretty 以pretty格式显示结果 + -j, --json 以json格式显示结果 + -c, --columns 仅显示指定列 +``` + +### 显示仓库的PR + +```bash +oegitext show pr -name src-openeuler/vscode +# 以pretty格式显示 +oegitext show pr -name src-openeuler/vscode -p +# 仅显示其中的state和url列 +oegitext show pr -name src-openeuler/vscode -c state,url +``` + +## 5. 显示openEuler仓库信息 + +```bash +oegitext show repo -h +``` + +```text +oegitext show repo [-h] [-owner {openeuler,src-openeuler}] [-p] [-j] [-c COLUMNS] +参数说明: + -h, --help 显示帮助信息 + -owner 仓库所有者(openeuler或者src-openeuler),默认openeuler + -p, --pretty 以pretty格式显示结果 + -j, --json 以json格式显示结果 + -c, --columns 仅显示指定列 +``` + +## 6. fork仓库 + +```bash +oegitext fork -h +``` + +```text +oegitext fork [-h] -user USER -repo REPO [-org ORG] [-name NAME] [-path PATH] [-show] +参数说明: + -h, --help 显示帮助信息 + -user USER 仓库所属空间地址(企业、组织或个人的地址path) + -repo REPO 仓库路径(path) + -org ORG 组织空间完整地址,不填写默认Fork到用户个人空间地址 + -name NAME fork 后仓库名称。默认: 源仓库名称 + -path PATH fork 后仓库地址。默认: 源仓库地址 + -show 显示requests结果 +``` + +## 7. 处理issue + +```bash +oegitext issue -h +``` + +```text +oegitext issue [-h] -cmd {create,update,close,open,get} [-user USER] [-repo REPO] [-title TITLE] [-number NUMBER] + [-body BODY] [-show] +参数说明: + -h, --help 显示帮助信息 + -cmd 处理issue命令 + -user USER issue所属空间地址(企业、组织或个人的地址path) + -repo REPO 仓库路径(path) + -title TITLE title + -number NUMBER issue number + -body BODY issue body + -show 显示requests结果 +``` + +### 获取仓库issue + +```text +oegitext issue -cmd get -user USER -repo REPO -number NUMBER [-show] +``` + +### 创建issue + +```text +oegitext issue -cmd create -user USER -repo REPO -title TITLE [-body BODY] [-show] +``` + +### 更新issue + +```text +oegitext issue -cmd update -user USER -repo REPO -title TITLE -number NUMBER [-body BODY] [-show] +``` + +### 关闭issue + +```text +oegitext issue -cmd close -user USER -repo REPO -number NUMBER [-show] +``` + +### 打开issue + +```text +oegitext issue -cmd open -user USER -repo REPO -number NUMBER [-show] +``` + +## 8. 处理PR + +```bash +oegitext pull -h +``` + +```text +oegitext pull [-h] -cmd {create,update,close,open,review,test,merge,get} [-user USER] [-repo REPO] [-title TITLE] + [-head HEAD] [-base BASE] [-number NUMBER] [-body BODY] [-state STATE] [-show] +参数说明: + -h, --help 显示帮助信息 + -cmd 处理PR命令, create,update,close,open,review,test,merge,get + -user USER PR所属空间地址(企业、组织或个人的地址path) + -repo REPO 仓库路径(path) + -title TITLE title + -head HEAD PR提交的源分支。格式:branch (master) 或者:path_with_namespace:branch (oschina/gitee:master) + -base BASE RP提交目标分支的名称 + -number NUMBER number + -body RP内容 + -state STATE state + -show 显示requests结果 + +``` + +### 获取PR信息 + +```text +oegitext pull -cmd get -user USER -repo REPO -number NUMBER [-show] +``` + +### 创建PR + +```text +oegitext pull -cmd create -user USER -repo REPO -title TITLE -head HEAD -base BASE [-body BODY] [-show] +参数说明: + -head HEAD: Pull Request 提交的源分支。格式:branch (master) 或者:path_with_namespace:branch (oschina/gitee:master) + -base BASE: Pull Request 提交目标分支的名称 +``` + +### 更新PR + +```text +oegitext pull -cmd update -user USER -repo REPO -number NUMBER -body BODY [-show] +``` + +### 关闭PR + +```text +oegitext pull -cmd close -user USER -repo REPO -number NUMBER [-show] +``` + +### 打开PR + +```text +oegitext pull -cmd open -user USER -repo REPO -number NUMBER [-show] +``` + +### review PR + +```text +oegitext pull -cmd review -user USER -repo REPO -number NUMBER -state {pass,reset} [-show] +参数说明: + -state pass: 强制review通过 + reset: 重置review状态 +``` + +### test PR + +```text +oegitext pull -cmd test -user USER -repo REPO -number NUMBER -state {pass,reset} [-show] +参数说明: + -state pass: 强制测试通过 + reset: 重置测试状态 +``` + +### merge PR + +```text +oegitext pull -cmd merge -user USER -repo REPO -number NUMBER [-show] +``` diff --git "a/docs/zh/docs/DevStation/oeGitExt/\345\256\211\350\243\205\345\215\270\350\275\275\346\214\207\345\257\274.md" "b/docs/zh/docs/DevStation/oeGitExt/\345\256\211\350\243\205\345\215\270\350\275\275\346\214\207\345\257\274.md" new file mode 100644 index 0000000000000000000000000000000000000000..c07bfdd942455b992558bcc9aec81d6ee7703f49 --- /dev/null +++ "b/docs/zh/docs/DevStation/oeGitExt/\345\256\211\350\243\205\345\215\270\350\275\275\346\214\207\345\257\274.md" @@ -0,0 +1,31 @@ +# 安装卸载指导 + +## 环境要求 + +- 操作系统:openEuler 25.03 + +## 安装 + +```bash +sudo dnf clean all +``` + +```bash +sudo dnf makecache +``` + +```bash +sudo dnf install oegitext +``` + +## 卸载 + +```bash +sudo dnf remove oegitext +``` + +然后使用以下命令删除配置文件。 + +```bash +rm ~/.oegitext +``` diff --git a/docs/zh/docs/DevStation/public_sys-resources/icon-caution.gif b/docs/zh/docs/DevStation/public_sys-resources/icon-caution.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e90d7cfc2193e39e10bb58c38d01a23f045d571 Binary files /dev/null and b/docs/zh/docs/DevStation/public_sys-resources/icon-caution.gif differ diff --git a/docs/zh/docs/DevStation/public_sys-resources/icon-danger.gif b/docs/zh/docs/DevStation/public_sys-resources/icon-danger.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e90d7cfc2193e39e10bb58c38d01a23f045d571 Binary files /dev/null and b/docs/zh/docs/DevStation/public_sys-resources/icon-danger.gif differ diff --git a/docs/zh/docs/DevStation/public_sys-resources/icon-note.gif b/docs/zh/docs/DevStation/public_sys-resources/icon-note.gif new file mode 100644 index 0000000000000000000000000000000000000000..6314297e45c1de184204098efd4814d6dc8b1cda Binary files /dev/null and b/docs/zh/docs/DevStation/public_sys-resources/icon-note.gif differ diff --git a/docs/zh/docs/DevStation/public_sys-resources/icon-notice.gif b/docs/zh/docs/DevStation/public_sys-resources/icon-notice.gif new file mode 100644 index 0000000000000000000000000000000000000000..86024f61b691400bea99e5b1f506d9d9aef36e27 Binary files /dev/null and b/docs/zh/docs/DevStation/public_sys-resources/icon-notice.gif differ diff --git a/docs/zh/docs/DevStation/public_sys-resources/icon-tip.gif b/docs/zh/docs/DevStation/public_sys-resources/icon-tip.gif new file mode 100644 index 0000000000000000000000000000000000000000..93aa72053b510e456b149f36a0972703ea9999b7 Binary files /dev/null and b/docs/zh/docs/DevStation/public_sys-resources/icon-tip.gif differ diff --git a/docs/zh/docs/DevStation/public_sys-resources/icon-warning.gif b/docs/zh/docs/DevStation/public_sys-resources/icon-warning.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e90d7cfc2193e39e10bb58c38d01a23f045d571 Binary files /dev/null and b/docs/zh/docs/DevStation/public_sys-resources/icon-warning.gif differ diff --git "a/docs/zh/docs/DevStation/\345\234\250VirtualBox\344\270\212\345\256\211\350\243\205DevStation.md" "b/docs/zh/docs/DevStation/\345\234\250VirtualBox\344\270\212\345\256\211\350\243\205DevStation.md" new file mode 100644 index 0000000000000000000000000000000000000000..32652b722e49980923a2f91aa3f82e6187198865 --- /dev/null +++ "b/docs/zh/docs/DevStation/\345\234\250VirtualBox\344\270\212\345\256\211\350\243\205DevStation.md" @@ -0,0 +1,3 @@ +# 在 VirtualBox 上安装 DevStation + +本文是介绍在 VirtualBox 上安装 openEuler Devstation 的步骤方法。 diff --git "a/docs/zh/docs/DevStation/\345\234\250\344\270\252\344\272\272PC\344\270\212\345\217\214\347\263\273\347\273\237\345\256\211\350\243\205DevStation.md" "b/docs/zh/docs/DevStation/\345\234\250\344\270\252\344\272\272PC\344\270\212\345\217\214\347\263\273\347\273\237\345\256\211\350\243\205DevStation.md" new file mode 100644 index 0000000000000000000000000000000000000000..c0949db9a5a36d36661c8cef0c43fe37499e6096 --- /dev/null +++ "b/docs/zh/docs/DevStation/\345\234\250\344\270\252\344\272\272PC\344\270\212\345\217\214\347\263\273\347\273\237\345\256\211\350\243\205DevStation.md" @@ -0,0 +1,5 @@ +# 在个人PC上双系统安装 DevStation + +前提:请先安装 windows 系统,再进行 openEuler DevStation 系统安装,不要将两者顺序颠倒,否则安装完成后无法引导 openEuler DevStation 系统。 + +本文是介绍在个人PC上安装 openEuler Devstation 的步骤方法,使用本手册需要具备基本的 Linux 系统管理知识。 diff --git "a/docs/zh/docs/DevStation/\345\256\211\350\243\205\345\207\206\345\244\207-1.md" "b/docs/zh/docs/DevStation/\345\256\211\350\243\205\345\207\206\345\244\207-1.md" new file mode 100644 index 0000000000000000000000000000000000000000..4f4823f6e658ee5978333bfa0384af9b4cf06d1e --- /dev/null +++ "b/docs/zh/docs/DevStation/\345\256\211\350\243\205\345\207\206\345\244\207-1.md" @@ -0,0 +1,156 @@ +# 安装准备 + +在安装前,需要考虑软硬件的兼容性问题,并评估相关配置和准备工作,确保安装过程顺利进行。 + +## 系统要求 + +### 1️⃣ **存储空间** + +| 项目 | 说明 | +| -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | +| **最低要求(Windows保留)** | Windows系统盘至少保留100GB可用空间(仅Windows系统+基本软件占用的空间) | +| **双系统推荐配置(DevStation)** | 需单独分出一个**空闲分区**(未使用的磁盘空间),大小至少40GB(建议80GB),这个空间将专门用于安装openEuler DevStation系统 | + +**举个🌰**: + +如果你的硬盘是500GB,典型分区建议: + +- Windows系统盘:150GB(实际Windows 11安装需约40GB,预留常用软件空间) +- 数据盘(D盘):300GB (存放个人文件) +- **空闲分区**:50GB(专门留给openEuler DevStation) + +> ⚠️ 注意:这里的"空闲分区"必须处于**未格式化状态**,安装系统时会自动格式化! + +### 2️⃣ **内存** + +| 项目 | 说明 | 对双系统的影响 | +| ------------------------------- | ---------------------------------------- | ----------------------------------------------------------------------- | +| **最低要求(4GB)** | 只要满足任一系统单独运行的最基本内存需求 | 当运行Windows或DevStation时,电脑能勉强启动使用(但无法同时运行双系统) | +| **推荐配置(8GB DDR4+)** | 现代操作系统的流畅运行基础 | 可让双系统中的任一系统运行时流畅开启开发工具(如VSCode、Docker等) | + +> 🤔 **常见误区**:双系统不是同时运行的!**同一时间只能使用一个系统**,内存需求是针对每个系统独立计算的。 + +### 3️⃣ **UEFI支持** + +**什么是UEFI?**:现代电脑的**新型启动模式**(相比传统的Legacy BIOS),提供更安全的启动环境和支持大容量硬盘。 + +| 关键项 | 要求说明 | 失败案例 | +| ----------------- | -------------------------------------------------------------------------------- | ------------------------------------ | +| **必需** | 你的电脑主板需支持UEFI启动模式(2012年后生产的电脑基本都支持) | 旧电脑使用Legacy模式可能导致分区失败 | +| **开启CSM** | 针对**老旧设备**:在主板设置中开启"兼容性支持模块"(让UEFI兼容Legacy设备) | 不开启可能导致安装界面卡死 | + +**▶ 如何检查UEFI模式?** +在Windows中按 `Win+R` 输入 `msinfo32` → 查看**BIOS模式**是否为"UEFI" + +**▶ 为什么要用UEFI?** + +- 支持超过2TB的硬盘 +- 更快的启动速度 +- 双系统引导更稳定(GRUB与Windows Boot Manager兼容性好) + +### ❓ **如果不符合要求会怎样?** + +| 硬件项 | 不符合后果 | 解决方案 | +| ---------- | -------------------------------- | -------------------------------------------------------- | +| 存储不足 | 安装过程中出现"磁盘空间不足"错误 | 压缩Windows分区 | +| 内存不足 | 系统运行极度卡顿,频繁崩溃 | 关闭后台程序或添加内存条(笔记本用户需确认是否支持扩展) | +| 无UEFI支持 | 无法完成安装程序初始化 | 旧电脑需开启CSM或单独制作Legacy模式启动盘 | + +**实际场景下的建议方案**: + +如果你是学生或开发者的典型配置: + +```markdown +硬盘:512GB SSD +- Windows分配200GB(系统+基础开发环境) +- DevStation分配80GB (Linux开发环境+容器) +- 剩余232GB作为公共数据盘(NTFS格式,Windows/Linux均可读写) + +内存:16GB DDR4 → 可同时应对IDE/虚拟机等重度场景 +固件:UEFI模式+关闭Secure Boot → 确保硬件驱动兼容性 +``` + +## 获取安装源 + +在安装开始前,您需要获取 openEuler DevStation 的镜像和校验文件。 + +请按以下步骤获取 openEuler Devstation 的镜像和校验文件: + +1. 登录[openEuler DevStation 社区镜像源](https://repo.openeuler.org/)网站。 +2. 选择 openEuler-25.03 版本。 +3. 根据实际待安装环境的架构和场景选择需要下载的 openEuler DevStation 的镜像和校验文件。 + 1. 若为 aarch64 架构。 + 1. 选择 aarch64 目录。 + 2. 将镜像 “openEuler-25.03-DevStation-aarch64-dvd.iso” 下载到本地。 + 2. 若为 x86_64 架构。 + 1. 选择 x86_64 目录。 + 2. 将镜像 “openEuler-25.03-DevStation-x86_64-dvd.iso” 下载到本地。 + +> ![](./public_sys-resources/icon-note.gif) **说明:** +> +> - aarch64 架构的镜像支持 UEFI 模式,x86\_64 架构的镜像支持 UEFI 模式和 Legacy 模式。 + +## 镜像完整性校验 + +> ![](./public_sys-resources/icon-note.gif) **说明:** +> 本章节以 aarch64 架构的镜像完整性校验为例,x86\_64 架构的镜像完整性校验的操作方法相同。 + +### 简介 + +为了确认软件包在传输过程中由于网络原因或者存储设备原因是否出现下载不完整的问题,在获取到软件包后,需要对软件包的完整性进行校验,通过了校验的软件包才能部署。 + +这里通过对比校验文件中记录的校验值和手动方式计算的 iso 文件校验值,判断软件包是否完整。若两个值相同,说明iso文件完整,否则,iso 完整性被破坏,请重新获取 iso 镜像。 + +### 前提条件 + +在校验镜像完整性之前,需要准备如下文件: + +- iso 文件:openEuler-25.03-DevStation-aarch64-dvd.iso。 +- 校验文件:openEuler-25.03-DevStation-aarch64-dvd.iso.sha256sum,文件保存ISO完整性校验值信息,校验信息与ISO值一一对应。 + +### 操作指导 + +文件完整性校验操作步骤如下: + +1. 计算文件的 sha256 校验值。执行命令如下: + + ```bash + sha256sum openEuler-25.03-DevStation-aarch64-dvd.iso + ``` + + 命令执行完成后,输出校验值。 +2. 对比步骤1计算的校验值与校验文件中复制的 SHA256 值是否一致。 + + 如果校验值一致说明 iso 文件完整,如果校验值不一致则可以确认文件完整性已被破坏,需要重新获取。 + +## 制作启动盘 + +1. 下载 [Rufus](https://rufus.ie/)(或使用Etcher、Ventoy等工具) +2. 插入U盘(容量≥8GB) +3. 打开Rufus,选择下载的ISO镜像: + 1. 分区类型:MBR + 2. 目标系统类型:BIOS 或 UEFI + 3. 文件系统:FAT32 +4. 制作完成后,记录U盘卷标(例如:"openEuler-25.03-DevStation-netin") + +## Windows 磁盘空间释放 + +### 分区压缩步骤 + +1. **打开磁盘管理** + + ![Win+X → 磁盘管理](./figures/compress.png) +2. **右键目标分区→压缩卷** +3. **输入压缩量(单位MB)**: + + ```bash + 推荐公式: (总空间 - 系统已用)*0.3 # 例如100GB系统盘建议保留30GB供Windows + ``` + +### 空间验证 + +```powershell +# 以管理员身份执行: +Get-Partition | ft -AutoSize +# 确认显示"未分配"空间 +``` diff --git "a/docs/zh/docs/DevStation/\345\256\211\350\243\205\345\207\206\345\244\207.md" "b/docs/zh/docs/DevStation/\345\256\211\350\243\205\345\207\206\345\244\207.md" new file mode 100644 index 0000000000000000000000000000000000000000..a22d596c14430ed69d70149eb7d0cf52b5f18780 --- /dev/null +++ "b/docs/zh/docs/DevStation/\345\256\211\350\243\205\345\207\206\345\244\207.md" @@ -0,0 +1,102 @@ +# 安装准备 + +在安装前,需要考虑软硬件的兼容性问题,并评估相关配置和准备工作,确保安装过程顺利进行。 + +## 获取安装源 + +在安装开始前,您需要获取 openEuler DevStation 的镜像和校验文件。 + +请按以下步骤获取 openEuler Devstation 的镜像和校验文件: + +1. 登录[openEuler DevStation 社区镜像源](https://repo.openeuler.org/)网站。 +2. 选择 openEuler-25.03 版本。 +3. 根据实际待安装环境的架构和场景选择需要下载的 openEuler DevStation 的镜像和校验文件。 + 1. 若为 aarch64 架构。 + 1. 选择 aarch64 目录。 + 2. 将镜像 “openEuler-25.03-DevStation-aarch64-dvd.iso” 下载到本地。 + 2. 若为 x86_64 架构。 + 1. 选择 x86_64 目录。 + 2. 将镜像 “openEuler-25.03-DevStation-x86_64-dvd.iso” 下载到本地。 + +> ![](./public_sys-resources/icon-note.gif) **说明:** +> +> - aarch64 架构的镜像支持 UEFI 模式,x86\_64 架构的镜像支持 UEFI 模式和 Legacy 模式。 + +## 镜像完整性校验 + +> ![](./public_sys-resources/icon-note.gif) **说明:** +> 本章节以 aarch64 架构的镜像完整性校验为例,x86\_64 架构的镜像完整性校验的操作方法相同。 + +### 简介 + +为了确认软件包在传输过程中由于网络原因或者存储设备原因是否出现下载不完整的问题,在获取到软件包后,需要对软件包的完整性进行校验,通过了校验的软件包才能部署。 + +这里通过对比校验文件中记录的校验值和手动方式计算的 iso 文件校验值,判断软件包是否完整。若两个值相同,说明iso文件完整,否则,iso 完整性被破坏,请重新获取 iso 镜像。 + +### 前提条件 + +在校验镜像完整性之前,需要准备如下文件: + +- iso 文件:openEuler-25.03-DevStation-aarch64-dvd.iso。 +- 校验文件:openEuler-25.03-DevStation-aarch64-dvd.iso.sha256sum,文件保存ISO完整性校验值信息,校验信息与ISO值一一对应。 + +### 操作指导 + +文件完整性校验操作步骤如下: + +1. 计算文件的 sha256 校验值。执行命令如下: + + ```bash + sha256sum openEuler-25.03-DevStation-aarch64-dvd.iso + ``` + + 命令执行完成后,输出校验值。 +2. 对比步骤1计算的校验值与校验文件中复制的 SHA256 值是否一致。 + + 如果校验值一致说明 iso 文件完整,如果校验值不一致则可以确认文件完整性已被破坏,需要重新获取。 + +## 物理机的安装要求 + +若需要在物理机环境上安装 openEuler DevStation ,则物理机需要满足如下的硬件兼容性和最小硬件要求。 + +### 硬件兼容支持 - 待补充 + +openEuler DevStation 安装时,应注意硬件兼容性方面的问题,当前已支持的服务器类型请参考[兼容性列表](https://www.openeuler.org/zh/compatibility/)。 - 待补充 + +### 最小硬件要求 + +openEuler DevStation 所需的最小硬件要求如[表2](#tff48b99c9bf24b84bb602c53229e2541)所示。 + +**表 2** 最小硬件要求`` + +| 部件名称 | 最小硬件要求 | +| :------- | :------------------------------------------------------ | +| 架构 | aarch64 或 x86_64 | +| CPU | 现代1Ghz 双核处理器 | +| 内存 | 不小于 4GB(为了获得更好的应用体验,建议不小于 8GB) | +| 硬盘 | 不小于 32GB(为了获得更好的应用体验,建议不小于 120GB) | + +## 虚拟机的安装要求 + +若需要在虚拟机环境上安装 openEuler DevStation ,则虚拟机需要满足如下的虚拟化平台兼容性和最小虚拟化要求。 + +### 虚拟化平台兼容性 + +openEuler DevStation 安装时,应注意虚拟化平台兼容性的问题,当前已支持的虚拟化平台为: + +- Hyper-v +- VMware Workstation +- VM VirtualBox + +### 最小虚拟化空间要求 + +openEuler所需的最小虚拟化空间要求如[表3](#tff48b99c9bf24b84bb602c53229e2542)所示。 + +**表 3** 最小虚拟化空间要求`` + +| 部件名称 | 最小虚拟化空间要求 | +| :------- | :------------------------------------------------------ | +| 架构 | aarch64 或 x86_64 | +| CPU | 双核 CPU | +| 内存 | 不小于 4GB(为了获得更好的应用体验,建议不小于 8GB) | +| 硬盘 | 不小于 32GB(为了获得更好的应用体验,建议不小于 120GB) | diff --git "a/docs/zh/docs/DevStation/\345\256\211\350\243\205\346\214\207\345\257\274-1.md" "b/docs/zh/docs/DevStation/\345\256\211\350\243\205\346\214\207\345\257\274-1.md" new file mode 100644 index 0000000000000000000000000000000000000000..154088eb6681b85d29c3652ca75c953d3205555d --- /dev/null +++ "b/docs/zh/docs/DevStation/\345\256\211\350\243\205\346\214\207\345\257\274-1.md" @@ -0,0 +1,246 @@ +# **安装指导** + +## 1. 安装前准备 + +### 1.1 BIOS设置 + +> ![](./public_sys-resources/icon-warning.gif) **重要提示:** +> +> - 不同品牌设备进入BIOS方式不同(常见品牌:F1/F2/DEL/ESC) +> - 必须关闭"安全启动"(Secure Boot)选项 +> - 错误修改BIOS设置可能导致系统无法启动 + +1. 插入U盘启动盘 +2. 开机时立即按下设备对应的BIOS键(持续快速点击) +3. 在Security选项中禁用Secure Boot +4. 保存设置(F10)并重启 + +### 1.2 启动菜单选择 + +> ![](./public_sys-resources/icon-note.gif) **说明:** +> +> - 启动菜单键通常为F12/ESC +> - 需在BIOS POST完成后快速按下 + +1. 重启后立即按下启动菜单键 +2. 选择带有"UEFI:"前缀的U盘设备 +3. 按Enter确认启动 + +## 2. 安装引导界面 + +### 2.1 引导菜单 + +系统将显示引导菜单,默认选项为: + +- `Start openEuler-25.03-DevStation-x86_64-dvd.iso 25.03`(推荐) +- `Troubleshooting`(仅用于问题诊断) + +> ![](./public_sys-resources/icon-note.gif) **操作说明:** +> +> - 使用↑/↓方向键选择 +> - 按Enter确认选择 +> - 60秒无操作将自动进入默认选项 + +**图1** 安装引导界面 + +![引导界面](./figures/3-installation.png) + +### 2.2 高级选项 + +- 按 `e`:编辑启动参数(高级用户) +- 按 `c`:进入命令行模式(故障诊断) + +## 3. 初始设置 + +### 3.1 语言选择 + +在欢迎界面选择"简体中文"(或其他支持语言) + +> ![](./public_sys-resources/icon-warning.gif) **注意:** +> +> - 此处选择的语言将作为系统默认语言 +> - 安装完成后仍可修改 + +**图2** 语言设置界面 + +![语言设置](./figures/1-welcome.jpg) + +### 3.2 时区设置 + +1. 选择"亚洲/北京"时区(UTC+8) +2. 如城市未列出,选择同区域最近城市 + +**图3** 时区设置界面 + +![时区设置](./figures/2-timezone.jpg) + +## 4. 账户与安全设置 + +### 4.1 用户账户设置 + +**图4** 账户设置界面 + +![账户设置](./figures/3-username.jpg) + +1. 设置用户名(建议使用英文) +2. 设置符合复杂度要求的密码: + - 至少8位字符 + - 包含大小写字母和数字 + - 建议使用特殊符号 + +> ![](./public_sys-resources/icon-warning.gif) **安全建议:** +> +> - 避免使用简单密码如"123456" +> - 不要使用与个人信息相关的密码 +> - 定期更换密码 + +### 4.2 Root账户设置 + +- 勾选"为管理员账号使用同样的密码"可统一密码 +- 取消勾选可单独设置Root密码 + +> ![](./public_sys-resources/icon-note.gif) **最佳实践:** +> +> - 日常操作建议使用普通账户 +> - 仅在进行系统管理时使用Root账户 + +## 5. 软件包选择 + +### 5.1 基础环境选择 + +**图5** 软件包选择界面 + +![软件选择](./figures/4-packages.png) + +可选方案: + +1. **DevStation全功能环境**(推荐): + 1. 包含开发工具链和常用应用 + 2. 适合大多数开发者 +2. **最小安装**: + 1. 仅基础系统组件 + 2. 适合自定义构建环境 + +> ![](./public_sys-resources/icon-note.gif) **扩展建议:** +> +> - 安装完成后可通过以下命令添加软件: +> ```bash +> sudo dnf install +> ``` +> - 可使用 `dnf search`命令查找可用软件包 + +## 6. 磁盘分区(关键步骤❗️❗️❗️) + +### 6.1 存储设备选择 + +> - 操作:选择"手动分区" ![](./public_sys-resources/icon-warning.gif) **重要警告:不要选择自动分区,请选择手动分区,请谨慎操作❗️❗️❗️** +> - 选择"自动分区"将会删除目前选定的存储器上所有数据,将会导致windows系统也被删除 +> - 请选择预留有空闲空间的磁盘 + +**图6** 存储设备列表 + +![存储设备](./figures/5-manifast.jpg) + +> ![](./public_sys-resources/icon-warning.gif) **重要警告:** +> +> - 错误的分区操作将导致数据永久丢失 +> - 建议提前备份重要数据 +> - 双系统用户请特别注意以下步骤 + +### 6.2 EFI系统分区设置 + +1. 选择现有的FAT32格式分区(通常为300-500MB) +2. 点击"编辑"按钮: + - 操作:选择"保留" ![](./public_sys-resources/icon-warning.gif) **重要警告:不保留的话,将导致windows系统永久丢失,请谨慎操作❗️❗️❗️** + - 挂载点:`/boot/efi` + +**图7** EFI分区设置 + +![EFI设置](./figures/7-bootefi.png) + +### 6.3 根分区设置 + +1. 选择安装前预留的空闲分区(如nvme0n1p7) +2. 点击"编辑"按钮: + - 文件系统:ext4 + - 挂载点:`/` + - 卷标:可自定义(如devstation) + +**图8** 根分区设置 + +![根分区](./figures/9-boot.png) + +### 6.4 分区确认 + +**图9** 分区总览 + +![分区总览](./figures/10-startinstall.jpg) + +> ![](./public_sys-resources/icon-warning.gif) **再次确认:** +> +> - 仔细检查每个分区的挂载点和大小 +> - 确认不会误操作其他系统的分区 + +## 7. 安装与初始化 + +### 7.1 安装确认 + +**图10** 安装确认界面 + +> ![](./public_sys-resources/icon-warning.gif) **最后确认:** +> +> - 再次检查所有设置,请确认分区当前和之后,是否选定**正确的空闲分区**上(如nvme0n1p7)安装 openEuler-25.03 +> - 确保电源稳定(笔记本请接通电源) + +点击"安装"开始系统部署 + +![安装确认](./figures/11-summary.png) + +### 7.2 安装进度 + +**图11** 安装过程界面 + +![安装进度](./figures/12-installing.jpg) + +预计时间:5-10分钟(取决于硬件配置) + +### 7.3 安装完成 + +1. 系统将提示安装成功 +2. 点击"重启"按钮 +3. **重要**:及时移除安装介质(U盘) + +**图12** 启动菜单 + +![启动菜单](./figures/13-grub.png) + +- 选择"openEuler"启动项 +- 首次启动可能需较长时间初始化 + +## 8. 首次启动配置 + +### 8.1 登录系统 + +- 使用安装时设置的账户登录 +- root账号可在终端中切换 + +### 8.2 网络配置 + +1. 点击系统托盘网络图标 +2. 选择Wi-Fi网络并输入密码 +3. 或有线网络将自动连接 + +### 8.3 应用管理 + +- 通过"应用中心"查找安装软件 +- 或使用终端命令: + +```bash +sudo dnf list installed +``` + +> ![](./public_sys-resources/icon-note.gif) **提示:** +> +> 遇到问题可查阅及反馈: +> +> - 社区论坛:[https://forum.openeuler.org](https://forum.openeuler.org) diff --git "a/docs/zh/docs/DevStation/\345\256\211\350\243\205\346\214\207\345\257\274.md" "b/docs/zh/docs/DevStation/\345\256\211\350\243\205\346\214\207\345\257\274.md" new file mode 100644 index 0000000000000000000000000000000000000000..5717ea8a6d2c46c336fc2151f37b2a4e0853b712 --- /dev/null +++ "b/docs/zh/docs/DevStation/\345\256\211\350\243\205\346\214\207\345\257\274.md" @@ -0,0 +1,128 @@ +# 安装指导 + +本章将以光盘安装为例,详细介绍如何安装 openEuler DevStation。对于其他安装方式,除了在启动安装时的引导方式可能有所不同外,其余的安装流程均相同,因此本章不再赘述。 + +## 启动安装 + +### 使用光盘引导安装 + +使用光盘引导安装 openEuler DevStation,具体步骤如下。 + +> ![](./public_sys-resources/icon-note.gif) **说明:** +> 在安装开始前,需要保证启动选项为光驱优先。安装步骤以 VirtualBox 挂载虚拟光驱进行光盘安装的操作举例。 + +1. 在 VM VirtualBox 工具栏中,单击新建如下图所示。 + + **图 1** 光驱图标 ``![](./figures/1-createvm.png) + + 弹出新建虚拟电脑对话框,如下图所示。 + + **图 2** 新建虚拟电脑对话框 ``![](./figures/2-create_dialog_box.png) +2. 在新建虚拟电脑对话框中,选择“虚拟光盘”, 并单击下拉框。选择 DevStation 镜像。 +3. 选择下一步,根据“安装准备”章节中所要求的硬件规格去进行配置。 + +### 安装引导界面 + +系统使用引导介质完成引导后会显示引导菜单。该引导菜单除启动安装程序外还提供一些选项。安装系统时,默认采用“Start openEuler-25.03-DevStation-x86_64-dvd.iso 25.03”方式进行安装。如果要选择默认选项之外的选项,请使用键盘中的“↑”和“↓”方向键进行选择,并在选项为高亮状态时按“Enter”。 + +> ![](./public_sys-resources/icon-note.gif) **说明:** +> +> - 如果60秒内未按任何键,系统将从默认选项“Start openEuler-25.03-DevStation-x86_64-dvd.iso 25.03”自动进入安装界面。 + +**图 3** 安装引导界面 `` + +![img](./figures/3-installation.png) + +安装引导选项说明如下: + +- Start openEuler-25.03-DevStation-x86_64-dvd.iso 25.03 —— 默认选项。 +- Troubleshooting —— 问题定位模式,系统无法正常安装时使用。-功能待完善 + +在安装引导界面,按“e”进入已选选项的参数编辑界面,按“c”进入命令行模式。 + +DevStation 正常启动之后,会以Livecd方式进入主界面,同时以devstation用户权限自动拉起系统安装服务进行落盘安装,如[图4](#zh-cn_topic_0186390097_zh-cn_topic_0122145868_fig17366454247)所示,点击图中"认证"进入安装欢迎页。 + +**图 4** 管理员权限认证 `` +![](./figures/7-apps.png) + +## 设置系统语言 + +在“欢迎”页面中选择“语言”,设置系统的语言。如[图5](#zh-cn_topic_0186390098_zh-cn_topic_0122145772_fig187301927172619)所示,用户也可根据实际情况进行调整,选择“简体中文”。 + +**图 5** 语言支持 `` +![](./figures/8-selectlanguage.png) + +## 设置时间和日期 + +在“基础设置”页面中选择“地区和区域”,设置系统的时区、日期、时间等。 + +设置时区时,用户可通过页面顶部的“地区”和“城市”下拉菜单中进行选择,如[图6](#zh-cn_topic_0186390096_zh-cn_topic_0122145900_fig1260162652312)所示。 + +如果您所在城市没有出现在下拉菜单中,请选择同一时区中离您最近的城市。 + +**图 6** 日期和时间 `` +![](./figures/9-timezone.png) + +## 设置帐户密码 + +在“用户设置”页面中设置账号密码,如[图7](#zh-cn_topic_0186390266_zh-cn_topic_0122145909_fig1323165793018)所示,根据[密码复杂度](#密码复杂度)输入密码并再次输入密码进行确认。 + +> ![](./public_sys-resources/icon-note.gif) **说明:** +> +> - root帐户是用来执行关键系统管理任务,不建议您在日常工作及系统访问时使用root帐户。 + +**图 7** root帐户 `` +![](./figures/10-username.png) + +如上图所示,界面选中“为管理员账号使用同样的密码”选项后,管理员账户(即root)的密码与界面设置的用户密码相同,该选项避免多次输入密码(习惯上人们都会趋向于不同账号设置同一个密码,方便记忆)。相反,当取消选择该选项后,在该页面可以为管理员账号及密码进行单独设置。 + +## 选择安装软件 + +在“用户设置”页面中选择“DevStation”,指定需要安装的软件包。 + +用户需要根据实际的业务需求,在左侧也可以选择一个“最小安装”,如[图8](#zh-cn_topic_0186390261_zh-cn_topic_0122145865_fig03031519101414)所示。 + +**图 8** 软件选择 ``![img](./figures/11-packages.png) + +> ![](./public_sys-resources/icon-note.gif) **说明:** +> +> - 在最小安装的环境下,并非安装源中所有的包都会安装。如果用户需要使用的包未安装,可将安装源挂载到本地制作repo源,通过DNF工具单独安装。 + +## 设置安装目的地 + +在“安装设置”页面中选择“存储器”,设置操作系统的安装磁盘及分区。 + +在[图9](#fig1195417125015)所示的页面中您可以看到计算机中的本地可用存储设备。 + +**图 9** 安装目标位置 `` +![](./figures/12-disk.png) + +### 存储配置 -待完善 + +**自动**分区 + +如果是在未使用过的存储设备中执行全新安装,或者不需要保留该存储设备中任何数据,建议选择“自动”进行自动分区。 + +**自定义**分区 -待完善 + +## 开始安装 + +在安装界面上完成所有必填选项的配置后。此时,用户可以单击“安装”进行系统安装,如[图10](#fig-install-sure)。 + +**图 10** 安装配置确认 `` +![](./figures/14-install-sure.png) + +## 安装过程 + +开始安装后会出现进度页面,显示安装进度及所选软件包写入系统的进度,如[图11](#zh-cn_topic_0186390266_zh-cn_topic_0122145909_fig1590863119306)所示。 + +> ![](./public_sys-resources/icon-note.gif) **说明:** +> +> 若系统安装过程中,单击“退出”,或复位、下电服务器,则安装过程被中断,系统将不可用,需要重新进行安装。 + +**图 11** 安装过程 `` +![](./figures/13-install.png) + +## 安装完成 + +在安装过程执行完成后,openEuler Devstation即完成了安装。请点击“重启系统”按钮,系统将会重新启动。 diff --git "a/docs/zh/docs/Embedded/UniProton/UniProton\345\212\237\350\203\275\350\256\276\350\256\241.md" "b/docs/zh/docs/Embedded/UniProton/UniProton\345\212\237\350\203\275\350\256\276\350\256\241.md" index aec2ada3f282c56901a85bc86bb5e2296655a240..f1f9eb88a762dfab96986edca0c74390705f075f 100644 --- "a/docs/zh/docs/Embedded/UniProton/UniProton\345\212\237\350\203\275\350\256\276\350\256\241.md" +++ "b/docs/zh/docs/Embedded/UniProton/UniProton\345\212\237\350\203\275\350\256\276\350\256\241.md" @@ -98,17 +98,17 @@ UniProton创建队列时,根据用户传入队列长度和消息单元大小 为避免for循环逐级判断空闲链表是否为空,定义一个32位的BitMap全局变量。若索引n的空闲链表非空,则BitMap的下标为n的位置1,否则清0。BitMap的下标为31的位在初始化时直接置1。于是查找从n+1开始的第一个非空闲链表,可以首先将BitMap复本的0到n位清零,然后获取复本的最左边的1的下标,若不等于31,即为第一个空闲链表非空的数组索引。 -所有的空闲块都以双向链表形式,串接在空闲链表中。若从链表中获取的第一个空闲块比较大,即分割出一个usSize的内存块后,剩下的空间至少可做一次最小分配。则将剩余的空闲块调整到对应的空闲链表中。 +所有的空闲块都以双向链表的形式,串接在空闲链表中。若从链表中获取的第一个空闲块比较大,即分割出一个uwSize的内存块后,剩下的空间至少可做一次最小分配,则将剩余的空闲块调整到对应的空闲链表中。 ![](./figures/MemoryApplication.png) -内存控制头中记录有空闲内存块的大小(包括控制头本身)。内存控制头中有一个复用成员,位于最首部时。当内存块空闲时,作为指向后一个空闲内存块的指针;当内存块占用时,存放魔术字,表示该内存块非空闲。为避免魔术字与指针冲突(与地址值相同),高低4位均为0xf。因为已分配的内存块起始地址需按4字节对齐,所以不存在冲突。 +内存控制头中记录空闲内存块的大小(包括控制头本身)。内存控制头中有一个复用成员,位于最首部。当内存块空闲时,作为指向后一个空闲内存块的指针;当内存块占用时,存放魔术字,表示该内存块非空闲。为避免魔术字与指针冲突(与地址值相同),高低4位均为0xf。因为已分配的内存块起始地址需按4字节对齐,所以不存在冲突。 #### 内存释放 当释放内存时,需要将前后相邻的空闲块进行合并。首先,通过判断控制头中的魔术字,确认地址参数(pAddr)的合法性。通过首地址加偏移值的方式,得到后邻的内存块控制头的起始地址。若后邻内存块是空闲的,则将后邻内存块从所属空闲链表中删除,调整当前内存块的大小。 -为了使内存释放时能迅速找到前邻的内存块控制头,及判断前邻的内存块是否空闲。内存控制头中增加一个成员,标记前邻的内存块是否空闲。可在内存申请的时,将后邻的该标记设置为占用态(若空闲内存块被分割成两块,前一块为空闲,将当前内存块的该标记设置为空闲态);在内存释放时,将后邻的该标记设置为空闲态。释放当前内存时,若前邻的内存块标记为使用,则不需要合并前邻的内存块;若前邻的内存块标记为空闲,则需要进行合并。若某个内存块为空闲时,则将其后邻控制块的标记设为到本控制块的距离值。 +为了使内存释放时能迅速找到前邻的内存块控制头,及判断前邻的内存块是否空闲。内存控制头中增加一个成员,标记前邻的内存块是否空闲。可在内存申请时,将后邻的该标记设置为占用态(若空闲内存块被分割成两块,前一块为空闲,将当前内存块的该标记设置为空闲态);在内存释放时,将后邻的该标记设置为空闲态。释放当前内存时,若前邻的内存块标记为使用,则不需要合并前邻的内存块;若前邻的内存块标记为空闲,则需要进行合并。若某个内存块为空闲时,则将其后邻控制块的标记设为到本控制块的距离值。 ![](./figures/MemoryRelease.png) @@ -196,4 +196,4 @@ UniProton提供shell命令行,它能够以命令行交互的方式访问操作 | SHELLCMD_ENTRY | 静态注册命令 | | osCmdReg | 动态注册命令 | -通常静态注册命令方式一般用于注册系统常用命令,动态注册命令方式一般用于注册用户命令。静态注册命令有5个入参,动态注册命令有4个入参。下面除去第一个入参是静态注册独有的,剩余的四个入参两个注册命令是一致的。接口详细信息可以查看[UniProton接口说明](./UniProton接口说明.md) \ No newline at end of file +通常静态注册命令方式一般用于注册系统常用命令,动态注册命令方式一般用于注册用户命令。静态注册命令有5个入参,动态注册命令有4个入参。下面除去第一个入参是静态注册独有的,剩余的四个入参两个注册命令是一致的。接口详细信息可以查看[UniProton接口说明](./UniProton接口说明.md) diff --git "a/docs/zh/docs/GCC/GCC14\345\211\257\347\211\210\346\234\254\347\274\226\350\257\221\345\267\245\345\205\267\351\223\276\347\224\250\346\210\267\346\214\207\345\215\227.md" "b/docs/zh/docs/GCC/GCC14\345\211\257\347\211\210\346\234\254\347\274\226\350\257\221\345\267\245\345\205\267\351\223\276\347\224\250\346\210\267\346\214\207\345\215\227.md" new file mode 100644 index 0000000000000000000000000000000000000000..dd81563b57ab4baa26a071012e378438eab6f0b4 --- /dev/null +++ "b/docs/zh/docs/GCC/GCC14\345\211\257\347\211\210\346\234\254\347\274\226\350\257\221\345\267\245\345\205\267\351\223\276\347\224\250\346\210\267\346\214\207\345\215\227.md" @@ -0,0 +1,133 @@ +# 背景介绍 + +## 简介 + +为确保操作系统的稳健性,基础软件的选型策略通常倾向于采用经过时间验证、相对稳定的版本,而非最新发布版本。这一策略旨在避免版本更迭带来的潜在不稳定因素,确保在整个长期支持(LTS)周期内,系统版本保持相对稳定。因此,当前 openEuler 在 24.03 LTS 版本整个生命周期都是选择使用 GCC 12.3.1 作为基线进行开发。 + +这样的选择会带来如下问题。首先,许多的硬件特性需要基础 GCC 工具链的支持,选择非最新版本的 GCC 会导致新特性无法及时在新发布的操作系统上使能。另外,某些用户倾向使用最新版本的编译器使能最新特性,这些特性相较于低版本编译器会带来部分性能提升。 + +因此,为了使能多样算例新特性,满足不同用户对不同硬件特性支持的需求,在 openEuler 24.09 版本推出 openEuler GCC Toolset 工具链,这是一个专为 openEuler 系统设计的 GCC 多版本编译工具链,该工具链提供一个高于系统主 GCC 版本的副版本 GCC 编译工具链,为用户提供了更加灵活且高效的编译环境选择。通过使用 openEuler GCC Toolset 14 多版本编译工具链,用户可以轻松地在不同版本的 GCC 之间进行切换,以便充分利用新硬件特性,同时享受到 GCC 最新优化所带来的性能提升。 + + +## 方案设计 + +### 编译工具链功能介绍 + +GCC 编译工具链是一套由 GNU 开发和维护的开源编译器集合,它是用于将高级语言代码转换为机器语言的工具集,GCC 编译工具链不仅包括GCC编译器本身,还包含一系列辅助工具和库,这些组件共同构成了一个完整的编译环境。 + +1. GCC 编译器(gcc/g++/gfrotran 等): +* 作用:GCC 编译器是工具链的核心,负责完成预处理和编译过程,将源代码转换成汇编代码或中间表示。对于 C++ 代码,g++ 是 GCC 的 C++ 编译器前端,除了完成编译工作外,还会自动链接 C++ 标准库。 + +2. Binutils 工具集: +* 包含工具:链接器(ld)、汇编器(as)、目标文件格式查看器(readelf)、符号查看器(nm)、目标文件格式转换工具(objcopy)、反汇编工具(objdump)、尺寸查看工具(size)等。 +* 作用:这些工具在编译过程中起辅助作用,如将汇编代码转换成机器码(汇编器)、将多个目标文件链接成可执行文件(链接器)、查看目标文件或可执行文件的信息(readelf、nm、objdump)等。 + +3. glibc 库: +* 作用: glibc 是 GNU C Library 的缩写,是 GNU 组织为 GNU 系统以及 Linux 系统编写的 C 语言标准库。它包含了 C 语言中常用的标准函数,如 printf、malloc 等,是编译 C 语言程序时必不可少的部分。 + +4. 其他辅助工具: + +* 调试器(gdb):用于调试可执行文件,帮助开发者定位和解决程序中的错误。 +* 性能分析工具(gprof):用于分析程序的性能,帮助开发者优化代码。 + +### 工具链选型 +在编译过程中,工具链中的软件组件对编译结果具有直接影响。具体而言,GCC、binutils 以及 glibc是其核心要素。glibc 作为 C 语言标准库,其选型通常与操作系统内核版本紧密绑定,不轻易进行更改。本工具链仅包含 GCC 和 binutils 两款软件来满足副版本编译需求。 + +当前最新的 GCC release 版本为 gcc-14.2.0,因此 openEuler GCC Toolset 工具链选型 的 GCC 的版本为gcc-14.2.0 。 + +至于 binutils,openEuler 24.09 的默认 binutils 为 2.41 版本,而最新的 GCC-14 官方推荐搭配 binutils-2.42 使用,因此本工具链的 binutils 的版本选择 binutils-2.42 。 + +基于此考量,openEuler GCC Toolset 副版本工具链引入 gcc-14.2.0 和 binutils-2.42,此举旨在确保编译环境的稳定性和效率,同时避免不必要的复杂性,力求在保障编译结果质量的同时,优化用户的使用体验。后期待 gcc-14.3.0 在上游社区 release 后,同步更新此工具链 GCC 版本。 + +### 架构设计 + +为区分于默认工具链安装,并防止 openEuler GCC Toolset 副版本编译工具链安装与默认编译工具链安装之间的依赖库冲突,将此工具链命名为 gcc-toolset-14 ,其软件包名均以前缀`gcc-toolset-14-`开头,后接原有工具链软件包名。同时,考虑到默认编译工具链安装路径为`/usr`,为避免路径重叠,特将 gcc-toolset-14 安装路径设定为`/opt/openEuler/gcc-toolset-14/`。为了与开源 GCC 做出区分,也便于后期合入更多 openEuler 社区特性,gcc-toolset-14-gcc 的版本设置为 14.2.1 。 + +副版本编译工具链 gcc-toolset-14 提供的应用程序和库不会取代系统默认GCC版本,其包含的应用程序和库旨在与系统默认编译工具链版本并存,而非取代或覆盖它们,亦不会自动设为默认或首选选项。此外,为了实现低成本切换编译工具链版本,便于版本切换与管理,本方案引入 scl-utils 版本切换工具,具体使用和切换方式见下文。 + +## 安装与部署 + +### 软件要求 +- 操作系统:openEuler 24.09 + +### 硬件要求 +- Aarch64 / X86_64 + +### 安装方式 + +默认 GCC 编译器 gcc-12.3.1,安装路径为 /usr : +```shell +yum install -y gcc gcc-c++ +``` + +副版本编译工具链 gcc-toolset-14 安装路径为 /opt/openEuler/gcc-toolset-14/root/usr/ : +```shell +yum install -y gcc-toolset-14-gcc* +yum install -y gcc-toolset-14-binutils* +``` + +## 使用方式 + +本方案引入 SCL(Software Collections)工具进行不同版本编译工具链的管理。 + +## scl工具 + +SCL(Software Collections)是 Linux 系统中一个非常重要的工具,它为用户提供了一种方便、安全的安装和使用应用程序及运行时环境多个版本的方式,同时避免了系统混乱。 + +SCL 的主要用途包括: + +1. 多版本共存:允许用户在同一系统上安装和使用多个版本的软件库、工具和语言运行环境,从而满足不同应用和开发需求。 +2. 避免系统冲突:通过隔离不同版本的软件,避免了新版本软件与系统原有版本之间的冲突。 +3. 提升开发效率:对于开发人员来说,SCL 提供了最新的开发工具链和运行时环境,从而提升了开发效率。 + +### 版本切换方式 + +**安装 SCL:** + +```shell +yum install scl-utils scl-utils-build +``` + +**注册 gcc-toolset-14:** + +```shell +## 注册 gcc-toolset-14 +scl register /opt/openEuler/gcc-toolset-14/ + +## 取消注册 gcc-toolset-14 +scl deregister gcc-toolset-14 +``` + +使用 `scl list-collections` 显示 gcc-toolset-14 已经在 scl 中注册成功; + +**切换 gcc-toolset-14:** + +``` +scl enable gcc-toolset-14 bash +``` + +此命令会启动一个新的 bash shell 会话,使用 gcc-toolset-14 内的工具版本,而不是系统默认版本。在新的 bash shell 会话中,无需再显式切换编译器版本和路径。 +如果需要退出 gcc-toolset-14 的编译环境,输入 `exit` 退出 bash shell 会话,此时编译工具链的版本切换成系统默认版本。 + +SCL工具的本质就是自动设置不同工具版本的环境变量,具体可以参考 `/opt/openEuler/gcc-toolset-14/enable` 文档,gcc-toolset-14 的环境变量均在该文件中设置。若用户系统没有 SCL 工具,则可以使用以下方式进行工具链版本切换: + +``` +## 方案一:无 SCL 工具,使用脚本切换编译工具链 +source /opt/openEuler/gcc-toolset-14/enable + +## 方案二:有 SCL 工具,使用 SCL 工具切换编译工具链并激活运行环境 +scl enable gcc-toolset-14 bash +``` + +## 使用约束 +### 编译场景 +主版本场景:正常编译使用系统默认的 gcc-12.3.1 进行构建; + +副版本场景:需要使用 GCC-14 高版本特性构建相关应用,使用 SCL 工具将 bash 环境切换为 gcc-toolset-14 编译工具链的编译环境。 + +### 副版本GCC-14使用说明 +1. openEuler GCC Toolset 14 副版本编译工具链提供如下两种使用方式: +1)动态链接:默认场景下会自动添加选项 -lstdc++ 进行动态链接,此时会链接系统库动态库 /usr/lib64/libstdc++.so.6 和 GCC-14 副版本提供的 libstdc++_nonshared.a 静态库,此静态库是 GCC-14 相比于 GCC-12 新增的稳定 C++ 特性; +2)静态链接:用户使用选项 -static 进行静态链接,此时会链接 GCC-14 副版本提供的 libstdc++.a 全量特性静态库,该静态库路径为 `/opt/openEuler/gcc-toolset-14/root/usr/lib/gcc/aarch64-openEuler-linux/14/libstdc++.a` ; + +2. 用户默认构建使用动态链接,会链接新增的 libstdc++_nonshared.a 静态库,该库为了保持和系统兼容性,仅对 C++ 中正式标准特性进行封装。对于 -fmodules-ts , -fmodule-header 等选项,属于 C++20 的模块特性,而该特性在 C++20 中仍属于实验性质,并未封装在 libstdc++_nonshared.a 中,若用户需要使用此类新增特性,建议直接使用静态链接的方式全量链接 GCC-14 副版本的静态库。 \ No newline at end of file diff --git "a/docs/zh/docs/GCC/GCC\344\274\230\345\214\226\347\211\271\346\200\247\347\224\250\346\210\267\346\214\207\345\215\227.md" "b/docs/zh/docs/GCC/GCC\344\274\230\345\214\226\347\211\271\346\200\247\347\224\250\346\210\267\346\214\207\345\215\227.md" new file mode 100644 index 0000000000000000000000000000000000000000..e228c5e4303b7219f59024e95f28e5004bc887d1 --- /dev/null +++ "b/docs/zh/docs/GCC/GCC\344\274\230\345\214\226\347\211\271\346\200\247\347\224\250\346\210\267\346\214\207\345\215\227.md" @@ -0,0 +1,279 @@ +# GCC 优化特性用户指南 + +## 简介 + +编译器优化特性对于提高应用程序的开发效率、运行性能和可维护性都非常重要。它是计算机科学领域的一个重要研究方向,也是软件开发过程中的重要环节之一。GCC for openEuler 在通用编译优化能力的基础上,对中后端性能优化技术进行了增强,包括指令优化、向量化增强、预取增强、数据流分析增强等优化。 + +## 安装与部署 + +### 软件要求 + +操作系统:openEuler 24.03 LTS SP2 + +### 硬件要求 + +aarch64 架构 + +### 安装软件 + +按需安装 GCC 和相关组件即可,以 GCC 为例。 + +```shell +yum install gcc +``` + +## 使用方法 + +### CRC 优化 + +#### 说明 + +识别 CRC 软件循环代码,生成高效硬件指令。 + +#### 使用方法 + +在编译时增加 -floop-crc 选项。 + +注:`-floop-crc`选项需要和`-O3 -march=armv8.1-a`一起使用。 + +### If-conversion 增强 + +#### 说明 + +增强 If conversion 优化,使用更多的寄存器以减少冲突。 + +#### 使用方法 + +本优化是 RTL 优化 if-conversion 的一部分,使用如下编译选项控制优化启用。 + +`-fifcvt-allow-complicated-cmps` + +`--param=ifcvt-allow-register-renaming=[0,1,2]`数字用于控制优化范围。 + +注:此优化依赖`-O2`优化等级,以及与`--param=max-rtl-if-conversion-unpredictable-cost=48`、`--param=max-rtl-if-conversion-predictable-cost=48`共同使用。 + +### 乘法计算优化 + +#### 说明 + +Arm 相关指令合并优化,实现32位复杂组合的64位整形乘法逻辑的识别,并以高效的64位指令数输出。 + +#### 使用方法 + +使用`-fuaddsub-overflow-match-all`和`-fif-conversion-gimple`选项使能优化。 + +注:此优化需要`-O3`及以上优化等级。 + +### cmlt 指令生成优化 + +#### 说明 + +对一些四则运算生成`cmlt`指令,减少指令数。 + +#### 使用方法 + +使用选项`-mcmlt-arith`使能优化。 + +注:此优化需要`-O3`以上优化等级使用。 + +### 向量化优化增强 + +#### 说明 + +识别并简化向量化过程中生成的冗余指令,允许更短的循环进入向量化。 + +#### 使用方法 + +使用参数`--param=vect-alias-flexible-segment-len=1`使能,默认为0。 + +注:此优化需要`-O3`及以上优化等级。 + +### min max 和 uzp1/uzp2 指令联合优化 + +#### 说明 + +识别 min max 和 uzp1/uzp2 指令联合优化机会,减少指令数从而提升性能。 + +#### 使用方法 + +使用`-fconvert-minmax`选项使能`min max`优化,`uzp1/uzp2`指令优化在`-O3`以上等级默认使能。 + +注:依赖`-O3`及以上优化等级。 + +### ldp/stp 优化 + +#### 说明 + +识别某些性能表现差的 ldp/stp,将其拆分成2个 ldr 和 str。 + +#### 使用方法 + +使用`-fsplit-ldp-stp`选项使能优化,使用参数`--param=param-ldp-dependency-search-range=[1,32]`控制搜索范围,默认16。 + +注:依赖`-O1`及以上优化等级。 + +### AES指令优化 + +#### 说明 + +识别 AES 软件算法指令序列,使用硬件指令加速。 + +#### 使用方法 + +使用`-fcrypto-accel-aes`选项使能优化。 + +注:依赖`-O3`及以上优化等级。 + +### 间接调用提升 + +#### 说明 + +识别和分析程序中的间接调用,尝试将其优化为直接调用。 + +#### 使用方法 + +使用选项`-ficp -ficp-speculatively`使能优化。 + +注:此优化需要和`-O2 -flto -flto-partition=one`共同使用。 + +### IPA-prefetch + +#### 说明 + +识别循环中的间接访存,插入预取指令,从而减少间接访存的延迟。 + +#### 使用方法 + +通过选项`-fipa-prefetch -fipa-ic`使能优化。 + +注:此优化需要和`-O3 -flto`共同使用。 + +### -fipa-struct-reorg + +#### 说明 + +内存空间布局优化,将结构体成员在内存中的排布进行新的排列组合,来提高 cache 的命中率。 + +#### 使用方法 + +在选项中加入`-O3 -flto -flto-partition=one -fipa-struct-reorg`即可。 + +注:`-fipa-struct-reorg`选项,需要在`-O3 -flto -flto-partition=one`全局同时开启的基础上才使能。 + +### -fipa-reorder-fields + +#### 说明 + +内存空间布局优化,根据结构体中成员的占用空间大小,将成员从大到小排列,以减少边界对齐引入的 padding,来减少结构体整体占用的内存大小,以提高 cache 的命中率。 + +#### 使用方法 + +在选项中加入`-O3 -flto -flto-partition=one -fipa-reorder-fields`即可。 + +注:`-fipa-reorder-fields`选项,需要在`-O3 -flto -flto-partition=one`全局同时开启的基础上才使能。 + +### -ftree-slp-transpose-vectorize + +#### 说明 + +该选项在循环拆分阶段,增强对存在连续访存读的循环的数据流分析能力,通过插入临时数组拆分循环;SLP 矢量化阶段,新增对 grouped_stores 进行转置的 SLP 分析。 + +#### 使用方法 + +在选项中加入`-O3 -ftree-slp-transpose-vectorize`即可。 + +注:`-ftree-slp-transpose-vectorize`选项,需要在`-O3`开启的基础上才使能。 + +### LLC-prefetch + +#### 说明 + +通过分析程序中主要的执行路径,对主路径上的循环进行访存的复用分析,计算排序出 TOP 的热数据,并插入预取指令将数据先分配至 LLC 中,减少 LLC miss。 + +#### 使用方法 + +使能 LLC 特性,需开启 `-O2` 及以上优化等级,同时使用编译选项 `-fllc-allocate`。 + +其他相关接口: + +| 选项 | 默认值 | 说明 | +| ---- | ---- | ---- | +| --param=mem-access-ratio=[0,100] | 20 | 循环内访存数对指令数的占比。| +| --param=mem-access-num=unsigned | 3 | 循环内访存数量。 | +| --param=outer-loop-nums=[1,10] | 1 | 允许扩展的外层循环的最大层数。 | +| --param=filter-kernels=[0,1] | 1 | 是否针对循环做路径串联筛选。 | +| --param=branch-prob-threshold=[50,100] | 80 | 高概率执行分支的概率阈值。 | +| --param=prefetch-offset=[1,999999] | 1024 | 预取偏移距离,一般为2的次幂。 | +| --param=issue-topn=unsigned | 1 | 预取指令个数。 | +| --param=force-issue=[0,1] | 0 | 是否执行强制预取,即静态模式。 | +| --param=llc-capacity-per-core=[0,999999] | 107 | 多分支预取下每个核平均分配的 LLC 容量。 | + +### -fipa-struct-sfc + +#### 说明 + +静态压缩结构体成员,从而减小结构体整体占用的内存大小,以提高 cache 命中率。 + +#### 使用方法 + +在选项中加入`-O3 -flto -flto-partition=one -fipa-reorder-fields -fipa-struct-sfc`即可,可在此基础上使用`-fipa-struct-sfc-bitfield`、`-fipa-struct-sfc-shadow`开启额外优化。 + +注:`-fipa-struct-sfc`选项,需要在`-O3 -flto -flto-partition=one`全局同时开启以及开启`-fipa-reorder-fields`或`-fipa-struct-reorg>=2`的基础上才能使能。 + +### -fipa-struct-dfc + +#### 说明 + +动态压缩结构体成员,克隆程序路径并启发式压缩结构体大小,根据运行时检查选择运行路径,以提高 cache 命中率。 + +#### 使用方法 + +在选项中加入`-O3 -flto -flto-partition=one -fipa-reorder-fields -fipa-struct-dfc`即可,可在此基础上使用`-fipa-struct-dfc-bitfield`、`-fipa-struct-dfc-shadow`开启额外优化。 + +注:`-fipa-struct-dfc`选项,需要在`-O3 -flto -flto-partition=one`全局同时开启以及开启`-fipa-reorder-fields`或`-fipa-struct-reorg>=2`的基础上才能使能。 + +### -fipa-alignment-propagation + +#### 说明 + +分析并传播局部变量地址对齐值,优化按位与运算。 + +#### 使用方法 + +在选项中加入`-O3 -fipa-alignment-propagation`即可。 + +注:`-fipa-alignment-propagation`选项,需要在`-O3`开启的基础上才使能。 + +### -fipa-localize-array + +#### 说明 + +将由 calloc 分配的全局指针变量转换为局部变量。 + +#### 使用方法 + +在选项中加入`-O3 -fipa-localize-array`即可。 + +注:`-fipa-localize-array`选项,需要在`-O3`开启的基础上才使能。 + +### -fipa-array-dse + +#### 说明 + +分析数组在函数之间的传递情况以及在被调用函数中的使用情况,消除冗余的数组写入。 + +#### 使用方法 + +在选项中加入`-O3 -fipa-array-dse`即可。 + +注:`-fipa-array-dse`选项,需要在`-O3`开启的基础上才使能。 + +### -ffind-with-sve + +#### 说明 + +识别 `std::find` 函数调用,尝试使用 SVE 指令优化。 + +#### 使用方法 + +在选项中加入 `-ffind-with-sve` 即可。 diff --git "a/docs/zh/docs/GCC/\345\212\250\346\200\201\345\217\215\351\246\210\344\274\230\345\214\226\346\241\206\346\236\266\347\224\250\346\210\267\346\214\207\345\215\227.md" "b/docs/zh/docs/GCC/\345\212\250\346\200\201\345\217\215\351\246\210\344\274\230\345\214\226\346\241\206\346\236\266\347\224\250\346\210\267\346\214\207\345\215\227.md" new file mode 100644 index 0000000000000000000000000000000000000000..94d706aaca967afeee72915b4353bc991c1933f7 --- /dev/null +++ "b/docs/zh/docs/GCC/\345\212\250\346\200\201\345\217\215\351\246\210\344\274\230\345\214\226\346\241\206\346\236\266\347\224\250\346\210\267\346\214\207\345\215\227.md" @@ -0,0 +1,95 @@ +# 动态反馈优化框架用户指南 + +## 介绍 + +D-FOT是动态反馈优化框架(**D**ynamic **F**eedback-oirected **O**ptimization **T**ool),目标是实现应用全自动、无感知使能反馈优化特性,全面提高反馈优化特性的易用性和性能表现。 +本框架计划实现两类动态优化特性:启动时优化和运行时优化,当前已实现基于oeAware在线调优框架的启动时优化功能。 +启动时优化:应用运行时自动执行采样和反馈优化,完成优化后自动接管下一次启动,不需要用户修改启动流程,应用重启后自动拉起优化版本。 +运行时优化:应用运行时自动执行采样和反馈优化,不需要用户操作重启,整个过程无用户介入,仅少量中断后即可使能优化版本。 + +## 软件架构说明 + +本框架包含以下几个模块: + +- 基于libkperf的采样数据处理 +- 基于sysboost的启动接管和二进制优化特性使能 +- 基于llvm-bolt的二进制反馈优化 +- oeAware调优插件dfot_tuner_sysboost实现 + +## 依赖项 + +系统OS要求:当前支持openEuler-22.03-LTS-SP4、openEuler-25.03 +以下依赖组件均可通过yum安装 + +| 组件 | 代码仓 | 说明 | +| --------------- | ---------------- | ----------- | +| oeAware-manager | [https://gitee.com/openeuler/oeAware-manager](https://gitee.com/openeuler/oeAware-manager) | 业务在线无感调优框架 | +| libkperf | [https://gitee.com/openeuler/libkperf](https://gitee.com/openeuler/libkperf) | 轻量级全内存化采集工具 | +| sysboost | [https://gitee.com/openeuler/sysboost](https://gitee.com/openeuler/sysboost) | 微架构优化工具 | +| llvm-bolt | https://gitee.com/src-openeuler/llvm-bolt | 二进制优化器 | + +## 使用流程 + +### 被优化应用的必要条件 + +1. 被优化二进制需要带有重定位信息。使用自编译的软件:需要在编译时增加`-Wl,-q`链接选项,如MySQL:`cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DBUILD_CONFIG=mysql_release -DWITH_BOOST=../boost -DCMAKE_C_LINK_FLAGS="-Wl,-q" -DCMAKE_CXX_LINK_FLAGS="-Wl,-q"`;使用oe软件包的场景:后续会提供对应应用的relocation包,直接安装即可。 +2. 如何判断目标二进制是否带有重定位信息:`-Wl,-q`生效后,二进制会增加RELA段,可以通过`readelf -SW /path/to/bin`来判断,如MySQL加选项之前,仅有`.rela.dyn`和`.rela.plt`段,增加后会出现`.rela.text`、`.rela.eh_frame`等10+ RELA段;如果`-Wl,-q`未生效,则在手动perf采样并执行`perf2bolt`时,或者执行`llvm-bolt`优化时(无论是否通过sysboost机制)会有告警:`BOLT-WARNING: non-relocation mode for AArch64 is not fully supported`。 + +### D-FOT准备 + +yum安装D-FOT或通过以下命令源码构建(注意如果libkperf或oeAware-manager也是源码构建,执行cmake时需要额外指定lib和include路径)。 + +```shell +cd D-FOT +mkdir build && cd build +cmake ../ -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_SKIP_RPATH=TRUE +make -j`nproc` + +cp build/libdfot.so /lib64/oeAware-plugin/ +chmod 440 /lib64/oeAware-plugin/libdfot.so +mkdir -p /etc/dfot/ +cp configs/dfot.ini /etc/dfot/ +``` + +### 配置修改 + +修改`/etc/dfot/dfot/ini`,内容项参考如下描述: +公共配置: [general] + +| 配置项 | 值范围 | 是否可用 | 说明 | +| ----------------------------- | ----------------------------------- | ---- | -------------------------------------------------------------------------------------- | +| LOG_LEVEL | `` | 可用 | 优化服务日志级别,注意级别越低打印的日志越多 | +| COLLECTOR_SAMPLING_STRATEGY | `<0>` | 不可用 | 采样策略
0表示插件enable后即持续低频采样
1表示enable时启动监控线程,只有负载达到阈值场景才采样
当前由oeaware控制采样流程,仅支持0 | +| COLLECTOR_HIGH_LOAD_THRESHOLD | `[0, cpus*100]` | 不可用 | 仅在采样策略1场景下生效,使用HIGH_LOAD_THRESHOLD作为触发采样的应用CPU使用率阈值,当前不支持 | +| COLLECTOR_DATA_AGING_TIME | 按实际需要确定 | 可用 | 采样数据老化时间,当前数据与最老数据时间差值达到阈值时,丢弃累积采样数据,单位ms | +| TUNER_TOOL | `["sysboost"]` | 不可用 | 二进制优化器,当前仅支持sysboost | +| TUNER_CHECK_PERIOD | `[10, max]` | 可用 | 优化插件检查时间间隔,每隔一段时间收集采样插件数据并决定是否进行优化,单位ms | +| TUNER_PROFILE_DIR | 按实际需要确定 | 可用 | 采样数据存放位置,profile文件被命名为`[app_name]_[full_path_hash]_[threshold].profile` | +| TUNER_OPTIMIZING_STRATEGY | `[0, 1]` | 可用 | 优化策略,0表示只优化一次,1表示只要采样信息在刷新,可以持续多次优化 | +| TUNER_OPTIMIZING_CONDITION | `[0, 2]` | 不可用 | 触发优化的条件,0表示应用退出后即开始优化,1表示低负载时优化,2表示应用退出且低负载时优化,当前仅支持0 | +应用配置: [app] + +| 配置项 | 值范围 | 是否可用 | 说明 | +| ----------------------------- | -------------- | ---- | ------------------------------------------------------------------------------------------ | +| FULL_PATH | 按实际需要确定 | 可用 | 应用二进制文件绝对路径 | +| DEFAULT_PROFILE | 按实际需要确定 | 可用 | 应用的开箱profile文件,用于冷启动时使能二进制优化,没有则留空 | +| COLLECTOR_DUMP_DATA_THRESHOLD | `[10000, max]` | 可用 | 采样数据达到该阈值行数时触发数据导出到profile,数值越大需要的采集的samples越多 | +| BOLT_DIR | NA | 不可用 | BOLT工具路径,留空则默认/usr/bin,内部会调用`${BOLT_DIR}/perf2bolt和${BOLT_DIR}/llvm-bolt`
当前由sysboost确定 | +| BOLT_OPTIONS | 按实际需要确定 | 可用 | BOLT优化选项,配置该项可以覆盖内置的默认选项,用于针对性的选项调优 | +| UPDATE_DEBUG_INFO | `[0, 1]` | 可用 | 优化时是否同步更新调试信息,1表示更新,0表示不更新,注意更新调试信息会有额外耗时 | + +### 插件使用 + +参考[oeAware-manager](https://gitee.com/openeuler/oeAware-manager/tree/master/docs) + +## 约束限制 + +1. 支持容器部署场景使用,D-FOT等优化组件需部署在容器外。 +2. 待优化的目标应用需要具备重定位信息。 +3. 作为oeAware调优插件使用D-FOT时,当前对应的oeAware采集插件pmu_sampling_collector固定采样频率为100,可能会导致采样时间较久(作为参考:perf默认采样频率为4000)。 + +## 未来规划 + +- [ ] 虚拟化场景完善 +- [ ] 运行时优化支持 +- [ ] 进一步提升二进制优化效果 diff --git "a/docs/zh/docs/GCC/\351\223\276\346\216\245\346\227\266\344\274\230\345\214\226\347\211\271\346\200\247\347\224\250\346\210\267\346\214\207\345\215\227.md" "b/docs/zh/docs/GCC/\351\223\276\346\216\245\346\227\266\344\274\230\345\214\226\347\211\271\346\200\247\347\224\250\346\210\267\346\214\207\345\215\227.md" new file mode 100644 index 0000000000000000000000000000000000000000..7744f40b490935345128ff93a972b0b5aa74cabd --- /dev/null +++ "b/docs/zh/docs/GCC/\351\223\276\346\216\245\346\227\266\344\274\230\345\214\226\347\211\271\346\200\247\347\224\250\346\210\267\346\214\207\345\215\227.md" @@ -0,0 +1,25 @@ +# 链接时优化简介 + +在传统编译流程中,gcc 将单个源文件(称谓一个编译单元)直接进行编译优化生成包含汇编代码的`.o`目标对象文件,并由链接器对这些`.o`文件进行符号表解析与重定位,链接成可执行文件。在这个过程中,拥有跨文件函数调用信息的链接器由于操作的是汇编代码,难以进行编译优化,而可以执行编译优化的环节,却没有跨文件的全局信息。这样的编译框架,虽然提高了编译效率,每次重新编译只需要编译修改过的少量编译单元,但也丢失了许多跨文件的优化机会。 + +链接时优化(LTO), 设计的初衷就是希望能够在链接时,拥有跨编译单元的调用信息的时候,进行编译优化,提供更多的优化机会。为了达到这个目的,LTO 需要将编译优化所需的 IR 信息保留到链接时。在链接时,链接器会调用 LTO 插件,执行全程序分析,生成更加有效的优化决策,再经由编译优化生成更高效的IR,进一步转成包含汇编代码的目标对象文件,最后由链接器完成常规的链接工作。 + +# 版本构建使能 + +## 背景 + +为了获得更优的性能与更小的二进制体积,许多海外社区已经在版本构建中使用了链接时优化,链接时优化也正在成为各方寻找编译优化机会的新战场。openEuler 计划从 24.09 创新版本开始,在版本构建中引入 LTO。 + +## 方案 + +我们将在 openEuler-rpm-config 的 macro 中所包含的全局编译选项中插入 `-flto -ffat-lto-objects` ,以达到在构建软件包是使能 lto 的效果。其中 `-flto` 用以使能链接时优化,而 `-ffat-lto-objects` 用以生成同时包含 LTO 对象信息和常规链接所需的汇编信息的胖目标对象。在当前构建中,LTO 对象信息会参与 LTO 优化,而由于 LTO 目标对象文件在不同版本的 gcc 之间是不通用的,因此在打包生成对应的 `.rpm` 包之前,我们会将 `.o/.a` 文件中的 LTO 相关字段给消除,仅保留常规链接所需的汇编代码信息,不对静态库本身产生影响。 + +## 使能范围 + +由于 LTO 的编译流程与常规的编译流程相差较大,影响较广,为了控制 LTO 对版本质量的冲击,我们当前仅对 500+ 个软件包使能了 lto,你可以在 `/usr/lib/rpm/%{_vendor}/lto_white_list` 中找到这些软件包的清单。这些白名单应用在使能了 LTO 之后构建成功,并通过了自带的测试套。lto 编译选项仅在构建白名单应用时被设置为 `-flto -ffat-lto-objects`,否则置为空。 + +我们会在后续的创新版本上,联合应用维护者,扩大 LTO 使能的范围。 + +## 注意事项 + +当前热补丁机制与 LTO 仍存在不兼容,热补丁在 LTO 开启时会失效。我们已与热补丁团队就解决方式达成一致,会在后续版本中解决该问题。 \ No newline at end of file diff --git a/docs/zh/docs/Gazelle/Gazelle.md b/docs/zh/docs/Gazelle/Gazelle.md index a40b562a7a6f64a10e8a519bee4e7ab26e61ec54..7dfbbbf4875468a244369c9b5453fe57c8781a74 100644 --- a/docs/zh/docs/Gazelle/Gazelle.md +++ b/docs/zh/docs/Gazelle/Gazelle.md @@ -12,7 +12,7 @@ Gazelle是一款高性能用户态协议栈。它基于DPDK在用户态直接读 完全兼容POSIX,零修改,适用不同类型的应用。 - 单进程且网卡支持多队列时,只需使用liblstack.so有更短的报文路径。其余场景使用ltran进程分发报文到各个线程。 + 单进程且网卡支持多队列时,只需使用liblstack.so有更短的报文路径。 ## 安装 @@ -36,22 +36,7 @@ dpdk >= 21.11-2 ### 1. 使用root权限安装ko -根据实际情况选择使用ko,提供虚拟网口、绑定网卡到用户态功能。 -若使用虚拟网口功能,则使用rte_kni.ko。 - -```sh -modprobe rte_kni carrier="on" -``` - -配置NetworkManager不托管kni网卡 - -```sh -[root@localhost ~]# cat /etc/NetworkManager/conf.d/99-unmanaged-devices.conf -[keyfile] -unmanaged-devices=interface-name:kni -[root@localhost ~]# systemctl reload NetworkManager -``` - +根据实际情况选择使用ko,提供绑定网卡到用户态功能。 网卡从内核驱动绑为用户态驱动的ko,根据实际情况选择一种。 ```sh @@ -99,21 +84,15 @@ cat查询实际预留页个数,连续内存不足时可能比预期少 ### 4. 挂载大页内存 -创建两个目录,分别给lstack的进程、ltran进程访问大页内存使用。操作步骤如下: +创建目录,给lstack的进程访问大页内存使用。操作步骤如下: ```sh -mkdir -p /mnt/hugepages-ltran mkdir -p /mnt/hugepages-lstack -chmod -R 700 /mnt/hugepages-ltran chmod -R 700 /mnt/hugepages-lstack -mount -t hugetlbfs nodev /mnt/hugepages-ltran -o pagesize=2M mount -t hugetlbfs nodev /mnt/hugepages-lstack -o pagesize=2M ``` ->说明: -/mnt/hugepages-ltran和/mnt/hugepages-lstack必须挂载同样pagesize大页 - ### 5. 应用程序使用Gazelle 有两种使用Gazelle方法,根据需要选择其一 @@ -150,31 +129,36 @@ gcc test.c -o test ${LSTACK_LIBS} |选项|参数格式|说明| |:---|:---|:---| -|dpdk_args|--socket-mem(必需)
--huge-dir(必需)
--proc-type(必需)
--legacy-mem
--map-perfect
-d|dpdk初始化参数,参考dpdk说明
--map-perfect为扩展特性,用于防止dpdk占用多余的地址空间,保证ltran有额外的地址空间分配给lstack。
-d参数加载指定so库文件| +|dpdk_args|--socket-mem(必需)
--huge-dir(必需)
--proc-type(必需)
--legacy-mem
--map-perfect
-d|dpdk初始化参数,参考dpdk说明
--map-perfect为扩展特性,用于防止dpdk占用多余的地址空间,保证有额外的地址空间分配给lstack。
-d参数加载指定so库文件| |listen_shadow| 0/1 | 是否使用影子fd监听。单listen线程,多协议栈线程时是能| -|use_ltran| 0/1 | 是否使用ltran | +|use_ltran| 0/1 | 是否使用ltran ,功能已衰退,不再支持| |num_cpus|"0,2,4 ..."|lstack线程绑定的cpu编号,编号的数量为lstack线程个数(小于等于网卡多队列数量)。可按NUMA选择cpu| -|num_wakeup|"1,3,5 ..."|wakeup线程绑定的cpu编号,编号的数量为wakeup线程个数,与lstack线程的数量保持一致。与numcpus选择对应NUMA的cpu。不配置则为不使用唤醒线程| |low_power_mode|0/1|是否开启低功耗模式,暂不支持| -|kni_switch|0/1|rte_kni开关,默认为0。只有不使用ltran时才能开启| +|kni_switch|0/1|rte_kni开关,默认为0。功能已衰退,不再支持| |unix_prefix|"string"|gazelle进程间通信使用的unix socket文件前缀字符串,默认为空,和需要通信的ltran.conf的unix_prefix或gazellectl的-u参数配置一致。不能含有特殊字符,最大长度为128。| |host_addr|"192.168.xx.xx"|协议栈的IP地址,也是应用程序的IP地址| |mask_addr|"255.255.xx.xx"|掩码地址| |gateway_addr|"192.168.xx.1"|网关地址| -|devices|"aa:bb:cc:dd:ee:ff"|网卡通信的mac地址,需要与ltran.conf的bond_macs配置一致| +|devices|"aa:bb:cc:dd:ee:ff"|网卡通信的mac地址,在bond1模式下作为bond的主网口| |app_bind_numa|0/1|应用的epoll和poll线程是否绑定到协议栈所在的numa,缺省值是1,即绑定| |send_connect_number|4|设置为正整数,表示每次协议栈循环中发包处理的连接个数| |read_connect_number|4|设置为正整数,表示每次协议栈循环中收包处理的连接个数| |rpc_number|4|设置为正整数,表示每次协议栈循环中rpc消息处理的个数| |nic_read_num|128|设置为正整数,表示每次协议栈循环中从网卡读取的数据包的个数| -|mbuf_pool_size|1024000|设置为小于5120000的正整数,表示初始化时申请的mbuf地址池大小,需要根据网卡硬件支持进行合理配置,配置过小会启动失败| +|bond_mode|-1|设置组bond,当前支持两个网口组bond模式,默认值-1关闭bond,当前支持bond1/4/6| +|bond_slave_mac|"aa:bb:cc:dd:ee:ff;AA:BB:CC:DD:EE:FF"|设置组bond网口的mac地址信息,以;分隔| +|bond_miimon|10|设置bond模式的监听间隔,默认值10,取值范围0~1500| +|udp_enable|0/1|是否开启udp功能,默认值1开启| +|nic_vlan_mode|-1|是否开启vlan模式,默认值-1关闭,取值范围-1~4095,0和4095是业界通用预留id无实际效果| +|tcp_conn_count|1500|tcp的最大连接数,该参数乘以mbuf_count_per_conn是初始化时申请的mbuf池大小,配置过小会启动失败,tcp_conn_count * mbuf_count_per_conn * 2048字节不能大于大页大小 | +|mbuf_count_per_conn|170|每个tcp连接需要的mbuf个数,该参数乘以tcp_conn_count是初始化时申请的mbuf地址池大小,配置过小会启动失败,tcp_conn_count * mbuf_count_per_conn * 2048字节不能大于大页大小| lstack.conf示例: ```sh dpdk_args=["--socket-mem", "2048,0,0,0", "--huge-dir", "/mnt/hugepages-lstack", "--proc-type", "primary", "--legacy-mem", "--map-perfect"] -use_ltran=1 +use_ltran=0 kni_switch=0 low_power_mode=0 @@ -192,56 +176,15 @@ read_connect_number=4 rpc_number=4 nic_read_num=128 mbuf_pool_size=1024000 -``` - -- ltran.conf用于指定ltran启动的参数,默认路径为/etc/gazelle/ltran.conf。使用ltran时,lstack.conf内配置use_ltran=1,配置参数如下: - -|选项|参数格式|说明| -|:---|:---|:---| -|forward_kit|"dpdk"|指定网卡收发模块。
保留字段,目前未使用。| -|forward_kit_args|-l
--socket-mem(必需)
--huge-dir(必需)
--proc-TYPE(必需)
--legacy-mem(必需)
--map-perfect(必需)
-d|dpdk初始化参数,参考dpdk说明。
--map-perfect为扩展特性,用于防止dpdk占用多余的地址空间,保证ltran有额外的地址空间分配给lstack。
-d参数加载指定so库文件| -|kni_switch|0/1|rte_kni开关,默认为0| -|unix_prefix|"string"|gazelle进程间通信使用的unix socket文件前缀字符串,默认为空,和需要通信的lstack.conf的unix_prefix或gazellectl的-u参数配置一致| -|dispatch_max_clients|n|ltran支持的最大client数。
lstack的协议栈线程总数不大于32| -|dispatch_subnet|192.168.xx.xx|子网掩码,表示ltran能识别的IP所在子网网段。参数为样例,子网按实际值配置。| -|dispatch_subnet_length|n|子网长度,表示ltran能识别的子网长度,例如length为4时,192.168.1.1-192.168.1.16| -|bond_mode|n|bond模式,目前只支持Active Backup(Mode1),取值为1| -|bond_miimon|n|bond链路监控时间,单位为ms,取值范围为1到2^64 - 1 - (1000 * 1000)| -|bond_ports|"0x01"|使用的dpdk网卡,0x01表示第一块| -|bond_macs|"aa:bb:cc:dd:ee:ff"|绑定的网卡mac地址,需要跟kni的mac地址保持一致| -|bond_mtu|n|最大传输单元,默认是1500,不能超过1500,最小值为68,不能低于68| - -ltran.conf示例: - -```sh -forward_kit_args="-l 0,1 --socket-mem 1024,0,0,0 --huge-dir /mnt/hugepages-ltran --proc-type primary --legacy-mem --map-perfect --syslog daemon" -forward_kit="dpdk" - -kni_switch=0 - -dispatch_max_clients=30 -dispatch_subnet="192.168.1.0" -dispatch_subnet_length=8 - bond_mode=1 -bond_mtu=1500 -bond_miimon=100 -bond_macs="aa:bb:cc:dd:ee:ff" -bond_ports="0x1" - -tcp_conn_scan_interval=10 +bond_slave_mac="aa:bb:cc:dd:ee:ff;AA:BB:CC:DD:EE:FF" +udp_enable=1 +nic_vlan_mode=-1 ``` -### 7. 启动应用程序 - -- 启动ltran进程 - - 单进程且网卡支持多队列,则直接使用网卡多队列分发报文到各线程,不启动ltran进程,lstack.conf的use_ltran配置为0. - 启动ltran时不使用-config-file指定配置文件,则使用默认路径/etc/gazelle/ltran.conf +- ltran模式功能已衰退,多进程使用需求可尝试使用SR-IOV组网硬件虚拟化组网模式: - ```sh - ltran --config-file ./ltran.conf - ``` +### 7. 启动应用程序 - 启动应用程序 @@ -258,40 +201,29 @@ Gazelle wrap应用程序POSIX接口,应用程序无需修改代码。 ### 9. 调测命令 -- 不使用ltran模式时不支持gazellectl ltran xxx命令,以及gazellectl lstack show {ip | pid} -r命令 - ```sh Usage: gazellectl [-h | help] - or: gazellectl ltran {quit | show | set} [LTRAN_OPTIONS] [time] [-u UNIX_PREFIX] or: gazellectl lstack {show | set} {ip | pid} [LSTACK_OPTIONS] [time] [-u UNIX_PREFIX] - quit ltran process exit - - where LTRAN_OPTIONS := - show ltran all statistics - -r, rate show ltran statistics per second - -i, instance show ltran instance register info - -b, burst show ltran NIC packet len per second - -l, latency show ltran latency - set: - loglevel {error | info | debug} set ltran loglevel - where LSTACK_OPTIONS := show lstack all statistics -r, rate show lstack statistics per second -s, snmp show lstack snmp -c, connetct show lstack connect -l, latency show lstack latency + -x, xstats show lstack xstats + -k, nic-features show state of protocol offload and other feature + -a, aggregatin [time] show lstack send/recv aggregation set: loglevel {error | info | debug} set lstack loglevel lowpower {0 | 1} set lowpower enable [time] measure latency time default 1S ``` --u参数指定gazelle进程间通信的unix socket前缀,和需要通信的ltran.conf或lstack.conf的unix_prefix配置一致。 +-u参数指定gazelle进程间通信的unix socket前缀,和需要通信的lstack.conf的unix_prefix配置一致。 **抓包工具** -gazelle使用的网卡由dpdk接管,因此普通的tcpdump无法抓到gazelle的数据包。作为替代,gazelle使用dpdk-tools软件包中提供的gazelle-pdump作为数据包捕获工具,它使用dpdk的多进程模式和lstack/ltran进程共享内存。在ltran模式下,gazelle-pdump只能抓取和网卡直接通信的ltran的数据包,通过tcpdump的数据包过滤,可以过滤特定lstack的数据包。 +gazelle使用的网卡由dpdk接管,因此普通的tcpdump无法抓到gazelle的数据包。作为替代,gazelle使用dpdk-tools软件包中提供的gazelle-pdump作为数据包捕获工具,它使用dpdk的多进程模式和lstack进程共享内存。 [详细使用方法](https://gitee.com/openeuler/gazelle/blob/master/doc/pdump.md) **线程名绑定** @@ -316,11 +248,9 @@ lstack启动时可以通过指定环境变量GAZELLE_THREAD_NAME来指定lstack - 不支持accept阻塞模式或者connect阻塞模式。 - 最多支持1500个TCP连接。 -- 当前仅支持TCP、ICMP、ARP、IPv4 协议。 +- 当前仅支持TCP、ICMP、ARP、IPv4、UDP 协议。 - 在对端ping Gazelle时,要求指定报文长度小于等于14000B。 - 不支持使用透明大页。 -- ltran不支持使用多种类型的网卡混合组bond。 -- ltran的bond1主备模式,只支持链路层故障主备切换(例如网线断开),不支持物理层故障主备切换(例如网卡下电、拔网卡)。 - 虚拟机网卡不支持多队列。 ### 操作约束 @@ -328,24 +258,25 @@ lstack启动时可以通过指定环境变量GAZELLE_THREAD_NAME来指定lstack - 提供的命令行、配置文件默认root权限。非root用户使用,需先提权以及修改文件所有者。 - 将用户态网卡绑回到内核驱动,必须先退出Gazelle。 - 大页内存不支持在挂载点里创建子目录重新挂载。 -- ltran需要最低大页内存为1GB。 - 每个应用实例协议栈线程最低大页内存为800MB 。 - 仅支持64位系统。 - 构建x86版本的Gazelle使用了-march=native选项,基于构建环境的CPU(Intel® Xeon® Gold 5118 CPU @ 2.30GHz指令集进行优化。要求运行环境CPU支持 SSE4.2、AVX、AVX2、AVX-512 指令集。 - 最大IP分片数为10(ping 最大包长14790B),TCP协议不使用IP分片。 - sysctl配置网卡rp_filter参数为1,否则可能不按预期使用Gazelle协议栈,而是依然使用内核协议栈。 -- 不使用ltran模式,KNI网口不可配置只支持本地通讯使用,且需要启动前配置NetworkManager不管理KNI网卡。 -- 虚拟KNI网口的IP及mac地址,需要与lstack.conf配置文件保持一致 。 +- 不支持使用多种类型的网卡混合组bond。 +- bond1主备模式,只支持链路层故障主备切换(例如网线断开),不支持物理层故障主备切换(例如网卡下电、拔网卡)。 +- 发送udp报文包长超过45952(32 * 1436)B时,需要将send_ring_size扩大为至少64个。 ## 注意事项 用户根据使用场景评估使用Gazelle +ltran模式及kni模块由于上游社区及依赖包变更,功能在新版本中不再支持. + 共享内存 - 现状 - 大页内存 mount 至 /mnt/hugepages-lstack 目录,进程初始化时在 /mnt/hugepages-lstack 目录下创建文件,每个文件对应一个大页,并 mmap 这些文件。ltran 在收到 lstask 的注册信息后,根据大页内存配置信息页 mmap 目录下文件,实现大页内存共享。 - ltran 在 /mnt/hugepages-ltran 目录的大页内存同理。 + 大页内存 mount 至 /mnt/hugepages-lstack 目录,进程初始化时在 /mnt/hugepages-lstack 目录下创建文件,每个文件对应一个大页,并 mmap 这些文件。 - 当前消减措施 大页文件权限 600,只有 OWNER 用户才能访问文件,默认 root 用户,支持配置成其他用户; 大页文件有 DPDK 文件锁,不能直接写或者映射。 @@ -356,4 +287,4 @@ lstack启动时可以通过指定环境变量GAZELLE_THREAD_NAME来指定lstack Gazelle没有做流量限制,用户有能力发送最大网卡线速流量的报文到网络,可能导致网络流量拥塞。 **进程仿冒** -合法注册到ltran的两个lstack进程,进程A可仿冒进程B发送仿冒消息给ltran,修改ltran的转发控制信息,造成进程B通讯异常,进程B报文转发给进程A信息泄露等问题。建议lstack进程都为可信任进程。 +建议lstack进程都为可信任进程。 diff --git a/docs/zh/docs/HSAK/hsak_tools_usage.md b/docs/zh/docs/HSAK/hsak_tools_usage.md index 847e786b1a608b6b3b2d679df18e55ae16739383..c74beb7e83d9e49cf2667adebfef2a8ae6aff6cd 100644 --- a/docs/zh/docs/HSAK/hsak_tools_usage.md +++ b/docs/zh/docs/HSAK/hsak_tools_usage.md @@ -43,7 +43,7 @@ libstorage-shutdown reset [ ...] - 在执行本命令时,管理组件(ublock)服务端必须已经启动,用户态IO组件未启动或已正确启动均可。 -- libstoage-shutdown reset命令为危险动作,请确认在切换nvme设备驱动之前,用户态实例已经停止对nvme设备下发IO,nvme设备上的fd已全部关闭,且访问nvme设备的实例已退出。 +- libstorage-shutdown reset命令为危险动作,请确认在切换nvme设备驱动之前,用户态实例已经停止对nvme设备下发IO,nvme设备上的fd已全部关闭,且访问nvme设备的实例已退出。 ### 获取IO统计数据命令 diff --git a/docs/zh/docs/Installation/FAQ-1.md b/docs/zh/docs/Installation/FAQ-1.md deleted file mode 100644 index ec8c058b9f698d436e14ac96e5a7a93d68da76f0..0000000000000000000000000000000000000000 --- a/docs/zh/docs/Installation/FAQ-1.md +++ /dev/null @@ -1,66 +0,0 @@ -# FAQ - -## 树莓派启动失败 - -### 问题现象 - -将 openEuler 发布的树莓派镜像刷写入 SD 卡后,树莓派启动失败。 - -### 原因分析 - -刷写 openEuler 发布的树莓派镜像后,树莓派启动失败,大致有以下几种情况: - -1. 下载的镜像文件不完整,请确保该镜像通过完整性校验。 -2. 镜像写入 SD 卡过程中出现问题,多出现在 Windows 环境下使用应用软件刷写镜像到 SD 卡的情况。 - -### 解决方法 - -将完整的镜像重新刷写入 SD 卡。 - -## nmcli 命令连接 WIFI 失败 - -### 问题现象 - -执行 `nmcli dev wifi connect SSID password PWD` 命令连接 WIFI 失败。例如提示 `Error: Connection activation failed: (7) Secrets were required, but not provided.` 等错误。 - -### 原因分析 - -执行的命令缺少密码。注意,如果密码中包含特殊字符,需要使用单引号将密码括起来。如果使用 nmcli 命令行连接 WIFI 失败,建议使用 nmtui 字符界面进行连接。 - -### 解决方法 - -执行 `nmtui` 命令进入到 nmtui 字符界面,按照以下步骤连接 WIFI。 - -1. 选择 `Edit a connection`,按 `Enter` 进入编辑网络连接窗口。 -2. 按下键盘右方向键选择 `Add`,按 `Enter` 进入新建网络连接窗口。 -3. 连接类型选择 `Wi-Fi` ,然后按下键盘右方向键选择 `Create`,按 `Enter` 进入 WIFI 编辑连接信息的界面。 -4. WIFI 连接信息界面主要需要编辑以下内容,其他信息根据实际情况而定。编辑结束后选择 `OK`,按 `Enter` 完成编辑并回退到编辑网络连接窗口。 - 1. `Profile name` 栏输入该 WIFI 连接的名称,这里可以使用默认名称,如 `Wi-Fi connection 1`; - 2. `Device` 栏输入要使用的无线网卡接口,这里输入 `wlan0`; - 3. `SSID` 栏输入要连接的 WIFI 的 SSID; - 4. `Security` 栏选择 WIFI 密码加密方式,这里根据实际情况选择,例如选择 `WPA & WPA2 Personal`; - 5. `Password` 栏输入 WIFI 密码。 - -5. 选择 `Back` 回退到最初的 nmtui 字符界面。 -6. 选择 `Activate a connection`,按 `Enter` 进入激活网络连接窗口。 -7. 查看添加的 WIFI 连接是否已激活(已激活的连接名称前有 `*` 标记)。如果未激活,选择该 WIFI 连接,然后按下键盘右方向键选择 `Activate`,按 `Enter` 激活该连接。待激活完成后,选择 `Back`,按 `Enter` 退出该激活界面,回退到最初的 nmtui 字符界面。 -8. 选择 `Quit`,然后按下键盘右方向键选择 `OK`,按 `Enter` 退出 nmtui 字符界面。 - -## tensorflow包及相关包安装失败 - -### 问题现象 - -使用yum安装tensorflow及相关包时失败。 - -### 原因分析 - -tensorflow的依赖包暂时未升级至适配tensorflow==2.12.1的版本,因此需要通过pip手动安装其依赖软件。 - -### 解决方法 - -1. yumdownloader下载tensorflow的rpm包:yumdownloader python3-tensorflow。 -2. 使用rpm --nodeps安装这个包:rpm -ivh --nodeps python3-tensorflow。 -3. 安装tensorflow依赖包。 - 1. 使用pip安装依赖:pip3 install tensorflow-estimator==2.12.0 keras==2.12.0 protobuf==3.20.3。 - 2. 使用yum安装其他依赖软件:yum install python3-termcolor python3-future python3-numpy python3-six python3-astunparse python3-google-pasta python3-opt-einsum python3-typing-extensions python3-wrapt python3-h5py python3-grpcio python3-absl-py python3-flatbuffers python3-gast -4. 直接用yum下载相关包,例如python-keras-rl2,直接执行yum install python-keras-rl2。 diff --git a/docs/zh/docs/Installation/FAQ.md b/docs/zh/docs/Installation/FAQ.md deleted file mode 100644 index d39fc49f12f8fedbadf92d3fc8db458e0c2b4cbe..0000000000000000000000000000000000000000 --- a/docs/zh/docs/Installation/FAQ.md +++ /dev/null @@ -1,341 +0,0 @@ -# FAQ - -## 安装openEuler时选择第二盘位为安装目标,操作系统无法启动 - -### 问题现象 - -安装操作系统时,直接将系统安装到第二块磁盘sdb,重启系统后启动失败。 - -### 原因分析 - -当安装系统到第二块磁盘时,MBR和GRUB会默认安装到第二块磁盘sdb。这样会有下面两种情况: - -1. 如果第一块磁盘中有完整系统,则加载第一块磁盘中的系统启动。 -2. 如果第一块磁盘中没有完好的操作系统,则会导致硬盘启动失败。 - -以上两种情况都是因为BIOS默认从第一块磁盘sda中加载引导程序启动系统,如果sda没有系统,则会导致启动失败。 - -### 解决方法 - -有以下两种解决方案: - -- 当系统处于安装过程中,在选择磁盘(选择第一块或者两块都选择)后,指定引导程序安装到第一块盘sda中。 -- 当系统已经安装完成,若BIOS支持选择从哪个磁盘启动,则可以通过修改BIOS中磁盘启动顺序,尝试重新启动系统。 - -## openEuler开机后进入emergency模式 - -### 问题现象 - -openEuler系统开机后进入emergency模式,如下图所示: - -![](./figures/zh-cn_image_0229291264.jpg) - -### 原因分析 - -操作系统文件系统损坏导致磁盘挂载失败,或者io压力过大导致磁盘挂载超时(超时时间为90秒)。 - -系统异常掉电、物理磁盘io性能低等情况都可能导致该问题。 - -### 解决方法 - -1. 用户直接输入root帐号的密码,登录系统。 -2. 使用fsck工具,检测并修复文件系统,然后重启。 - - > ![](./public_sys-resources/icon-note.gif) **说明:** - > fsck(file system check)用来检查和维护不一致的文件系统。若系统掉电或磁盘发生问题,可利用fsck命令对文件系统进行检查。 用户可以通过“fsck.ext3 -h”、“fsck.ext4 -h”命令查看fsck的使用方法。 - -另外,如果用户需要取消磁盘挂载超时时间,可以直接在“/etc/fstab”文件中添加“x-systemd.device-timeout=0”。如下: - -```sh -# /etc/fstab -# Created by anaconda on Mon Sep 14 17:25:48 2015 -# -# Accessible filesystems, by reference, are maintained under '/dev/disk' -# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info -# -/dev/mapper/openEuler-root / ext4 defaults,x-systemd.device-timeout=0 0 0 -UUID=afcc811f-4b20-42fc-9d31-7307a8cfe0df /boot ext4 defaults,x-systemd.device-timeout=0 0 0 -/dev/mapper/openEuler-home /home ext4 defaults 0 0 -/dev/mapper/openEuler-swap swap swap defaults 0 0 -``` - -## 系统中存在无法激活的逻辑卷组时,重装系统失败 - -### 问题现象 - -由于磁盘故障,系统中存在无法激活的逻辑卷组,重装系统出现异常。 - -### 原因分析 - -安装时有激活逻辑卷组的操作,无法激活时会抛出异常。 - -### 解决方法 - -重装系统前如果系统中存在无法激活的逻辑卷组,为了避免重装系统过程出现异常,需在重装前将逻辑卷组恢复到正常状态或者清除这些逻辑卷组。举例如下: - -- 恢复逻辑卷组状态 - 1. 使用以下命令清除vg激活状态, 防止出现“Can't open /dev/sdc exclusively mounted filesystem”。 - - ```sh - # vgchange -a n testvg32947 - ``` - - 2. 根据备份文件重新创建pv。 - - ```sh - # pvcreate --uuid JT7zlL-K5G4-izjB-3i5L-e94f-7yuX-rhkLjL --restorefile /etc/lvm/backup/testvg32947 /dev/sdc - ``` - - 3. 恢复vg信息。 - - ```sh - # vgcfgrestore testvg32947 - ``` - - 4. 重新激活vg。 - - ```sh - # vgchange -ay testvg32947 - ``` - -- 清除逻辑卷组 - - ```sh - # vgchange -a n testvg32947 - # vgremove -y testvg32947 - ``` - -## 选择安装源出现异常 - -### 问题现象 - -选择安装源后出现:"Error checking software selection"。 - -### 原因分析 - -这种现象是由于安装源中的软件包依赖存在问题。 - -### 解决方法 - -检查安装源是否存在异常。使用新的安装源。 - -## 如何手动开启kdump服务 - -### 问题现象 - -执行systemctl status kdump命令,显示状态信息如下,提示无预留内存。 - -![](./figures/zh-cn_image_0229291280.png) - -### 原因分析 - -kdump服务需要系统预留一段内存用于运行kdump内核,而当前系统没有为kdump服务预留内存,所以无法运行kdump服务。 - -### 解决方法 - -已安装操作系统的场景 - -1. 修改/boot/efi/EFI/openEuler/grub.cfg,添加crashkernel=1024M,high。 -2. 重启系统使配置生效。 -3. 执行如下命令,检查kdump状态: - - ```sh - # systemctl status kdump - ``` - - 若回显如下,即kdump的状态为active,说明kdump已使能,操作结束。 - - ![](./figures/zh-cn_image_0229291272.png) - -### 参数说明 - -kdump内核预留内存参数说明如下: - -**表 1** crashkernel参数说明 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

内核启动参数

-

描述

-

缺省值

-

备注

-

crashkernel=X

-

在4G以下的物理内存预留X大小的内存给kdump使用

-

无,用户根据实际情况调整

-

该配置方法只在4G以下内存预留,必须保证4G以下连续可用内存足够预留

-

crashkernel=X@Y

-

在Y起始地址预留X大小的内存给kdump使用

-

无,用户根据实际情况调整

-

需要确保Y起始地址的X大小内存未被其他模块预留

-

crashkernel=X,high

-

在4G以下的物理内存中预留256M大小,在4G以上预留X大小内存给kdump使用

-

无,用户根据实际情况调整,推荐值为1024M,high

-

确保4G以下内存有256M连续可用内存,4G以上有连续X大小内存可预留。实际预留内存大小为256M+X

-

crashkernel=X,low

-

crashkernel=Y,high

-

在4G以下的物理内存中预留X大小,在4G以上预留Y大小内存给kdump使用

-

无,用户根据实际情况调整

-

需要确保4G以下有X大小连续可用内存,4G以上有Y大小连续可用内存。实际预留内存大小为X+Y

-
- -## 多块磁盘组成逻辑卷安装系统后,再次安装不能只选其中一块磁盘 - -### 问题现象 - -在安装系统时,如果之前的系统选择多块磁盘组成逻辑卷进行安装,再次安装时,如果只选择了其中的一块或几块磁盘,没有全部选择,在保存配置时提示配置错误,如[图1](#fig115949762617)所示。 - -**图 1** 配置错误提示 -![](./figures/Configuration_error_prompt.png) - -### 原因分析 - -之前的逻辑卷包含了多块磁盘,只在一块磁盘上安装会破坏逻辑卷。 - -### 解决方法 - -因为多块磁盘组成逻辑卷相当于一个整体,所以只需要删除对应的卷组即可。 - -1. 按“Ctrl+Alt+F2”可以切换到命令行,执行如下命令找到卷组。 - - ```sh - # vgs - ``` - - ![](./figures/zh-cn_image_0231657950.png) - -2. 执行如下命令,删除卷组。 - - ```sh - # vgremove euleros - ``` - -3. 执行如下命令,重启安装程序即可生效。 - - ```sh - # systemctl restart anaconda - ``` - - > ![](./public_sys-resources/icon-note.gif) **说明:** - > 图形模式下也可以按“Ctrl+Alt+F6”回到图形界面,点击[图1](#fig115949762617)右下角的“Refresh”刷新存储配置生效。 - -## x86物理机UEFI模式由于security boot安全选项问题无法安装 - -### 问题现象 - -x86物理机安装系统时,由于设置了BIOS选项security boot 为enable(默认是disable),导致系统一直停留在“No bootable device”提示界面,无法继续安装,如[图2](#fig115949762618)所示。 - -**图 2** “No bootable device”提示界面 -![](./figures/No-bootable-device.png) - -### 原因分析 - -开启security boot后,主板会验证引导程序及操作系统 ,若没有用对应的私钥进行签名,则无法通过主板上内置公钥的认证。 - -### 解决方法 - -进入BIOS,设置security boot为disable,重新安装即可。 - -1. 系统启动时,按“F11”,输入密码“Admin@9000”进入BIOS。 - - ![](./figures/BIOS.png) - -2. 选择进入Administer Secure Boot。 - - ![](./figures/security.png) - -3. 设置Enforce Secure Boot为Disabled。 - - ![](./figures/select.png) - - > ![](./public_sys-resources/icon-note.gif) **说明:** - > 设置security boot为disable之后,保存退出,重新安装即可。 - -## 安装openEuler时,软件选择页面选择“服务器-性能工具”,安装后messages日志有pmie_check报错信息 - -### 问题现象 - -安装系统时软件选择勾选服务器-性能工具,会安装pcp相关软件包,正常安装并重启后,/var/log/messages日志文件中会产生报错:pmie_check failed in /usr/share/pcp/lib/pmie。 - -### 原因分析 - -anaconda不支持在chroot环境中安装selinux策略模块,当安装pcp-selinux时,postin脚本安装pcp相关selinux策略模块执行失败,从而导致重启后产生报错。 - -### 解决办法 - -完成安装并重启后,以下方法选择其一。 - -1. 执行如下命令,安装selinux策略模块pcpupstream - - ```sh - # /usr/libexec/pcp/bin/selinux-setup /var/lib/pcp/selinux install "pcpupstream" - ``` - -2. 重新安装pcp-selinux - - ```sh - # sudo dnf reinstall pcp-selinux - ``` - -## 在两块已经安装了系统的磁盘上进行重复选择,并自定义分区时,安装失败 - -### 问题现象 - -用户在安装操作系统过程中,存在两块都已经安装过的磁盘,此时如果先选择一块盘,进行自定义分区,然后点击取消按钮,再选择第二块盘,并进行自定义分区时,会出现安装失败。 - -![](./figures/cancle_disk.png) -![](./figures/custom_paratition.png) - -### 原因分析 - -用户存在两次选择磁盘的操作,当前点击取消后,再选择第二块磁盘,磁盘信息不正确,导致安装失败。 - -### 解决方法 - -直接选择目标磁盘进行自定义分区,请勿频繁取消操作,如果一定要进行取消重选建议重新安装。 - -### issue访问链接 - - - -## 安装LSI MegaRAID卡的物理机kdump无法生成vmcore - -### 问题现象 - -部署好kdump服务后,手动执行`echo c > /proc/sysrq-trigger`命令或由于kernel故障导致kernel宕机,触发kdump启动second kernel过程中,MegaRAID驱动报错“BRCM Debug mfi stat 0x2d,data len requested/completed 0x200/0x0”,报错信息如下图,最终导致无法生成vmcore。 - -![](./figures/Megaraid_IO_Request_uncompleted.png) - -### 原因分析 - -由于默认配置了reset_devices启动参数,second kernel启动过程中会触发设备复位(reset_devices)操作,设备复位操作导致MegaRAID控制器或磁盘状态故障,转储vmcore文件时访问MegaRAID卡的磁盘报错,进而无法生成vmcore。 - -### 解决方法 - -在物理机`etc/sysconfig/kdump`文件中将second kernel默认启动参数`reset_devices`删除,可以规避second kernel启动过程中由于MegaRAID卡驱动复位设备所致IO请求未完成问题,以成功生成vmcore。 -![](./figures/reset_devices.png) diff --git "a/docs/zh/docs/Installation/\345\256\211\350\243\205\345\207\206\345\244\207.md" "b/docs/zh/docs/Installation/\345\256\211\350\243\205\345\207\206\345\244\207.md" index e9ab494bba8c776910b2b3abb6e220fb469c9786..1c062808e7d337531604074da6c88de2fe8171c7 100644 --- "a/docs/zh/docs/Installation/\345\256\211\350\243\205\345\207\206\345\244\207.md" +++ "b/docs/zh/docs/Installation/\345\256\211\350\243\205\345\207\206\345\244\207.md" @@ -42,9 +42,9 @@ 在校验发布包完整性之前,需要准备如下文件: -iso文件:openEuler-22.03-LTS-SP2-aarch64-dvd.iso +- iso文件:openEuler-22.03-LTS-SP2-aarch64-dvd.iso。 -校验文件:ISO对应完整性校验值,复制保存对应的ISO值 +- 校验文件:ISO对应完整性校验值,复制保存对应的ISO值。 ### 操作指导 @@ -68,18 +68,7 @@ iso文件:openEuler-22.03-LTS-SP2-aarch64-dvd.iso ### 硬件兼容支持 -openEuler安装时,应注意硬件兼容性方面的问题,当前已支持的服务器类型如[表1](#table14948632047)所示。 - ->![](./public_sys-resources/icon-note.gif) **说明:** -> ->- TaiShan 200服务器基于华为鲲鹏920处理器。 ->- 当前仅支持华为TaiShan服务器和FusionServer Pro 机架服务器,后续将逐步增加对其他厂商服务器的支持。 - -**表 1** 支持的服务器类型 -| 服务器形态 | 服务器名称 | 服务器型号 | -| :---- | :---- | :---- | -| 机架服务器 | TaiShan 200 | 2280均衡型 | -| 机架服务器 | FusionServer Pro 机架服务器 | FusionServer Pro 2288H V5
说明:
服务器要求配置Avago 3508 RAID控制卡和启用LOM-X722网卡| +openEuler安装时,应注意硬件兼容性方面的问题,当前已支持的服务器类型请参考[兼容性列表](https://www.openeuler.org/zh/compatibility/)。 ### 最小硬件要求 diff --git "a/docs/zh/docs/Installation/\345\256\211\350\243\205\346\214\207\345\257\274.md" "b/docs/zh/docs/Installation/\345\256\211\350\243\205\346\214\207\345\257\274.md" index 2caae5a352479380c1525be1386a7d01a49f76bf..e16b25aa12ce1bb5fe764762f2ae38c09da80956 100644 --- "a/docs/zh/docs/Installation/\345\256\211\350\243\205\346\214\207\345\257\274.md" +++ "b/docs/zh/docs/Installation/\345\256\211\350\243\205\346\214\207\345\257\274.md" @@ -141,21 +141,19 @@ - http 或 https 方式 - http 或 https 方式的安装源如下图所示。 + http 或 https 方式的安装源如下图所示。输入框内容以实际版本发布的安装源地址为准,如 ,其中openEuler-21.03 为版本号,x86_64 为CPU 架构,可根据实际情况输入。 ![](./figures/installsource.png) 如果https服务器使用的是私有证书,则需要在安装引导界面按“e”进入已选选项的参数编辑界面,在参数中增加 inst.noverifyssl 参数。 - 输入框内容以实际版本发布的安装源地址为准,如 ,其中openEuler-21.03 为版本号,x86_64 为CPU 架构,可根据实际情况输入。 - - ftp 方式 ftp 方式的安装源如下图所示,输入框内容根据的 ftp 地址输入。 ![](./figures/sourceftp.png) - ftp服务器需要用户自己搭建,将openEuler-21.09-x86_64-dvd.iso镜像进行挂载,挂载出的文件拷贝到ftp的共享目录中。其中x86_64为CPU 架构,可根据实际情况使用镜像。 + ftp服务器需要用户自己搭建,将iso镜像进行挂载,挂载出的文件拷贝到ftp的共享目录中。其中x86_64为CPU 架构,可根据实际情况使用镜像。 - nfs 方式 @@ -163,9 +161,9 @@ ![](./figures/sourcenfs.png) - nfs服务器需要用户自己搭建,将openEuler-21.09-x86_64-dvd.iso镜像进行挂载,挂载出的文件拷贝到nfs的共享目录中。其中x86_64为CPU 架构,可根据实际情况使用镜像。 + nfs服务器需要用户自己搭建,将iso镜像进行挂载,挂载出的文件拷贝到nfs的共享目录中。其中x86_64为CPU 架构,可根据实际情况使用镜像。 -安装过程中,如果“设置安装源”有疑问,可参考“[选择安装源出现异常](./FAQ.html#选择安装源出现异常)”。 +安装过程中,如果“设置安装源”有疑问,可参考“[选择安装源出现异常](./安装在服务器常见问题与解决方法.md#问题4选择安装源出现异常)”。 设置完成后,请单击左上角“完成”返回“安装概览”页面。 diff --git "a/docs/zh/docs/Installation/\346\233\264\345\244\232\350\265\204\346\272\220.md" "b/docs/zh/docs/Installation/\346\233\264\345\244\232\350\265\204\346\272\220.md" index 5c2d1f65d4c616d2dfe3048de4d3567d2e56e5c8..3694c0654909b4d1d809a54577d87f7df8a63853 100644 --- "a/docs/zh/docs/Installation/\346\233\264\345\244\232\350\265\204\346\272\220.md" +++ "b/docs/zh/docs/Installation/\346\233\264\345\244\232\350\265\204\346\272\220.md" @@ -1,4 +1,4 @@ # 参考资料 -- 如何构建树莓派镜像文件 -- 如何使用树莓派 +- 如何构建树莓派镜像文件 +- 如何使用树莓派 diff --git "a/docs/zh/docs/K3s/K3s\351\203\250\347\275\262\346\214\207\345\215\227.md" "b/docs/zh/docs/K3s/K3s\351\203\250\347\275\262\346\214\207\345\215\227.md" index 6671cf170d9ac19c37e8c8e8abb1bfe75e3d0166..791e33de5a16c8e952c737b59cd5bf455530a4c4 100644 --- "a/docs/zh/docs/K3s/K3s\351\203\250\347\275\262\346\214\207\345\215\227.md" +++ "b/docs/zh/docs/K3s/K3s\351\203\250\347\275\262\346\214\207\345\215\227.md" @@ -13,12 +13,12 @@ K3s 是一个轻量级的 Kubernetes 发行版,它针对边缘计算、物联 ### 适用场景 K3s 适用于以下场景: -- 边缘计算-Edge -- 物联网-IoT -- CI -- Development -- ARM -- 嵌入 K8s +- 边缘计算(Edge Computing) +- 物联网(Internet of Things,IoT) +- 持续集成(Continuous Integration,CI) +- 开发(Development) +- 基于ARM的单板计算机(ARM-based single-board computers) +- 嵌入式K8s(Embedded K8s) 由于运行 K3s 所需的资源相对较少,所以 K3s 也适用于开发和测试场景。在这些场景中,如果开发或测试人员需要对某些功能进行验证,或对某些问题进行重现,那么使用 K3s 不仅能够缩短启动集群的时间,还能够减少集群需要消耗的资源。 diff --git "a/docs/zh/docs/Kernel/TLBi\344\274\230\345\214\226\347\211\271\346\200\247\344\275\277\347\224\250\346\214\207\345\215\227.md" "b/docs/zh/docs/Kernel/TLBi\344\274\230\345\214\226\347\211\271\346\200\247\344\275\277\347\224\250\346\214\207\345\215\227.md" new file mode 100644 index 0000000000000000000000000000000000000000..2bb4c8dca3c2b8a554615f4a324157b3338bc51c --- /dev/null +++ "b/docs/zh/docs/Kernel/TLBi\344\274\230\345\214\226\347\211\271\346\200\247\344\275\277\347\224\250\346\214\207\345\215\227.md" @@ -0,0 +1,69 @@ +# TLBi优化 + +[1.1 概述](#概述) + +[1.2 约束限制](#约束限制) + +[1.3 使用方法](#使用方法) + +## 概述 + +本特性通过在HostOS中关闭TLBi指令的全域广播,以及在GuestOS中将TLB的tlb刷新范围限定在该虚机进程执行过的CPU上,优化了TLB的广播范围,从而在众核多虚机场景下,降低TLB刷新低噪,有效提升unixbench的跑分线性度。 + +## 约束限制 + +1. 本特性目前仅适用于ARM64。 +2. 使能本特性,需要增加内核编译参数:`CONFIG_ARM64_TLBI_IPI`和`CONFIG_ARM64_KVM_HCR_NOFB`。 +3. 使能本特性,需要依赖启动参数`kvm-arm.hcr_nofb=1`。 + +## 使用方法 + +### 编译并更换内核 + +1. 在内核根目录下执行`make openeuler_defconfig`生成.config文件。 + +2. 通过`make menuconfig`指定内核编译参数,打开`CONFIG_ARM64_TLBI_IPI`参数,打开后通过查看.config文件中对应的配置项,确保设置生效。 + +3. 编译rpm包:`make binrpm-pkg -j`,生成的rpm包位于rpmbuild/RPMS/aarch64目录下。 + +4. 在rpm包所在目录执行`rpm -ivh --force kernel*.rpm`安装编译的新内核。 + +5. 通过命令`grub2-set-default`设置默认启动内核,示例如下: + + ``` shell + # 查询当前设置的默认启动内核 + [root@localhost ~]# grub2-editenv list + saved_entry=openEuler (6.12.0) 24.03 (LTS-SP1) + + # 查询当前安装的所有内核版本 + [root@localhost ~]# grep "^menuentry" /etc/grub2-efi.cfg + menuentry 'openEuler (6.12.0) 24.03 (LTS-SP1)' --class openeuler --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-6.12.0-advanced-887bd997-932e-4cd0-84e3-ec71abbe368b' { + menuentry 'openEuler (6.6.0-77.0.0.81.oe2403sp1.aarch64) 24.03 (LTS-SP1)' --class openeuler --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-6.6.0-77.0.0.81.oe2403sp1.aarch64-advanced-887bd997-932e-4cd0-84e3-ec71abbe368b' { + + # 设置默认启动内核为'openEuler (6.6.0-77.0.0.81.oe2403sp1.aarch64) 24.03 (LTS-SP1)' + [root@localhost ~]# grub2-set-default 'openEuler (6.6.0-77.0.0.81.oe2403sp1.aarch64) 24.03 (LTS-SP1)' + + # 再次查询当前设置的默认启动内核 + [root@localhost ~]# grub2-editenv list + saved_entry=openEuler (6.6.0-77.0.0.81.oe2403sp1.aarch64) 24.03 (LTS-SP1) + ``` + +### 设置内核启动参数 + +1. 编辑/etc/default/grub文件,在`GRUB_CMDLINE_LINUX`中添加`kvm-arm.hcr_nofb=1`。 + +2. 查看修改结果,示例结果如下: + + ``` shell + [root@localhost ~]# cat /etc/default/grub | grep GRUB_CMDLINE_LINUX + GRUB_CMDLINE_LINUX="rd.lvm.lv=openeuler/root rd.lvm.lv=openeuler/swap video=VGA-1:640x480-32@60me cgroup_disable=files apparmor=0 crashkernel=1024M,high smmu.bypassdev=0x1000:0x17 smmu.bypassdev=0x1000:0x15 arm64.nopauth console=tty0 kvm-arm.hcr_nofb=1" + ``` + +3. 使用命令`grub2-mkconfig -o /boot/efi/EFI/openEuler/grub.cfg`更新grub配置文件。 + +### 重启主机,检查参数设置 + +1. 重启主机 +2. 执行命令`zcat /proc/config.gz | grep CONFIG_ARM64_TLBI_IPI`,确认回显为`CONFIG_ARM64_TLBI_IPI=y`。 +3. 执行命令`zcat /proc/config.gz | grep CONFIG_ARM64_KVM_HCR_NOFB`,确认回显为`CONFIG_ARM64_KVM_HCR_NOFB=y`。 +4. 执行命令`cat /proc/cmdline`,确保回显包含`kvm-arm.hcr_nofb=1`和`disable_tlbflush_is=[page,switch,mm]`。 diff --git "a/docs/zh/docs/Kernel/\345\206\205\345\255\230\345\217\257\351\235\240\346\200\247\345\210\206\347\272\247\347\211\271\346\200\247\344\275\277\347\224\250\346\214\207\345\215\227.md" "b/docs/zh/docs/Kernel/\345\206\205\345\255\230\345\217\257\351\235\240\346\200\247\345\210\206\347\272\247\347\211\271\346\200\247\344\275\277\347\224\250\346\214\207\345\215\227.md" index 58a6d97e562129ed78f867039258097061ebaa1b..4296a5c3fd05bfba4a99d2fc10db055f50732317 100644 --- "a/docs/zh/docs/Kernel/\345\206\205\345\255\230\345\217\257\351\235\240\346\200\247\345\210\206\347\272\247\347\211\271\346\200\247\344\275\277\347\224\250\346\214\207\345\215\227.md" +++ "b/docs/zh/docs/Kernel/\345\206\205\345\255\230\345\217\257\351\235\240\346\200\247\345\210\206\347\272\247\347\211\271\346\200\247\344\275\277\347\224\250\346\214\207\345\215\227.md" @@ -140,7 +140,7 @@ #### 使用方法 -本子特性提供较多接口,使能特性并校验只需要步骤1-6即可。 +本特性提供较多接口,使能特性并校验只需要步骤1-6即可。 1. 配置启动参数“kernelcore=reliable”,代表打开内存分级管理开关,CONFIG_MEMORY_RELIABLE是必要的配置,否则整个系统的内存可靠性分级管理不使能。 @@ -161,7 +161,7 @@ [ 0.000000] efi: mem07: [Conventional Memory| | | | | | | | |WB| | | ] range=[0x0000000140000000-0x000000083eb6cfff] (28651MB) ``` -6. 内核态开发时,对于一个页面struct page,可以通过其所处的 zone来判断,ZONE_MOVABLE为低可靠内存区,zone编号小于ZONE_MOVABLE的均为高可靠内存区,判断方式举例如下。 +6. 内核态开发时,对于一个页面struct page,可以通过其所处的zone来判断,ZONE_MOVABLE为低可靠内存区,zone编号小于ZONE_MOVABLE的均为高可靠内存区,判断方式举例如下。 ```c bool page_reliable(struct page *page) @@ -174,7 +174,7 @@ 此外提供的若干接口按照功能点分类列举如下: - 1. **代码层面判断可靠性是否使能:**在内核模块中通过如下接口来判断,返回 true 表示内存分级功能真正使能,返回false则未使能。 + 1. **代码层面判断可靠性是否使能:**在内核模块中通过如下接口来判断,返回true表示内存分级功能真正使能,返回false则未使能。 ```c #include @@ -234,7 +234,7 @@ echo 500 > /sys/module/clear_freelist_page/parameters/cfp_timeout_ms # 设置超时为500ms ``` - 6. **查看更改当前进程高低可靠属性:**可以通过/proc//reliable来查看该进程是否是高可靠进程;运行写入,该标识会继承,如果子进程不需要,则手动修改子进程属性;systemd和内核线程不支持该属性的读写;可以写0或 者1,默认为0,代表低可靠进程(权限为0644)。 + 6. **查看更改当前进程高低可靠属性:**可以通过/proc//reliable来查看该进程是否是高可靠进程;运行写入,该标识会继承,如果子进程不需要,则手动修改子进程属性;systemd和内核线程不支持该属性的读写;可以写0或者1,默认为0,代表低可靠进程(权限为0644)。 ```Shell # 更改pid=1024的进程为高可靠进程,从更改之后开始进程缺页申请的内存是从高可靠内存区域申请,申请不到有可能fallback到低可靠 @@ -255,7 +255,7 @@ Page cache 也叫页缓冲或文件缓冲,在linux读写文件时,它用于 #### 约束限制 -1. page cache超过限制后,page cache会进行定期回收,如果page cache的产生的速度大于page cache回收的速度则无法保证page cache的数量在指定的限制之下。 +1. page cache超过限制后,page cache会进行定期回收,如果page cache产生的速度大于page cache回收的速度则无法保证page cache的数量在指定的限制之下。 2. /proc/sys/vm/reliable_pagecache_max_bytes的使用有一定限制,有部分场景的page cache会强制使用可靠内存,如读文件系统的元数据(inode, dentry等),会导致page cache使用的可靠内存超过接口的限制,可以通过 echo 2 \> /proc/sys/vm/drop_caches 来释放inode和dentry。 3. page cache使用的高可靠内存超过reliable_pagecache_max_bytes限制时,会默认申请低可靠内存,若低可靠内存申请不到,则遵循原生流程处理。 4. FileCache的统计会先统计到per cpu的缓存中,当缓存中的值超过阈值时才会加到整个系统中,之后才能在/proc/meminfo中体现,ReliableFileCache在/proc/meminfo中没有上述的阈值,会导致有时ReliableFileCache比FileCache的统计值稍大。 diff --git "a/docs/zh/docs/KernelLiveUpgrade/\345\270\270\350\247\201\351\227\256\351\242\230\344\270\216\350\247\243\345\206\263\346\226\271\346\263\225.md" "b/docs/zh/docs/KernelLiveUpgrade/\345\270\270\350\247\201\351\227\256\351\242\230\344\270\216\350\247\243\345\206\263\346\226\271\346\263\225.md" deleted file mode 100644 index 5a72eb79bf9f1231a431377143f9f52beb9e2126..0000000000000000000000000000000000000000 --- "a/docs/zh/docs/KernelLiveUpgrade/\345\270\270\350\247\201\351\227\256\351\242\230\344\270\216\350\247\243\345\206\263\346\226\271\346\263\225.md" +++ /dev/null @@ -1,29 +0,0 @@ -# 常见问题与解决方法 - -1. 执行nvwa update后未升级 - - 原因:保留现场或者内核替换过程中出现错误。 - - 解决方法:查看日志,找出错误原因。 - -2. 开启加速特性后,nvwa执行命令失败 - - 原因:nvwa提供了诸多加速特性,包括quick kexec,pin memory,cpu park等等。这些特性都涉及到cmdline的配置和内存的分配,在选取内存时,通过cat /proc/iomemory确保选取的内存没有与其他程序冲突。必要时,通过dmesg查看使能特性后是否存在错误日志。 - -3. 热升级后,相关现场未被恢复 - - 原因:首先检查nvwa服务是否运行,运行情况下,可能存在两种情况:一种是服务恢复失败,一种是进程恢复失败。 - - 解决方法:通过service nvwa status查看nvwa的日志,如果是服务启动失败,首先确认是否使能了该服务,再通过systemd查看对应服务的日志。进一步的日志,去criu_dir指定的路径对应命名的进程/服务文件夹中。其中dump.log为保存现场产生的日志,restore.log为恢复现场产生的。 - -4. 恢复失败,日志显示Can't fork for 948: File exists - - 原因:内核热升级工具在恢复程序过程中,发现程序的pid已经被占用。 - - 解决方法:当前内核没有提供保留pid的机制,相关策略正在开发,预计会在将来的内核版本中解决这一限制,当前仅能手动重启相关进程。 - -5. 使用nvwa去保存和恢复简单程序(hello world),显示失败或者程序未在执行 - - 原因: criu使用存在诸多限制。 - - 解决办法:查看nvwa的日志,如果显示是criu相关的错误,去相应的目录下检查dump.log或者restore.log,criu相关使用限制,可以参考[criu社区wiki](https://criu.org/What_cannot_be_checkpointed)。 diff --git "a/docs/zh/docs/Kmesh/\345\270\270\350\247\201\351\227\256\351\242\230\344\270\216\350\247\243\345\206\263\345\212\236\346\263\225.md" "b/docs/zh/docs/Kmesh/\345\270\270\350\247\201\351\227\256\351\242\230\344\270\216\350\247\243\345\206\263\345\212\236\346\263\225.md" deleted file mode 100644 index 66afb72547ad9c416a4227aabd84f5332b5f3957..0000000000000000000000000000000000000000 --- "a/docs/zh/docs/Kmesh/\345\270\270\350\247\201\351\227\256\351\242\230\344\270\216\350\247\243\345\206\263\345\212\236\346\263\225.md" +++ /dev/null @@ -1,23 +0,0 @@ -# 常见问题及解决办法 - -## 问题1:在使用集群启动模式时,若没有配置控制面程序ip信息,Kmesh服务启动后会报错退出 - -![](./figures/not_set_cluster_ip.png) - -原因:集群启动模式下,Kmesh服务需要跟控制面程序通信,然后从控制面获取配置信息,因此需要设置正确的控制面程序ip信息。 - -解决办法:参考[安装与部署](./安装与部署.md)章节中集群启动模式,设置正确的控制面程序ip信息。 - -## 问题2:Kmesh服务在启动时,提示"get kube config error!" - -![](./figures/get_kubeconfig_error.png) - -原因:集群启动模式下,Kmesh服务会根据k8s的配置,自动获取控制面程序ip信息,若环境中没有配置k8s的kubeconfig路径,会导致获取kubeconfig失败,然后提示上述信息。(若已经手动修改Kmesh的配置文件,正确配置控制面程序ip信息,该问题可忽略) - -解决办法:按如下方式配置kubeconfig: - -```shell -mkdir -p $HOME/.kube -sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config -sudo chown $(id -u):$(id -g) $HOME/.kube/config -``` diff --git "a/docs/zh/docs/KubeEdge/KubeEdge\344\275\277\347\224\250\346\226\207\346\241\243.md" "b/docs/zh/docs/KubeEdge/KubeEdge\344\275\277\347\224\250\346\226\207\346\241\243.md" index 3fcb029e67790128c688c757cc5afdbe1fdef689..ce0fccbf42a3dd3a225c3051035a889e95489b0b 100644 --- "a/docs/zh/docs/KubeEdge/KubeEdge\344\275\277\347\224\250\346\226\207\346\241\243.md" +++ "b/docs/zh/docs/KubeEdge/KubeEdge\344\275\277\347\224\250\346\226\207\346\241\243.md" @@ -204,7 +204,7 @@ kubeedge-pi-counter-c69698d6-rb4xz 1/1 Running 0 2m 192 |Name | Description | |---|---| - |[LED-RaspBerry-Pi](led-raspberrypi/README.md) |Controlling a LED light with Raspberry Pi using KubeEdge platform.| + |[LED-RaspBerry-Pi](https://github.com/kubeedge/examples/blob/master/led-raspberrypi/README.md) |Controlling a LED light with Raspberry Pi using KubeEdge platform.| |[Data Analysis @ Edge](apache-beam-analysis/README.md) | Analyzing data at edge by using Apache Beam and KubeEdge.| |[Security@Edge](security-demo/README.md) | Security at edge using SPIRE for identity management.| |[ Bluetooth-CC2650-demo](bluetooth-CC2650-demo/README.md) |Controlling a CC2650 SensorTag bluetooth device using KubeEdge platform.| diff --git a/docs/zh/docs/KubeOS/overview.md b/docs/zh/docs/KubeOS/overview.md index beb6b093378dc4c24fd7d81e1f37081c1ebf6a91..3b9405aa48795ce6ede124d3aa67b17f00c590d9 100644 --- a/docs/zh/docs/KubeOS/overview.md +++ b/docs/zh/docs/KubeOS/overview.md @@ -6,4 +6,3 @@ * 熟悉Linux基本操作。 * 对kubernetes和docker有一定了解 - diff --git "a/docs/zh/docs/KubeOS/\344\275\277\347\224\250\346\226\271\346\263\225.md" "b/docs/zh/docs/KubeOS/\344\275\277\347\224\250\346\226\271\346\263\225.md" index 22db85467ed49e737ff7bd105ec135e1bac545db..6c143abdaf0eb8958a370fef16bbcd882a0f7581 100644 --- "a/docs/zh/docs/KubeOS/\344\275\277\347\224\250\346\226\271\346\263\225.md" +++ "b/docs/zh/docs/KubeOS/\344\275\277\347\224\250\346\226\271\346\263\225.md" @@ -2,183 +2,596 @@ - - - [使用方法](#使用方法) - - [注意事项](#注意事项) - + - [OS CR参数说明](#os-cr参数说明) - [升级指导](#升级指导) - + - [配置(Settings)指导](#配置settings指导) - [回退指导](#回退指导) - - [使用场景](#使用场景) - - - [手动回退](#手动回退) - - - [工具回退](#工具回退) - - + - [手动回退指导](#手动回退指导) + - [工具回退指导](#工具回退指导) + - [附录](#附录) + - [Setting 列表](#setting-列表) + - [kernel Settings](#kernel-settings) + - [Grub Settings](#grub-settings) + - [kubelet配置](#kubelet配置) + - [containerd配置](#containerd配置) + - [Pam Limits配置](#pam-limits配置) - ## 注意事项 -1. 容器 OS 升级为所有软件包原子升级,默认不在容器 OS 内提供单包升级能力。 -2. 容器 OS 升级为双区升级的方式,不支持更多分区数量。 -3. 单节点的升级过程的日志可在节点的/var/log/messages文件查看。 -4. 请严格按照提供的升级和回退流程进行操作,异常调用顺序可能会导致系统无法升级或回退。 -5. 使用docker镜像升级和mtls双向认证仅支持 openEuler 22.09 及之后的版本 -6. 不支持跨大版本升级 +* 公共注意事项 + * 仅支持虚拟机和物理机x86和arm64 UEFI场景。 + * 使用kubectl apply通过YAML创建或更新OS的CR时,不建议并发apply,当并发请求过多时,kube-apiserver会无法处理请求导致失败。 + * 如用户配置了容器镜像仓的证书或密钥,请用户保证证书或密钥文件的权限最小。 +* 升级注意事项 + * 升级为所有软件包原子升级,默认不提供单包升级能力。 + * 升级为双区升级的方式,不支持更多分区数量。 + * 当前暂不支持跨大版本升级。 + * 单节点的升级过程的日志可在节点的 /var/log/messages 文件查看。 + * 请严格按照提供的升级和回退流程进行操作,异常调用顺序可能会导致系统无法升级或回退。 + * 节点上containerd如需配置ctr使用的私有镜像,请将配置文件host.toml按照ctr指导放在/etc/containerd/certs.d目录下。 + * 使用OCI 镜像升级和mtls双向认证仅支持 openEuler 22.09 及之后的版本。 + * nodeselector、executionmode、timewindow和timeinterval 仅支持openEuler 24.09及之后版本。 + * KubeOS 24.03-LTS-SP1 版本与历史版本不兼容。 + * 使用从http/https服务器下载升级镜像功能需要同步使用对应版本镜像制作工具。 + +* 配置注意事项 + * 用户自行指定配置内容,用户需保证配置内容安全可靠 ,尤其是持久化配置(kernel.sysctl.persist、grub.cmdline.current、grub.cmdline.next、kubernetes.kubelet、container.containerd、pam.limits),KubeOS不对参数有效性进行检验。 + * opstype=config时,若osversion与当前集群节点的OS版本不一致,配置不会进行。 + * 当前仅支持kernel参数临时配置(kernel.sysctl)、持久化配置(kernel.sysctl.persist)和grub cmdline配置(grub.cmdline.current和grub.cmdline.next)、kubelet配置(kubernetes.kubelet)、containerd配置(container.containerd)和pam limits配置(pam.limits)。 + * 持久化配置会写入persist持久化分区,升级重启后配置保留;kernel参数临时配置重启后不保留。 + * 配置grub.cmdline.current或grub.cmdline.next时,如为单个参数(非key=value格式参数),请指定key为该参数,value为空。 + * 进行配置删除(operation=delete)时,key=value形式的配置需保证key、value和实际配置一致。 + * 配置不支持回退,如需回退,请修改配置版本和配置内容,重新下发配置。 + * 配置出现错误,节点状态陷入config时,请将配置版本恢复成上一版本并重新下发配置,从而使节点恢复至idle状态。 但是请注意:出现错误前已经配置完成的参数无法恢复。 + * 在配置grub.cmdline.current或grub.cmdline.next时,若需要将已存在的“key=value”格式的参数更新为只有key无value格式,比如将“rd.info=0”更新成rd.info,需要先删除“key=value”,然后在下一次配置时,添加key。不支持直接更新或者更新删除动作在同一次完成。 + +## OS CR参数说明 + +在集群中创建类别为OS的定制对象,设置相应字段。类别OS来自于[安装和部署章节](./安装与部署.md)创建的CRD对象,字段及说明如下: + +* imageurl指定的地址里包含协议,只支持http或https协议。imageurl为https协议时为安全传输,imageurl为http地址时,需指定flagSafe为true,即用户明确该地址为安全时,才会下载镜像。如imageurl为http地址且没有指定flagSafe为true,默认该地址不安全,不会下载镜像并且在升级节点的日志中提示用户该地址不安全。 +* 对于imageurl,推荐使用https协议,使用https协议需要升级的机器已安装相应证书。如果镜像服务器由用户自己维护,需要用户自己进行签名,并保证升级节点已安装对应证书。用户需要将证书放在容器OS```/etc/KubeOS/certs```目录下。地址由管理员传入,管理员应该保证网址的安全性,推荐采用内网地址。 +* 容器OS镜像的合法性检查需要由容器OS镜像服务提供者做合法性检查,确保下载的容器OS镜像来源可靠。 +* 集群存在多OS版本即存在多个OS的实例时,OS的nodeselector字段需要与其他OS不同,即通过label区分的一类node只能对应一个OS实例: + * 当有OS的nodeselector为all-label时,集群只能存在这一个OS的有效实例(有效实例为存在与这个OS对应的节点)。 + * nodeselector不配置的OS也只能有一个,因为nodeselector不配置时认为是对没有label的节点进行操作。 +* timewinterval参数说明: + * 参数不设置时默认为15s。 + * 参数设置为0时,由于k8s controller-runtime的rate limit限制,operator下发任务的时间间隔会逐渐增加直至1000s。 + * 并行时为每批次operator下发升级/配置的时间间隔。 + * 在串行时为每批次节点串行升级完毕后与下次升级/配置下发的时间间隔,批次内部的时间间隔为15s。 + * OS的实例字段进行更新会立刻触发operator。 + + | 参数 |参数类型 | 参数说明 | 使用说明 | 是否必选 | + | -------------- | ------ | ------------------------------------------------------------ | ----- | ---------------- | + | imagetype | string | 升级镜像的类型 | 仅支持docker ,containerd ,或者是 disk,仅在升级场景有效。**注意**:若使用containerd,agent优先使用crictl工具拉取镜像,没有crictl时才会使用ctr命令拉取镜像。使用ctr拉取镜像时,镜像如果在私有仓内,需按照[官方文档](https://github.com/containerd/containerd/blob/main/docs/hosts.md)在/etc/containerd/certs.d目录下配置私有仓主机信息,才能成功拉取镜像。 |是 | + | opstype | string | 操作类型:升级,回退或者配置 | 仅支持upgrade ,config 或者 rollback |是 | + | osversion | string | 升级/回退的目标版本 | osversion需与节点的目标os版本对应(节点上/etc/os-release中PRETTY_NAME字段或k8s检查到的节点os版本) 例如:KubeOS 1.0.0。 |是 | + | maxunavailable | int | 每批同时进行升级/回退/配置的节点数。 | maxunavailable值大于实际节点数时,取实际节点数进行升级/回退/配置。 |是 | + | containerimage | string | 用于升级的容器镜像 | 仅在imagetype是容器类型时生效,仅支持以下3种格式的容器镜像地址: repository/name repository/name@sha256:xxxx repository/name:tag |是 | + | imageurl | string | 用于升级的磁盘镜像的地址 | imageurl中包含协议,只支持http或https协议,例如:```https://192.168.122.15/update.img``` ,仅在使用磁盘镜像升级场景下有效 |是 | + | checksum | string | 用于升级的磁盘镜像校验的checksum(SHA-256)值或者是用于升级的容器镜像的digests值 | 仅在升级场景下有效 |是 | + | flagSafe | bool | 当imageurl的地址使用http协议表示是否是安全的 | 需为 true 或者 false ,仅在imageurl使用http协议时有效 |是 | + | mtls | bool | 用于表示与imageurl连接是否采用https双向认证 | 需为 true 或者 false ,仅在imageurl使用https协议时有效|是 | + | cacert | string | https或者https双向认证时使用的根证书文件 | 仅在imageurl使用https协议时有效| imageurl使用https协议时必选 | + | clientcert | string | https双向认证时使用的客户端证书文件 | 仅在使用https双向认证时有效|mtls为true时必选 | + | clientkey | string | https双向认证时使用的客户端公钥 | 仅在使用https双向认证时有效|mtls为true时必选 | + | evictpodforce | bool | 升级/回退时是否强制驱逐pod | 需为 true 或者 false ,仅在升级或者回退时有效| 必选 | + | sysconfigs | / | 配置设置 | 1. “opstype=config”时只进行配置。
2.“opstype=upgrade/rollback”时,代表升级/回退后配置,即在升级/回退重启后进行配置,详细字段说明请见[配置(Settings)指导](#配置settings指导) | “opstype=config”时必选 | + | upgradeconfigs | / | 升级前配置设置 | 在升级或者回退时有效,在升级或者回退操作之前起效,详细字段说明请见[配置(Settings)指导](#配置settings指导)| 可选 | + | nodeselector | string | 需要进行升级/配置/回滚操作的节点label | 用于只对具有某些特定label的节点而不是集群所有worker节点进行运维的场景,需要进行运维操作的节点需要包含key为upgrade.openeuler.org/node-selector的label,nodeselector为该label的value值。
注意事项:
1.此参数不配置时,或者配置为“no-label”时对没有upgrade.openeuler.org/node-selector的节点进行操作
2.此参数为“”时,对具有upgrade.openeuler.org/node-selector=“”的节点进行操作
3.如需忽略label,对所有节点进行操作,需指定此参数为all-label| 可选 | + | timewindow | / | 升级/配置/回滚操作的时间窗口 |1.指定时间窗口时starttime和endtime都需指定,即二者需要同时为空或者同时不为空
2.starttime和endtime类型为string,需要为YYYY-MM-DD HH:MM:SS格式或者HH:MM:SS格式,且二者格式需一致
3.为HH:MM:SS格式时,starttime < endtime认为starttime是下一天的该时间
4.timewindow不配置时默认为不存在时间窗限制| 可选 | + | timeinterval | int | 升级/配置/回滚操作每批次任务下发的时间间隔 |参数单位为秒,时间间隔为operator下发任务的时间间隔,如k8s集群繁忙无法立即响应operator请求,实际时间间隔可能会大于指定时间| 可选 | + | executionmode | string | 升级/配置/回滚操作执行的方式 |仅支持serial或者parallel,即串行或者并行,当次参数不设置时,默认采用并行的方式| 可选 | ## 升级指导 -在集群中创建类别为OS的定制对象,设置相应字段。类别OS来自于安装和部署章节创建的CRD对象,字段及说明如下: +1.编写YAML文件,在集群中部署 OS 的cr实例,用于部署cr实例的YAML示例如下,假定将上面的YAML保存到upgrade_v1alpha1_os.yaml; + * 使用磁盘镜像进行升级 + + ```yaml + apiVersion: upgrade.openeuler.org/v1alpha1 + kind: OS + metadata: + name: os-sample + spec: + imagetype: disk + opstype: upgrade + osversion: edit.os.version + maxunavailable: edit.node.upgrade.number + containerimage: "" + evictpodforce: true/false + imageurl: edit.image.url + checksum: image.checksum + flagSafe: imageurl.safety + mtls: imageurl use mtls or not + cacert: ca certificate + clientcert: client certificate + clientkey: client certificate key + ``` + + * 使用容器镜像进行升级 + * 使用容器镜像进行升级前请先制作升级所需的容器镜像,制作方式请见[《容器OS镜像制作指导》](./容器OS镜像制作指导.md)中 [KubeOS OCI 镜像制作](./容器OS镜像制作指导.md#kubeos-oci-镜像制作)。 + * 节点容器引擎为docker + + ``` yaml + apiVersion: upgrade.openeuler.org/v1alpha1 + kind: OS + metadata: + name: os-sample + spec: + imagetype: docker + opstype: upgrade + osversion: edit.os.version + maxunavailable: edit.node.upgrade.number + containerimage: container image like repository/name:tag + evictpodforce: true/false + imageurl: "" + checksum: container image digests + flagSafe: false + mtls: true + ``` + + * 节点容器引擎为containerd + + ```yaml + apiVersion: upgrade.openeuler.org/v1alpha1 + kind: OS + metadata: + name: os-sample + spec: + imagetype: containerd + opstype: upgrade + osversion: edit.os.version + maxunavailable: edit.node.upgrade.number + containerimage: container image like repository/name:tag + evictpodforce: true/false + imageurl: "" + checksum: container image digests + flagSafe: false + mtls: true + ``` + + * 升级并且进行配置的示例如下: + * 以节点容器引擎为containerd为例,升级方式对配置无影响,upgradeconfigs在升级前起效,sysconfigs在升级后起效,配置参数说明请见[配置(Settings)指导](#配置settings指导)。 + * 升级并且配置时opstype字段需为upgrade。 + * upgradeconfig为升级之前执行的配置,sysconfigs为升级机器重启后执行的配置,用户可按需进行配置。 + + ```yaml + apiVersion: upgrade.openeuler.org/v1alpha1 + kind: OS + metadata: + name: os-sample + spec: + imagetype: "" + opstype: upgrade + osversion: edit.os.version + maxunavailable: edit.node.upgrade.number + containerimage: "" + evictpodforce: true/false + imageurl: "" + checksum: container image digests + flagSafe: false + mtls: false + sysconfigs: + version: edit.os.version + configs: + - model: kernel.sysctl + contents: + - key: kernel param key1 + value: kernel param value1 + - key: kernel param key2 + value: kernel param value2 + - model: kernel.sysctl.persist + configpath: persist file path + contents: + - key: kernel param key3 + value: kernel param value3 + - key: "" + value: "" + upgradeconfigs: + version: 1.0.0 + configs: + - model: kernel.sysctl + contents: + - key: kernel param key4 + value: kernel param value4 + ``` + * 设置nodeselector、timewindow、timeinterval、executionmode升级部分节点示例如下: + * 以节点容器引擎为containerd为例,升级方式对节点筛选无影响。 + * 需要进行升级的节点需包含key为`upgrade.openeuler.org/node-selector`的label,nodeselector的值为该label的value,即假定nodeselector值为kubeos,则只对包含`upgrade.openeuler.org/node-selector=kubeos`的label的worker节点进行升级。 + * nodeselector、timewindow、timeinterval、executionmode对配置和回滚同样有效。 + * 节点添加label、修改label、删除label和查看label命令示例如下: + ``` shell + # 为节点kubeos-node1增加label + kubectl label nodes kubeos-node1 upgrade.openeuler.org/node-selector=kubeos-v1 + # 修改节点kubeos-node1的label + kubectl label --overwrite nodes kubeos-node1 upgrade.openeuler.org/node-selector=kubeos-v2 + # 删除节点kubeos-node1的label + kubectl label nodes kubeos-node1 upgrade.openeuler.org/node-selector- + # 查看节点的label + kubectl get nodes --show-labels + ``` + * yaml示例如下: + ```yaml + apiVersion: upgrade.openeuler.org/v1alpha1 + kind: OS + metadata: + name: os-sample + spec: + imagetype: containerd + opstype: upgrade + osversion: edit.os.version + maxunavailable: edit.node.upgrade.number + containerimage: container image like repository/name:tag + evictpodforce: true/false + imageurl: "" + checksum: container image digests + flagSafe: false + mtls: true + nodeselector: edit.node.label.key + timewindow: + starttime: "HH::MM::SS/YYYY-MM-DD HH::MM::SS" + endtime: "HH::MM::SS/YYYY-MM-DD HH::MM::SS" + timeinterval: time intervel like 30 + executionmode: serial/parallel + ``` + +2. 查看未升级的节点的 OS 版本。 + + ```shell + kubectl get nodes -o custom-columns='NAME:.metadata.name,OS:.status.nodeInfo.osImage' + ``` -| 参数 |参数类型 | 参数说明 | 使用说明 | 是否必选 | -| -------------- | ------ | ------------------------------------------------------------ | ----- | ---------------- | -| imagetype | string | 使用的升级镜像的类型 | 需为 docker 或者 disk ,其他值无效,且该参数仅在升级场景有效|是 | -| opstype | string | 进行的操作,升级或者回退 | 需为 upgrade ,或者 rollback ,其他值无效 |是 | -| osversion | string | 用于升级或回退的镜像的OS版本 | 需为 KubeOS version , 例如: KubeOS 1.0.0|是 | -| maxunavailable | int | 同时进行升级或回退的节点数 | maxunavailable值设置为大于实际集群的节点数时也可正常部署,升级或回退时会按照集群内实际节点数进行|是 | -| dockerimage | string | 用于升级的容器镜像 | 需要为容器镜像格式:repository/name:tag,仅在使用容器镜像升级场景下有效|是 | -| imageurl | string | 用于升级的磁盘镜像的地址 | imageurl中包含协议,只支持http或https协议,例如:https://192.168.122.15/update.img 仅在使用磁盘镜像升级场景下有效|是 | -| checksum | string | 用于升级的磁盘镜像校验的checksum(SHA-256)值 | 仅在使用磁盘镜像升级场景下有效 |是 | -| flagSafe | bool | 当imageurl的地址使用http协议表示是否是安全的 | 需为 true 或者 false ,仅在imageurl使用http协议时有效 |是 | -| mtls | bool | 用于表示与imageurl连接是否采用https双向认证 | 需为 true 或者 false ,仅在imageurl使用https协议时有效|是 | -| cacert | string | https或者https双向认证时使用的根证书文件 | 仅在imageurl使用https协议时有效| imageurl使用https协议时必选 | -| clientcert | string | https双向认证时使用的客户端证书文件 | 仅在使用https双向认证时有效|mtls为true时必选 | -| clientkey | string | https双向认证时使用的客户端公钥 | 仅在使用https双向认证时有效|mtls为true时必选 | +3. 执行命令,在集群中部署cr实例后,节点会根据配置的参数信息进行升级。 -imageurl指定的地址里包含协议,只支持http或https协议。imageurl为https协议时为安全传输,imageurl为http地址时,需指定flagSafe为true,即用户明确该地址为安全时,才会下载镜像。如imageurl为http地址且没有指定flagSafe为true,默认该地址不安全,不会下载镜像并且在升级节点的日志中提示用户该地址不安全 + ```shell + kubectl apply -f upgrade_v1alpha1_os.yaml + ``` -对于imageurl,推荐使用https协议,使用https协议需要升级的机器已安装相应证书。如果镜像服务器由用户自己维护,需要用户自己进行签名,并保证升级节点已安装对应证书。用户需要将证书放在容器OS /etc/KubeOS/certs目录下。地址由管理员传入,管理员应该保证网址的安全性,推荐采用内网地址。 +4. 再次查看节点的 OS 版本来确认节点是否升级完成。 -容器OS镜像的合法性检查需要由容器OS镜像服务提供者做合法性检查,确保下载的容器OS镜像来源可靠 + ```shell + kubectl get nodes -o custom-columns='NAME:.metadata.name,OS:.status.nodeInfo.osImage' + ``` -编写YAML文件,在集群中部署 OS 的cr实例,用于部署cr实例的YAML示例如下: +> ![](./public_sys-resources/icon-note.gif)**说明**: +> +> 如果后续需要再次升级,与上面相同对 upgrade_v1alpha1_os.yaml 的 相应字段进行相应修改。 -* 使用磁盘镜像进行升级 +## 配置(Settings)指导 - ``` - apiVersion: upgrade.openeuler.org/v1alpha1 - kind: OS - metadata: - name: os-sample - spec: - imagetype: disk - opstype: upgrade - osversion: edit.os.version - maxunavailable: edit.node.upgrade.number - dockerimage: "" - imageurl: edit.image.url - checksum: image.checksum - flagSafe: imageurl.safety - mtls: imageurl use mtls or not - cacert: ca certificate - clientcert: client certificate - clientkey: client certificate key - ``` +* Settings参数说明: -* 使用容器镜像升级 + 基于示例YAML对配置的参数进行说明,示例YAML如下,配置的格式(缩进)需和示例保持一致: - ``` shell + ```yaml apiVersion: upgrade.openeuler.org/v1alpha1 kind: OS metadata: name: os-sample spec: - imagetype: docker - opstype: upgrade + imagetype: "" + opstype: config osversion: edit.os.version - maxunavailable: edit.node.upgrade.number - dockerimage: dockerimage like repository/name:tag - imageurl: "" + maxunavailable: edit.node.config.number + containerimage: "" + evictpodforce: false checksum: "" - flagSafe: false - mtls: true + sysconfigs: + version: edit.sysconfigs.version + configs: + - model: kernel.sysctl + contents: + - key: kernel param key1 + value: kernel param value1 + - key: kernel param key2 + value: kernel param value2 + operation: delete + - model: kernel.sysctl.persist + configpath: persist file path + contents: + - key: kernel param key3 + value: kernel param value3 + - model: grub.cmdline.current + contents: + - key: boot param key1 + - key: boot param key2 + value: boot param value2 + - key: boot param key3 + value: boot param value3 + operation: delete + - model: grub.cmdline.next + contents: + - key: boot param key4 + - key: boot param key5 + value: boot param value5 + - key: boot param key6 + value: boot param value6 + operation: delete ``` - 使用容器镜像进行升级前请先制作升级所需的容器镜像,制作方式请见《容器OS镜像制作指导》 + 配置的参数说明如下: -假定将上面的YAML保存到upgrade_v1alpha1_os.yaml + | 参数 | 参数类型 | 参数说明 | 使用说明 | 配置中是否必选 | + | ---------- | -------- | --------------------------- | ------------------------------------------------------------ | ----------------------- | + | version | string | 配置的版本 | 通过version是否相等来判断配置是否触发,version为空(为""或者没有值)时同样进行判断,所以不配置sysconfigs/upgradeconfigs时,继存的version值会被清空并触发配置。 | 是 | + | configs | / | 具体配置内容 | 包含具体配置项列表。 | 是 | + | model | string | 配置的类型 | 支持的配置类型请看附录下的[Settings列表](#setting-列表) | 是 | + | configpath | string | 配置文件路径 | 仅在kernel.sysctl.persist配置类型中生效,请看附录下的[Settings列表](#setting-列表)对配置文件路径的说明。 | 否 | + | contents | / | 具体key/value的值及操作类型 | 包含具体配置参数列表。 | 是 | + | key | string | 参数名称 | key不能为空,不能包含"=",不建议配置含空格、tab键的字符串,具体请看附录下的[Settings列表](#setting-列表)中每种配置类型对key的说明。 | 是 | + | value | string | 参数值 | key=value形式的参数中,value不能为空,不建议配置含空格、tab键的字符串,具体请看附录下的[Settings列表](#setting-列表)中对每种配置类型对value的说明。 | key=value形式的参数必选 | + | operation | string | 对参数进行的操作 | 仅对kernel.sysctl.persist、grub.cmdline.current、grub.cmdline.next类型的参数生效。默认为添加或更新。仅支持配置为delete,代表删除已存在的参数(key=value需完全一致才能删除)。 | 否 | -查看未升级的节点的 OS 版本 + * upgradeconfigs与sysconfigs参数相同,upgradeconfigs为升级/回退前进行的配置,仅在upgrade/rollback场景起效,sysconfigs既支持只进行配置,也支持在升级/回退重启后进行配置。 -``` -kubectl get nodes -o custom-columns='NAME:.metadata.name,OS:.status.nodeInfo.osImage' -``` +* 使用说明 -执行命令,在集群中部署cr实例后,节点会根据配置的参数信息进行升级。 + * 编写YAML文件,在集群中部署 OS 的cr实例,用于部署cr实例的YAML示例如上,假定将上面的YAML保存到upgrade_v1alpha1_os.yaml。 -``` -kubectl apply -f upgrade_v1alpha1_os.yaml -``` + * 查看配置之前的节点的配置的版本和节点状态(NODESTATUS状态为idle)。 -再次查看节点的 OS 版本来确认节点是否升级完成 + ```shell + kubectl get osinstances -o custom-columns='NAME:.metadata.name,NODESTATUS:.spec.nodestatus,SYSCONFIG:status.sysconfigs.version,UPGRADECONFIG:status.upgradeconfigs.version' + ``` -``` -kubectl get nodes -o custom-columns='NAME:.metadata.name,OS:.status.nodeInfo.osImage' -``` + * 执行命令,在集群中部署cr实例后,节点会根据配置的参数信息进行配置,再次查看节点状态(NODESTATUS变成config)。 -> ![](./public_sys-resources/icon-note.gif)**说明**: -> -> 如果后续需要再次升级,与上面相同对 upgrade_v1alpha1_os.yaml 的 imageurl ,osversion,checksum,maxunavailable,flagSafe 或者dockerimage字段进行相应修改。 + ```shell + kubectl apply -f upgrade_v1alpha1_os.yaml + kubectl get osinstances -o custom-columns='NAME:.metadata.name,NODESTATUS:.spec.nodestatus,SYSCONFIG:status.sysconfigs.version,UPGRADECONFIG:status.upgradeconfigs.version' + ``` + + * 再次查看节点的配置的版本确认节点是否配置完成(NODESTATUS恢复为idle)。 + + ```shell + kubectl get osinstances -o custom-columns='NAME:.metadata.name,NODESTATUS:.spec.nodestatus,SYSCONFIG:status.sysconfigs.version,UPGRADECONFIG:status.upgradeconfigs.version' + ``` + +* 如果后续需要再次配置,与上面相同对 upgrade_v1alpha1_os.yaml 的相应字段进行相应修改。 ## 回退指导 ### 使用场景 -- 虚拟机无法正常启动时,需要退回到上一可以启动的版本时进行回退操作,仅支持手动回退容器 OS 。 -- 虚拟机能够正常启动并且进入系统,需要将当前版本退回到老版本时进行回退操作,支持工具回退(类似升级方式)和手动回退,建议使用工具回退。 +* 虚拟机无法正常启动时,可在grub启动项页面手动切换启动项,使系统回退至上一版本(即手动回退)。 +* 虚拟机能够正常启动并且进入系统时,支持工具回退和手动回退,建议使用工具回退。 +* 工具回退有两种方式: + 1. rollback模式直接回退至上一版本。 + 2. upgrade模式重新升级至上一版本。 -### 手动回退 +### 手动回退指导 -手动重启虚拟机,选择第二启动项进行回退,手动回退仅支持回退到本次升级之前的版本。 +* 手动重启虚拟机,进入启动项页面后,选择第二启动项进行回退,手动回退仅支持回退到上一个版本。 -### 工具回退 +### 工具回退指导 -* 回退至任意版本 - * 修改 OS 的cr实例的YAML 配置文件(例如 upgrade_v1alpha1_os.yaml),设置相应字段为期望回退的老版本镜像信息。类别OS来自于安装和部署章节创建的CRD对象,字段说明及示例请见上一节升级指导。 +* 回退至任意版本 + 1. 修改 OS 的cr实例的YAML 配置文件(例如 upgrade_v1alpha1_os.yaml),设置相应字段为期望回退的老版本镜像信息。类别OS来自于安装和部署章节创建的CRD对象,字段说明及示例请见上一节升级指导。 - * YAML修改完成后执行更新命令,在集群中更新定制对象后,节点会根据配置的字段信息进行回退 + 2. YAML修改完成后执行更新命令,在集群中更新定制对象后,节点会根据配置的字段信息进行回退 - ``` - kubectl apply -f upgrade_v1alpha1_os.yaml - ``` + ```shell + kubectl apply -f upgrade_v1alpha1_os.yaml + ``` * 回退至上一版本 + * OS回退至上一版本:修改upgrade_v1alpha1_os.yaml,设置osversion为上一版本,opstype为rollback,回退至上一版本(即切换至上一分区)。YAML示例如下: - * 修改upgrade_v1alpha1_os.yaml,设置osversion为上一版本,opstype为rollback,回退至上一版本(即切换至上一分区)。YAML示例如下: - - ``` + ```yaml + apiVersion: upgrade.openeuler.org/v1alpha1 + kind: OS + metadata: + name: os-sample + spec: + imagetype: "" + opstype: rollback + osversion: KubeOS pervious version + maxunavailable: 2 + containerimage: "" + evictpodforce: true/false + imageurl: "" + checksum: "" + flagSafe: false + mtls: true + ``` + + * 配置回退至上一版本:修改upgrade_v1alpha1_os.yaml,设置sysconfigs/upgradeconfigs的version为上一版本,回退至上一版本(已配置的参数无法回退)。YAML示例如下: + + ```yaml apiVersion: upgrade.openeuler.org/v1alpha1 kind: OS metadata: name: os-sample spec: imagetype: "" - opstype: rollback - osversion: KubeOS pervious version - maxunavailable: 2 - dockerimage: "" + opstype: config + osversion: edit.os.version + maxunavailable: edit.node.config.number + containerimage: "" + evictpodforce: true/false imageurl: "" checksum: "" flagSafe: false - mtls:true + mtls: false + sysconfigs: + version: previous config version + configs: + - model: kernel.sysctl + contents: + - key: kernel param key1 + value: kernel param value1 + - key: kernel param key2 + value: kernel param value2 + - model: kernel.sysctl.persist + configpath: persist file path + contents: + - key: kernel param key3 + value: kernel param value3 ``` - * YAML修改完成后执行更新命令,在集群中更新定制对象后,节点会根据配置的字段信息进行回退 +* YAML修改完成后执行更新命令,在集群中更新定制对象后,节点会根据配置的字段信息进行回退。 - ``` - kubectl apply -f upgrade_v1alpha1_os.yaml + ```shell + kubectl apply -f upgrade_v1alpha1_os.yaml + ``` + + 更新完成后,节点会根据配置信息回退容器 OS。 +* 查看节点容器 OS 版本(回退OS版本)或节点config版本&节点状态为idle(回退config版本),确认回退是否成功。 + + ```shell + kubectl get osinstances -o custom-columns='NAME:.metadata.name,NODESTATUS:.spec.nodestatus,SYSCONFIG:status.sysconfigs.version,UPGRADECONFIG:status.upgradeconfigs.version' + ``` + +## 附录 + +### Setting 列表 + +#### kernel Settings + +* kenerl.sysctl:临时设置内核参数,重启后无效,key/value 表示内核参数的 key/value, key与value均不能为空且key不能包含“=”,该参数不支持删除操作(operation=delete)示例如下: + + ```yaml + configs: + - model: kernel.sysctl + contents: + - key: user.max_user_namespaces + value: 16384 + - key: net.ipv4.tcp_tw_recycle + value: 0 + operation: delete + ``` + +* kernel.sysctl.persist: 设置持久化内核参数,key/value表示内核参数的key/value,key与value均不能为空且key不能包含“=”, configpath为配置文件路径,支持新建(需保证父目录存在),如不指定configpath默认修改/etc/sysctl.conf,示例如下: + ```yaml + configs: + - model: kernel.sysctl.persist + configpath : /etc/persist.conf + contents: + - key: user.max_user_namespaces + value: 16384 + - key: net.ipv4.tcp_tw_recycle + value: 0 + operation: delete ``` - 更新完成后,节点会根据配置信息回退容器 OS。 +#### Grub Settings + +* grub.cmdline.current/next: 设置grub.cfg文件中的内核引导参数,该行参数在grub.cfg文件中类似如下示例: -* 查看节点容器 OS 版本,确认回退是否成功。 + ```shell + linux /boot/vmlinuz root=/dev/sda2 ro rootfstype=ext4 nomodeset quiet oops=panic softlockup_panic=1 nmi_watchdog=1 rd.shell=0 selinux=0 crashkernel=256M panic=3 + ``` + + * 在dm-verity模式下,grub.cmdline配置下发无效。 + + * KubeOS使用双分区,grub.cmdline.current/next支持对当前分区或下一分区进行配置: + + * grub.cmdline.current:对当前分区的启动项参数进行配置。 + * grub.cmdline.next:对下一分区的启动项参数进行配置。 + + * 注意:升级/回退前后的配置,始终基于升级/回退操作下发时的分区位置进行current/next的区分。假设当前分区为A分区,下发升级操作并在sysconfigs(升级重启后配置)中配置grub.cmdline.current,重启后进行配置时仍修改A分区对应的grub cmdline。 + + * grub.cmdline.current/next支持“key=value”(value不能为空),也支持单key。若value中有“=”,例如“root=UUID=some-uuid”,key应设置为第一个“=”前的所有字符,value为第一个“=”后的所有字符。 配置方法示例如下: + + ```yaml + configs: + - model: grub.cmdline.current + contents: + - key: selinux + value: "0" + - key: root + value: UUID=e4f1b0a0-590e-4c5f-9d8a-3a2c7b8e2d94 + - key: panic + value: "3" + operation: delete + - key: crash_kexec_post_notifiers + - model: grub.cmdline.next + contents: + - key: selinux + value: "0" + - key: root + value: UUID=e4f1b0a0-590e-4c5f-9d8a-3a2c7b8e2d94 + - key: panic + value: "3" + operation: delete + - key: crash_kexec_post_notifiers + ``` +#### kubelet配置 + +* kuberntes.kubelet: 配置节点kubelet的配置文件中的参数,参数说明和约束如下: + * 仅支持```KubeletConfiguration```中的配置参数。 + * 节点kubelet配置文件需要为yaml格式的文件。 + * 如不指定configpath,默认配置文件路径为```/var/lib/kubelet/config.yaml```,并且需要注意的是配置文件的路径需要与kubelet启动时的```-- config```参数指定的路径一致才能生效,用户需保证配置文件路径有效。 + * kubelet配置的value参数类型支持为空/null、int、float、string、boolean和数组。当为数组时,数组元素允许重复,数组参数进行更新时会追加到已有数组中。如需修改数组中的元素,需要先删除数组,再新增数组来完成修改。 + * 如配置存在嵌套,则通过```'.'```连接嵌套的key值,例如如果修改如下yaml示例中```cacheAuthorizedTTL```参数为1s。 + + ```yaml + authorization: + mode: Webhook + webhook: + cacheAuthorizedTTL: 0s ``` - kubectl get nodes -o custom-columns='NAME:.metadata.name,OS:.status.nodeInfo.osImage' + 参数配置示例如下: + ```yaml + configs: + - model: kuberntes.kubelet + configpath: /etc/test.yaml + contents: + - key: authorization.webhook.cacheAuthorizedTTL + value: 1s ``` + * kubernetes.kubelet进行删除时,不对value与配置文件中的值进行比较。 +#### containerd配置 + +* container.containerd: 配置节点上containerd的配置文件中的参数,参数说明和约束如下: + * containerd需要配置文件为toml格式,所以key为toml中该参数的表头.键名,例如希望修改如下toml示例中```no_shim```为true。 + ```toml + [plugins."io.containerd.runtime.v1.linux"] + no_shim=false + runtime="runc" + runtime_root=" + ``` + 参数配置示例如下: + ```yaml + configs: + - model: container.containerd + configpath: /etc/test.toml + contents: + - key: plugins."io.containerd.runtime.v1.linux".no_shim + value: true + ``` + * toml使用```.```分割键,os-agent识别时与toml保持一致,所以当键名中包含```.```时,该键名需要使用```""```,例如上例中的```"io.containerd.runtime.v1.linux"```为一个键 + * 如不指定configpath,默认配置文件路径为```/etc/containerd/config.toml```,用户需要保证配置文件路径有效。 + * container.conatainerd配置的key和value均不能为空,value参数类型支持int、float、string、boolean和数组。当为数组时,数组元素允许重复,数组参数进行更新时会追加到已有数组中。如需修改数组中的元素,需要先删除数组,再新增数组来完成修改。 + * container.containerd进行删除时,不对value与配置文件中的值进行比较。 + +#### Pam Limits配置 + +* pam.limits:配置节点上/etc/security/limits.conf文件 + * key为domain值,value的格式需要为type.item.value(limits.conf文件要求每行格式为:\ \ \ \),例如: + ```yaml + configs: + - model: pam.limits + contents: + - key: ftp + value: soft.core.0 + ``` + * 更新时,如不需要对type/item/value更新时,可以使用```_```,忽略对此参数的更新,但value必须为点隔的三段式,例如: + ```yaml + configs: + - model: pam.limits + contents: + - key: ftp + value: hard._.1 + ``` + * pam.limits新增时,value中不允许包含```_``` + * pam.limits删除时,会对value进行校验,当value与配置文件中的值不同时,删除失败 + * pam.limits配置的key和value均不能为空 diff --git "a/docs/zh/docs/KubeOS/\345\256\211\350\243\205\344\270\216\351\203\250\347\275\262.md" "b/docs/zh/docs/KubeOS/\345\256\211\350\243\205\344\270\216\351\203\250\347\275\262.md" index a613ae27e30700461c06a734ed7cc026490c9055..e678699819a38166cc3e1508d19b3baa4f5930c0 100644 --- "a/docs/zh/docs/KubeOS/\345\256\211\350\243\205\344\270\216\351\203\250\347\275\262.md" +++ "b/docs/zh/docs/KubeOS/\345\256\211\350\243\205\344\270\216\351\203\250\347\275\262.md" @@ -4,25 +4,22 @@ - - - [安装与部署](#安装与部署) - - [软硬件要求](#软硬件要求) - - [硬件要求](#硬件要求) - [软件要求](#软件要求) - [环境准备](#环境准备) - - [安装容器OS升级工具](#安装容器os升级工具) - - [部署容器OS升级工具](#部署容器os升级工具) - - [制作os-operator和os-proxy镜像](#制作os-operator和os-proxy镜像) - - [制作容器OS镜像](#制作容器os镜像) - - [部署CRD,operator和proxy](#部署crd,operator和proxy) - - + - [环境准备](#环境准备-1) + - [操作步骤](#操作步骤) + - [制作容器OS虚拟机镜像](#制作容器os虚拟机镜像) + - [注意事项](#注意事项) + - [操作步骤](#操作步骤-1) + - [部署CRD,operator和proxy](#部署crdoperator和proxy) + - [注意事项](#注意事项-1) + - [操作步骤](#操作步骤-2) @@ -34,7 +31,7 @@ ### 软件要求 -* 操作系统:openEuler 22.09 +* 操作系统:openEuler 24.03-LTS-SP1 ### 环境准备 @@ -45,33 +42,23 @@ 安装容器 OS 升级工具的操作步骤如下: -1. 配置 yum 源:openEuler 22.09 和 openEuler 22.09 EPOL - - ``` - [openEuler22.09] # openEuler 22.09 官方发布源 - name=openEuler22.09 - baseurl=http://repo.openeuler.org/openEuler-22.09/everything/$basearch/ - enabled=1 - gpgcheck=1 - gpgkey=http://repo.openeuler.org/openEuler-22.09/everything/$basearch/RPM-GPG-KEY-openEuler - ``` +1. 配置 openEuler 24.03-LTS-SP1 yum 源: ``` - [Epol] # openEuler 22.09:Epol 官方发布源 - name=Epol - baseurl=http://repo.openeuler.org/openEuler-22.09/EPOL/main/$basearch/ + [openEuler24.03-LTS-SP1] # openEuler 24.03-LTS-SP1 官方发布源 + name=openEuler24.03-LTS-SP1 + baseurl=http://repo.openeuler.org/openEuler-24.03-LTS-SP1/everything/$basearch/ enabled=1 gpgcheck=1 - gpgkey=http://repo.openeuler.org/openEuler-22.09/OS/$basearch/RPM-GPG-KEY-openEuler + gpgkey=http://repo.openeuler.org/openEuler-24.03-LTS-SP1/everything/$basearch/RPM-GPG-KEY-openEuler ``` 2. 使用 root 帐户安装容器 OS 升级工具: ```shell - # yum install KubeOS KubeOS-scripts -y + yum install KubeOS KubeOS-scripts -y ``` - > ![](./public_sys-resources/icon-note.gif)**说明**: > > 容器 OS 升级工具会安装在 /opt/kubeOS 目录下,包括os-operator,os-proxy,os-agent二进制,制作容器 OS 工具及相应配置文件 。 @@ -106,23 +93,23 @@ export IMG_OPERATOR=your_imageRepository/os-operator_imageName:version ``` -4. 请用户自行编写Dockerfile来构建镜像 ,Dockfile编写请注意以下几项 +4. 请用户自行编写Dockerfile来构建镜像 ,Dockfile编写请注意以下几项: - * os-operator和os-proxy镜像需要基于baseimage进行构建,请用户保证baseimage的安全性 - * 需将os-operator和os-proxy二进制文件分别拷贝到对应的镜像中 - * 请确保os-proxy镜像中os-proxy二进制文件件属主和属组为root,文件权限为500 - * 请确保os-operator镜像中os-operator二进制文件属主和属组为容器内运行os-operator进程的用户,文件权限为500 + * os-operator和os-proxy镜像需要基于baseimage进行构建,请用户保证baseimage的安全性。 + * 需将os-operator和os-proxy二进制文件分别拷贝到对应的镜像中。 + * 请确保os-proxy镜像中os-proxy二进制文件件属主和属组为root,文件权限为500。 + * 请确保os-operator镜像中os-operator二进制文件属主和属组为容器内运行os-operator进程的用户,文件权限为500。 * os-operator和os-proxy的二进制文件在镜像内的位置和容器启动时运行的命令需与部署的yaml中指定的字段相对应。 Dockerfile示例如下 - ``` + ```dockerfile FROM your_baseimage COPY ./bin/proxy /proxy ENTRYPOINT ["/proxy"] ``` - ``` + ```dockerfile FROM your_baseimage COPY --chown=6552:6552 ./bin/operator /operator ENTRYPOINT ["/operator"] @@ -149,20 +136,19 @@ docker push ${IMG_PROXY} ``` - ### 制作容器OS虚拟机镜像 #### 注意事项 -* 以虚拟机镜像为例,如需进行物理机的镜像制作请见《容器OS镜像制作指导》 -* 制作容器OS 镜像需要使用 root 权限 -* 容器OS 镜像制作工具的 rpm 包源为 openEuler 具体版本的 everything 仓库和 EPOL 仓库。制作镜像时提供的 repo 文件中,yum 源建议同时配置 openEuler 具体版本的 everything 仓库和 EPOL 仓库 -* 使用默认 rpmlist 制作的容器OS虚拟机镜像,默认和制作工具保存在相同路径,该分区至少有 25GiB 的剩余磁盘空间 -* 制作容器 OS 镜像时,不支持用户自定义配置挂载文件 +* 以虚拟机镜像为例,如需进行物理机的镜像制作请见《[容器OS镜像制作指导](./容器OS镜像制作指导.md)》。 +* 制作容器OS 镜像需要使用 root 权限。 +* 容器OS 镜像制作工具的 rpm 包源为 openEuler 具体版本的 everything 仓库和 EPOL 仓库。制作镜像时提供的 repo 文件中,yum 源建议同时配置 openEuler 具体版本的 everything 仓库和 EPOL 仓库。 +* 使用默认 rpmlist 制作的容器OS虚拟机镜像,默认保存在调用`kbimg`路径下的`scripts-auto`文件夹内,该分区至少有 25GiB 的剩余磁盘空间。 +* 制作容器 OS 镜像时,不支持用户自定义配置挂载文件。 #### 操作步骤 -制作容器OS 虚拟机镜像使用 kbimg.sh 脚本,命令详情请见《容器OS镜像制作指导》 +制作容器OS 虚拟机镜像使用 kbimg,命令详情请见《[容器OS镜像制作指导](./容器OS镜像制作指导.md)》。 制作容器OS 虚拟机镜像的步骤如下: @@ -172,32 +158,30 @@ cd /opt/kubeOS/scripts ``` -2. 执行 kbming.sh 制作容器OS,参考命令如下: +2. 执行 kbming 制作容器OS,参考命令如下: ```shell - bash kbimg.sh create vm-image -p xxx.repo -v v1 -b ../bin/os-agent -e '''$1$xyz$RdLyKTL32WEvK3lg8CXID0''' + ./kbimg create -f ./kbimg.toml vm-img ``` - 其中 xx.repo 为制作镜像所需要的 yum 源,yum 源建议配置为 openEuler 具体版本的 everything 仓库和 EPOL 仓库。 - 容器 OS 镜像制作完成后,会在 /opt/kubeOS/scripts 目录下生成: + 容器 OS 镜像制作完成后,会在 /opt/kubeOS/scripts/scripts-auto 目录下生成: - - raw格式的系统镜像system.img,system.img大小默认为20G,支持的根文件系统分区大小<2020MiB,持久化分区<16GB。 - - qcow2 格式的系统镜像 system.qcow2。 - - 可用于升级的根文件系统分区镜像 update.img 。 + - raw格式的系统镜像system.img,system.img大小默认为20G,支持的根文件系统分区大小<2560MiB,持久化分区<15GB。 + - qcow2 格式的系统镜像 system.qcow2。 + - 可用于升级的根文件系统 kubeos.tar。 制作出来的容器 OS 虚拟机镜像目前只能用于 CPU 架构为 x86 和 AArch64 的虚拟机场景,不支持 x86 架构的虚拟机使用 legacy 启动模式启动。 - ### 部署CRD,operator和proxy #### 注意事项 -* 请先部署 Kubernetes 集群,部署方法参考《openEuler 22.09 Kubernetes 集群部署指南》 +* 请先部署 Kubernetes 集群,部署方法参考[《openEuler 24.03-LTS-SP1 Kubernetes 集群部署指南》](../Kubernetes/Kubernetes.md)。 -- 集群中准备进行升级的 Worker 节点的 OS 需要为使用上一节方式制作出来的容器 OS,如不是,请用 system.qcow2重新部署虚拟机,虚拟机部署请见《openEuler 22.09 虚拟化用户指南》,Master节点目前不支持容器 OS 升级,请用openEuler 22.09部署Master节点 +- 集群中准备进行升级的 Worker 节点的 OS 需要为使用上一节方式制作出来的容器 OS,如不是,请用 system.qcow2重新部署虚拟机,虚拟机部署请见[《openEuler 24.03-LTS-SP1 虚拟化用户指南》](../Virtualization/virtualization.md),Master节点目前不支持容器 OS 升级,请用openEuler 24.03-LTS-SP1部署Master节点。 - 部署 OS 的 CRD(CustomResourceDefinition),os-operator,os-proxy 以及 RBAC (Role-based access control) 机制的 YAML 需要用户自行编写。 -- operator 和 proxy 部署在 kubernetes 集群中,operator 应部署为 deployment,proxy 应部署为damonset -- 尽量部署好 kubernetes 的安全措施,如 rbac 机制,pod 的 service account 和 security policy 配置等 +- operator 和 proxy 部署在 kubernetes 集群中,operator 应部署为 deployment,proxy 应部署为daemonset。 +- 尽量部署好 kubernetes 的安全措施,如 rbac 机制,pod 的 service account 和 security policy 配置等。 #### 操作步骤 @@ -216,9 +200,3 @@ ```shell kubectl get pods -A ``` - - - - - - diff --git "a/docs/zh/docs/KubeOS/\345\256\271\345\231\250OS\351\225\234\345\203\217\345\210\266\344\275\234\346\214\207\345\257\274.md" "b/docs/zh/docs/KubeOS/\345\256\271\345\231\250OS\351\225\234\345\203\217\345\210\266\344\275\234\346\214\207\345\257\274.md" index 3409b87389beacaf911bb122a9955af52a043e7f..0e91f0167bbd0baab213178d4c796564de4d6ba3 100644 --- "a/docs/zh/docs/KubeOS/\345\256\271\345\231\250OS\351\225\234\345\203\217\345\210\266\344\275\234\346\214\207\345\257\274.md" +++ "b/docs/zh/docs/KubeOS/\345\256\271\345\231\250OS\351\225\234\345\203\217\345\210\266\344\275\234\346\214\207\345\257\274.md" @@ -1,162 +1,506 @@ -# 容器OS镜像制作指导# +# 容器OS镜像制作指导 -## 简介 ## +## 简介 kbimg是KubeOS部署和升级所需的镜像制作工具,可以使用kbimg制作KubeOS docker,虚拟机和物理机镜像。 -## 命令介绍 ## +## 命令介绍 -### 命令格式 ### +### 命令格式 -**bash kbimg.sh** \[ --help | -h \] create \[ COMMANDS \] \[ OPTIONS \] +kbimg - CLI tool for generating various types of image for KubeOS -### 参数说明 ### +```text +Usage: kbimg [OPTIONS] -* COMMANDS +Commands: + create Create a new KubeOS image + help Print this message or the help of the given subcommand(s) - | 参数 | 描述 | - | ------------- | ---------------------------------------------- | - | upgrade-image | 生成用于安装和升级的docker镜像格式的 KubeOS 镜像 | - | vm-image | 生成用于部署和升级的虚拟机镜像 | - | pxe-image | 生成物理机安装所需的镜像及文件 | +Options: + -d, --debug Enable debug mode, generate the scripts without execution + -h, --help Print help + -V, --version Print version +``` + +kbimg-create - Create a new KubeOS image + +```text +Usage: kbimg create --file + +Arguments: + [possible values: vm-img, pxe-img, upgrade-img, admin-container] + +Options: + -f, --file Path to the toml configuration file + -h, --help Print help +``` + +### 配置文件说明 + +#### from_repo + +从 repo 创建升级容器镜像、虚拟机镜像或PXE物理机镜像 + + | 参数 | 描述 | + | --- | --- | + | agent_path | os-agent 二进制的路径 | + | legacy_bios | 目前仅支持设置为`false`,即UEFI引导 | + | repo_path | repo 文件的路径,repo 文件中配置制作镜像所需要的 yum 源 | + | root_passwd | root 用户密码,与/etc/shadow文件内密码格式一致,可使用`openssl passwd -6 -salt $(head -c18 /dev/urandom \| openssl base64)`命令生成 | + | version | KubeOS 镜像的版本,将写入/etc/os-release文件内作为OS标识 | + | rpmlist | 期望安装进镜像内的rpm包列表 | + | upgrade_img | [可选项]指定生成的升级容器镜像的镜像名(制作升级容器镜像必需) | + +#### admin_container + +制作admin运维容器 + + | 参数 | 描述 | + | --- | --- | + | hostshell | hostshell二进制路径,可在项目根目录下通过`make hostshell`编译 | + | img_name | 指定生成的容器镜像名 | + +#### pxe_config + +在制作PXE物理机镜像时,配置该参数用于PXE安装。制作PXE物理机镜像时必需。 + + | 参数 | 描述 | + | --- | --- | + | server_ip | 用于下载根文件系统 tar 包的 HTTP 服务器地址 | + | rootfs_name | 放置于 HTTP 服务器的文件系统 tar 包名称 | + | disk | 安装 KubeOS 系统的目标磁盘名 | + | route_ip | 配置目标机器网卡的路由 IP | + | dhcp | [可选项] 是否启用 DHCP 模式配置网络,默认为 false | + | local_ip | [可选项] 配置目标机器网卡的 IP,dhcp 为 false 时必需 | + | net_name | [可选项] 配置目标机器网卡名,dhcp 为 false 时必需 | + | netmask | [可选项] 配置目标机器网卡的子网掩码,dhcp 为 false 时必需 | + +**注意**:`pxe_config`下的配置参数无法进行校验,需要用户自行确认其正确性。 + +#### users + +[可选项] 添加用户 + + | 参数 | 描述 | + | --- | --- | + | name | 用户名 | + | passwd | 密码 | + | primary_groups | [可选项] 用户主组(默认为用户同名组) | + | groups | [可选项] 用户附加组 | + +**注意**:添加用户会默认创建用户同名组,配置用户附加组时,若组不存在会报错失败。若有特殊配置需求,用户可通过[chroot_script](#chroot_script)脚本自行实现。 + +#### copy_files + +[可选项] 拷贝文件到rootfs内指定目录 + + | 参数 | 描述 | + | --- | --- | + | dst | 目标路径 | + | src | 源文件路径 | + | create_dir | [可选项]拷贝前创建文件夹 | + +**注意**:拷贝文件无法保留权限,如果需要特殊权限,可借助[chroot_script](#chroot_script)脚本自行实现。 + +#### grub - +[可选项] grub配置,配置dm-verity时必需 -* OPTIONS + | 参数 | 描述 | + | --- | --- | + | passwd | grub 明文密码 | - | 参数 | 描述 | - | ------------ | ------------------------------------------------------------ | - | -p | repo 文件的路径,repo 文件中配置制作镜像所需要的 yum 源 | - | -v | 制作出来的KubeOS镜像的版本 | - | -b | os-agent二进制的路径 | - | -e | KubeOS 镜像 root 用户密码,加密后的带盐值的密码,可以用 openssl,kiwi 命令生成 | - | -d | 生成或者使用的 docke r镜像 | - | -h --help | 查看帮助信息 | +#### systemd_service - +[可选项] 配置 systemd 服务开机自启 -## 使用说明 ## + | 参数 | 描述 | + | --- | --- | + | name | systemd 服务名 | -#### 注意事项 ### +#### chroot_script -* kbimg.sh 执行需要 root 权限 -* 当前仅支持 x86和 AArch64 架构使用 -* 容器 OS 镜像制作工具的 rpm 包源为 openEuler 具体版本的 everything 仓库和 EPOL 仓库。制作镜像时提供的 repo 文件中,yum 源建议同时配置 openEuler 具体版本的 everything 仓库和 EPOL 仓库 +[可选项] 自定义 chroot 脚本 -### KubeOS docker镜像制作 ### + | 参数 | 描述 | + | --- | --- | + | path | 脚本路径 | + | rm | [可选项]执行完毕后是否删除该脚本,配置`true`删除,`false`或空保留 | -#### 注意事项 #### +#### disk_partition -* 制作的 docker 镜像仅用于后续的虚拟机/物理机镜像制作或升级使用,不支持启动容器 -* 使用默认 rpmlist 进行容器OS镜像制作时所需磁盘空间至少为6G,如自已定义 rpmlist 可能会超过6G +[可选项] 自定义分区大小和镜像大小 -#### 使用示例 #### -* 如需进行DNS配置,请先在```scripts```目录下自定义```resolv.conf```文件 -```shell - cd /opt/kubeOS/scripts - touch resolv.conf - vim resolv.conf + | 参数 | 描述 | + | --- | --- | + | root | root分区大小, 单位为MiB,默认2560MiB | + | img_size | [可选项]镜像大小,单位为GB,默认20GB | + +#### persist_mkdir + +[可选项] persist 分区新建目录 + + | 参数 | 描述 | + | --- | --- | + | name | 目录名 | + +#### dm_verity + +[可选项] 制作启用dm-verity功能的虚拟机或升级镜像 + + | 参数 | 描述 | + | --- | --- | + | efi_key | efi明文口令 | + | grub_key | grub明文口令 | + | keys_dir |[可选项]可指定密钥文件夹,复用先前制作镜像创建的密钥 | + +## 使用说明 + +### 注意事项 + +- kbimg 执行需要 root 权限。 +- 当前仅支持 x86和 AArch64 架构使用。 +- 不支持并发执行。如果使用脚本`&`连续执行可能会出现异常情况。制作过程中碰到异常掉电或中断后无法清理环境时,可参考[异常退出清理方法](#异常退出清理方法)清理后重新制作。 +- 制作容器OS镜像的环境需关闭SELinux。 +- 容器 OS 镜像制作工具的 rpm 包源为 openEuler 具体版本的 everything 仓库和 EPOL 仓库。制作镜像时提供的 repo 文件中,yum 源建议同时配置 openEuler 具体版本的 everything 仓库和 EPOL 仓库。 +- dm-verity使用说明: + - 仅支持虚拟机场景,暂不支持物理机环境。 + - 不支持通过 HTTP/HTTPS 服务器下载升级镜像进行系统升级。仅支持从容器镜像仓库下载升级镜像进行升级。 + - 启动虚拟机时,必须配置使用 virtio 类型设备。 + - 启用dm-verity功能的升级容器镜像不可用于升级未开启dm-verity的容器OS。同理,未启动dm-verity功能的升级容器镜像不可用于升级开启dm-verity功能的容器OS。在集群内,部分节点开启dm-verity功能,部分未开启,需要用户控制下发对应的升级镜像。 + - 制作升级容器镜像和虚拟机镜像时,推荐使用相同的密钥(配置`keys_dir`为先前制作镜像时创建的密钥文件路径。配置`efi_key`或`grub_key`一致不能保证密钥文件是一模一样的)。若密钥不一致,在切换备用分区时可能导致证书校验失败,从而无法启动系统。出现证书校验失败问题时,需要重新导入备用分区证书进行修复。 + +### KubeOS OCI 镜像制作 + +#### 注意事项 + +- 制作出的 OCI 镜像仅用于后续的虚拟机/物理机镜像升级使用,不支持启动容器。 +- 使用默认 rpmlist 进行容器OS镜像制作时所需磁盘空间至少为6G,若使用自定义 rpmlist 可能会超过6G。 + +#### 使用示例 + +- 配置文件示例 + +```toml +[from_repo] +agent_path = "./bin/rust/release/os-agent" +legacy_bios = false +repo_path = "/etc/yum.repos.d/openEuler.repo" +root_passwd = "$1$xyz$RdLyKTL32WEvK3lg8CXID0" # default passwd: openEuler12#$ +rpmlist = [ + "NetworkManager", + "cloud-init", + "conntrack-tools", + "containerd", + "containernetworking-plugins", + "cri-tools", + "dhcp", + "ebtables", + "ethtool", + "iptables", + "kernel", + "kubernetes-kubeadm", + "kubernetes-kubelet", + "openssh-server", + "passwd", + "rsyslog", + "socat", + "tar", + "vi", +] +upgrade_img = "kubeos-upgrade:v1" +version = "v1" ``` -* 制作KubeOS容器镜像 -``` shell -cd /opt/kubeOS/scripts -bash kbimg.sh create upgrade-image -p xxx.repo -v v1 -b ../bin/os-agent -e '''$1$xyz$RdLyKTL32WEvK3lg8CXID0''' -d your_imageRepository/imageName:version + +- 结果说明 + - 制作完成后,通过`docker images`查看制作出来的KubeOS容器镜像 + - update-boot.img/update-root.img/update-hash.img: 仅在dm-verity模式下生成,可忽略。 + +### KubeOS 虚拟机镜像制作 + +#### 注意事项 + +- 制作出来的容器 OS 虚拟机镜像目前只能用于 CPU 架构为 x86 和 AArch64 的虚拟机。 +- 容器 OS 目前不支持 x86 架构的虚拟机使用 legacy 启动模式启动。 +- 默认root密码为openEuler12#$ +- 使用默认rpmlist进行容器OS镜像制作时所需磁盘空间至少为25G,若使用自定义rpmlist可能会超过25G。 + +#### 使用示例 + +- 配置文件示例 + +```toml +[from_repo] +agent_path = "./bin/rust/release/os-agent" +legacy_bios = false +repo_path = "/etc/yum.repos.d/openEuler.repo" +root_passwd = "$1$xyz$RdLyKTL32WEvK3lg8CXID0" # default passwd: openEuler12#$ +rpmlist = [ + "NetworkManager", + "cloud-init", + "conntrack-tools", + "containerd", + "containernetworking-plugins", + "cri-tools", + "dhcp", + "ebtables", + "ethtool", + "iptables", + "kernel", + "kubernetes-kubeadm", + "kubernetes-kubelet", + "openssh-server", + "passwd", + "rsyslog", + "socat", + "tar", + "vi", +] +version = "v1" ``` -* 制作完成后查看制作出来的KubeOS容器镜像 +#### 结果说明 -``` shell -docker images -``` +容器 OS 镜像制作完成后,会在 ./scripts-auto 目录下生成 -### KubeOS 虚拟机镜像制作 ### +- system.qcow2: 用于启动虚拟机的qcow2 格式的系统镜像,大小默认为 20GiB,支持的根文件系统分区大小 < 2560 MiB,持久化分区 < 15GB 。 +- system.img: 用于启动虚拟机的img 格式的系统镜像,大小默认为 20GiB,支持的根文件系统分区大小 < 2560 MiB,持久化分区 < 15GB 。 +- kubeos.tar: 用于升级的根文件系统tar包。 +- update-boot.img/update-root.img/update-hash.img: 仅在dm-verity模式下生成,可忽略。 -#### 注意事项 #### +### KubeOS 物理机安装所需镜像及文件制作 -* 如使用 docker 镜像制作请先拉取相应镜像或者先制作docker镜像,并保证 docker 镜像的安全性 -* 制作出来的容器 OS 虚拟机镜像目前只能用于 CPU 架构为 x86 和 AArch64 的虚拟机 -* 容器 OS 目前不支持 x86 架构的虚拟机使用 legacy 启动模式启动 -* 使用默认rpmlist进行容器OS镜像制作时所需磁盘空间至少为25G,如自已定义rpmlist可能会超过25G +#### 注意事项 -#### 使用示例 #### +- 制作出来的容器 OS 物理安装所需的镜像目前只能用于 CPU 架构为 x86 和 AArch64 的物理机安装。 +- `pxe_config`配置中指定的ip为安装时使用的临时ip,请在系统安装启动后请参考[《openEuler 24.03-LTS-SP1 管理员指南-配置网络》](../Administration/配置网络.md)进行网络配置。 +- 不支持多个磁盘都安装KubeOS,可能会造成启动失败或挂载紊乱。 +- 容器OS 目前不支持 x86 架构的物理机使用 legacy 启动模式启动。 +- 使用默认rpmlist进行镜像制作时所需磁盘空间至少为5G,如自已定义 rpmlist 可能会超过5G。 +- PXE物理机镜像制作不支持dm-verity功能 +- 在 PXE 安装阶段,需要从 HTTP 服务器的根目录下载根分区 tar 包(tar包名称为toml配置文件中配置的名称)。请确保机器拥有足够的内存空间以存储根分区 tar 包及临时中间文件。 -* 使用repo源制作 - * 如需进行DNS配置,请先在```scripts```目录下自定义```resolv.conf```文件 - ```shell - cd /opt/kubeOS/scripts - touch resolv.conf - vim resolv.conf - ``` - * KubeOS虚拟机镜像制作 - ``` shell - cd /opt/kubeOS/scripts - bash kbimg.sh create vm-image -p xxx.repo -v v1 -b ../bin/os-agent -e '''$1$xyz$RdLyKTL32WEvK3lg8CXID0''' - ``` +#### 使用示例 -* 使用docker镜像制作 +- 首先需要修改```kbimg.toml```中```pxe_config```的配置,对相关参数进行配置,详细参数可见[参数说明](#pxe_config),ip目前仅支持ipv4,配置示例如下 - ``` shell - cd /opt/kubeOS/scripts - bash kbimg.sh create vm-image -d your_imageRepository/imageName:version - ``` -* 结果说明 - 容器 OS 镜像制作完成后,会在 /opt/kubeOS/scripts 目录下生成: - * system.qcow2: qcow2 格式的系统镜像,大小默认为 20GiB,支持的根文件系统分区大小 < 2020 MiB,持久化分区 < 16GiB 。 - * update.img: 用于升级的根文件系统分区镜像 - - -### KubeOS 物理机安装所需镜像及文件制作 ### - -#### 注意事项 #### - -* 如使用 docker 镜像制作请先拉取相应镜像或者先制作 docker 镜像,并保证 docker 镜像的安全性 -* 制作出来的容器 OS 物理安装所需的镜像目前只能用于 CPU 架构为 x86 和 AArch64 的物理机安装 -* Global.cfg配置中指定的ip为安装时使用的临时ip,请在系统安装启动后请参考《openEuler 22.09 管理员指南-配置网络》进行网络配置 -* 不支持多个磁盘都安装KubeOS,可能会造成启动失败或挂载紊乱 -* 容器OS 目前不支持 x86 架构的物理机使用 legacy 启动模式启动 -* 使用默认rpmlist进行镜像制作时所需磁盘空间至少为5G,如自已定义 rpmlist 可能会超过5G -#### 使用示例 #### - -* 首先需要修改```00bootup/Global.cfg```的配置,对相关参数进行配置,参数均为必填,ip目前仅支持ipv4,配置示例如下 - - ```shell + ```toml + [pxe_config] + dhcp = false # rootfs file name - rootfs_name=kubeos.tar + rootfs_name = "kubeos.tar" # select the target disk to install kubeOS - disk=/dev/sda + disk = "/dev/vda" # pxe server ip address where stores the rootfs on the http server - server_ip=192.168.1.50 - # target machine temporary ip - local_ip=192.168.1.100 - # target machine temporary route - route_ip=192.168.1.1 - # target machine temporary netmask - netmask=255.255.255.0 + server_ip = "192.168.122.50" + # target machine ip + local_ip = "192.168.122.100" + # target machine route + route_ip = "192.168.122.1" + # target machine netmask + netmask = "255.255.255.0" # target machine netDevice name - net_name=eth0 + net_name = "eth0" ``` -* 使用 repo 源制作 - * 如需进行DNS配置,请在```scripts```目录下自定义```resolv.conf```文件 - ```shell - cd /opt/kubeOS/scripts - touch resolv.conf - vim resolv.conf - ``` - * KubeOS物理机安装所需镜像制作 - ``` - cd /opt/kubeOS/scripts - bash kbimg.sh create pxe-image -p xxx.repo -v v1 -b ../bin/os-agent -e '''$1$xyz$RdLyKTL32WEvK3lg8CXID0''' - ``` +- 如需进行DNS配置,请先自定义```resolv.conf```文件,并启用```copy_files```字段将配置文件拷贝到```/etc```目录 -* 使用 docker 镜像制作 - ``` shell - cd /opt/kubeOS/scripts - bash kbimg.sh create pxe-image -d your_imageRepository/imageName:version + ```toml + [[copy_files]] + dst = "/etc" + src = "" ``` -* 结果说明 - - * initramfs.img: 用于pxe启动用的 initramfs 镜像 - * kubeos.tar: pxe安装所用的 OS +- KubeOS物理机安装所需镜像制作,及pxe_config配置全示例 + + ```toml + [from_repo] + agent_path = "./bin/rust/release/os-agent" + legacy_bios = false + repo_path = "/etc/yum.repos.d/openEuler.repo" + root_passwd = "$1$xyz$RdLyKTL32WEvK3lg8CXID0" # default passwd: openEuler12#$ + rpmlist = [ + "NetworkManager", + "cloud-init", + "conntrack-tools", + "containerd", + "containernetworking-plugins", + "cri-tools", + "dhcp", + "ebtables", + "ethtool", + "iptables", + "kernel", + "kubernetes-kubeadm", + "kubernetes-kubelet", + "openssh-server", + "passwd", + "rsyslog", + "socat", + "tar", + "vi", + "coreutils", + "dosfstools", + "dracut", + "gawk", + "hwinfo", + "net-tools", + "parted", + ] + version = "v1" + + [pxe_config] + dhcp = true + rootfs_name = "kubeos.tar" + disk = "/dev/vda" + server_ip = "192.168.122.50" + route_ip = "192.168.122.1" + #local_ip = "192.168.1.100" + #netmask = "255.255.255.0" + #net_name = "eth0" + ``` +- 结果说明 + - initramfs.img: 用于pxe启动用的 initramfs 镜像 + - kubeos.tar: pxe安装所用的根分区文件系统 + +## 附录 + +### 异常退出清理方法 + +1. 若在使用`kbimg`制作镜像过程中,异常退出,无法清理环境,可使用如下方法进行清理: + + ```bash + function unmount_dir() { + local dir=$1 + if [ -L "${dir}" ] || [ -f "${dir}" ]; then + echo "${dir} is not a directory, please check it." + return 1 + fi + if [ ! -d "${dir}" ]; then + return 0 + fi + local real_dir=$(readlink -e "${dir}") + local mnts=$(awk '{print $2}' < /proc/mounts | grep "^${real_dir}" | sort -r) + for m in ${mnts}; do + echo "Unmount ${m}" + umount -f "${m}" || true + done + return 0 + } + ls -l ./scripts-auto/test.lock && rm -rf ./scripts-auto/test.lock + unmount_dir ./scripts-auto/rootfs/proc + unmount_dir ./scripts-auto/rootfs/sys + unmount_dir ./scripts-auto/rootfs/dev/pts + unmount_dir ./scripts-auto/rootfs/dev + unmount_dir ./scripts-auto/mnt/boot/grub2 + unmount_dir ./scripts-auto/mnt + rm -rf ./scripts-auto/rootfs ./scripts-auto/mnt + ``` + +2. 如果执行以上命令仍然无法删除目录,可尝试先调用如下命令,再重新执行第一步的命令。 + + ```bash + fuser -kvm ./scripts-auto/rootfs + fuser -kvm ./scripts-auto/mnt + ``` + +### 详细toml配置文件示例 + +请根据需求和[配置文件说明](#配置文件说明),修改如下示例配置文件,生成所需镜像。 + +```toml +[from_repo] +agent_path = "./bin/rust/release/os-agent" +legacy_bios = false +repo_path = "/etc/yum.repos.d/openEuler.repo" +root_passwd = "$1$xyz$RdLyKTL32WEvK3lg8CXID0" # default passwd: openEuler12#$, use "openssl passwd -6 -salt $(head -c18 /dev/urandom | openssl base64)" to generate your passwd +rpmlist = [ + "NetworkManager", + "cloud-init", + "conntrack-tools", + "containerd", + "containernetworking-plugins", + "cri-tools", + "dhcp", + "ebtables", + "ethtool", + "iptables", + "kernel", + "kubernetes-kubeadm", + "kubernetes-kubelet", + "openssh-server", + "passwd", + "rsyslog", + "socat", + "tar", + "vi", + # Below packages are required for pxe-image. Uncomment them if you want to generate pxe-image. + # "coreutils", + # "dosfstools", + # "dracut", + # "gawk", + # "hwinfo", + # "net-tools", + # "parted", +] +upgrade_img = "kubeos-upgrade:v1" +version = "v1" + +# [admin_container] +# img_name = "kubeos-admin-container:v1" +# hostshell = "./bin/hostshell" + +# [pxe_config] +# dhcp = false +# disk = "/dev/vda" +# local_ip = "192.168.1.100" +# net_name = "eth0" +# netmask = "255.255.255.0" +# rootfs_name = "kubeos.tar" +# route_ip = "192.168.1.1" +# server_ip = "192.168.1.50" + +# [[users]] +# groups = ["admin", "wheel"] +# name = "foo" +# passwd = "foo" +# primary_group = "foo" + +# [[users]] +# groups = ["example"] +# name = "bar" +# passwd = "bar" + +# [[copy_files]] +# create_dir = "/root/test" +# dst = "/root/test/foo.txt" +# src = "/root/KubeOS/foo.txt" + +# [[copy_files]] +# dst = "/etc/bar.txt" +# src = "../bar.txt" + +# [grub] +# passwd = "foo" + +# [systemd_service] +# name = ["containerd", "kubelet"] + +# [chroot_script] +# path = "./my_chroot.sh" +# rm = true + +# [disk_partition] +# img_size = 30 # GB +# root = 3000 # MiB + +# [persist_mkdir] +# name = ["bar", "foo"] + +# [dm_verity] +# efi_key = "foo" +# grub_key = "bar" +# keys_dir = "./keys" +``` diff --git "a/docs/zh/docs/Kubernetes/Kubernetes\351\233\206\347\276\244\351\203\250\347\275\262\346\214\207\345\215\227 - containerd.md" "b/docs/zh/docs/Kubernetes/Kubernetes\351\233\206\347\276\244\351\203\250\347\275\262\346\214\207\345\215\227 - containerd.md" new file mode 100644 index 0000000000000000000000000000000000000000..18f89355956c264ca8e54eecd9c1f6232e2fee53 --- /dev/null +++ "b/docs/zh/docs/Kubernetes/Kubernetes\351\233\206\347\276\244\351\203\250\347\275\262\346\214\207\345\215\227 - containerd.md" @@ -0,0 +1,244 @@ +# Kubernetes集群部署指南 - containerd +Kubernetes自1.21版本开始不再支持Kubernetes+docker部署Kubernetes集群,本文介绍以containerd作为容器运行时快速搭建Kubernetes集群。若需要对集群进行个性化配置,请查阅[官方文档](https://kubernetes.io/zh-cn/docs/home/) 。 +## 软件包安装 +### 1. 安装必要软件包 +``` +$ yum install -y containerd +$ yum install -y kubernetes* +$ yum install -y cri-tools +``` +> ![](./public_sys-resources/icon-note.gif)**说明** +> +> - 如果系统中已经安装了Docker,请确保在安装containerd之前卸载Docker,否则可能会引发冲突。 + +要求使用1.6.22-15或更高版本的containerd,如果下载的版本过低请运行以下命令升级成1.6.22-15版本,或自行升级。 +``` +$ wget --no-check-certificate https://repo.openeuler.org/openEuler-24.03-LTS/update/x86_64/Packages/containerd-1.6.22-15.oe2403.x86_64.rpm +$ rpm -Uvh containerd-1.6.22-15.oe2403.x86_64.rpm +``` +本教程中通过yum下载的软件包版本如下所示: +``` +1. containerd + -架构:x86_64 + -版本:1.6.22-15 +2. kubernetes - client/help/kubeadm/kubelet/master/node + -架构:x86_64 + -版本:1.29.1-4 +3. cri-tools + -架构:X86_64 + -版本:1.29.0-3 +``` + +### 2. 下载cni组件 + +``` +$ mkdir -p /opt/cni/bin +$ cd /opt/cni/bin +$ wget --no-check-certificate https://github.com/containernetworking/plugins/releases/download/v1.5.1/cni-plugins-linux-amd64-v1.5.1.tgz +$ tar -xzvf ./cni-plugins-linux-amd64-v1.5.1.tgz -C . +``` +> ![](./public_sys-resources/icon-note.gif)**说明** +> +> - 这里提供的是AMD64架构版本的下载链接,请根据系统架构选择合适的版本,其他版本可从[github仓库](https://github.com/containernetworking/plugins/releases/)获取。 + +### 3. 下载CNI插件(Flannel) +``` +$ wget https://raw.githubusercontent.com/flannel-io/flannel/master/Documentation/kube-flannel.yml --no-check-certificate +``` +## 环境配置 +本节对Kubernetes运行时所需的操作系统环境进行配置。 +### 1. 设置主机名 + +``` +$ hostnamectl set-hostname nodeName +``` +### 2. 配置防火墙 +**方法一:** + +配置防火墙规则以开放etcd和API Server的端口,确保控制平面和工作节点之间的正常通信。 +开放etcd的端口: +``` +$ firewall-cmd --zone=public --add-port=2379/tcp --permanent +$ firewall-cmd --zone=public --add-port=2380/tcp --permanent +``` +开放API Server的端口: +``` +$ firewall-cmd --zone=public --add-port=6443/tcp --permanent +``` +使防火墙规则生效: + +``` +$ firewall-cmd --reload +``` +> ![](./public_sys-resources/icon-note.gif)**说明** +> +> - 防火墙配置可能会导致某些容器镜像无法正常使用。为了确保其顺利运行,需要根据所使用的镜像开放相应的端口。 + +**方法二:** + +使用以下命令禁用防火墙: + +``` +$ systemctl stop firewalld +$ systemctl disable firewalld +``` +### 3. 禁用SELinux +SELinux的安全策略可能会阻止容器内的某些操作,比如写入特定目录、访问网络资源、或执行具有特权的操作。这会导致 CoreDNS 等关键服务无法正常运行,并表现为CrashLoopBackOff或 Error状态。可以使用以下命令来禁用SELinux: +``` +$ setenforce 0 +$ sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config +``` +### 4. 禁用swap +Kubernetes的资源调度器根据节点的可用内存和CPU资源来决定将哪些Pod分配到哪些节点上。如果节点上启用了swap,实际可用的物理内存和逻辑上可用的内存可能不一致,这会影响调度器的决策,导致某些节点出现过载,或者在某些情况下调度错误。因此需要禁用swap: +``` +$ swapoff -a +$ sed -ri 's/.*swap.*/#&/' /etc/fstab +``` +### 5. 网络配置 +启用桥接网络上的IPv6和IPv4流量通过iptables进行过滤,并启动IP转发,运行内核转发IPv4包,确保跨界点的Pod间通信: + +``` +$ cat > /etc/sysctl.d/k8s.conf << EOF +net.bridge.bridge-nf-call-ip6tables = 1 +net.bridge.bridge-nf-call-iptables = 1 +net.ipv4.ip_forward = 1 +vm.swappiness=0 +EOF +$ modprobe br_netfilter +$ sysctl -p /etc/sysctl.d/k8s.conf +``` +## 配置containerd +本节对containerd进行配置,包括设置pause_image、cgroup驱动、关闭"registry.k8s.io"镜像源证书验证、配置代理。 + +首先,生成containerd的默认配置文件并将其输出到containerd_conf指定的文件: + +``` +$ containerd_conf="/etc/containerd/config.toml" +$ mkdir -p /etc/containerd +$ containerd config default > "${containerd_conf}" +``` +配置pause_image: +``` +$ pause_img=$(kubeadm config images list | grep pause | tail -1) +$ sed -i "/sandbox_image/s#\".*\"#\"${pause_img}\"#" "${containerd_conf}" +``` +将cgroup驱动指定为systemd: +``` +$ sed -i "/SystemdCgroup/s/=.*/= true/" "${containerd_conf}" +``` +关闭"registry.k8s.io"镜像源证书验证: +``` +$ sed -i '/plugins."io.containerd.grpc.v1.cri".registry.configs/a\[plugins."io.containerd.grpc.v1.cri".registry.configs."registry.k8s.io".tls]\n insecure_skip_verify = true' /etc/containerd/config.toml +``` +配置代理(将HTTP_PROXY、HTTPS_PROXY、NO_PROXY中的"***"替换为自己的代理信息): +``` +$ server_path="/etc/systemd/system/containerd.service.d" +$ mkdir -p "${server_path}" +$ cat > "${server_path}"/http-proxy.conf << EOF +[Service] +Environment="HTTP_PROXY=***" +Environment="HTTPS_PROXY=***" +Environment="NO_PROXY=***" +EOF +``` +重启containerd,使得以上配置生效: +``` +$ systemctl daemon-reload +$ systemctl restart containerd +``` +## 配置crictl使用containerd作为容器运行时 +``` +$ crictl config runtime-endpoint unix:///run/containerd/containerd.sock +$ crictl config image-endpoint unix:///run/containerd/containerd.sock +``` +## 配置kubelet使用systemd作为cgroup驱动 + +``` +$ systemctl enable kubelet.service +$ echo 'KUBELET_EXTRA_ARGS="--runtime-cgroups=/systemd/system.slice --kubelet-cgroups=/systemd/system.slice"' >> /etc/sysconfig/kubelet +$ systemctl restart kubelet +``` +## 使用Kubeadm创建集群(仅控制平面需要) +### 1. 配置集群信息 +``` +$ kubeadm config print init-defaults --component-configs KubeletConfiguration >> kubeletConfig.yaml +$ vim kubeletConfig.yaml +``` +在kubeletConfig.yaml文件中,配置节点名称、广播地址(advertiseAddress)以及Pod网络的CIDR。 +
+**修改name为主机名,与环境配置[第一步](#1-设置主机名)一致:** +
+![](./figures/name.png) +
+**将advertiseAddress修改为控制平面的ip地址:** +
+![](./figures/advertiseAddress.png) +
+**在Networking中添加podSubnet指定CIDR范围:** +
+![](./figures/podSubnet.png) + +### 2. 部署集群 +这里使用kubeadm部署集群,许多配置是默认生成的(如认证证书),如需修改请查阅[官方文档](https://kubernetes.io/zh-cn/docs/home/ )。 + +**关闭代理(如有):** +``` +$ unset http_proxy https_proxy +``` +使用kubeadm init部署集群: + +``` +$ kubeadm init --config kubeletConfig.yaml +``` +指定kubectl使用的配置文件: +``` +$ mkdir -p "$HOME"/.kube +$ cp -i /etc/kubernetes/admin.conf "$HOME"/.kube/config +$ chown "$(id -u)":"$(id -g)" "$HOME"/.kube/config +$ export KUBECONFIG=/etc/kubernetes/admin.conf +``` +### 3. 部署cni插件(flannel) +本教程中使用flannel作为cni插件,以下介绍flannel下载和部署。 +以下使用的flannel从registry-1.docker.io镜像源下载,为避免证书验证失败的问题,请在containerd配置文件(/etc/containerd/config.toml)中配置该镜像源跳过证书验证。 +
+![](./figures/flannelConfig.png) +
+使用kubectl apply部署最开始在软件包安装中下载的kube-flannel.yml。 +``` +$ kubectl apply -f kube-flannel.yml +``` +> ![](./public_sys-resources/icon-note.gif)**说明** +> +> 控制平面可能会有污点的问题,导致kubectl get nodes中节点状态无法变成ready,请查阅[官方文档](https://kubernetes.io/zh-cn/docs/concepts/scheduling-eviction/taint-and-toleration/)去除污点。 +## 加入集群(仅工作节点需要) +**关闭代理(如有):** +``` +$ unset http_proxy https_proxy +``` +工作节点安装配置完环境后可以通过以下命令加入集群。 + +``` +$ kubeadm join : --token --discovery-token-ca-cert-hash sha256: +``` +这个命令会在控制平面库kubeadm init结束后生成,也可以在控制平面按照以下命令获取: + +``` +$ kubeadm token create #生成token +$ openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | \ + openssl dgst -sha256 -hex | sed 's/^.* //' #获取hash +``` + +加入后可以在控制平面通过以下命令查看工作节点的状态: + +``` +$ kubectl get nodes +``` +如果节点状态显示为not ready,可能是因为Flannel插件未成功部署。在这种情况下,请运行本地生成的Flannel可执行文件来完成部署。 +
+**在工作节点运行kubectl命令(可选):** + +如果需要在工作节点上运行kubectl命令,需要将控制面板的配置文件/etc/kubernetes/admin.conf复制到同样的目录,然后运行以下命令进行配置: + +``` +$ export KUBECONFIG=/etc/kubernetes/admin.conf +``` \ No newline at end of file diff --git "a/docs/zh/docs/Kubernetes/eggo\351\203\250\347\275\262\351\233\206\347\276\244.md" "b/docs/zh/docs/Kubernetes/eggo\351\203\250\347\275\262\351\233\206\347\276\244.md" index deac5b80cb22f740bcf7d9999b7fb683b2dfbfdc..4ee2bb86b74e2f25b4babe42d1b0c20f19bd9287 100644 --- "a/docs/zh/docs/Kubernetes/eggo\351\203\250\347\275\262\351\233\206\347\276\244.md" +++ "b/docs/zh/docs/Kubernetes/eggo\351\203\250\347\275\262\351\233\206\347\276\244.md" @@ -192,7 +192,7 @@ $ eggo template -f template.yaml 或者直接使用命令行方式修改默认配置,参考命令如下: ```shell -$ eggo template -f template.yaml -n k8s-cluster -u username -p password --masters 192.168.0.1 --masters 192.168.0.2 --workers 192.168.0.3 --etcds 192.168.0.4 --loadbalancer 192.168.0.5 +$ eggo template -f template.yaml -n k8s-cluster -u username -p password --masters 192.168.0.1 --masters 192.168.0.2 --workers 192.168.0.3 --etcds 192.168.0.4 --loadbalance 192.168.0.5 ``` ## 安装 Kubernetes 集群 diff --git a/docs/zh/docs/Kubernetes/figures/advertiseAddress.png b/docs/zh/docs/Kubernetes/figures/advertiseAddress.png new file mode 100644 index 0000000000000000000000000000000000000000..b36e5c4664f2d2e5faaa23128fd4711c11e30179 Binary files /dev/null and b/docs/zh/docs/Kubernetes/figures/advertiseAddress.png differ diff --git a/docs/zh/docs/Kubernetes/figures/flannelConfig.png b/docs/zh/docs/Kubernetes/figures/flannelConfig.png new file mode 100644 index 0000000000000000000000000000000000000000..dc9e7c665edd02fad16d3e6f4970e3125efcbef8 Binary files /dev/null and b/docs/zh/docs/Kubernetes/figures/flannelConfig.png differ diff --git a/docs/zh/docs/Kubernetes/figures/name.png b/docs/zh/docs/Kubernetes/figures/name.png new file mode 100644 index 0000000000000000000000000000000000000000..dd6ddfdc3476780e8c896bfd5095025507f62fa8 Binary files /dev/null and b/docs/zh/docs/Kubernetes/figures/name.png differ diff --git a/docs/zh/docs/Kubernetes/figures/podSubnet.png b/docs/zh/docs/Kubernetes/figures/podSubnet.png new file mode 100644 index 0000000000000000000000000000000000000000..b368f77dd7dfd7722dcf7751b3e37ec28755e42d Binary files /dev/null and b/docs/zh/docs/Kubernetes/figures/podSubnet.png differ diff --git "a/docs/zh/docs/Kubernetes/\345\207\206\345\244\207\350\257\201\344\271\246.md" "b/docs/zh/docs/Kubernetes/\345\207\206\345\244\207\350\257\201\344\271\246.md" index a355988d398e7da8ad77692bb47ce2691af2920c..63b4a973ad35351fb770cf1e051b80cc9de25db3 100644 --- "a/docs/zh/docs/Kubernetes/\345\207\206\345\244\207\350\257\201\344\271\246.md" +++ "b/docs/zh/docs/Kubernetes/\345\207\206\345\244\207\350\257\201\344\271\246.md" @@ -6,6 +6,28 @@ 部署集群前,需要生成集群各组件之间通信所需的证书。本文使用开源 CFSSL 作为验证部署工具,以便用户了解证书的配置和集群组件之间证书的关联关系。用户可以根据实际情况选择合适的工具,例如 OpenSSL 。 +## 配置go环境 + +1. 下载go +``` +wget https://go.dev/dl/go1.22.3.linux-amd64.tar.gz +``` + +2. 移除旧版本并安装 +``` +$ rm -rf /usr/local/go && tar -C /usr/local -xzf go1.22.3.linux-amd64.tar.gz +``` + +3. 添加环境变量 +``` +export PATH=$PATH:/usr/local/go/bin +``` + +4. 检查是否安装成功 +``` +go version +``` + ## 编译安装 CFSSL 编译安装 CFSSL 的参考命令如下(需要互联网下载权限,需要配置代理的请先完成配置,需要配置 go语言环境): diff --git "a/docs/zh/docs/Kubernetes/\345\256\211\350\243\205Kubernetes\350\275\257\344\273\266\345\214\205.md" "b/docs/zh/docs/Kubernetes/\345\256\211\350\243\205Kubernetes\350\275\257\344\273\266\345\214\205.md" index 98fc9552e3d9d5fe80981ee9bf43d42f2d6cfba4..924795f889b5bf8747baed8d21904f1dda27aba9 100644 --- "a/docs/zh/docs/Kubernetes/\345\256\211\350\243\205Kubernetes\350\275\257\344\273\266\345\214\205.md" +++ "b/docs/zh/docs/Kubernetes/\345\256\211\350\243\205Kubernetes\350\275\257\344\273\266\345\214\205.md" @@ -1,13 +1,11 @@ # 安装 Kubernetes 软件包 - ```bash -$ dnf install -y docker conntrack-tools socat +dnf install -y docker conntrack-tools socat ``` 配置EPOL源之后,可以直接通过 dnf 安装 K8S ```bash -$ rpm -ivh kubernetes*.rpm +dnf install kubernetes ``` - diff --git "a/docs/zh/docs/LLM/llama.cpp\344\275\277\347\224\250\346\214\207\345\215\227.md" "b/docs/zh/docs/LLM/llama.cpp\344\275\277\347\224\250\346\214\207\345\215\227.md" index 68d2ccc039b0d4ebf8e188cc5dcf47949cab96b5..609af9b39f59602c5ccd3dc9a151595287cecc7c 100644 --- "a/docs/zh/docs/LLM/llama.cpp\344\275\277\347\224\250\346\214\207\345\215\227.md" +++ "b/docs/zh/docs/LLM/llama.cpp\344\275\277\347\224\250\346\214\207\345\215\227.md" @@ -15,7 +15,7 @@ llama.cpp 核心架构分为两层: 特性: -- 基于 ggml的C/C++ 实现 +- 基于 ggml的C/C++ 实现; - 通过 int4/int8 量化、优化的KV缓存和并行计算等多种方式加速 CPU 推理; - 互动界面是流媒体生成,具有打字机效果; - 无需 GPU,可只用 CPU 运行。 diff --git "a/docs/zh/docs/NestOS/NestOS For Container\347\224\250\346\210\267\346\214\207\345\215\227.md" "b/docs/zh/docs/NestOS/NestOS For Container\347\224\250\346\210\267\346\214\207\345\215\227.md" new file mode 100644 index 0000000000000000000000000000000000000000..47385becf24cb21b9eda03ae665920b02e990079 --- /dev/null +++ "b/docs/zh/docs/NestOS/NestOS For Container\347\224\250\346\210\267\346\214\207\345\215\227.md" @@ -0,0 +1,995 @@ +# NestOS用户使用指南 + +## 1. NestOS介绍 + +### 1.1 前言 + +NestOS是麒麟软件在openEuler社区开源孵化的云底座操作系统,集成了rpm-ostree支持、ignition配置等技术,采用双根文件系统互为主备、原子化更新的设计思路,提供nestos-assembler工具快速集成构建。NestOS针对K8S、OpenStack平台进行适配,优化容器运行底噪,使系统具备十分便捷的集群组建能力,可以更安全的运行大规模的容器化工作负载。 + +本手册将完整阐述从构建、安装部署到使用NestOS的全流程,帮助用户充分利用NestOS的优势,快速高效地完成系统的配置和部署。 + +### 1.2 应用场景与优势 + +NestOS 适合作为以容器化应用为主的云场景基础运行环境,解决了在使用容器技术与容器编排技术实现业务发布、运维时与底层环境高度解耦而带来的运维技术栈不统一,运维平台重复建设等问题,保证了业务与底座操作系统运维的一致性。 + +![figure1](./figures/figure1.png) + +## 2. 环境准备 + +### 2.1 构建环境要求 + +#### 2.1.1 制作构建工具nestos-assembler环境要求 + +- 推荐使用openEuler环境 + +- 剩余可用硬盘空间 > 5G + +#### 2.1.2 构建NestOS环境要求 + +| **类别** | **要求** | +| :------: | :---------------: | +| CPU | 4vcpu | +| 内存 | 4GB | +| 硬盘 | 剩余可用空间>10GB | +| 架构 | x86_64或aarch64 | +| 其他 | 支持kvm | + +### 2.2 部署配置要求 + +| **类别** | **推荐配置** | **最低配置** | +| :------: | :-------------: | :----------: | +| CPU | >4vcpu | 1vcpu | +| 内存 | >4GB | 512M | +| 硬盘 | >20GB | 10GB | +| 架构 | x86_64、aarch64 | / | + +## 3. 快速使用 + +### 3.1 快速构建 + +1)获取nestos-assembler容器镜像 + +推荐使用基于openEuler的base镜像,更多说明请参考6.1 + +``` +docker pull hub.oepkgs.net/nestos/nestos-assembler:24.03-LTS.20240903.0-aarch64 +``` + +2)编写名为nosa的脚本并存放至/usr/local/bin,并赋予可执行权限 + +``` +#!/bin/bash + +sudo docker run --rm -it --security-opt label=disable --privileged --user=root \ + -v ${PWD}:/srv/ --device /dev/kvm --device /dev/fuse --network=host \ + --tmpfs /tmp -v /var/tmp:/var/tmp -v /root/.ssh/:/root/.ssh/ -v /etc/pki/ca-trust/:/etc/pki/ca-trust/ \ + ${COREOS_ASSEMBLER_CONFIG_GIT:+-v $COREOS_ASSEMBLER_CONFIG_GIT:/srv/src/config/:ro} \ + ${COREOS_ASSEMBLER_GIT:+-v $COREOS_ASSEMBLER_GIT/src/:/usr/lib/coreos-assembler/:ro} \ + ${COREOS_ASSEMBLER_CONTAINER_RUNTIME_ARGS} \ + ${COREOS_ASSEMBLER_CONTAINER:-nestos-assembler:your_tag} "$@" +``` + +注意修改COREOS_ASSEMBLER_CONTAINER 的值为本地环境中实际的nestos-assembler容器镜像。 + +3)获取nestos-config + +使用nosa init 初始化构建工作目录,拉取构建配置,创建工作目录nestos-build,在该目录下执行如下命令 + +``` +nosa init https://gitee.com/openeuler/nestos-config +``` + +4)调整构建配置 + +nestos-config提供默认构建配置,无需额外操作。如需调整,请参考第5章。 + +5)NestOS镜像构建 + +``` +# 拉取构建配置、更新缓存 +nosa fetch +# 生成根文件系统、qcow2及OCI镜像 +nosa build +# 生成live iso及PXE镜像 +nosa buildextend-metal +nosa buildextend-metal4k +nosa buildextend-live +``` + +详细构建及部署流程请参考第6章。 + +### 3.2 快速部署 + +以NestOS ISO镜像为例,启动进入live环境后,执行如下命令根据向导提示完成安装: + +``` +sudo installnestos +``` + +其他部署方式请参考第8章。 + +## 4. 系统默认配置 + +| **选项** | **默认配置** | +| :-------------: | :---------------------: | +| docker服务 | 默认disable,需主动开启 | +| ssh服务安全策略 | 默认仅支持密钥登录 | + +## 5. 构建配置nestos-config + +### 5.1 获取配置 + +nestos-config的仓库地址为https://gitee.com/openeuler/nestos-config + +### 5.2 配置目录结构说明 + +| **目录/****文件** | **说明** | +| :---------------: | :--------------------: | +| live/* | 构建liveiso的引导配置 | +| overlay.d/* | 自定义文件配置 | +| tests/* | 用户自定义测试用例配置 | +| *.repo | repo源配置 | +| .yaml,manifests/ | 主要构建配置 | + +### 5.3 主要文件解释 + +#### 5.3.1 repo文件 + +目录下的repo文件可用来配置用于构建nestos的软件仓库。 + +#### 5.3.2 yaml配置文件 + +目录下的yaml文件主要是提供nestos构建的各种配置,详见5.4章节。 + +### 5.4 主要字段解释 + +| **字段名称** | **作用** | +| :------------------------------------------ | ------------------------------------------------------------ | +| packages-aarch64、packages-x86_64、packages | 软件包集成范围 | +| exclude-packages | 软件包集成黑名单 | +| remove-from-packages | 从指定软件包删除文件(夹) | +| remove-files | 删除特定文件(夹) | +| extra-kargs | 额外内核引导参数 | +| initramfs-args | initramfs构建参数 | +| postprocess | 文件系统构建后置脚本 | +| default-target | 配置default-target,如 multi-user.target | +| rolij.name、releasever | 镜像相关信息(镜像名称、版本) | +| lockfile-repos | 构建可使用的仓库名列表,与5.3.1 介绍的repo文件中的仓库名需要对应 | + +### 5.5 用户可配置项说明 + +#### 5.5.1 repo源配置 + +1)在配置目录编辑repo文件,将内容修改为期望的软件仓库 + +``` +$ vim nestos-pool.repo +[repo_name_1] +Name=xxx +baseurl = https://ip.address/1 +enabled = 1 + +[repo_name_2] +Name=xxx +baseurl = https://ip.address/2 +enabled = 1 +``` + +2)修改yaml配置文件中的lockfile-repo字段内容为相应的仓库名称列表 + +注:仓库名称为repo文件中[]内的内容,不是name字段内容 + +``` +$ vim manifests/rpmlist.yaml +修改lockfile-repo字段内容为 +lockfile-repos: +- repo_name_1 +- repo_name_2 +``` + +#### 5.5.2 软件包裁剪 + +修改packages、packages-aarch64、packages-x86_64字段,可在其中添加或删除软件包。 + +如下所示,在package字段中添加了nano,构建安装后系统中会有nano 。 + +``` +$ vim manifests/rpmlist.yaml +packages: +- bootupd +... +- authselect +- nano +... +packages-aarch64: +- grub2-efi-aa64 +packages-x86_64: +- microcode_ctl +- grub2-efi-x64 +``` + +#### 5.5.3 自定义镜像名称与版本号 + +修改yaml文件中的releasever及rolij.name 字段,这些字段分别控制镜像的版本号及名称。 + +``` +$ vim manifest.yaml + +releasever: "1.0" +rojig: + license: MIT + name: nestos + summary: NestOS stable +``` + +如上配置,构建出的镜像格式为:nestos-1.0.$(date "+%Y%m%d").$build_num.$type,其中build_num为构建次数,type为类型后缀。 + +#### 5.5.4 自定义镜像中的release信息 + +正常release信息是由我们集成的release包(如openeuler-release)提供的,但是我们也可以通过添加postprocess脚本对/etc/os-release文件进行重写操作。 + +``` +$ vim manifests/ system-configuration.yaml +在postprocess添加如下内容,若已存在相关内容,则只需修改对应release信息即可 +postprocess: + - | + #!/usr/bin/env bash + set -xeuo pipefail + export OSTREE_VERSION="$(tail -1 /etc/os-release)" + date_now=$(date "+%Y%m%d") + echo -e 'NAME="openEuler NestOS"\nVERSION="24.03-LTS"\nID="openeuler"\nVERSION_ID="24.03-LTS"\nPRETTY_NAME="NestOS"\nANSI_COLOR="0;31"\nBUILDID="'${date_now}'"\nVARIANT="NestOS"\nVARIANT_ID="nestos"\n' > /usr/lib/os-release + echo -e $OSTREE_VERSION >> /usr/lib/os-release + cp -f /usr/lib/os-release /etc/os-release +``` + +#### 5.5.5 成自定义文件 + +在overlay.d目录下每个目录进行自定义文件的添加和修改,这种操作可以实现构建镜像内容的自定义。 + +``` +mkdir -p overlay.d/15nestos/etc/test/test.txt +echo "This is a test message !" > overlay.d/15nestos/etc/test/test.txt +``` + +使用如上配置进行镜像构建,启动构建出的镜像,查看系统中对应文件内容即为我们上述自定义添加的内容。 + +``` +[root@nosa-devsh ~]# cat /etc/test/test.txt +This is a test message ! +``` + +## 6.构建流程 + +NestOS采用容器化的方式将构建工具链集成为一个完整的容器镜像,称为NestOS-assembler。 + +NestOS提供构建NestOS-assembler容器镜像能力,方便用户使用。使用该容器镜像,用户可在任意linux发行版环境中构建多种形态NestOS镜像(例如在现有CICD环境中使用),也可对构建发布件进行管理、调试和自动化测试。 + +### 6.1 制作构建工具NestOS-assembler容器镜像 + +#### 6.1.1 前置步骤 + +1)准备容器base镜像 + +NestOS-assembler容器镜像需要基于支持yum/dnf软件包管理器的base镜像制作,理论上可由任意发行版base镜像制作,但为最大程度减少软件包兼容性问题,仍推荐使用基于openEuler的base镜像。 + +2)安装必要软件包 + +安装必备依赖docker + +``` +dnf install -y docker +``` + +3)克隆nestos-assembler源代码仓库 + +``` +git clone --depth=1 --single-branch https://gitee.com/openeuler/nestos-assembler.git +``` + +#### 6.1.2 构建NestOS-assembler容器镜像 + +使用openEuler容器镜像作为base镜像,使用以下指令构建: + +``` +cd nestos-assembler/ +docker build -f Dockerfile . -t nestos-assembler:your_tag +``` + +### 6.2 使用NestOS-assembler容器镜像 + +#### 6.2.1 前置步骤 + +1)准备nestos-assembler容器镜像 + +参考6.1章节构建nestos-assembler容器镜像后,可通过私有化部署容器镜像仓库对该容器镜像进行管理和分发。请确保构建NestOS前,拉取适当版本的nestos-assembler容器镜像至当前环境。 + +2)编写使用脚本nosa + +因NestOS构建过程需多次调用nestos-assembler容器镜像执行不同命令,同时需配置较多参数,为简化用户操作,可编写nosa命令脚本,可参见3.1快速构建部分。 + +#### 6.2.2 使用说明 + +构建工具命令一览 + +| **命令** | **功能说明** | +| :-------------------: | :-------------------------------------------------: | +| init | 初始化构建环境及构建配置,详见6.3 | +| fetch | 根据构建配置获取最新软件包至本地缓存 | +| build | 构建ostree commit,是构建NestOS的核心命令 | +| run | 直接启动一个qemu实例,默认使用最新构建版本 | +| prune | 清理历史构建版本,默认保留最新3个版本 | +| clean | 删除全部构建发布件,添加--all参数时同步清理本地缓存 | +| list | 列出当前构建环境中存在的版本及发布件 | +| build-fast | 基于前次构建记录快速构建新版本 | +| push-container | 推送容器镜像发布件至容器镜像仓库 | +| buildextend-live | 构建支持live环境的ISO发布件及PXE镜像 | +| buildextend-metal | 构建裸金属raw发布件 | +| buildextend-metal4k | 构建原生4K模式的裸金属raw发布件 | +| buildextend-openstack | 构建适用于openstack平台的qcow2发布件 | +| buildextend-qemu | 构建适用于qemu的qcow2发布件 | +| basearch | 获得当前架构信息 | +| compress | 压缩发布件 | +| kola | 自动化测试框架 | +| kola-run | 输出汇总结果的自动化测试封装 | +| runc | 以容器方式挂载当前构建根文件系统 | +| tag | 管理构建工程tag | +| virt-install | 通过virt-install为指定构建版本创建实例 | +| meta | 管理构建工程元数据 | +| shell | 进入nestos-assembler容器镜像 | + +### 6.3 准备构建环境 + +NestOS构建环境需要独立的空文件夹作为工作目录,且支持多次构建,保留、管理历史构建版本。创建构建环境前需首先准备构建配置(参考第5章)。 + +建议一份独立维护的构建配置对应一个独立的构建环境,即如果您希望构建多个不同用途的NestOS,建议同时维护多份构建配置及对应的构建环境目录,这样可以保持不同用途的构建配置独立演进和较为清晰的版本管理。 + +#### 6.3.1 初始化构建环境 + +进入待初始化工作目录,执行如下命令即可初始化构建环境: + +``` +nosa init https://gitee.com/openeuler/nestos-config +``` + +仅首次构建时需初始化构建环境,后续构建在不对构建配置做出重大更改的前提下,可重复使用该构建环境。 + +#### 6.3.2 构建环境说明 + +初始化完成后,工作目录创建出如下文件夹: + +**builds:**构建发布件及元数据存储目录,latest子目录软链接指向最新构建版本。 + +**cache:**缓存目录,根据构建配置中的软件源及软件包列表拉取至本地,历史构建NestOS的ostree repo均缓存于此目录。 + +**overrides:**构建过程希望附加到最终发布件rootfs中的文件或rpm包可置于此目录。 + +**src:**构建配置目录,存放nestos-config相关内容。 + +**tmp:**临时目录,构建过程、自动化测试等场景均会使用该目录作为临时目录,构建发生异常时可在此处查看虚拟机命令行输出、journal日志等信息。 + +### 6.4 构建步骤 + +NestOS构建主要步骤及参考命令如下: + +![figure2](./figures/figure2.png) + +#### 6.4.1 首次构建 + +首次构建时需初始化构建环境,详见6.3。 + +非首次构建可直接使用原构建环境,可通过nosa list查看当前构建环境已存在版本及对应发布件。 + +#### 6.4.2 更新构建配置及缓存 + +初始化构建环境后,执行如下命令更新构建配置及缓存: + +``` +nosa fetch +``` + +该步骤初步校验构建配置是否可用,并通过配置的软件源拉取软件包至本地缓存。当构建配置发生变更或单纯希望更新软件源中最新版本软件包,均需要重新执行该步骤,否则可能导致构建失败或不符合预期。 + +当构建配置发生较大变更,希望清空本地缓存重新拉取时,需执行如下命令: + +``` +nosa clean --all +``` + +#### 6.4.3 构建不可变根文件系统 + +NestOS不可变操作系统的核心是基于ostree技术的不可变根文件系统,执行如下步骤构建ostree文件系统: + +``` +nosa build +``` + +build命令默认会生成ostree文件系统和OCI归档文件,您也可以在执行命令时同步添加qemu、metal、metal4k中的一个或多个,同步构建发布件,等效于后续继续执行buildextend-qemu、buildextend-metal和buildextend-metal4k命令。 + +``` +nosa build qemu metal metal4k +``` + +如您希望在构建NestOS时,添加自定义文件或rpm包,请在执行build命令前将相应文件放入构建环境overrides目录下rootfs/或rpm/文件夹。 + +#### 6.4.4 构建各类发布件 + +build命令执行完毕后,可继续执行buildextend-XXX命令用于构建各类型发布件,具体介绍如下: + +- 构建qcow2镜像 + +``` +nosa buildextend-qemu +``` + +- 构建带live环境的ISO镜像或PXE启动组件 + +``` +nosa buildextend-metal +nosa buildextend-metal4k +nosa buildextend-live +``` + +- 构建适用于openstack环境的qcow2镜像 + +``` +nosa buildextend-openstack +``` + +- 构建适用于容器镜像方式更新的容器镜像 + +执行nosa build命令构建ostree文件系统时,会同时生成ociarchive格式镜像,该镜像可直接执行如下命令推送到本地或远程镜像仓库,无需执行其他构建步骤。 + +``` +nosa push-container [container-image-name] +``` + + 远程镜像仓库地址需附加到推送容器镜像名称中,且除隔离镜像tag外,不得出现":"。如未检测到":",该命令会自动生成{latest_build}-{arch}格式的tag。示例如下: + +``` +nosa push-container registry.example.com/nestos:1.0.20240903.0-x86_64 +``` + +该命令支持以下可选参数: + +--authfile :指定登录远程镜像仓库的鉴权文件 + +--insecure:如远程镜像仓库采用自签名证书等场景,添加该参数可不校验SSL/TLS协议 + +--transport:指定目标镜像推送协议,默认为docker,具体支持项及说明如下: + +​ containers-storage:推送至podman、crio等容器引擎本地存储目录 + +​ dir:推送至指定本地目录 + +​ docker:以docker API推送至私有或远端容器镜像仓库 + +​ docker-archive:等效于docker save导出归档文件,可供docker load使用 + +​ docker-daemon:推送至docker容器引擎本地存储目录 + +### 6.5 获取发布件 + +构建完毕后,发布件均生成于构建环境中如下路径: + +``` +builds/{version}/{arch}/ +``` + +如您仅关心最新构建版本或通过CI/CD调用,提供latest目录软链接至最新版本目录,即: + +``` +builds/latest/{arch}/ +``` + +为方便传输,您可以调用如下命令,压缩发布件体积: + +``` +nosa compress +``` + +压缩后原文件会被移除,会导致部分调试命令无法使用,可以调用解压命令恢复原文件: + +``` +nosa uncompress +``` + +### 6.6 构建环境维护 + +在构建NestOS环境前后,可能存在如下需求,可使用推荐的命令解决相应问题: + +#### 6.6.1 清理历史或无效构建版本,以释放磁盘空间 + +可以通过以下命令清理历史版本构建: + +``` +nosa prune +``` + +也可删除当前构建环境中的全部发布件: + +``` +nosa clean +``` + +如构建配置更换过软件源或历史缓存无保留价值,可彻底清理当前构建环境缓存: + +``` +nosa clean --all +``` + +#### 6.6.2 临时运行构建版本实例,用于调试或确认构建正确 + +``` +nosa run +``` + +可通过--qemu-image或--qemu-iso指定启动镜像地址,其余参数请参考nosa run --help说明。 + +实例启动后,构建环境目录会被挂载至/var/mnt/workdir,可通过构建环境目录 + +#### 6.6.3 运行自动化测试 + +``` +nosa kola run +``` + +该命令会执行预设的测试用例,也可在其后追加测试用例名称,单独执行单条用例。 + +``` +nosa kola testiso +``` + +该命令会执行iso或pxe live环境安装部署测试,可作为构建工程的冒烟测试。 + +#### 6.6.4 调试验证构建工具(NestOS-assembler) + +``` +nosa shell +``` + +该命令可启动进入构建工具链容器的shell环境,您可以通过此命令验证构建工具链工作环境是否正常。 + +## 7. 部署配置 + +### 7.1 前言 + +在开始部署NestOS之前,了解和准备必要的配置是至关重要的。NestOS通过点火文件(ignition文件)提供了一系列灵活的配置选项,可以通过Butane工具进行管理,方便用户进行自动化部署和环境设置。 + +在本章节中,将详细的介绍Butane工具的功能和使用方法,并根据不同场景提供配置示例。这些配置将帮助您快速启动和运行NestOS,在满足应用需求的同时,确保系统的安全性和可靠性。此外,还会介绍如何自定义镜像,将点火文件预集成至镜像中,以满足特定应用场景的需求,从而实现高效的配置和部署NestOS。 + +### 7.2 Butane简介 + +Butane是一个用于将人类可读的YAML配置文件转换为NestOS点火文件(Ignition 文件)的工具。Butane工具简化了复杂配置的编写过程,允许用户以更易读的格式编写配置文件,然后将其转换为适合NestOS使用的JSON格式。 + +NestOS对Butane进行了适配修改,新增nestos变体支持和配置规范版本v1.0.0,对应的点火(ignition)配置规范为v3.3.0,确保了配置的稳定性和兼容性。 + +### 7.3 Butane使用 + +安装butane软件包 + +``` +dnf install butane +``` + +编辑example.yaml并执行以下指令将其转换为点火文件example.ign,其中关于yaml文件的编写,将在后续展开: + +``` +butane example.yaml -o example.ign -p +``` + +### 7.4 支持的功能场景 + +以下配置示例(example.yaml)简述了NestOS主要支持的功能场景和进阶使用方法。 + +#### 7.4.1 设置用户和组并配置密码/密钥 + +``` +variant: nestos +version: 1.0.0 +passwd: + users: + - name: nest + ssh_authorized_keys: + - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDHn2eh... + - name: jlebon + groups: + - wheel + ssh_authorized_keys: + - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDC5QFS... + - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIveEaMRW... + - name: miabbott + groups: + - docker + - wheel + password_hash: $y$j9T$aUmgEDoFIDPhGxEe2FUjc/$C5A... + ssh_authorized_keys: + - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDTey7R... +``` + +#### 7.4.2 文件操作——以配置网卡为例 + +``` +variant: nestos +version: 1.0.0 +storage: + files: + - path: /etc/NetworkManager/system-connections/ens2.nmconnection + mode: 0600 + contents: + inline: | + [connection] + id=ens2 + type=ethernet + interface-name=ens2 + [ipv4] + address1=10.10.10.10/24,10.10.10.1 + dns=8.8.8.8; + dns-search= + may-fail=false + method=manual +``` + +#### 7.4.3 创建目录、文件、软连接并配置权限 + +``` +variant: nestos +version: 1.0.0 +storage: + directories: + - path: /opt/tools + overwrite: true + files: + - path: /var/helloworld + overwrite: true + contents: + inline: Hello, world! + mode: 0644 + user: + name: dnsmasq + group: + name: dnsmasq + - path: /opt/tools/transmogrifier + overwrite: true + contents: + source: https://mytools.example.com/path/to/archive.gz + compression: gzip + verification: + hash: sha512-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + mode: 0555 + links: + - path: /usr/local/bin/transmogrifier + overwrite: true + target: /opt/tools/transmogrifier + hard: false +``` + +#### 7.4.4 编写systemd服务——以启停容器为例 + +``` +variant: nestos +version: 1.0.0 +systemd: + units: + - name: hello.service + enabled: true + contents: | + [Unit] + Description=MyApp + After=network-online.target + Wants=network-online.target + + [Service] + TimeoutStartSec=0 + ExecStartPre=-/bin/podman kill busybox1 + ExecStartPre=-/bin/podman rm busybox1 + ExecStartPre=/bin/podman pull busybox + ExecStart=/bin/podman run --name busybox1 busybox /bin/sh -c ""trap 'exit 0' INT TERM; while true; do echo Hello World; sleep 1; done"" + + [Install] + WantedBy=multi-user.target +``` + +### 7.5 点火文件预集成 + +NestOS构建工具链支持用户根据实际使用场景和需求定制镜像。在镜像制作完成后,nestos-installer还提供了针对镜像部署与应用等方面进行自定义的一系列功能,如嵌入点火文件、预分配安装位置、增删内核参数等功能,以下将针对主要功能进行介绍。 + +#### 7.5.1 点火文件预集成至ISO镜像 + +准备好NestOS的ISO镜像至本地;安装nestos-installer软件包;编辑example.yaml,并使用butane工具将其转换为ign文件,在这里,我们仅配置简单的用户名和密码(密码要求加密,示例中为qwer1234),内容如下: + +``` +variant: nestos +version: 1.0.0 +passwd: + users: + - name: root + password_hash: "$1$root$CPjzNGH.NqmQ7rh26EeXv1" +``` + +将上述yaml转换为ign文件后,执行如下指令嵌入点火文件并指定目标磁盘位置,其中xxx.iso为准备至本地的NestOS ISO镜像: + +``` +nestos-installer iso customize --dest-device /dev/sda --dest-ignition example.ign xxx.iso +``` + +使用该集成点火文件的ISO镜像进行安装时,NestOS会自动读取点火文件并安装至目标磁盘,待进度条完成度为100%后,自动进入安装好的NestOS环境,用户可根据ign文件配置的用户名和密码进入系统。 + +#### 7.5.2 点火文件预集成至PXE镜像 + +准备好NestOS的PXE镜像至本地,组件获取方式参考6.5【获取发布件】章节,其他步骤同上。 + +为了方便用户使用,nestos-installer也支持从ISO镜像中提取PXE组件的功能,执行如下指令,其中xxx.iso为保存至本地的NestOS ISO镜像: + +``` +nestos-installer iso extract pxe xxx.iso +``` + +得到如下输出件: + +``` +xxx-initrd.img +xxx-rootfs.img +xxx-vmlinuz +``` + +执行如下指令嵌入点火文件并指定目标磁盘位置: + +``` +nestos-installer pxe customize --dest-device /dev/sda --dest-ignition example.ign xxx-initrd.img --output custom-initrd.img +``` + +根据使用PXE安装NestOS的方式,替换相应的xxx-initrd.img为custom-initrd.img。启动后NestOS会自动读取点火文件并安装至目标磁盘,待进度条完成度为100%后,自动进入安装好的NestOS环境,用户可根据ign文件配置的用户名和密码进入系统。 + +## 8. 部署流程 + +### 8.1 简介 + +NestOS支持多种部署平台及常见部署方式,当前主要支持qcow2、ISO与PXE三种部署方式。与常见通用OS部署相比,主要区别在于如何传入以ign文件为特征的自定义部署配置,以下各部分将会分别介绍。 + +### 8.2 使用qcow2镜像安装 + +#### 8.2.1 使用qemu创建qcow2实例 + +准备NestOS的qcow2镜像及相应点火文件(详见第7章),终端执行如下步骤: + +``` +IGNITION_CONFIG="/path/to/example.ign" +IMAGE="/path/to/image.qcow2" +IGNITION_DEVICE_ARG="-fw_cfg name=opt/com.coreos/config,file=${IGNITION_CONFIG}" + +qemu-img create -f qcow2 -F qcow2 -b ${IMAGE} my-nestos-vm.qcow2 +``` + +aarch64环境执行如下命令: + +``` +qemu-kvm -m 2048 -M virt -cpu host -nographic -drive if=virtio,file=my-nestos-vm.qcow2 ${IGNITION_DEVICE_ARG} -nic user,model=virtio,hostfwd=tcp::2222-:22 -bios /usr/share/edk2/aarch64/QEMU_EFI-pflash.raw +``` + +x86_64环境执行如下命令: + +``` +qemu-kvm -m 2048 -M pc -cpu host -nographic -drive if=virtio,file=my-nestos-vm.qcow2 ${IGNITION_DEVICE_ARG} -nic user,model=virtio,hostfwd=tcp::2222-:22 +``` + +#### 8.2.2 使用virt-install创建qcow2实例 + +假设libvirt服务正常,网络默认采用default子网,绑定virbr0网桥,您可参考以下步骤创建NestOS实例。 + +准备NestOS的qcow2镜像及相应点火文件(详见第7章),终端执行如下步骤: + +``` +IGNITION_CONFIG="/path/to/example.ign" +IMAGE="/path/to/image.qcow2" +VM_NAME="nestos" +VCPUS="4" +RAM_MB="4096" +DISK_GB="10" +IGNITION_DEVICE_ARG=(--qemu-commandline="-fw_cfg name=opt/com.coreos/config,file=${IGNITION_CONFIG}") +``` + +**注意:使用virt-install安装,qcow2镜像及ign文件需指定绝对路径。** + +执行如下命令创建实例: + +``` +virt-install --connect="qemu:///system" --name="${VM_NAME}" --vcpus="${VCPUS}" --memory="${RAM_MB}" --os-variant="kylin-hostos10.0" --import --graphics=none --disk="size=${DISK_GB},backing_store=${IMAGE}" --network bridge=virbr0 "${IGNITION_DEVICE_ARG[@]} +``` + +### 8.3 使用ISO镜像安装 + +准备NestOS的ISO镜像并启动。首次启动的NestOS ISO镜像会默认进入Live环境,该环境为易失的内存环境。 + +#### 8.3.1 通过nestos-installer安装向导脚本安装OS至目标磁盘 + +1)在NestOS的Live环境中,根据首次进入的打印提示,可输入以下指令,即可自动生成一份简易的点火文件并自动安装重启 + +``` +sudo installnestos +``` + +2)根据终端提示信息依次输入用户名和密码; + +3)选择目标磁盘安装位置,可直接选择回车设置为默认项/dev/sda; + +4)执行完以上步骤后,nestos-installer开始根据我们提供的配置将NestOS安装至目标磁盘,待进度条100%后,自动重启; + +5)重启后自动进入NestOS,在grub菜单直接回车或者等待5s后启动系统,随后根据此前配置的用户名和密码进入系统。至此,安装完成。 + +#### 8.3.2 通过nestos-installer命令手动安装OS至目标磁盘 + +1)准备好点火文件example.ign(详见第7章); + +2)根据首次进入NestOS的Live环境打印的提示,输入以下指令开始安装: + +``` +sudo nestos-installer install /dev/sda --ignition-file example.ign +``` + +如具备网络条件,点火文件也可通过网络获取,如: + +``` +sudo nestos-installer install /dev/sda --ignition-file http://www.example.com/example.ign +``` + +3)执行完上述指令后,nestos-installer开始根据我们提供的配置将NestOS安装至目标磁盘,待进度条100%后,自动重启; + +4)重启后自动进入NestOS,在gurb菜单直接回车或者等待5s后启动系统,随后根据此前配置的用户名和密码进入系统。至此,安装完成 + +### 8.4 PXE部署 + +NestOS的PXE安装组件包括kernel、initramfs.img和rootfs.img。这些组件以nosa buildextend-live命令生成(详见第6章)。 + +1)使用PXELINUX 的kernel命令行指定内核,简单示例如下: + +``` +KERNEL nestos-live-kernel-x86_64 +``` + +2)使用PXELINUX 的append命令行指定initrd和rootfs,简单示例如下: + +``` +APPEND initrd=nestos-live-initramfs.x86_64.img,nestos-live-rootfs.x86_64.img +``` + +**注意:如您采用7.5章节所述,已将点火文件预集成至PXE组件,则仅需在此进行替换,无需执行后续步骤。** + +3)指定安装位置,以/dev/sda为例,在APPEND后追加,示例如下: + +``` +nestosos.inst.install_dev=/dev/sda +``` + +4)指定点火文件,需通过网络获取,在APPEND后追加相应地址,示例如下: + +``` +nestos.inst.ignition_url=http://www.example.com/example.ign +``` + +5)启动后NestOS会自动读取点火文件并安装至目标磁盘,待进度条完成度为100%后,自动进入安装好的NestOS环境,用户可根据ign文件配置的用户名和密码进入系统。 + +## 9. 基本使用 + +### 9.1 简介 + +NestOS采用基于ostree和rpm-ostree技术的操作系统封装方案,将关键目录设置为只读状态,核心系统文件和配置不会被意外修改;采用overlay分层思想,允许用户在基础ostree文件系统之上分层管理RPM包,不会破坏初始系统体系结构;同时支持构建OCI格式镜像,实现以镜像为最小粒度进行操作系统版本的切换。 + +### 9.2 SSH连接 + +出于安全考虑,NestOS 默认不支持用户使用密码进行SSH登录,而只能使用密钥认证方式。这一设计旨在增强系统的安全性,防止因密码泄露或弱密码攻击导致的潜在安全风险。 + +NestOS通过密钥进行SSH连接的方法与openEuler一致,如果用户需要临时开启密码登录,可按照以下步骤执行: + +1)编辑ssh服务附加配置文件 + +``` +vi /etc/ssh/sshd_config.d/40-disable-passwords.conf +``` + +2)修改默认配置PasswordAuthentication为如下内容: + +``` +PasswordAuthentication yes +``` + +3)重启sshd服务,便可实现临时使用密码进行SSH登录。 + +### 9.3 RPM包安装 + +**注意:不可变操作系统不提倡在运行环境中安装软件包,提供此方法仅供临时调试等场景使用,因业务需求需要变更集成软件包列表请通过更新构建配置重新构建实现。** + +NestOS不支持常规的包管理器dnf/yum,而是通过rpm-ostree来管理系统更新和软件包安装。rpm-ostree结合了镜像和包管理的优势,允许用户在基础系统之上分层安装和管理rpm包,并且不会破环初始系统的结构。使用以下命令安装rpm包: + +``` +rpm-ostree install +``` + +安装完成后,重新启动操作系统,可以看到引导加载菜单出现了两个分支,默认第一个分支为最新的分支 + +``` +systemctl reboot +``` + +重启进入系统,查看系统包分层状态,可看到当前版本已安装 + +``` +rpm-ostree status -v +``` + +### 9.4 版本回退(临时/永久) + +更新/rpm包安装完成后,上一版本的操作系统部署仍会保留在磁盘上。如果更新导致问题,用户可以使用rpm-ostree进行版本回退,这一步操作需要用户手动操作,具体流程如下: + +#### 9.4.1 临时回退 + +要临时回滚到之前的OS部署,在系统启动过程中按住shift键,当引导加载菜单出现时,在菜单中选择相应的分支(默认有两个,选择另外一个即可)。在此之前,可以使用以下指令查看当前环境中已存在的两个版本分支: + +``` +rpm-ostree status +``` + +#### 9.4.2 永久回退 + +要永久回滚到之前的操作系统部署,用户需在当前版本中运行如下指令,此操作将使用之前版本的系统部署作为默认部署。 + +``` +rpm-ostree rollback +``` + +重新启动以生效,引导加载菜单的默认部署选项已经改变,无需用户手动切换。 + +``` +systemctl reboot +``` + +## 10. 容器镜像方式更新 + +### 10.1 应用场景说明 + +NestOS作为基于不可变基础设施思想的容器云底座操作系统,将文件系统作为一个整体进行分发和更新。这一方案在运维与安全方面带来了巨大的便利。然而,在实际生产环境中,官方发布的版本往往难以满足用户的需求。例如,用户可能希望在系统中默认集成自维护的关键基础组件,或者根据特定场景的需求对软件包进行进一步的裁剪,以减少系统的运行负担。因此,与通用操作系统相比,用户对NestOS有着更强烈和更频繁的定制需求。 + + NestOS-assembler 可提供符合OCI标准的容器镜像,且不仅是将根文件系统打包分发,利用ostree native container特性,可使容器云场景用户使用熟悉的技术栈,只需编写一个ContainerFile(Dockerfile)文件,即可轻松构建定制版镜像,用于自定义集成组件或后续的升级维护工作。 + +### 10.2 使用方式 + +#### 10.2.1 定制镜像 + +- 基本步骤 + +(1) 参考第6章构建NestOS容器镜像,可使用nosa push-container命令推送至公共或私有容器镜像仓库。 + +(2) 编写Containerfile(Dockerfile)示例如下: + +``` +FROM registry.example.com/nestos:1.0.20240603.0-x86_64 + +# 执行自定义构建步骤,例如安装软件或拷贝自构建组件 +# 此处以安装strace软件包为例 +RUN rpm-ostree install strace && rm -rf /var/cache && ostree container commit +``` + +(3)执行docker build或集成于CICD中构建相应镜像 + +- 注意事项 + +(1) NestOS 无yum/dnf包管理器,如需安装软件包可采用rpm-ostree install命令安装本地rpm包或软件源中提供软件 + +(2) 如有需求也可修改/etc/yum.repo.d/目录下软件源配置 + +(3) 每层有意义的构建命令末尾均需添加&& ostree container commit命令,从构建容器镜像最佳实践角度出发,建议尽可能减少RUN层的数量 + +(4) 构建过程中会对非/usr或/etc目录内容进行清理,因此通过容器镜像方式定制主要适用于软件包或组件更新,请勿通过此方式进行系统维护或配置变更(例如添加用户useradd) + +#### 10.2.2 部署/升级镜像 + +假设上述步骤构建容器镜像被推送为registry.example.com/nestos:1.0.20240903.0-x86_64。 + +在已部署NestOS的环境中执行如下命令: + +``` +sudo rpm-ostree rebase ostree-unverified-registry:registry.example.com/nestos:1.0.20240903.0-x86_64 +``` + +重新引导后完成定制版本部署。 + +当您使用容器镜像方式部署后,rpm-ostree upgrade 默认会将更新源从ostree更新源地址更新为容器镜像地址。之后,您可以在相同的tag下更新容器镜像,使用 rpm-ostree upgrade 可以检测远端镜像是否已经更新,如果有变更,它会拉取最新的镜像并完成部署。 diff --git a/docs/zh/docs/NestOS/figures/figure1.png b/docs/zh/docs/NestOS/figures/figure1.png new file mode 100644 index 0000000000000000000000000000000000000000..b4eb9017ed202e854c076802492d8561942dfc88 Binary files /dev/null and b/docs/zh/docs/NestOS/figures/figure1.png differ diff --git a/docs/zh/docs/NestOS/figures/figure2.png b/docs/zh/docs/NestOS/figures/figure2.png new file mode 100644 index 0000000000000000000000000000000000000000..90049769c04e2bd494533da1613e38a5199da3d7 Binary files /dev/null and b/docs/zh/docs/NestOS/figures/figure2.png differ diff --git a/docs/zh/docs/NestOS/overview.md b/docs/zh/docs/NestOS/overview.md index e3b20eb3686e4fce9b34a3786fec7b33e6678599..1d744c820ca42dca9441b53db275b9d72cddaa21 100644 --- a/docs/zh/docs/NestOS/overview.md +++ b/docs/zh/docs/NestOS/overview.md @@ -1,3 +1,4 @@ -# NestOS用户指南 +# NestOS云底座操作系统 -本文介绍云底座操作系统NestOS的安装部署与各个特性说明和使用方法,使用户能够快速了解并使用NestOS。Nestos搭载了docker、iSulad、podman、cri-o等常见容器引擎,将ignition配置、rpm-ostree、OCI支持、SElinux强化等技术集成在一起,采用基于双系统分区、容器技术和集群架构的设计思路,可以适配云场景下多种基础运行环境。同时NestOS针对Kubernetes进行优化,在IaaS生态构建方面,针对openStack、oVirt等平台提供支持;在PaaS生态构建方面,针对OKD、Rancher等平台提供支持,使系统具备十分便捷的集群组件能力,可以更安全的运行大规模的容器化工作负载。镜像下载地址详见[NestOS仓库](https://gitee.com/openeuler/NestOS)。 \ No newline at end of file +本文介绍云底座操作系统NestOS For Container(下称NestOS)的安装部署与各个特性说明和使用方法,使用户能够快速了解并使用NestOS。NestOS For Virt的使用方法与通用操作系统使用方法一致,可参考欧拉官方文档。 +Nestos搭载了docker、iSulad、podman、cri-o等常见容器引擎,将ignition配置、rpm-ostree、OCI支持、SElinux强化等技术集成在一起,采用基于双系统分区、容器技术和集群架构的设计思路,可以适配云场景下多种基础运行环境。同时NestOS针对Kubernetes进行优化,在IaaS生态构建方面,针对openStack、oVirt等平台提供支持;在PaaS生态构建方面,针对OKD、Rancher等平台提供支持,使系统具备十分便捷的集群组建能力,可以更安全的运行大规模的容器化工作负载。镜像下载地址详见[NestOS官网](https://nestos.openeuler.org/)。 diff --git "a/docs/zh/docs/NestOS/\344\275\277\347\224\250\346\226\271\346\263\225.md" "b/docs/zh/docs/NestOS/\344\275\277\347\224\250\346\226\271\346\263\225.md" deleted file mode 100644 index 64d86973bc37dc83903c05f0a5b6d826edbb92c6..0000000000000000000000000000000000000000 --- "a/docs/zh/docs/NestOS/\344\275\277\347\224\250\346\226\271\346\263\225.md" +++ /dev/null @@ -1,906 +0,0 @@ -# 基于NestOS容器化部署Kubernetes - -​ - -## 整体方案 - -Kubernetes(k8s)是为容器服务而生的一个可移植容器的编排管理工具。本指南旨在提供NestOS快速容器化部署k8s的解决方案。该方案以虚拟化平台创建多个NestOS节点作为部署k8s的验证环境,并通过编写Ignition文件的方式,提前将k8s所需的环境配置到一个yaml文件中。在安装NestOS操作系统的同时,即可完成对k8s所需资源的部署并创建节点。裸金属环境也可以参考本文并结合NestOS裸金属安装文档完成k8s部署。 - -- 版本信息: - - - NestOS镜像版本:22.09 - - - k8s版本:v1.23.10 - - - isulad版本:2.0.16 - -- 安装要求 - - 每台机器2GB或更多的RAM - - CPU2核心及以上 - - 集群中所有机器之间网络互通 - - 节点之中不可以有重复的主机名 - - 可以访问外网,需要拉取镜像 - - 禁止swap分区 - - 关闭selinux -- 部署内容 - - NestOS镜像以集成isulad和kubeadm、kubelet、kubectl等二进制文件 - - 部署k8s Master节点 - - 部署容器网络插件 - - 部署k8s Node节点,将节点加入k8s集群中 - -## K8S节点配置 - -NestOS通过Ignition文件机制实现节点批量配置。本章节简要介绍Ignition文件的生成方法,并提供容器化部署k8s时的Ignition配置示例。NestOS节点系统配置内容如下: - -| 配置项 | 用途 | -| ------------ | -------------------------------------- | -| passwd | 配置节点登录用户和访问鉴权等相关信息 | -| hostname | 配置节点的hostname | -| 时区 | 配置节点的默认时区 | -| 内核参数 | k8s部署环境需要开启部分内核参数 | -| 关闭selinux | k8s部署环境需要关闭selinux | -| 设置时间同步 | k8s部署环境通过chronyd服务同步集群时间 | - -### 生成登录密码 - -使用密码登录方式访问NestOS实例,可使用下述命令生成${PASSWORD_HASH} 供点火文件配置使用: - -``` -openssl passwd -1 -salt yoursalt -``` - -### 生成ssh密钥对 - -采用ssh公钥方式访问NestOS实例,可通过下述命令生成ssh密钥对: - -``` -ssh-keygen -N '' -f /root/.ssh/id_rsa -``` - -查看公钥文件id_rsa.pub,获取ssh公钥信息后供Ignition文件配置使用: - -``` -cat /root/.ssh/id_rsa.pub -``` - -### 编写butane配置文件 - -本配置文件示例中,下列字段均需根据实际部署情况自行配置。部分字段上文提供了生成方法: - -- ${PASSWORD_HASH}:指定节点的登录密码 -- ${SSH-RSA}:配置节点的公钥信息 -- ${MASTER_NAME}:配置主节点的hostname -- ${MASTER_IP}:配置主节点的IP -- ${MASTER_SEGMENT}:配置主节点的网段 -- ${NODE_NAME}:配置node节点的hostname -- ${NODE_IP}:配置node节点的IP -- ${GATEWAY}:配置节点网关 -- ${service-cidr}:指定service分配的ip段 -- ${pod-network-cidr}:指定pod分配的ip段 -- ${image-repository}:指定镜像仓库地址,例:https://registry.cn-hangzhou.aliyuncs.com -- ${token}:加入集群的token信息,通过master节点获取 - -master节点butane配置文件示例: - -```yaml -variant: fcos -version: 1.1.0 -##passwd相关配置 -passwd: - users: - - name: root - ##登录密码 - password_hash: "${PASSWORD_HASH}" - "groups": [ - "adm", - "sudo", - "systemd-journal", - "wheel" - ] - ##ssh公钥信息 - ssh_authorized_keys: - - "${SSH-RSA}" -storage: - directories: - - path: /etc/systemd/system/kubelet.service.d - overwrite: true - files: - - path: /etc/hostname - mode: 0644 - contents: - inline: ${MASTER_NAME} - - path: /etc/hosts - mode: 0644 - overwrite: true - contents: - inline: | - 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 - ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 - ${MASTER_IP} ${MASTER_NAME} - ${NODE_IP} ${NODE_NAME} - - path: /etc/NetworkManager/system-connections/ens2.nmconnection - mode: 0600 - overwrite: true - contents: - inline: | - [connection] - id=ens2 - type=ethernet - interface-name=ens2 - [ipv4] - address1=${MASTER_IP}/24,${GATEWAY} - dns=8.8.8.8 - dns-search= - method=manual - - path: /etc/sysctl.d/kubernetes.conf - mode: 0644 - overwrite: true - contents: - inline: | - net.bridge.bridge-nf-call-iptables=1 - net.bridge.bridge-nf-call-ip6tables=1 - net.ipv4.ip_forward=1 - - path: /etc/isulad/daemon.json - mode: 0644 - overwrite: true - contents: - inline: | - { - "exec-opts": ["native.cgroupdriver=systemd"], - "group": "isula", - "default-runtime": "lcr", - "graph": "/var/lib/isulad", - "state": "/var/run/isulad", - "engine": "lcr", - "log-level": "ERROR", - "pidfile": "/var/run/isulad.pid", - "log-opts": { - "log-file-mode": "0600", - "log-path": "/var/lib/isulad", - "max-file": "1", - "max-size": "30KB" - }, - "log-driver": "stdout", - "container-log": { - "driver": "json-file" - }, - "hook-spec": "/etc/default/isulad/hooks/default.json", - "start-timeout": "2m", - "storage-driver": "overlay2", - "storage-opts": [ - "overlay2.override_kernel_check=true" - ], - "registry-mirrors": [ - "docker.io" - ], - "insecure-registries": [ - "${image-repository}" - ], - "pod-sandbox-image": "k8s.gcr.io/pause:3.6", - "native.umask": "secure", - "network-plugin": "cni", - "cni-bin-dir": "/opt/cni/bin", - "cni-conf-dir": "/etc/cni/net.d", - "image-layer-check": false, - "use-decrypted-key": true, - "insecure-skip-verify-enforce": false, - "cri-runtimes": { - "kata": "io.containerd.kata.v2" - } - } - - path: /root/pull_images.sh - mode: 0644 - overwrite: true - contents: - inline: | - #!/bin/sh - KUBE_VERSION=v1.23.10 - KUBE_PAUSE_VERSION=3.6 - ETCD_VERSION=3.5.1-0 - DNS_VERSION=v1.8.6 - CALICO_VERSION=v3.19.4 - username=${image-repository} - images=( - kube-proxy:${KUBE_VERSION} - kube-scheduler:${KUBE_VERSION} - kube-controller-manager:${KUBE_VERSION} - kube-apiserver:${KUBE_VERSION} - pause:${KUBE_PAUSE_VERSION} - etcd:${ETCD_VERSION} - ) - for image in ${images[@]} - do - isula pull ${username}/${image} - isula tag ${username}/${image} k8s.gcr.io/${image} - isula rmi ${username}/${image} - done - isula pull ${username}/coredns:${DNS_VERSION} - isula tag ${username}/coredns:${DNS_VERSION} k8s.gcr.io/coredns/coredns:${DNS_VERSION} - isula rmi ${username}/coredns:${DNS_VERSION} - isula pull calico/node:${CALICO_VERSION} - isula pull calico/cni:${CALICO_VERSION} - isula pull calico/kube-controllers:${CALICO_VERSION} - isula pull calico/pod2daemon-flexvol:${CALICO_VERSION} - touch /var/log/pull-images.stamp - - path: /etc/systemd/system/kubelet.service.d/10-kubeadm.conf - mode: 0644 - contents: - inline: | - # Note: This dropin only works with kubeadm and kubelet v1.11+ - [Service] - Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf" - Environment="KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml" - # This is a file that "kubeadm init" and "kubeadm join" generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically - EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env - # This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use - # the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file. - EnvironmentFile=-/etc/sysconfig/kubelet - ExecStart= - ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS - - path: /root/init-config.yaml - mode: 0644 - contents: - inline: | - apiVersion: kubeadm.k8s.io/v1beta2 - kind: InitConfiguration - nodeRegistration: - criSocket: /var/run/isulad.sock - name: k8s-master01 - kubeletExtraArgs: - volume-plugin-dir: "/opt/libexec/kubernetes/kubelet-plugins/volume/exec/" - --- - apiVersion: kubeadm.k8s.io/v1beta2 - kind: ClusterConfiguration - controllerManager: - extraArgs: - flex-volume-plugin-dir: "/opt/libexec/kubernetes/kubelet-plugins/volume/exec/" - kubernetesVersion: v1.23.10 - imageRepository: k8s.gcr.io - controlPlaneEndpoint: "${MASTER_IP}:6443" - networking: - serviceSubnet: "${service-cidr}" - podSubnet: "${pod-network-cidr}" - dnsDomain: "cluster.local" - dns: - type: CoreDNS - imageRepository: k8s.gcr.io/coredns - imageTag: v1.8.6 - links: - - path: /etc/localtime - target: ../usr/share/zoneinfo/Asia/Shanghai - -systemd: - units: - - name: kubelet.service - enabled: true - contents: | - [Unit] - Description=kubelet: The Kubernetes Node Agent - Documentation=https://kubernetes.io/docs/ - Wants=network-online.target - After=network-online.target - - [Service] - ExecStart=/usr/bin/kubelet - Restart=always - StartLimitInterval=0 - RestartSec=10 - - [Install] - WantedBy=multi-user.target - - - name: set-kernel-para.service - enabled: true - contents: | - [Unit] - Description=set kernel para for Kubernetes - ConditionPathExists=!/var/log/set-kernel-para.stamp - - [Service] - Type=oneshot - RemainAfterExit=yes - ExecStart=modprobe br_netfilter - ExecStart=sysctl -p /etc/sysctl.d/kubernetes.conf - ExecStart=/bin/touch /var/log/set-kernel-para.stamp - - [Install] - WantedBy=multi-user.target - - - name: pull-images.service - enabled: true - contents: | - [Unit] - Description=pull images for kubernetes - ConditionPathExists=!/var/log/pull-images.stamp - - [Service] - Type=oneshot - RemainAfterExit=yes - ExecStart=systemctl start isulad - ExecStart=systemctl enable isulad - ExecStart=sh /root/pull_images.sh - - [Install] - WantedBy=multi-user.target - - - name: disable-selinux.service - enabled: true - contents: | - [Unit] - Description=disable selinux for kubernetes - ConditionPathExists=!/var/log/disable-selinux.stamp - - [Service] - Type=oneshot - RemainAfterExit=yes - ExecStart=bash -c "sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config" - ExecStart=setenforce 0 - ExecStart=/bin/touch /var/log/disable-selinux.stamp - - [Install] - WantedBy=multi-user.target - - - name: set-time-sync.service - enabled: true - contents: | - [Unit] - Description=set time sync for kubernetes - ConditionPathExists=!/var/log/set-time-sync.stamp - - [Service] - Type=oneshot - RemainAfterExit=yes - ExecStart=bash -c "sed -i '3aserver ntp1.aliyun.com iburst' /etc/chrony.conf" - ExecStart=bash -c "sed -i '24aallow ${MASTER_SEGMENT}' /etc/chrony.conf" - ExecStart=bash -c "sed -i '26alocal stratum 10' /etc/chrony.conf" - ExecStart=systemctl restart chronyd.service - ExecStart=/bin/touch /var/log/set-time-sync.stamp - - [Install] - WantedBy=multi-user.target - - - name: init-cluster.service - enabled: true - contents: | - [Unit] - Description=init kubernetes cluster - Requires=set-kernel-para.service pull-images.service disable-selinux.service set-time-sync.service - After=set-kernel-para.service pull-images.service disable-selinux.service set-time-sync.service - ConditionPathExists=/var/log/set-kernel-para.stamp - ConditionPathExists=/var/log/set-time-sync.stamp - ConditionPathExists=/var/log/disable-selinux.stamp - ConditionPathExists=/var/log/pull-images.stamp - ConditionPathExists=!/var/log/init-k8s-cluster.stamp - - [Service] - Type=oneshot - RemainAfterExit=yes - ExecStart=kubeadm init --config=/root/init-config.yaml --upload-certs - ExecStart=/bin/touch /var/log/init-k8s-cluster.stamp - - [Install] - WantedBy=multi-user.target - - - - name: install-cni-plugin.service - enabled: true - contents: | - [Unit] - Description=install cni network plugin for kubernetes - Requires=init-cluster.service - After=init-cluster.service - - [Service] - Type=oneshot - RemainAfterExit=yes - ExecStart=bash -c "curl https://docs.projectcalico.org/v3.19/manifests/calico.yaml -o /root/calico.yaml" - ExecStart=/bin/sleep 6 - ExecStart=bash -c "sed -i 's#usr/libexec/#opt/libexec/#g' /root/calico.yaml" - ExecStart=kubectl apply -f /root/calico.yaml --kubeconfig=/etc/kubernetes/admin.conf - - [Install] - WantedBy=multi-user.target - -``` - -Node节点butane配置文件示例: - -```yaml -variant: fcos -version: 1.1.0 -passwd: - users: - - name: root - password_hash: "${PASSWORD_HASH}" - "groups": [ - "adm", - "sudo", - "systemd-journal", - "wheel" - ] - ssh_authorized_keys: - - "${SSH-RSA}" -storage: - directories: - - path: /etc/systemd/system/kubelet.service.d - overwrite: true - files: - - path: /etc/hostname - mode: 0644 - contents: - inline: ${NODE_NAME} - - path: /etc/hosts - mode: 0644 - overwrite: true - contents: - inline: | - 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 - ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 - ${MASTER_IP} ${MASTER_NAME} - ${NODE_IP} ${NODE_NAME} - - path: /etc/NetworkManager/system-connections/ens2.nmconnection - mode: 0600 - overwrite: true - contents: - inline: | - [connection] - id=ens2 - type=ethernet - interface-name=ens2 - [ipv4] - address1=${NODE_IP}/24,${GATEWAY} - dns=8.8.8.8; - dns-search= - method=manual - - path: /etc/sysctl.d/kubernetes.conf - mode: 0644 - overwrite: true - contents: - inline: | - net.bridge.bridge-nf-call-iptables=1 - net.bridge.bridge-nf-call-ip6tables=1 - net.ipv4.ip_forward=1 - - path: /etc/isulad/daemon.json - mode: 0644 - overwrite: true - contents: - inline: | - { - "exec-opts": ["native.cgroupdriver=systemd"], - "group": "isula", - "default-runtime": "lcr", - "graph": "/var/lib/isulad", - "state": "/var/run/isulad", - "engine": "lcr", - "log-level": "ERROR", - "pidfile": "/var/run/isulad.pid", - "log-opts": { - "log-file-mode": "0600", - "log-path": "/var/lib/isulad", - "max-file": "1", - "max-size": "30KB" - }, - "log-driver": "stdout", - "container-log": { - "driver": "json-file" - }, - "hook-spec": "/etc/default/isulad/hooks/default.json", - "start-timeout": "2m", - "storage-driver": "overlay2", - "storage-opts": [ - "overlay2.override_kernel_check=true" - ], - "registry-mirrors": [ - "docker.io" - ], - "insecure-registries": [ - "${image-repository}" - ], - "pod-sandbox-image": "k8s.gcr.io/pause:3.6", - "native.umask": "secure", - "network-plugin": "cni", - "cni-bin-dir": "/opt/cni/bin", - "cni-conf-dir": "/etc/cni/net.d", - "image-layer-check": false, - "use-decrypted-key": true, - "insecure-skip-verify-enforce": false, - "cri-runtimes": { - "kata": "io.containerd.kata.v2" - } - } - - path: /root/pull_images.sh - mode: 0644 - overwrite: true - contents: - inline: | - #!/bin/sh - KUBE_VERSION=v1.23.10 - KUBE_PAUSE_VERSION=3.6 - ETCD_VERSION=3.5.1-0 - DNS_VERSION=v1.8.6 - CALICO_VERSION=v3.19.4 - username=${image-repository} - images=( - kube-proxy:${KUBE_VERSION} - kube-scheduler:${KUBE_VERSION} - kube-controller-manager:${KUBE_VERSION} - kube-apiserver:${KUBE_VERSION} - pause:${KUBE_PAUSE_VERSION} - etcd:${ETCD_VERSION} - ) - for image in ${images[@]} - do - isula pull ${username}/${image} - isula tag ${username}/${image} k8s.gcr.io/${image} - isula rmi ${username}/${image} - done - isula pull ${username}/coredns:${DNS_VERSION} - isula tag ${username}/coredns:${DNS_VERSION} k8s.gcr.io/coredns/coredns:${DNS_VERSION} - isula rmi ${username}/coredns:${DNS_VERSION} - touch /var/log/pull-images.stamp - - path: /etc/systemd/system/kubelet.service.d/10-kubeadm.conf - mode: 0644 - contents: - inline: | - # Note: This dropin only works with kubeadm and kubelet v1.11+ - [Service] - Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf" - Environment="KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml" - # This is a file that "kubeadm init" and "kubeadm join" generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically - EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env - # This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use - # the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file. - EnvironmentFile=-/etc/sysconfig/kubelet - ExecStart= - ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS - - path: /root/join-config.yaml - mode: 0644 - contents: - inline: | - apiVersion: kubeadm.k8s.io/v1beta3 - caCertPath: /etc/kubernetes/pki/ca.crt - discovery: - bootstrapToken: - apiServerEndpoint: ${MASTER_IP}:6443 - token: ${token} - unsafeSkipCAVerification: true - timeout: 5m0s - tlsBootstrapToken: ${token} - kind: JoinConfiguration - nodeRegistration: - criSocket: /var/run/isulad.sock - imagePullPolicy: IfNotPresent - name: ${NODE_NAME} - taints: null - links: - - path: /etc/localtime - target: ../usr/share/zoneinfo/Asia/Shanghai - -systemd: - units: - - name: kubelet.service - enabled: true - contents: | - [Unit] - Description=kubelet: The Kubernetes Node Agent - Documentation=https://kubernetes.io/docs/ - Wants=network-online.target - After=network-online.target - - [Service] - ExecStart=/usr/bin/kubelet - Restart=always - StartLimitInterval=0 - RestartSec=10 - - [Install] - WantedBy=multi-user.target - - - name: set-kernel-para.service - enabled: true - contents: | - [Unit] - Description=set kernel para for kubernetes - ConditionPathExists=!/var/log/set-kernel-para.stamp - - [Service] - Type=oneshot - RemainAfterExit=yes - ExecStart=modprobe br_netfilter - ExecStart=sysctl -p /etc/sysctl.d/kubernetes.conf - ExecStart=/bin/touch /var/log/set-kernel-para.stamp - - [Install] - WantedBy=multi-user.target - - - name: pull-images.service - enabled: true - contents: | - [Unit] - Description=pull images for kubernetes - ConditionPathExists=!/var/log/pull-images.stamp - - [Service] - Type=oneshot - RemainAfterExit=yes - ExecStart=systemctl start isulad - ExecStart=systemctl enable isulad - ExecStart=sh /root/pull_images.sh - - [Install] - WantedBy=multi-user.target - - - name: disable-selinux.service - enabled: true - contents: | - [Unit] - Description=disable selinux for kubernetes - ConditionPathExists=!/var/log/disable-selinux.stamp - - [Service] - Type=oneshot - RemainAfterExit=yes - ExecStart=bash -c "sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config" - ExecStart=setenforce 0 - ExecStart=/bin/touch /var/log/disable-selinux.stamp - - [Install] - WantedBy=multi-user.target - - - name: set-time-sync.service - enabled: true - contents: | - [Unit] - Description=set time sync for kubernetes - ConditionPathExists=!/var/log/set-time-sync.stamp - - [Service] - Type=oneshot - RemainAfterExit=yes - ExecStart=bash -c "sed -i '3aserver ${MASTER_IP}' /etc/chrony.conf" - ExecStart=systemctl restart chronyd.service - ExecStart=/bin/touch /var/log/set-time-sync.stamp - - [Install] - WantedBy=multi-user.target - - - name: join-cluster.service - enabled: true - contents: | - [Unit] - Description=node join kubernetes cluster - Requires=set-kernel-para.service pull-images.service disable-selinux.service set-time-sync.service - After=set-kernel-para.service pull-images.service disable-selinux.service set-time-sync.service - ConditionPathExists=/var/log/set-kernel-para.stamp - ConditionPathExists=/var/log/set-time-sync.stamp - ConditionPathExists=/var/log/disable-selinux.stamp - ConditionPathExists=/var/log/pull-images.stamp - - [Service] - Type=oneshot - RemainAfterExit=yes - ExecStart=kubeadm join --config=/root/join-config.yaml - - [Install] - WantedBy=multi-user.target - -``` - -### 生成Ignition文件 - -为了方便使用者读、写,Ignition文件增加了一步转换过程。将Butane配置文件(yaml格式)转换成Ignition文件(json格式),并使用生成的Ignition文件引导新的NestOS镜像。Butane配置转换成Ignition配置命令: - -``` -podman run --interactive --rm quay.io/coreos/butane:release --pretty --strict < your_config.bu > transpiled_config.ign -``` - - - -## K8S集群搭建 - -利用上一节配置的Ignition文件,执行下述命令创建k8s集群的Master节点,其中 vcpus、ram 和 disk 参数可自行调整,详情可参考 virt-install 手册。 - -``` -virt-install --name=${NAME} --vcpus=4 --ram=8192 --import --network=bridge=virbr0 --graphics=none --qemu-commandline="-fw_cfg name=opt/com.coreos/config,file=${IGNITION_FILE_PATH}" --disk=size=40,backing_store=${NESTOS_RELEASE_QCOW2_PATH} --network=bridge=virbr1 --disk=size=40 -``` - -Master节点系统安装成功后,系统后台会起一系列环境配置服务,其中set-kernel-para.service会配置内核参数,pull-images.service会拉取集群所需的镜像,disable-selinux.service会关闭selinux,set-time-sync.service服务会设置时间同步,init-cluster.service会初始化集群,之后install-cni-plugin.service会安装cni网络插件。整个集群部署过程中由于要拉取镜像,所以需要等待几分钟。 - -通过kubectl get pods -A命令可以查看是否所有pod状态都为running - - -在Master节点上通过下面命令查看token: - -``` -kubeadm token list -``` - -将查询到的token信息添加到Node节点的ignition文件中,并利用该ignition文件创建Node节点。Node节点创建完成后,在Master节点上通过执行kubectl get nodes命令,可以查看Node节点是否加入到了集群中。 - -至此,k8s部署成功 - -# rpm-ostree使用 - -## rpm-ostree安装软件包 - -安装wget - -``` -rpm-ostree install wget -``` - -重启系统,可在启动时通过键盘上下按键选择rpm包安装完成后或安装前的系统状态,其中【ostree:0】为安装之后的版本。 - -``` -systemctl reboot -``` - -查看wget是否安装成功 - -``` -rpm -qa | grep wget -``` - -## rpm-ostree 手动更新升级 NestOS - -在NestOS中执行命令可查看当前rpm-ostree状态,可看到当前版本号 - -``` -rpm-ostree status -``` - -执行检查命令查看是否有升级可用,发现存在新版本 - -``` -rpm-ostree upgrade --check -``` - -预览版本的差异 - -``` -rpm-ostree upgrade --preview -``` - -在最新版本中,我们将nano包做了引入。 -执行如下指令会下载最新的ostree和RPM数据,不需要进行部署 - -``` -rpm-ostree upgrade --download-only -``` - -重启NestOS,重启后可看到系统的新旧版本两个状态,选择最新版本的分支进入 - -``` -rpm-ostree upgrade --reboot -``` - -## 比较NestOS版本差别 - -检查状态,确认此时ostree有两个版本,分别为LTS.20210927.dev.0和LTS.20210928.dev.0 - -``` -rpm-ostree status -``` - -根据commit号比较2个ostree的差别 - -``` -rpm-ostree db diff 55eed9bfc5ec fe2408e34148 -``` - -## 系统回滚 - -当一个系统更新完成,之前的NestOS部署仍然在磁盘上,如果更新导致了系统出现问题,可以使用之前的部署回滚系统。 - -### 临时回滚 - -要临时回滚到之前的OS部署,在系统启动过程中按住shift键,当引导加载菜单出现时,在菜单中选择相关的分支。 - -### 永久回滚 - -要永久回滚到之前的操作系统部署,登录到目标节点,运行rpm-ostree rollback,此操作将使用之前的系统部署作为默认部署,并重新启动到其中。 -执行命令,回滚到前面更新前的系统。 - -``` -rpm-ostree rollback -``` - -重启后失效。 - -## 切换版本 - -在上一步将NestOS回滚到了旧版本,可以通过命令切换当前 NestOS 使用的rpm-ostree版本,将旧版本切换为新版本。 - -``` -rpm-ostree deploy -r 22.03.20220325.dev.0 -``` - -重启后确认目前NestOS已经使用的是新版本的ostree了。 - - -# zincati自动更新使用 - -zincati负责NestOS的自动更新,zincati通过cincinnati提供的后端来检查当前是否有可更新版本,若检测到有可更新版本,会通过rpm-ostree进行下载。 - -目前系统默认关闭zincati自动更新服务,可通过修改配置文件设置为开机自动启动自动更新服务。 - -``` -vi /etc/zincati/config.d/95-disable-on-dev.toml -``` - -将updates.enabled设置为true -同时增加配置文件,修改cincinnati后端地址 - -``` -vi /etc/zincati/config.d/update-cincinnati.toml -``` - -添加如下内容 - -``` -[cincinnati] -base_url="http://nestos.org.cn:8080" -``` - -重新启动zincati服务 - -``` -systemctl restart zincati.service -``` - -当有新版本时,zincati会自动检测到可更新版本,此时查看rpm-ostree状态,可以看到状态是“busy”,说明系统正在升级中。 - -一段时间后NestOS将自动重启,此时再次登录NestOS,可以再次确认rpm-ostree的状态,其中状态转为"idle",而且当前版本已经是“20220325”,这说明rpm-ostree版本已经升级了。 - -查看zincati服务的日志,确认升级的过程和重启系统的日志。另外日志显示的"auto-updates logic enabled"也说明更新是自动的。 - -# 定制NestOS - -我们可以使用nestos-installer 工具对原始的NestOS ISO文件进行加工,将Ignition文件打包进去从而生成定制的 NestOS ISO文件。使用定制的NestOS ISO文件可以在系统启动完成后自动执行NestOS的安装,因此NestOS的安装会更加简单。 - -在开始定制NestOS之前,需要做如下准备工作: - -- 下载 NestOS ISO -- 准备 config.ign文件 - -## 生成定制NestOS ISO文件 - -### 设置参数变量 - -``` -$ export COREOS_ISO_ORIGIN_FILE=nestos-22.03.20220324.x86_64.iso -$ export COREOS_ISO_CUSTOMIZED_FILE=my-nestos.iso -$ export IGN_FILE=config.ign -``` - -### ISO文件检查 - -确认原始的NestOS ISO文件中是没有包含Ignition配置。 - -``` -$ nestos-installer iso ignition show $COREOS_ISO_ORIGIN_FILE - -Error: No embedded Ignition config. -``` - -### 生成定制NestOS ISO文件 - -将Ignition文件和原始NestOS ISO文件打包生成定制的NestOS ISO文件。 - -``` -$ nestos-installer iso ignition embed $COREOS_ISO_ORIGIN_FILE --ignition-file $IGN_FILE $COREOS_ISO_ORIGIN_FILE --output $COREOS_ISO_CUSTOMIZED_FILE -``` - -### ISO文件检查 - -确认定制NestOS ISO 文件中已经包含Ignition配置了 - -``` -$ nestos-installer iso ignition show $COREOS_ISO_CUSTOMIZED_FILE -``` - -执行命令,将会显示Ignition配置内容 - -## 安装定制NestOS ISO文件 - -使用定制的 NestOS ISO 文件可以直接引导安装,并根据Ignition自动完成NestOS的安装。在完成安装后,我们可以直接在虚拟机的控制台上用nest/password登录NestOS。 \ No newline at end of file diff --git "a/docs/zh/docs/NestOS/\345\212\237\350\203\275\347\211\271\346\200\247\346\217\217\350\277\260.md" "b/docs/zh/docs/NestOS/\345\212\237\350\203\275\347\211\271\346\200\247\346\217\217\350\277\260.md" index c513fd2f0ab3d70525af432656d53d78388e9c8b..f0f661d462d4f467b910c0aa902434865937af6d 100644 --- "a/docs/zh/docs/NestOS/\345\212\237\350\203\275\347\211\271\346\200\247\346\217\217\350\277\260.md" +++ "b/docs/zh/docs/NestOS/\345\212\237\350\203\275\347\211\271\346\200\247\346\217\217\350\277\260.md" @@ -102,4 +102,4 @@ Afterburn包含了很多可以在实例生命周期中不同时间段运行的 (2)从实例元数据中检索属性 -(3)给提供者登记以便报道成功的启动或实例供应 \ No newline at end of file +(3)给提供者登记以便报道成功的启动或实例供应 diff --git "a/docs/zh/docs/NestOS/\345\256\211\350\243\205\344\270\216\351\203\250\347\275\262.md" "b/docs/zh/docs/NestOS/\345\256\211\350\243\205\344\270\216\351\203\250\347\275\262.md" deleted file mode 100644 index ba1f7cacbd6b9e8cccd2623f66ba2e9f7d3e3c25..0000000000000000000000000000000000000000 --- "a/docs/zh/docs/NestOS/\345\256\211\350\243\205\344\270\216\351\203\250\347\275\262.md" +++ /dev/null @@ -1,129 +0,0 @@ -# 安装与部署 - -## 在 VMware 上部署 NestOS - -本指南展示了如何在VMware虚拟机管理程序上配置最新的 NestOS。 - -目前NestOS已支持x86_64和aarch64架构。 - -### 开始之前 - -​ 在开始部署 NestOS 之前,需要做如下准备工作: - -- 下载 NestOS ISO -- 准备 config.bu 文件 -- 配置 butane 工具(Linux环境/win10环境) -- 安装有VMware的宿主机 - -### 初步安装与启动 - -#### 启动 NestOS - -初次启动 NestOS ,ignition 尚未安装,可根据系统提示使用 nestos-installer 组件进行ignition的安装。 - -### 配置 ignition 文件 - -#### 获取 Butane - -可以通过 Butane 将 bu 文件转化为 ignition 文件。ignition 配置文件被设计为可读但难以编写,是为了 -阻止用户尝试手动编写配置。 -Butane 提供了多种环境的支持,可以在 linux/windows 宿主机中或容器环境中进行配置。 - -``` -docker pull quay.io/coreos/butane:release -``` - -#### 生成登录密码 - -在宿主机执行如下命令,并输入你的密码。 - -``` -# openssl passwd -1 -salt yoursalt -Password: -$1$yoursalt$1QskegeyhtMG2tdh0ldQN0 -``` - -#### 生成ssh-key - -在宿主机执行如下命令,获取公钥和私钥以供后续 ssh 登录。 - -``` -# ssh-keygen -N '' -f ./id_rsa -Generating public/private rsa key pair. -Your identification has been saved in ./id_rsa -Your public key has been saved in ./id_rsa.pub -The key fingerprint is: -SHA256:4fFpDDyGHOYEd2fPaprKvvqst3T1xBQuk3mbdon+0Xs root@host-12-0-0-141 -``` - -``` -The key's randomart image is: -+---[RSA 3072]----+ -| ..= . o . | -| * = o * . | -| + B = * | -| o B O + . | -| S O B o | -| * = . . | -| . +o . . | -| +.o . .E | -| o*Oo ... | -+----[SHA256]-----+ -``` - -可以在当前目录查看id_rsa.pub公钥: - -``` -# cat id_rsa.pub -ssh-rsa -AAAAB3NzaC1yc2... -``` - -#### 编写bu文件 - -进行最简单的初始配置,如需更多详细的配置,参考后面的 ignition 详解。 -如下为最简单的 config.bu 文件: - -``` -variant: fcos -version: 1.1.0 -passwd: - users: - - name: nest - password_hash: "$1$yoursalt$1QskegeyhtMG2tdh0ldQN0" - ssh_authorized_keys: - - "ssh-rsa - AAAAB3NzaC1yc2EAAA..." -``` - -#### 生成ignition文件 - -将 config.bu 通过 Butane 工具转换为 config.ign 文件,如下为在容器环境下进行转换。 - -``` -# docker run --interactive --rm quay.io/coreos/butane:release \ ---pretty --strict < your_config.bu > transpiled_config.ign -``` - -### 安装 NestOS - -将宿主机生成的config.ign文件通过scp拷贝到前面初步启动的 NestOS 中,该OS目前运行在内存中, -并没有安装到硬盘。 - -``` -sudo -i -scp root@your_ipAddress:/root/config.ign /root -``` - -根据系统所给提示,执行如下指令完成安装。 - -``` -nestos-installer install /dev/sda --ignition-file config.ign -``` - -安装完成后重启 NestOS 。 - -``` -systemctl reboot -``` -完成。 diff --git "a/docs/zh/docs/Ods-Pipeline/ods pipeline\347\224\250\346\210\267\346\214\207\345\215\227.md" "b/docs/zh/docs/Ods-Pipeline/ods pipeline\347\224\250\346\210\267\346\214\207\345\215\227.md" index 57aa7758fc7a6a7f8d320a434138a1b8be4b8c39..46f0b9d591447e1c7cb8db6386ca9eb5c8dabf79 100644 --- "a/docs/zh/docs/Ods-Pipeline/ods pipeline\347\224\250\346\210\267\346\214\207\345\215\227.md" +++ "b/docs/zh/docs/Ods-Pipeline/ods pipeline\347\224\250\346\210\267\346\214\207\345\215\227.md" @@ -9,7 +9,7 @@ ### 使用对象 - 社区开发者 -- 版本Maitainer +- 版本Maintainer - 性能优化工程师 ### 术语说明 diff --git "a/docs/zh/docs/ROS/\345\270\270\350\247\201\351\227\256\351\242\230\344\270\216\350\247\243\345\206\263\346\226\271\346\263\225.md" "b/docs/zh/docs/ROS/\345\270\270\350\247\201\351\227\256\351\242\230\344\270\216\350\247\243\345\206\263\346\226\271\346\263\225.md" index f43a30740d3910758e0b705a6772c2707a943801..a7a4901b6ede1390eb2eb734b9817422b2e99cd6 100644 --- "a/docs/zh/docs/ROS/\345\270\270\350\247\201\351\227\256\351\242\230\344\270\216\350\247\243\345\206\263\346\226\271\346\263\225.md" +++ "b/docs/zh/docs/ROS/\345\270\270\350\247\201\351\227\256\351\242\230\344\270\216\350\247\243\345\206\263\346\226\271\346\263\225.md" @@ -1,10 +1,12 @@ -# 常见问题及解决方法 +# 常见问题与解决方法 -## 问题1: +## **问题1** ![](./figures/problem.png) -原因:出现该警告的原因在于环境变量中同时存在ROS1、ROS2,解决办法:修改环境变量,避免两个版本冲突。 +原因:出现该警告的原因在于环境变量中同时存在ROS1、ROS2。 + +解决方法:修改环境变量,避免两个版本冲突。 ```shell [root@openEuler ~]# vim /opt/ros/humble/share/ros_environment/environment/1.ros_distro.sh diff --git "a/docs/zh/docs/ROS/\350\256\244\350\257\206ROS.md" "b/docs/zh/docs/ROS/\350\256\244\350\257\206ROS.md" index df0ee4246d307be9155c02fa4627bc634c0af5ea..fa57fa8b6b484c06b6a5d26229111f838b53714a 100644 --- "a/docs/zh/docs/ROS/\350\256\244\350\257\206ROS.md" +++ "b/docs/zh/docs/ROS/\350\256\244\350\257\206ROS.md" @@ -2,7 +2,7 @@ ## 简介 -ROS 是一个适用于机器人的开源的元操作系统。它提供了操作系统应有的服务,包括硬件抽象,底层设备控制,常用函数的实现,进程间消息传递,以及包管理。它也提供用于获取、编译、编写、和跨计算机运行代码所需的工具和库函数。 +ROS 是一个适用于机器人的开源的元操作系统。它提供了操作系统应有的服务,包括硬件抽象,底层设备控制,常用函数的实现,进程间消息传递,以及包管理。它也提供用于获取、编译、编写和跨计算机运行代码所需的工具和库函数。 ROS的运行架构是一种使用ROS通信模块实现模块间[P2P](https://zh.wikipedia.org/wiki/對等網路)的松耦合的网络连接的处理架构,它执行若干种类型的通讯,包括: diff --git "a/docs/zh/docs/Releasenotes/\345\205\263\351\224\256\347\211\271\346\200\247.md" "b/docs/zh/docs/Releasenotes/\345\205\263\351\224\256\347\211\271\346\200\247.md" index 8cd6be1657ab976f5f9dbb28d1d8d95ff13c3fee..516ef17d7080fa60948b5495d686be56d4202599 100644 --- "a/docs/zh/docs/Releasenotes/\345\205\263\351\224\256\347\211\271\346\200\247.md" +++ "b/docs/zh/docs/Releasenotes/\345\205\263\351\224\256\347\211\271\346\200\247.md" @@ -10,7 +10,7 @@ - **用户API**: 使用 OS 的 mmap 分配统一虚拟内存,GMEM 在 mmap 系统调用中新增分配统一虚拟内存标志(MMAP_PEER_SHARED)。同时 libgmem 用户态库提供内存预取语义 hmadvise 接口,协助用户优化加速器内存访问效率。 -## 开源大模型原生支持(LLaMA和ChatGLM) +## 开源大模型原生支持(LLaMa和ChatGLM) llama.cpp 和 chatglm-cpp 是基于 C/C++ 实现的模型推理框架,通过模型量化等手段,支持用户可以在CPU机器上完成开源大模型的部署和使用。llama.cpp 支持多个英文开源大模型的部署,如 LLaMa/LLaMa2/Vicuna 等。chatglm-cpp 支持多个中文开源大模型的部署,如 ChatGLM-6B/ChatGLM2-6B/Baichuan-13B等。 @@ -18,35 +18,31 @@ llama.cpp 和 chatglm-cpp 是基于 C/C++ 实现的模型推理框架,通过 - 通过 int4/int8 量化、优化的 KV 缓存和并行计算等多种方式加速内存高效 CPU 推理。 -## openEuler 6.4 内核中的特性 +## openEuler 6.6 内核中的特性 -openEuler 23.09 基于 Linux Kernel 6.4 内核构建,在此基础上,同时吸收了社区高版本的有益特性及社区创新特性。 +openEuler 24.09 基于 Linux Kernel 6.6 内核构建,在此基础上,同时吸收了社区高版本的有益特性及社区创新特性。 -- **潮汐 affinity 调度特性**:感知业务负载动态调整业务 CPU 亲和性,当业务负载低时使用 prefered cpus 处理,增强资源的局部性;当业务负载高时,突破 preferred cpus 范围限制,通过增加CPU核的供给提高业务的 QoS。 +- **内存管理folio特性**:Linux内存管理基于page(页)转换到由folio(拉丁语 foliō,对开本)进行管理,相比page,folio可以由一个或多个page组成,采用struct folio参数的函数声明它将对整个(1个或者多个)页面进行操作,而不仅仅是PAGE_SIZE字节,从而移除不必要复合页转换,降低误用tail page问题;从内存管理效率上采用folio减少LRU链表数量,提升内存回收效率,另一方,一次分配更多连续内存减少page fault次数,一定程度降低内存碎片化;而在IO方面,可以加速大IO的读写效率,提升吞吐。全量支持匿名页、文件页的large folio,提供系统级别的开关控制,业务可以按需使用。对于ARM64架构,基于硬件contiguous bit技术(16个连续PTE只占一个 TLB entry),可以进一步降低系统TLB miss,从而提升整体系统性能。24.09新增支持anonymous shmem分配mTHP与支持mTHP的lazyfree,进一步增加内存子系统对于large folio的支持;新增page cache分配mTHP的sysfs控制接口,提供系统级别的开关控制,业务可以按需使用。 -- **CPU QoS优先级负载均衡特性**:在离线混部 CPU QoS 隔离增强, 支持多核 CPU QoS 负载均衡,进一步降低离线业务 QoS 干扰。 +- **MPTCP特性支持**:MPTCP协议诞生旨在突破传统 TCP 协议的单一路径传输瓶颈,允许应用程序使用多个网络路径进行并行数据传输。这一设计优化了网络硬件资源的利用效率,通过智能地将流量分配至不同传输路径,显著缓解了网络拥塞问题,从而提高数据传输的可靠性和吞吐量。 -- **SMT 驱离优先级反转特性**:解决混部 SMT 驱离特性的优先级反转问题,减少离线任务对在线任务 QoS 的影响。 + 目前,MPTCP 在下述网络场景中已经展现出了其优秀的性能: -- **混部多优先级**:允许 cgroup 配置-2~2的cpu.qos_level,即多个优先级,使用 qos_level_weight 设置不同优先级权重,按照 CPU 的使用比例进行资源的划分,并提供唤醒抢占能力。 + - 网络通路的选择:在现有的网络通路中,根据延迟、带宽等指标评估,选择最优的通路。 + - 无缝切网:在不同类型网络之间切换时,数据传输不中断。 + - 数据分流:同时使用多个通道传输,对数据包进行分发实现并发传输,增加网络带宽。 -- **可编程调度**:基于 eBPF 的可编程调度框架,支持内核调度器动态扩展调度策略,以满足不同负载的性能需求。 + 在实验环境中,采用MPTCP v1技术的RSYNC文件传输工具展现出了令人满意的效率提升。具体而言,传输1.3GB大小的文件时,传输时间由原来的114.83 s缩短至仅14.35s,平均传输速度由原来的11.08 MB/s提升至88.25 MB/s,可以极大程度的缩减文件传输时间。同时,实验模拟了传输过程中一条或多条路径突发故障而断开的场景,MPTCP在此种场景下可以将数据无缝切换至其他可用的数据通道,确保数据传输的连续性与完整性。 -- **Numa Aware spinlock**:基于 MCS 自旋锁在锁传递算法上针对多 NUMA 系统优化,通过优先在本 NUMA 节点内传递,能大量减少跨 NUMA 的 Cache 同步和乒乓,从而提升锁的整体吞吐量,提升业务性能。 + 在openEuler 24.09中,已经完成了对linux主线内核6.9中MPTCP相关特性的全面移植与功能优化。 -- **支持 TCP 压缩**:在 TCP 层对指定端口的数据进行压缩后再传输,收包侧把数据解压后再传给用户态,从而提升分布式场景节点间数据传输的效率。 +- **ext4文件系统支持Large folio**:iozone性能总分可以提升80%。 -- **内核热补丁**:主要针对内核的函数实现的 bug 进行免重启修复,原理主要在于如何完成动态函数替换,采用直接修改指令的方法,而非主线基于 ftrace 实现,在运行时直接跳转至新函数,无需经过查找中转,效率较高。 + iomap框架回写流程支持批量映射block。支持ext4默认模式下批量申请block,大幅优化各类benchmark下ext4性能表现。ext4 buffer io读写流程以及pagecache回写流程弃用老旧的buffer_head框架,切换至iomap框架,并通过iomap框架实现ext4支持large folio。24.09新增对于block size < folio size场景的小buffered IO(<=4KB)的性能优化,性能提升20%。 -- **Sharepool 共享内存**:一种在多个进程之间共享数据的技术。它允许多个进程访问同一块内存区域,从而实现数据共享。 +- **按需加载支持failover特性**:cachefiles在按需模式下,如果守护进程崩溃或被关闭,按需加载相关的读取和挂载将返回-EIO。所有挂载点必须要在重新拉起 daemon 后重新挂载后方可继续使用。这在公共云服务生产环境中发生时是无法接受的,这样的I/O错误将传播给云服务用户,可能会影响他们作业的执行,并危及系统的整体稳定性。cachefiles failover 特性避免了守护进程崩溃后重新挂载所有挂载点,只需快速重新拉起守护进程即可,用户和服务是不感知守护进程崩溃的。 -- **memcg 异步回收**:一种优化机制,它可以在系统负载较低的时候,异步地回收 memcg 中的内存,以避免在系统负载高峰期间出现内存回收的延迟和性能问题。 - -- **支持 filescgroup**:Cgroup files 子系统提供对系统中一组进程打开的文件数量(即句柄数)进行分组管理,相比于已有的 rlimit 方法,能更好的实现文件句柄数的资源控制(资源申请及释放、资源使用动态调整、实现分组控制等)。 - -- **cgroupv1 使能 cgroup writeback**:cgroup writeback 用于控制和管理文件系统缓存的写回行为,提供了一种灵活的方式来管理文件系统缓存的写回行为,以满足不同应用场景下的需求。主要功能包括:缓存写回控制、IO 优先级控制、写回策略调整等。 - -- **支持核挂死检测特性**:解决 PMU 停止计数导致 hardlockup 无法检测系统卡死的问题,利用核间 CPU 挂死检测机制,让每个 CPU 检测相邻 CPU 是否挂死,保障系统在部分 CPU 关中断挂死场景下能够自愈。 +- **支持CLANG 编译的PGO优化**:PGO(Profile-Guided Optimization)是一种编译器反馈优化技术,通过收集程序运行时的信息,指导编译器的优化决策。根据业界经验,对于数据中心大型应用(如MySQL、Nginx、Redis等)通过反馈优化技术优化应用本身和Linux kernel有较好优化效果。经过测试,LLVM PGO可以在Nginx上有20%+性能提升,其中优化kernel提升10+%。 ## 嵌入式 @@ -270,7 +266,7 @@ PilotGo核心功能模块包括: - **批次管理**:支持运维操作并发执行,稳定高效。 -- **日志审计**:跟踪记录用户及插件的变更操作,方便问题回溯及安全审计。 。 +- **日志审计**:跟踪记录用户及插件的变更操作,方便问题回溯及安全审计。 - **告警管理**:平台异常实时感知。 @@ -288,7 +284,7 @@ PilotGo核心功能模块包括: ## EulerMaker 构建系统 -EulerMaker 构建系统是一款软件包构建系统,完成源码到二进制软件包的构建,并支持开发者通过搭积木方式,组装和定制出适合自己需求的场景化 OS。主要提供增量/全量构建,分层定制与镜像定制的能力。 +EulerMaker 构建系统是一款软件包构建系统,完成源码到二进制软件包的构建,并支持开发者通过搭积木的方式,组装和定制出适合自己需求的场景化 OS。主要提供增量/全量构建,分层定制与镜像定制的能力。 - **增量/全量构建**:基于软件包变化,结合软件包依赖关系,分析影响范围,得到待构建软件包列表,按照依赖顺序并行下发构建任务。 diff --git a/contribute/.keep b/docs/zh/docs/Sbom/.keep similarity index 100% rename from contribute/.keep rename to docs/zh/docs/Sbom/.keep diff --git "a/docs/zh/docs/Sbom/SBOM\350\257\264\346\230\216.md" "b/docs/zh/docs/Sbom/SBOM\350\257\264\346\230\216.md" new file mode 100644 index 0000000000000000000000000000000000000000..7204b98ba0345f5a4e5aa9c1b6feef51465a13bf --- /dev/null +++ "b/docs/zh/docs/Sbom/SBOM\350\257\264\346\230\216.md" @@ -0,0 +1,52 @@ +# 1. SBOM介绍 + +SBOM是一种正式标准化的、机器可读的元数据,它唯一地标识软件组件及其内容;也可能包括版权和许可证等成分数据。SBOM旨在跨组织共享,有助于提供软件供应链成分清单与透明度,并且未来趋势将作为软件交付件必要清单。 + + + +# 2. SBOM最小集定义 + +美国国家电信和信息管理局(National Telecommunications and Information Administration)发布SBOM最小集的定义: 数据字段是关于必须捕获和维护每个组件的基础数据,以便在整个软件供应链中跟踪组件,并基于此扩展License和漏洞库等其他数据字段。 + +| 数据字段 | 描述 | +| :------------- | :----------------------------------------------------------- | +| 供应商名称 | 创建、定义和标识组件的实体的名称。 | +| 组件名称 | 分配给原始供应商定义的软件单元的名称。 | +| 组件的版本 | 组件版本号、供应商用来指定软件从先前标识的版本发生变化的标识符。 | +| 其它唯一标识符 | 用于标识组件或用作相关数据库的查找键的其他标识符。 | +| 依赖关系 | 软件依赖关系、表征上游组件 X 包含在软件 Y 中的关系 | +| SBOM数据的作者 | 为此组件创建SBOM数据的实体的名称。 | +| 时间戳 | 记录SBOM数据组装的日期和时间。 | +| **推荐的数据** | | +| 组件的哈希 | 组件的唯一哈希,以帮助允许列表或拒绝列表。 | +| 生命周期阶段 | SDLC 中捕获 SBOM 数据的获取的阶段。 | + + + +# 3. openEuler发布的SBOM字段说明 + +| 最小集数据字段 | SPDX | +| ----------------- | ------------------------------------------------------------ | +| 组件供应商名称 | document->packages->supplier | +| 组件名称 | document->packages->name | +| 组件版本 | document->packages->versionInfo(openEuler使用了epoch:version-release格式) | +| 组件其他唯一标识 | document->packages->externalRefs(category:PACKAGE_MANAGER)->purl | +| 组件依赖关系 | document->packages->externalRefs(category:EXTERNAL_MANAGER)->purl | +| SBOM数据作者 | document->creationInfo->creators | +| SBOM时间戳 | document->creationInfo->created | +| 组件的哈希 | document->packages->checksums | +| 生命周期阶段 | 未支持 | +| 其他组件关系 | 内部子组件:document->packages->externalRefs(category:PROVIDE_MANAGER)->purl 运行时依赖:document->relationships(relationshipType:DEPENDS_ON) | +| 组件License信息 | document->packages->licenseDeclared document->packages->licenseConcluded | +| 组件Copyright信息 | document->packages->copyrightText | +| 组件上游社区信息 | document->packages->externalRefs(category:SOURCE_MANAGER)->url | +| 组件补丁信息 | 补丁文件:document->files(fileTypes:SOURCE) 补丁关系:document->relationships(relationshipType:PATCH_APPLIED) | +| 组件来源 | document->packages->downloadLocation | +| 组件信息 | document->packages->description document->packages->summary | +| 组件官网/博客 | document->packages->homepage | + +# 4. SBOM文件示例 + +解析最小颗粒度是RPM包 + +![输入图片说明](../../../../image.png) \ No newline at end of file diff --git "a/docs/zh/docs/SecHarden/\346\223\215\344\275\234\347\263\273\347\273\237\345\212\240\345\233\272\346\246\202\350\277\260.md" "b/docs/zh/docs/SecHarden/\346\223\215\344\275\234\347\263\273\347\273\237\345\212\240\345\233\272\346\246\202\350\277\260.md" index 7145e9610ac4806b4b95f78c5f18b9c3257ea705..9a54afbd0ae4b4d4a3e579809419b65ecfa28b98 100644 --- "a/docs/zh/docs/SecHarden/\346\223\215\344\275\234\347\263\273\347\273\237\345\212\240\345\233\272\346\246\202\350\277\260.md" +++ "b/docs/zh/docs/SecHarden/\346\223\215\344\275\234\347\263\273\347\273\237\345\212\240\345\233\272\346\246\202\350\277\260.md" @@ -27,7 +27,7 @@ ### 加固方式 -用户可以通过手动修改加固配置或执行相关命令对系统进行加固,也可以通过加固工具批量修改加固项。openEuler的安全加固工具security tool以openEuler-security.service服务的形式运行。系统首次启动时会自动运行该服务去执行默认加固策略,且自动设置后续开机不启动该服务。 +用户可以通过手动修改加固配置或执行相关命令对系统进行加固,也可以通过加固工具批量修改加固项。openEuler的安全加固工具security tool以openEuler-security.service服务的形式运行。系统首次启动时会自动运行该服务去执行默认加固策略,服务运行后会将该服务自动设置为后续开机不启动。 用户可以通过修改security.conf,使用安全加固工具实现个性化安全加固的效果。 diff --git "a/docs/zh/docs/ShangMi/RPM\347\255\276\345\220\215\351\252\214\347\255\276.md" "b/docs/zh/docs/ShangMi/RPM\347\255\276\345\220\215\351\252\214\347\255\276.md" new file mode 100644 index 0000000000000000000000000000000000000000..13718904bfb1278790cc5165f5449285e72569ad --- /dev/null +++ "b/docs/zh/docs/ShangMi/RPM\347\255\276\345\220\215\351\252\214\347\255\276.md" @@ -0,0 +1,85 @@ +# RPM验签 + +## 概述 + +openEuler当前采用RPM格式的软件包管理,RPM采用符合openPGP签名规范,openEuler-24.03-LTS-SP1版本发布的RPM软件在开源版本的基础上增加了对SM2/3算法的签名/验签功能支持。 + +对如下软件包进行商密使能: +- GnuPG:gpg命令行应用程序支持生成国密签名 +- RPM:支持调用gpg命令以及openSSL API实现国密签名生成/验证 +- openSSL:支持国密签名验证(开源已支持) + +## 前置条件 + +1. openEuler操作系统安装的gnupg2、libgcrypt、rpm软件版本号需大于等于如下版本: + + ``` + $ rpm -qa libgcrypt + libgcrypt-1.10.2-3.oe2403sp1.x86_64 + + $ rpm -qa gnupg2 + gnupg2-2.4.3-5.oe2403sp1.x86_64 + + $ rpm -qa rpm + rpm-4.18.2-20.oe2403sp1.x86_64 + ``` +2. ecdsa的签名及验签仅支持sm2的 + +## 使用方法 + + +1. 生成秘钥 + + 方法1: + ```sh + $ gpg --full-generate-key --expert + ``` + 方法2: + ```sh + $ gpg --quick-generate-key <密钥标识> sm2p256v1 + ``` + 中间会要求输入密码,后续操作秘钥或签名需要输入密码,若直接不输入,按回车,则表示无密码。 + +2. 导出证书 + + ```sh + $ gpg -o <证书路径> --export <密钥标识> + ``` +3. 打开配置sm3哈希算法和sm2算法的宏 + ``` + $ vim /usr/lib/rpm/macros + %_enable_sm2p256v1_sm3_algo 1 + ``` +4. 将证书导入rpm数据库 + ```sh + $ rpm --import <证书路径> + ``` +5. 编写签名所需的macro + + ``` + $ vim ~/.rpmmacros + %_signature gpg + %_gpg_path /root/.gnupg + %_gpg_name <密钥标识> + %_gpgbin /usr/bin/gpg2 + + %__gpg_sign_cmd %{shescape:%{__gpg}} \ + gpg --no-verbose --no-armor --no-secmem-warning --passphrase-file /root/passwd \ + %{?_gpg_digest_algo:--digest-algo=%{_gpg_digest_algo}} \ + %{?_gpg_sign_cmd_extra_args} \ + %{?_gpg_name:-u %{shescape:%{_gpg_name}}} \ + -sbo %{shescape:%{?__signature_filename}} \ + %{?__plaintext_filename:-- %{shescape:%{__plaintext_filename}}} + ``` + 其中%__gpg_sign_cmd信息为默认信息加上了--passphrase-file /root/passwd,passwd文件存的是密码,若步骤1没有设置密码,则无需添加。 + +6. 生成RPM包签名 + ```sh + $ rpmsign --addsign + ``` + +7. 验证RPM包签名 + ```sh + $ rpm -Kv + ``` + 如果输出中显示“Header V4 ECDSA/SM3 Signature”,并且显示“OK”,则说明签名验证成功。 diff --git "a/docs/zh/docs/ShangMi/SSH\345\215\217\350\256\256\346\240\210.md" "b/docs/zh/docs/ShangMi/SSH\345\215\217\350\256\256\346\240\210.md" index 89f8d05685516bf567f8f18610755c5fe341a2c1..b906fe6938d251f6113acda89b8db99692000d91 100644 --- "a/docs/zh/docs/ShangMi/SSH\345\215\217\350\256\256\346\240\210.md" +++ "b/docs/zh/docs/ShangMi/SSH\345\215\217\350\256\256\346\240\210.md" @@ -32,20 +32,20 @@ $ ssh-keygen -t sm2 -m PEM -f /etc/ssh/ssh_host_sm2_key $ cat /path/to/id_sm2.pub >> ~/.ssh/authorized_keys ``` -3. 服务端修改/etc/ssh/sshd_config,配置支持商密算法登录。商密的配置项可选商密参数如下表: +3. 修改配置文件,配置支持商密算法登录。服务端的配置文件路径为/etc/ssh/sshd_config,客户端配置文件路径为/etc/ssh/ssh_config。可配置的商密参数如下表: | 配置项含义 | 配置项参数 | 配置项参数的商密取值 | |---------------------|------------------------|---------------| -| 主机密钥公钥认证密钥 (仅服务端可配) | HostKeyAlgorithms | /etc/ssh/ssh_host_sm2_key | -| 主机密钥公钥认证算法 | HostKeyAlgorithms | sm2 | -| 密钥交换算法 | KexAlgorithms | sm2-sm3 | -| 对称加密算法 | Ciphers | sm4-ctr | -| 完整性校验算法 | MACs | hmac-sm3 | -| 用户公钥认证算法 | PubkeyAcceptedKeyTypes | sm2 | -| 用户公钥认证密钥(仅客户端可配) | IdentityFile | ~/.ssh/id_sm2 | -| 打印密钥指纹使用的哈希算法 | FingerprintHash | sm3 | - -4. 客户端配置商密算法完成登录。客户端可以使用命令行方式或者修改配置文件的方式使能商密算法套件。使用命令行登录方式如下: +| HostKey | 主机密钥公钥认证密钥 | /etc/ssh/ssh_host_sm2_key | +| HostKeyAlgorithms | 主机密钥公钥认证算法 | sm2 | +| KexAlgorithms | 密钥交换算法 | sm2-sm3 | +| Ciphers | 对称加密算法 | sm4-ctr | +| MACs | 完整性校验算法 | hmac-sm3 | +| PubkeyAcceptedKeyTypes | 用户公钥认证算法 | sm2 | +| IdentityFile | 用户公钥认证密钥 | ~/.ssh/id_sm2 | +| FingerprintHash | 打印密钥指纹使用的哈希算法 | sm3 | + +4. 客户端配置商密算法完成登录。客户端可以使用命令行方式或者修改配置文件(默认配置文件路径为/etc/ssh/ssh_config)的方式使能商密算法套件。使用命令行登录方式如下: ``` ssh -o PreferredAuthentications=publickey -o HostKeyAlgorithms=sm2 -o PubkeyAcceptedKeyTypes=sm2 -o Ciphers=sm4-ctr -o MACs=hmac-sm3 -o KexAlgorithms=sm2-sm3 -i ~/.ssh/id_sm2 [remote-ip] diff --git "a/docs/zh/docs/ShangMi/TLCP\345\215\217\350\256\256\346\240\210.md" "b/docs/zh/docs/ShangMi/TLCP\345\215\217\350\256\256\346\240\210.md" index 899621ed4b29fd59c9b94913df9fe007e25ad634..714ad4943a8939b90bc6b12a53fe4b558913c230 100644 --- "a/docs/zh/docs/ShangMi/TLCP\345\215\217\350\256\256\346\240\210.md" +++ "b/docs/zh/docs/ShangMi/TLCP\345\215\217\350\256\256\346\240\210.md" @@ -16,6 +16,7 @@ openEuler操作系统安装的openSSL软件版本号大于1.1.1m-4: $ rpm -qa openssl openssl-1.1.1m-6.oe2209.x86_64 ``` +注意:当前仅openssl 1.1.1支持TLCP协议栈,openssl 3.x版本暂未支持。 ## 如何使用 diff --git "a/docs/zh/docs/ShangMi/\346\226\207\344\273\266\345\256\214\346\225\264\346\200\247\344\277\235\346\212\244.md" "b/docs/zh/docs/ShangMi/\346\226\207\344\273\266\345\256\214\346\225\264\346\200\247\344\277\235\346\212\244.md" index c65eb80e5e2e1dc22a6ef7276b8a5fb65d25a296..3722026df3578ccf4a0d29bb80c29c9138a8da48 100644 --- "a/docs/zh/docs/ShangMi/\346\226\207\344\273\266\345\256\214\346\225\264\346\200\247\344\277\235\346\212\244.md" +++ "b/docs/zh/docs/ShangMi/\346\226\207\344\273\266\345\256\214\346\225\264\346\200\247\344\277\235\346\212\244.md" @@ -7,46 +7,50 @@ IMA全称Integrity Measurement Architecture,是Linux内核提供的强制访 ### 前置条件 1. 准备openEuler内核编译环境,可参考: -2. 内核模块签名支持商密算法在openEuler 5.10内核支持,建议选取最新5.10内核源码进行编译; -3. 生成内核SM2根证书: - ```sh +2. 建议选取最新内核源码进行编译; + +3. 生成IMA校验证书(仅评估模式涉及): + + ``` # 生成证书配置文件(配置文件其他字段可按需定义) - # echo 'subjectKeyIdentifier=hash' > ca.cfg + echo 'subjectKeyIdentifier=hash' > ima.cfg + echo 'authorityKeyIdentifier=keyid,issuer' >> ima.cfg + echo 'keyUsage=digitalSignature,nonRepudiation' >> ima.cfg # 生成SM2签名私钥 - # openssl ecparam -genkey -name SM2 -out ca.key + # openssl ecparam -genkey -name SM2 -out ima.key # 生成签名请求 - # openssl req -new -sm3 -key ca.key -out ca.csr + # openssl req -new -sm3 -key ima.key -out ima.csr # 生成SM2证书 - # openssl x509 -req -days 3650 -extfile ca.cfg -signkey ca.key -in ca.csr -out ca.crt + # openssl x509 -req -days 3650 -extfile ima.cfg -signkey ima.key -in ima.csr -out ima.crt ``` 4. 生成IMA二级证书: - ```sh - # 创建证书配置文件 - echo 'subjectKeyIdentifier=hash' > ima.cfg - echo 'authorityKeyIdentifier=keyid,issuer' >> ima.cfg - # 生成私钥 - openssl ecparam -genkey -name SM2 -out ima.key - # 生成签名请求 - openssl req -new -sm3 -key ima.key -out ima.csr - # 基于一级证书生成二级证书 - openssl x509 -req -sm3 -CAcreateserial -CA ca.crt -CAkey ca.key -extfile ima.cfg -in ima.csr -out ima.crt - # 转换为DER格式 - openssl x509 -outform DER -in ima.crt -out x509_ima.der - ``` - -5. 将根证书放置到内核源码目录,并修改内核编译选项CONFIG_SYSTEM_TRUSTED_KEYS,将指定证书编译到内核TRUSTED密钥中: + ```sh + # 创建证书配置文件 + echo 'subjectKeyIdentifier=hash' > ima.cfg + echo 'authorityKeyIdentifier=keyid,issuer' >> ima.cfg + # 生成私钥 + openssl ecparam -genkey -name SM2 -out ima.key + # 生成签名请求 + openssl req -new -sm3 -key ima.key -out ima.csr + # 基于一级证书生成二级证书 + openssl x509 -req -sm3 -CAcreateserial -CA ca.crt -CAkey ca.key -extfile ima.cfg -in ima.csr -out ima.crt + # 转换为DER格式 + openssl x509 -outform DER -in ima.crt -out x509_ima.der0 + ``` + +5. 将根证书放置到内核源码目录,并修改内核编译选项CONFIG_SYSTEM_TRUSTED_KEYS,将指定证书编译到内核TRUSTED密钥中(仅评估模式涉及): ```sh - # cp /path/to/ca.crt . + # cp /path/to/ima.crt . # make openeuler_defconfig # cat .config | grep CONFIG_SYSTEM_TRUSTED_KEYS - CONFIG_SYSTEM_TRUSTED_KEYS="ca.crt" + CONFIG_SYSTEM_TRUSTED_KEYS="ima.crt" ``` -6. 编译并安装内核: +6. 编译并安装内核(仅评估模式涉及): ```sh make -j64 @@ -123,31 +127,6 @@ $ rpm -qa ima-evm-utils ima-evm-utils-1.3.2-4.oe2209.x86_64 ``` -生成IMA二级证书: - -```sh -# 创建证书配置文件 -# echo 'subjectKeyIdentifier=hash' > ima.cfg -# echo 'authorityKeyIdentifier=keyid,issuer' >> ima.cfg -# 生成私钥 -# openssl ecparam -genkey -name SM2 -out ima.key -# 生成签名请求 -# openssl req -new -sm3 -key ima.key -out ima.csr -# 基于一级证书生成二级证书 -# openssl x509 -req -sm3 -CAcreateserial -CA ca.crt -CAkey ca.key -extfile ima.cfg -in ima.csr -out ima.crt -# 转换为DER格式 -# openssl x509 -outform DER -in ima.crt -out x509_ima.der -``` - -将IMA证书放置在/etc/keys目录下,执行dracut重新制作initrd: - -```sh -# mkdir -p /etc/keys -# cp x509_ima.der /etc/keys -# echo 'install_items+=" /etc/keys/x509_ima.der "' >> /etc/dracut.conf -# dracut -f -``` - 对需要进行保护的文件执行签名操作,如此处对/usr/bin目录下所有root用户的可执行文件进行签名: ```sh @@ -212,7 +191,7 @@ cat /sys/kernel/security/ima/ascii_runtime_measurements ...... ``` -#### 配置SM2证书校验摘要列表 +#### 配置SM2证书校验摘要列表(评估模式) **前置条件:** @@ -228,60 +207,22 @@ digest-list-tools-0.3.95-10.oe2209.x86_64 **执行步骤**: -1. 生成IMA/EVM二级证书(需要为内核预置的商密根证书的子证书): +将IMA摘要列表使用IMA/EVM证书对应的私钥进行签名,签名后可被正常导入内核: - ```sh - # 创建证书配置文件 - # echo 'subjectKeyIdentifier=hash' > ima.cfg - # echo 'authorityKeyIdentifier=keyid,issuer' >> ima.cfg - # 生成私钥 - # openssl ecparam -genkey -name SM2 -out ima.key - # 生成签名请求 - # openssl req -new -sm3 -key ima.key -out ima.csr - # 基于一级证书生成二级证书 - # openssl x509 -req -sm3 -CAcreateserial -CA ca.crt -CAkey ca.key -extfile ima.cfg -in ima.csr -out ima.crt - # 转换为DER格式 - # openssl x509 -outform DER -in ima.crt -out x509_ima.der - # openssl x509 -outform DER -in ima.crt -out x509_evm.der - ``` - -2. 将IMA/EVM证书放置在/etc/keys目录下,执行dracut重新制作initrd: - - ```sh - # mkdir -p /etc/keys - # cp x509_ima.der /etc/keys - # cp x509_evm.der /etc/keys - # echo 'install_items+=" /etc/keys/x509_ima.der /etc/keys/x509_evm.der "' >> /etc/dracut.conf - # dracut -f -e xattr - ``` - -3. 配置启动参数,开启IMA摘要列表功能,重启后可以检查证书被导入IMA/EVM密钥环: - - ```sh - # cat /proc/keys - ...... - 024dee5e I------ 1 perm 1f0f0000 0 0 keyring .evm: 1 - ...... - 3980807f I------ 1 perm 1f0f0000 0 0 keyring .ima: 1 - ...... - ``` - -4. 将IMA摘要列表使用IMA/EVM证书对应的私钥进行签名,签名后可被正常导入内核: - - ```sh - # 使用evmctl对摘要列表进行签名 - # evmctl ima_sign --key /path/to/ima.key -a sm3 0-metadata_list-compact-tree-1.8.0-2.oe2209.x86_64 - # 检查签名后的扩展属性 - # getfattr -m - -d 0-metadata_list-compact-tree-1.8.0-2.oe2209.x86_64 - file: 0-metadata_list-compact-tree-1.8.0-2.oe2209.x86_64 - security.ima=0sAwIRNJFkBQBHMEUCIQCzdKVWdxw1hoVm9lgZB6sl+sxapptUFNjqHt5XZD87hgIgBMuZqBdrcNm7fXq/reQw7rzY/RN/UXPrIOxrVvpTouw= - security.selinux="unconfined_u:object_r:admin_home_t:s0" - # 将签名后的摘要列表文件导入内核 - # echo /root/tree/etc/ima/digest_lists/0-metadata_list-compact-tree-1.8.0-2.oe2209.x86_64 > /sys/kernel/security/ima/digest_list_data - # 检查度量日志,可以看到摘要列表的导入记录 - # cat /sys/kernel/security/ima/ascii_runtime_measurements - 11 43b6981f84ba2725d05e91f19577cedb004adffb ima-sig sm3:b9430bbde2b7f30e935d91e29ab6778b6a825a2c3e5e7255895effb8747b7c1a /root/tree/etc/ima/digest_lists/0-metadata_list-compact-tree-1.8.0-2.oe2209.x86_64 0302113491640500473045022100b374a556771c35868566f6581907ab25facc5aa69b5414d8ea1ede57643f3b86022004cb99a8176b70d9bb7d7abfade430eebcd8fd137f5173eb20ec6b56fa53a2ec - ``` +```sh +# 使用evmctl对摘要列表进行签名 +# evmctl ima_sign --key /path/to/ima.key -a sm3 0-metadata_list-compact-tree-1.8.0-2.oe2209.x86_64 +# 检查签名后的扩展属性 +# getfattr -m - -d 0-metadata_list-compact-tree-1.8.0-2.oe2209.x86_64 +file: 0-metadata_list-compact-tree-1.8.0-2.oe2209.x86_64 +security.ima=0sAwIRNJFkBQBHMEUCIQCzdKVWdxw1hoVm9lgZB6sl+sxapptUFNjqHt5XZD87hgIgBMuZqBdrcNm7fXq/reQw7rzY/RN/UXPrIOxrVvpTouw= +security.selinux="unconfined_u:object_r:admin_home_t:s0" +# 将签名后的摘要列表文件导入内核 +# echo /root/tree/etc/ima/digest_lists/0-metadata_list-compact-tree-1.8.0-2.oe2209.x86_64 > /sys/kernel/security/ima/digest_list_data +# 检查度量日志,可以看到摘要列表的导入记录 +# cat /sys/kernel/security/ima/ascii_runtime_measurements +11 43b6981f84ba2725d05e91f19577cedb004adffb ima-sig sm3:b9430bbde2b7f30e935d91e29ab6778b6a825a2c3e5e7255895effb8747b7c1a /root/tree/etc/ima/digest_lists/0-metadata_list-compact-tree-1.8.0-2.oe2209.x86_64 0302113491640500473045022100b374a556771c35868566f6581907ab25facc5aa69b5414d8ea1ede57643f3b86022004cb99a8176b70d9bb7d7abfade430eebcd8fd137f5173eb20ec6b56fa53a2ec +``` **注意:** @@ -306,6 +247,8 @@ digest-list-tools-0.3.95-10.oe2209.x86_64 Cannon parse /etc/ima/digest_lists/0-metadata_list-rpm-...... ``` +3. 当前openEuler 24.03内核暂不支持二级商密IMA证书(/etc/keys/x509_ima.der和/etc/keys/x509_evm.der)导入。 + ## 轻量入侵检测(AIDE) AIDE是一款轻量级的入侵检测工具,主要通过检测文件的完整性,以及时发现针对系统的恶意入侵行为。AIDE数据库能够使用sha256、sha512等哈希算法,用密文形式建立每个文件的校验码或散列号。openEuler提供的AIDE在开源软件的基础上新增了对SM3算法的支持。 diff --git "a/docs/zh/docs/ShangMi/\346\246\202\350\277\260.md" "b/docs/zh/docs/ShangMi/\346\246\202\350\277\260.md" index 2b4ff12dc95ff2bc488afb751eff61e31b5b7531..bac4db358ed3a0b22b75db08f73025d209ab4d5a 100644 --- "a/docs/zh/docs/ShangMi/\346\246\202\350\277\260.md" +++ "b/docs/zh/docs/ShangMi/\346\246\202\350\277\260.md" @@ -1,4 +1,12 @@ # 概述 +国产商用密码算法(后文简称商密)属于商用的、不涉及国家秘密的密码技术。密码算法是信息系统的安全技术基础,在国际上已经有广泛使用的RSA、AES、SHA256等密码算法。与之相对的,国内也有一系列自主研发的密码算法,可以覆盖主流的应用场景。其中在操作系统场景,相对应用广泛的算法是SM2/3/4: +| 算法 | 是否公开 | 类型 | 应用场景 | +|---|---|---|---| +| SM2 | 是 | 非对称加解密算法 | 数字签名、密钥交换、加解密,广泛应用于PKI体系 | +| SM3 | 是 | 杂凑算法(哈希算法) | 应用于完整性保护、单向加密等通用场景 | +| SM4 | 是 | 对称加解密算法) | 数据加密存储、安全传输 | + +除此之外,还包括SM9、ZUC等公开算法,以及SM1、SM7等非公开算法。值得一提的是,所有已经公开的国产算法都已经纳入ISO/IEC标准,成为了被国际所认可的密码算法。围绕这些密码算法,我国制定并发布一系列密码技术规范和应用标准,如商密证书标准、TLCP协议栈等。它们共同构成了我国的商密标准体系,指导了国内的密码安全产业链的构建。 openEuler操作系统商密支持旨在对操作系统的关键安全特性进行商密算法使能,并为上层应用提供商密算法库、证书、安全传输协议等密码服务。 @@ -15,4 +23,5 @@ openEuler操作系统商密支持旨在对操作系统的关键安全特性进 9. 内核模块签名/验签支持SM2证书; 10. 内核KTLS支持SM4-CBC和SM4-GCM算法; 11. 鲲鹏KAE加速引擎支持SM3/4算法加速; -12. UEFI安全启动支持SM3摘要算法和SM2数字签名。 \ No newline at end of file +12. UEFI安全启动支持SM3摘要算法和SM2数字签名; +13. RPM支持国密SM2加解密算法+SM3摘要算法的签名及验签。 \ No newline at end of file diff --git "a/docs/zh/docs/ShangMi/\347\243\201\347\233\230\345\212\240\345\257\206.md" "b/docs/zh/docs/ShangMi/\347\243\201\347\233\230\345\212\240\345\257\206.md" index e708e6e488ae9f79634afdceba4b89e66645df07..3738629ad8116956c326ff99fc654ea9281eec3b 100644 --- "a/docs/zh/docs/ShangMi/\347\243\201\347\233\230\345\212\240\345\257\206.md" +++ "b/docs/zh/docs/ShangMi/\347\243\201\347\233\230\345\212\240\345\257\206.md" @@ -37,6 +37,7 @@ a. luks2模式 ``` # cryptsetup luksFormat /dev/sdd -c sm4-xts-plain64 --key-size 256 --hash sm3 +# cryptsetup luksOpen /dev/sdd crypt1 ``` b. plain模式 @@ -85,5 +86,5 @@ sdd 8:48 0 50G 0 disk 关闭设备: ``` -# cryptsetup luksClose crypt1 +# cryptsetup close crypt1 ``` \ No newline at end of file diff --git "a/docs/zh/docs/ShangMi/\350\257\201\344\271\246.md" "b/docs/zh/docs/ShangMi/\350\257\201\344\271\246.md" index 12d4ba5c104378351407e01d8eb23dcddbc1a2a8..f1ce7fdd9b6e18dac287e58544b75a1f131f15f7 100644 --- "a/docs/zh/docs/ShangMi/\350\257\201\344\271\246.md" +++ "b/docs/zh/docs/ShangMi/\350\257\201\344\271\246.md" @@ -45,7 +45,15 @@ $ openssl x509 -text -in sm2.crt #### 使用x509命令(一般用于功能测试) -1. 生成SM2签名私钥和签名请求: +1. 生成CA私钥和证书: + +``` +$ openssl ecparam -genkey -name SM2 -out ca.key +$ openssl req -new -sm3 -key ca.key -out ca.csr +$ openssl x509 -req -days 3650 -signkey ca.key -in ca.csr -out ca.crt +``` + +1. 生成二级签名私钥和签名请求: ``` $ openssl ecparam -genkey -name SM2 -out sm2.key diff --git a/docs/zh/docs/StratoVirt/StratoVirtGuide.md b/docs/zh/docs/StratoVirt/StratoVirtGuide.md index f4a7fc9fb1c17a06728a1d5f91eecee87e4e654d..a30dd3ff222b84a3866aca5df1e25fb0480ef17c 100644 --- a/docs/zh/docs/StratoVirt/StratoVirtGuide.md +++ b/docs/zh/docs/StratoVirt/StratoVirtGuide.md @@ -1,4 +1,3 @@ # StratoVirt用户指南 本文档介绍Stratovirt虚拟化,并给出基于openEuler安装StratoVirt的方法,以及StratoVirt虚拟化的使用指导。让用户了解Stratovirt,并指导用户和管理员安装和使用StratoVirt。 - diff --git "a/docs/zh/docs/StratoVirt/StratoVirt\344\273\213\347\273\215.md" "b/docs/zh/docs/StratoVirt/StratoVirt\344\273\213\347\273\215.md" index 9842e25a699a15057e001e585e46da8d4a05ef60..d83c172b8ac2c919a9b334deab28d52afc8e4d03 100644 --- "a/docs/zh/docs/StratoVirt/StratoVirt\344\273\213\347\273\215.md" +++ "b/docs/zh/docs/StratoVirt/StratoVirt\344\273\213\347\273\215.md" @@ -1,13 +1,10 @@ # StratoVirt介绍 - ## 概述 StratoVirt是计算产业中面向云数据中心的企业级虚拟化平台,实现了一套架构统一支持虚拟机、容器、Serverless三种场景。StratoVirt在轻量低噪、软硬协同、Rust语言级安全等方面具备关键技术竞争优势。 StratoVirt在架构设计和接口上预留了组件化拼装的能力和接口,StratoVirt可以按需灵活组装高级特性直至演化到支持标准虚拟化,在特性需求、应用场景和轻快灵巧之间找到最佳的平衡点。 - - ## 架构说明 StratoVirt核心架构自顶向下分为三层: @@ -15,8 +12,8 @@ StratoVirt核心架构自顶向下分为三层: - 外部接口:兼容QMP(QEMU Monitor Protocol)协议,具有完备的OCI兼容能力,同时支持对接libvirt。 - BootLoader:轻量化场景下抛弃传统BIOS+GRUB的启动模式实现快速启动,同时标准虚拟化场景下支持UEFI启动。 - 模拟主板: - - microvm: 充分利用软硬协同能力,精简化设备模型,低时延资源伸缩能力。 - - 标准机型:提供ACPI表实现UEFI启动,支持添加virtio-pci以及VFIO直通设备等,极大提高虚拟机的I/O性能。 + - microvm: 充分利用软硬协同能力,精简化设备模型,低时延资源伸缩能力。 + - 标准机型:提供ACPI表实现UEFI启动,支持添加virtio-pci以及VFIO直通设备等,极大提高虚拟机的I/O性能。 整体架构视图如**图1**所示。 @@ -37,15 +34,15 @@ StratoVirt核心架构自顶向下分为三层: ## 实现 -#### 运行架构 +### 运行架构 - StratoVirt虚拟机是Linux中一个独立的进程。进程有三种线程:主线程、VCPU线程、I/O线程: - - 主线程是异步收集和处理来自外部模块(如VCPU线程)的事件的循环; - - 每个VCPU都有一个线程处理本VCPU的trap事件; - - 可以为I/O设备配置iothread提升I/O性能; + - 主线程是异步收集和处理来自外部模块(如VCPU线程)的事件的循环; + - 每个VCPU都有一个线程处理本VCPU的trap事件; + - 可以为I/O设备配置iothread提升I/O性能; -#### 约束 +### 约束 -- 仅支持Linux操作系统,推荐内核版本为4.19, 5.10; -- 虚拟机操作系统仅支持Linux,内核版本建议为4.19, 5.10; +- 仅支持Linux操作系统; +- 虚拟机操作系统仅支持Linux; - 最大支持254个CPU; diff --git "a/docs/zh/docs/StratoVirt/\345\207\206\345\244\207\344\275\277\347\224\250\347\216\257\345\242\203.md" "b/docs/zh/docs/StratoVirt/\345\207\206\345\244\207\344\275\277\347\224\250\347\216\257\345\242\203.md" index 5c17d7213dd925c78d18a73921501ad26119b99f..81ebbfbb6128bb6eae3ff5ea06d4081644d6b956 100644 --- "a/docs/zh/docs/StratoVirt/\345\207\206\345\244\207\344\275\277\347\224\250\347\216\257\345\242\203.md" +++ "b/docs/zh/docs/StratoVirt/\345\207\206\345\244\207\344\275\277\347\224\250\347\216\257\345\242\203.md" @@ -72,7 +72,7 @@ $ make -j vmlinux && objcopy -O binary vmlinux vmlinux.bin ``` -5. 如果想在x86平台使用bzImzge格式的kernel,可以使用如下命令进行编译。 +5. 如果想在x86平台使用bzImage格式的kernel,可以使用如下命令进行编译。 ``` $ make -j bzImage diff --git "a/docs/zh/docs/SysCare/\344\275\277\347\224\250SysCare.md" "b/docs/zh/docs/SysCare/\344\275\277\347\224\250SysCare.md" index 4fbd5748f29d20eb8c60d01f49a18cad302a5c24..40aa4ccc18428d741094f7c2e2a30ee8d7295453 100644 --- "a/docs/zh/docs/SysCare/\344\275\277\347\224\250SysCare.md" +++ "b/docs/zh/docs/SysCare/\344\275\277\347\224\250SysCare.md" @@ -1,15 +1,18 @@ # 使用SysCare + 本章介绍在openEuler中使用SysCare的方法。 ## 前提条件 + 安装openEuler 23.09版本。 ## SysCare使用 + 本章节将介绍 SysCare 的使用方法,包含热补丁制作及热补丁管理。 ### 热补丁制作 -用户可以使用`sycare build`命令制作热补丁,该命令为纯CLI工具,提供从RPM包生成热补丁包的功能,热补丁包以RPM包的形式封装维护,支持制作内核热补丁及用户态热补丁。 +用户可以使用`syscare build`命令制作热补丁,该命令为纯CLI工具,提供从RPM包生成热补丁包的功能,热补丁包以RPM包的形式封装维护,支持制作内核热补丁及用户态热补丁。 #### 热补丁制作流程 @@ -161,8 +164,8 @@ Caused by: For more information, please check "/home/dev/syscare-build.345549/build.log" ``` - ### 热补丁包管理 + 热补丁的安装以及卸载需要提供对应rpm包的名称,下面使用`$patch_package`来指代rpm包名称。 1. 热补丁包安装 @@ -170,17 +173,20 @@ For more information, please check "/home/dev/syscare-build.345549/build.log" ```shell dnf install $patch_package.rpm ``` + 热补丁包安装后,热补丁相关文件存放在如下路径: - ``` + + ```shell /usr/lib/syscare/patches ``` 2. 热补丁包卸载 - ``` + + ```shell dnf remove $patch_package ``` - 注:若热补丁处于`ACTIVED`以上状态时,热补丁将会被自动卸载。 + 注:若热补丁处于`ACTIVED`以上状态时,热补丁将会被自动卸载。 ### 热补丁管理 @@ -189,8 +195,10 @@ For more information, please check "/home/dev/syscare-build.345549/build.log" 对单一热补丁操作前,用户需要提供一个字符串来搜索热补丁,后续使用`$patch_identifier`来指代这个字符串。 热补丁管理搜索规则为:目标包名/补丁名,其中“目标包名/”在补丁名唯一的情况下可以省略,也可使用UUID来进行管理。 -* 目标包名:待打入补丁的目标软件的软件包名称; -* 补丁名:热补丁名称。 + +- 目标包名:待打入补丁的目标软件的软件包名称; + +- 补丁名:热补丁名称。 #### 补丁元信息 @@ -230,61 +238,74 @@ patch: ``` #### 热补丁状态 + SysCare将热补丁的生命周期分成如下状态: -* 未加载:`NOT-APPLIED` -* 未激活:`DEACTIVED` -* 已激活:`ACTIVED` -* 已接受:`ACCEPTED` +- 未加载:`NOT-APPLIED` +- 未激活:`DEACTIVED` +- 已激活:`ACTIVED` +- 已接受:`ACCEPTED` #### 补丁信息查询 + 1. 补丁基本信息查询: + ```shell syscare info $patch_identifier ``` 2. 补丁状态查询: + ```shell syscare status $patch_identifier ``` 3. 查询所有补丁状态: + ```shell syscare list ``` #### 热补丁状态管理 + 1. 加载热补丁: + ```shell syscare apply $patch_identifier ``` 2. 卸载热补丁: + ```shell syscare remove $patch_identifier ``` 3. 激活热补丁: + ```shell syscare active $patch_identifier ``` 4. 反激活热补丁: + ```shell syscare deactive $patch_identifier ``` 5. 接受热补丁: + ```shell syscare accept $patch_identifier ``` 6. 保存所有补丁状态: + ```shell syscare save ``` 7. 恢复所有补丁状态: + ```shell syscare restore ``` diff --git "a/docs/zh/docs/SysCare/\345\270\270\350\247\201\351\227\256\351\242\230\344\270\216\350\247\243\345\206\263\346\226\271\346\263\225.md" "b/docs/zh/docs/SysCare/\345\270\270\350\247\201\351\227\256\351\242\230\344\270\216\350\247\243\345\206\263\346\226\271\346\263\225.md" deleted file mode 100644 index 34e0b960bf44536028429ff31017bada06b6d729..0000000000000000000000000000000000000000 --- "a/docs/zh/docs/SysCare/\345\270\270\350\247\201\351\227\256\351\242\230\344\270\216\350\247\243\345\206\263\346\226\271\346\263\225.md" +++ /dev/null @@ -1,13 +0,0 @@ -# 常见问题与解决方法 - -## 问题1:报错:“alloc upatch module memory failed” - - 原因:触发selinux约束。 - - 解决方法:按照报错建议命令操作,手动添加策略,由于不同情况添加策略不同,无法穷尽枚举,参考该issue: 。 - -## 问题2:报错: “patch file error 2” - - 原因:补丁检测失败。 - - 解决方法:补丁无法正常打入,更换补丁。 - -## 问题3:报错: “build project error 11” - - 原因:源码包编译失败。 - - 解决方法:尝试使用```rpmbuild -ra *.src.rpm```命令测试源码包是否可正常编译并满足其编译依赖。 diff --git "a/docs/zh/docs/SystemOptimization/MySQL\346\200\247\350\203\275\350\260\203\344\274\230\346\214\207\345\215\227.md" "b/docs/zh/docs/SystemOptimization/MySQL\346\200\247\350\203\275\350\260\203\344\274\230\346\214\207\345\215\227.md" index c9b155884a311c945109acedc70a0b84dca5b0ef..9b761a0990f743652aa61f008cf6368b758fd1e5 100644 --- "a/docs/zh/docs/SystemOptimization/MySQL\346\200\247\350\203\275\350\260\203\344\274\230\346\214\207\345\215\227.md" +++ "b/docs/zh/docs/SystemOptimization/MySQL\346\200\247\350\203\275\350\260\203\344\274\230\346\214\207\345\215\227.md" @@ -142,7 +142,7 @@ TLB(Translation lookaside buffer)为页表(存放虚拟地址的页地址 1. 执行`make menuconfig`。 - 2. 选择PAGESIZE大小为64K(Kernel Features--\>Page size(64KB)。 + 2. 选择PAGESIZE大小为64K(Kernel Features--\>Page size(64KB))。 3. 编译和安装内核。 @@ -325,10 +325,10 @@ sql_mode=STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_AUTO_VALUE_ON_ZERO,STRICT | innodb_read_io_threads | 执行请求队列中的读请求操作的线程数。 | 根据CPU核数及读写比例进一步更改来提高性能。 | | innodb_write_io_threads | 执行请求队列中的写请求操作的线程数。 | 根据CPU核数及读写比例进一步更改来提高性能。 | | innodb_buffer_pool_instances | 开启多个内存缓冲池,把需要缓冲的数据hash到不同的缓冲池中,这样可以并行的内存读写 | 建议设置8\~32。 | -| innodb_open_files | 在innodb_file_per_table模式下,限制Innodb能打开的文件数量。 | 建议此值调大一些,尤其是表特别多的情况。 | +| innodb_open_files | 在innodb_file_per_table模式下,限制InnoDB能打开的文件数量。 | 建议此值调大一些,尤其是表特别多的情况。 | | innodb_buffer_pool_size | 缓存数据和索引的地方。 | 通常建议内存的60%左右。 | | innodb_log_buffer_size | 缓存重做日志。 | 缺省值是64M,建议通过查看innodb_log_wait,调整innodb_log_buffer_size大小。 | -| innodb_io_capacity | innodb 后台线程每秒最大iops上限。 | 建议为IO QPS总能力的75%。 | +| innodb_io_capacity | InnoDB 后台线程每秒最大iops上限。 | 建议为IO QPS总能力的75%。 | | innodb_log_files_in_group | 重做日志组的个数。 | - | | innodb_log_file_size | 重做日志文件大小。 | 如果存在大量写操作,建议增加日志文件大小,但日志文件过大,会影响数据恢复时间。 如果是非生产环境,测试极限性能时,尽量调大日志文件。 如果是商用场景,需要考虑数据恢复时间,综合折中后设置日志文件大小。 | | innodb_flush_method | Log和数据刷新磁盘的方法: datasync模式:写数据时,write这一步并不需要真正写到磁盘才算完成(可能写入到操作系统buffer中就会返回完成),真正完成是flush操作,buffer交给操作系统去flush,并且文件的元数据信息也都需要更新到磁盘。 O_DSYNC模式:写日志操作是在write这步完成,而数据文件的写入是在flush这步通过fsync完成。 O_DIRECT模式:数据文件的写入操作是直接从mysql innodb buffer到磁盘的,并不用通过操作系统的缓冲,而真正的完成也是在flush这步,日志还是要经过OS缓冲。 | 建议O_DIRECT模式。 | diff --git "a/docs/zh/docs/TailorCustom/imageTailor\344\275\277\347\224\250\346\214\207\345\215\227.md" "b/docs/zh/docs/TailorCustom/imageTailor\344\275\277\347\224\250\346\214\207\345\215\227.md" index 72d3a4281f666f38958118d6149af570de0e6954..f17d35cead2af7fd8b5530268295baf961c5b32e 100644 --- "a/docs/zh/docs/TailorCustom/imageTailor\344\275\277\347\224\250\346\214\207\345\215\227.md" +++ "b/docs/zh/docs/TailorCustom/imageTailor\344\275\277\347\224\250\346\214\207\345\215\227.md" @@ -759,11 +759,13 @@ mkdliso -p openEuler -c custom/cfg_openEuler [--minios yes|no|force] [--sec] [-h > > - mkdliso 所在的绝对路径中不能有空格,否则会导致制作 ISO 失败。 > - 制作 ISO 的环境中,umask 的值必须设置为 0022。 +> - 命令需在/opt/imageTailor目录中执行 1. 使用 root 权限,执行 mkdliso 命令,生成 ISO 镜像文件。参考命令如下: ```shell - # sudo /opt/imageTailor/mkdliso -p openEuler -c custom/cfg_openEuler --sec + # cd /opt/imageTailor/ + # sudo mkdliso -p openEuler -c custom/cfg_openEuler --sec ``` 命令执行完成后,制作出的新文件在 /opt/imageTailor/result/{日期} 目录下,包括 openEuler-aarch64.iso 和 openEuler-aarch64.iso.sha256 。 diff --git "a/docs/zh/docs/TailorCustom/isocut\344\275\277\347\224\250\346\214\207\345\215\227.md" "b/docs/zh/docs/TailorCustom/isocut\344\275\277\347\224\250\346\214\207\345\215\227.md" index 79d839523105d0e9415064c965a7f5b294ae2463..8fb860279f638d905f431860cdf9ab52db73702a 100644 --- "a/docs/zh/docs/TailorCustom/isocut\344\275\277\347\224\250\346\214\207\345\215\227.md" +++ "b/docs/zh/docs/TailorCustom/isocut\344\275\277\347\224\250\346\214\207\345\215\227.md" @@ -7,11 +7,12 @@ - [命令介绍](#命令介绍) - [软件包来源](#软件包来源) - [操作指导](#操作指导) -- [FAQ](#FAQ) + - [新镜像的自动安装(在riscv64环境下)](#新镜像的自动安装在riscv64环境下) +- [FAQ](#faq) - [默认 rpm 包列表安装系统失败](#默认-rpm-包列表安装系统失败) - ## 简介 + openEuler 光盘镜像较大,下载、传输镜像很耗时。另外,使用 openEuler 光盘镜像安装操作系统时,会安装镜像所包含的全量 RPM 软件包,用户无法只安装部分所需的软件包。 在某些场景下,用户不需要安装镜像提供的全量软件包,或者需要一些额外的软件包。因此,openEuler 提供了镜像裁剪定制工具。通过该工具,用户可以基于 openEuler 光盘镜像裁剪定制仅包含所需 RPM 软件包的 ISO 镜像。这些软件包可以来自原有 ISO 镜像,也可以额外指定,从而满足用户定制需求。 @@ -22,34 +23,25 @@ openEuler 光盘镜像较大,下载、传输镜像很耗时。另外,使用 使用 openEuler 裁剪定制工具制作 ISO 所使用的机器需要满足如下软硬件要求: -- CPU 架构为 AArch64 或者 x86_64 -- 操作系统为 openEuler 20.03 LTS SP3 +- CPU 架构为 AArch64 / x86_64 / riscv64 - 建议预留 30 GB 以上的磁盘空间(用于运行裁剪定制工具和存放 ISO 镜像) ## 安装工具 -此处以 openEuler 20.03 LTS SP3 版本的 AArch64 架构为例,介绍 ISO 镜像裁剪定制工具的安装操作。 - -1. 确认机器已安装操作系统 openEuler 20.03 LTS SP3(镜像裁剪定制工具的运行环境)。 +1. 确认机器已安装操作系统。 ``` shell script - $ cat /etc/openEuler-release - openEuler release 20.03 (LTS-SP3) + # cat /etc/openEuler-release ``` 2. 下载对应架构的 ISO 镜像(必须是 everything 版本),并存放在任一目录(建议该目录磁盘空间大于 20 GB),此处假设存放在 /home/isocut_iso 目录。 - AArch64 架构的镜像下载链接为: + AArch64 架构的镜像下载链接为: + x86_64 架构的镜像下载链接为: + riscv64 架构的镜像下载链接为: - https://repo.openeuler.org/openEuler-20.03-LTS-SP3/ISO/aarch64/openEuler-20.03-LTS-SP3-everything-aarch64-dvd.iso +3. 创建文件 /etc/yum.repos.d/local.repo,配置对应 yum 源。配置内容参考如下,其中 baseurl 是用于挂载 ISO 镜像的目录。 - > **说明:** - > x86_64 架构的镜像下载链接为: - > - > https://repo.openeuler.org/openEuler-20.03-LTS-SP3/ISO/x86_64/openEuler-20.03-LTS-SP3-everything-x86_64-dvd.iso - -3. 创建文件 /etc/yum.repos.d/local.repo,配置对应 yum 源。配置内容参考如下,其中 baseurl 是用于挂载 ISO 镜像的目录: - ``` shell script [local] name=local @@ -57,21 +49,21 @@ openEuler 光盘镜像较大,下载、传输镜像很耗时。另外,使用 gpgcheck=0 enabled=1 ``` - -4. 使用 root 权限,挂载光盘镜像到 /home/isocut_mount 目录(请与上述 repo 文件中配置的 baseurl 保持一致)作为 yum 源,参考命令如下: + +4. 使用 root 权限,挂载光盘镜像到 /home/isocut_mount 目录(请与上述 repo 文件中配置的 baseurl 保持一致)作为 yum 源。参考命令如下: ```shell - sudo mount -o loop /home/isocut_iso/openEuler-20.03-LTS-SP3-everything-aarch64-dvd.iso /home/isocut_mount + sudo mount -o loop /home/isocut_iso/openEuler-24.03-LTS-everything-aarch64-dvd.iso /home/isocut_mount ``` -5. 使 yum 源生效: +5. 使 yum 源生效。 ```shell yum clean all yum makecache ``` -6. 使用 root 权限,安装镜像裁剪定制工具: +6. 使用 root 权限,安装镜像裁剪定制工具。 ```shell sudo yum install -y isocut @@ -97,11 +89,9 @@ openEuler 光盘镜像较大,下载、传输镜像很耗时。另外,使用 -k file_path kickstart file ``` - - ## 裁剪定制镜像 -此处介绍如何使用镜像裁剪定制工具基于 openEuler 光盘镜像裁剪或添加额外 RPM 软件包制作新镜像的方法。 +此处介绍如何使用镜像裁剪定制工具基于 openEuler 光盘镜像裁剪或添加额外 RPM 软件包制作新镜像的方法。 ### 命令介绍 @@ -122,8 +112,6 @@ openEuler 光盘镜像较大,下载、传输镜像很耗时。另外,使用 | *source_iso* | 是 | 用于裁剪的 ISO 源镜像所在路径和名称。不指定路径时,默认当前路径。 | | *dest_iso* | 是 | 裁剪定制生成的 ISO 新镜像存放路径和名称。不指定路径时,默认当前路径。 | - - ### 软件包来源 新镜像的 RPM 包来源有: @@ -132,14 +120,11 @@ openEuler 光盘镜像较大,下载、传输镜像很耗时。另外,使用 - 额外指定。执行 **isocut** 时使用 -r 参数指定软件包所在路径,并将添加的 RPM 包按上述格式添加到配置文件 /etc/isocut/rpmlist 中。 - - >![](./public_sys-resources/icon-note.gif) **说明:** > >- 裁剪定制镜像时,若无法找到配置文件中指定的 RPM 包,则镜像中不会添加该 RPM 包。 >- 若 RPM 包的依赖有问题,则裁剪定制镜像时可能会报错。 - ### kickstart 功能介绍 用户需要实现镜像自动化安装,可以通过 kickstart 的方式。在执行 **isocut** 时使用 -k 参数指定 kickstart 文件。 @@ -165,15 +150,15 @@ isocut 为用户提供了 kickstart 模板,路径是 /etc/isocut/anaconda-ks.c rootpw --iscrypted ${pwd} ``` -这里给出设置 root 初始密码的方法(需使用 root 权限): +这里给出设置 root 初始密码的方法(需使用 root 权限)。 1. 添加用于生成密码的用户,此处假设 testUser。 ``` shell script - $ sudo useradd testUser + sudo useradd testUser ``` -2. 设置 testUser 用户的密码。参考命令如下,根据提示设置密码: +2. 设置 testUser 用户的密码。参考命令如下,根据提示设置密码。 ``` shell script $ sudo passwd testUser @@ -190,14 +175,15 @@ rootpw --iscrypted ${pwd} testUser:***:19052:0:90:7:35:: ``` -4. 拷贝上述加密密码替换 /etc/isocut/anaconda-ks.cfg 中的 pwd 字段,如下所示(请用实际内容替换 *** ): +4. 拷贝上述加密密码替换 /etc/isocut/anaconda-ks.cfg 中的 pwd 字段,如下所示(请用实际内容替换 *** )。 + ``` shell script rootpw --iscrypted *** ``` ###### 配置 grub2 初始密码 -/etc/isocut/anaconda-ks.cfg 文件中添加以下配置,配置 grub2 初始密码。其中 ${pwd} 需要替换成用户实际的加密密文: +/etc/isocut/anaconda-ks.cfg 文件中添加以下配置,配置 grub2 初始密码。其中 ${pwd} 需要替换成用户实际的加密密文。 ```shell %addon com_huawei_grub_safe --iscrypted --password='${pwd}' @@ -209,27 +195,18 @@ rootpw --iscrypted ${pwd} > - 配置 grub 初始密码需要使用 root 权限。 > - grub 密码对应的默认用户为 root 。 > -> - 系统中需有 grub2-set-password 命令,若不存在,请提前安装该命令。 +> - 系统中需有 grub2-mkpasswd-pbkdf2 命令,若不存在,请提前安装该命令。 -1. 执行如下命令,根据提示设置 grub2 密码: +1. 执行如下命令,根据提示设置 grub2 密码。 ```shell - $ sudo grub2-set-password -o ./ + $ sudo grub2-mkpasswd-pbkdf2 -o ./ Enter password: Confirm password: - grep: .//grub.cfg: No such file or directory - WARNING: The current configuration lacks password support! - Update your configuration with grub2-mkconfig to support this feature. + PBKDF2 hash of your password is grub.pbkdf2.sha512.*** ``` -2. 命令执行完成后,会在当前目录生成 user.cfg 文件,grub.pbkdf2.sha512 开头的内容即 grub2 加密密码。 - - ```shell - $ sudo cat user.cfg - GRUB2_PASSWORD=grub.pbkdf2.sha512.*** - ``` - -3. 复制上述密文,并在 /etc/isocut/anaconda-ks.cfg 文件中增加如下配置: +2. 复制上述密文,并在 /etc/isocut/anaconda-ks.cfg 文件中增加如下配置。 ```shell %addon com_huawei_grub_safe --iscrypted --password='grub.pbkdf2.sha512.***' @@ -267,6 +244,9 @@ kernel.aarch64 %end ``` +##### (在使用 QEMU 启动的 riscv64 中需要)修改 kickstart 文件中的设备名 + +将 `/etc/isocut/anaconda-ks.cfg` 中所有 `sda` 改为 `vda`(共 3 处),使其与 QEMU 虚拟机使用的 VirtIO 设备名称一致,确保自动化安装识别磁盘。 ### 操作指导 @@ -274,11 +254,9 @@ kernel.aarch64 > >- 请不要修改或删除 /etc/isocut/rpmlist 文件中的默认配置项。 >- isocut 的所有操作需要使用 root 权限。 ->- 待裁剪的源镜像可以为基础镜像,也可以是 everything 版镜像,例子中以基础版镜像 openEuler-20.03-LTS-SP3-aarch64-dvd.iso 为例。 +>- 待裁剪的源镜像可以为基础镜像,也可以是 everything 版镜像,例子中以基础版镜像 openEuler-24.03-LTS-aarch64-dvd.iso 为例。 >- 例子中假设新生成的镜像名称为 new.iso,且存放在 /home/result 路径;运行工具的临时目录为 /home/temp;额外的 RPM 软件包存放在 /home/rpms 目录。 - - 1. 修改配置文件 /etc/isocut/rpmlist,指定用户需要安装的 RPM 软件包(来自原有 ISO 镜像)。 ``` shell script @@ -298,13 +276,13 @@ kernel.aarch64 /dev/sda2 976M 114M 796M 13% /boot /dev/mapper/openeuler_openeuler-home 61G 21G 38G 35% /home ``` - + 3. 执行裁剪定制。 **场景一**:新镜像的所有 RPM 包来自原有 ISO 镜像 ``` shell script - $ sudo isocut -t /home/temp /home/isocut_iso/openEuler-20.03-LTS-SP3-aarch64-dvd.iso /home/result/new.iso + $ sudo isocut -t /home/temp /home/isocut_iso/openEuler-24.03-LTS-aarch64-dvd.iso /home/result/new.iso Checking input ... Checking user ... Checking necessary tools ... @@ -322,19 +300,73 @@ kernel.aarch64 ISO cutout succeeded, enjoy your new image "/home/result/new.iso" isocut.lock unlocked ... ``` + 回显如上,说明新镜像 new.iso 定制成功。 **场景二**:新镜像的 RPM 包除来自原有 ISO 镜像,还包含来自 /home/rpms 的额外软件包 - + ```shell - sudo isocut -t /home/temp -r /home/rpms /home/isocut_iso/openEuler-20.03-LTS-SP3-aarch64-dvd.iso /home/result/new.iso + sudo isocut -t /home/temp -r /home/rpms /home/isocut_iso/openEuler-24.03-LTS-aarch64-dvd.iso /home/result/new.iso ``` **场景三**:使用 kickstart 文件实现自动化安装,需要修改 /etc/isocut/anaconda-ks.cfg 文件 + ```shell - sudo isocut -t /home/temp -k /etc/isocut/anaconda-ks.cfg /home/isocut_iso/openEuler-20.03-LTS-SP3-aarch64-dvd.iso /home/result/new.iso + sudo isocut -t /home/temp -k /etc/isocut/anaconda-ks.cfg /home/isocut_iso/openEuler-24.03-LTS-aarch64-dvd.iso /home/result/new.iso ``` +### 新镜像的自动安装(在riscv64环境下) + +1. 使用 UEFI 启动,下载 `RISCV_VIRT_CODE.fd` 和 `RISCV_VIRT_VARS.fd` + 可在 [openEuler 官方镜像站](https://dl-cdn.openeuler.openatom.cn/openEuler-24.03-LTS/virtual_machine_img/riscv64/) 获取。 + +2. 创建虚拟硬盘,例如: + + ``` + qemu-img create -f qcow2 riscv\_disk.qcow2 10G + ``` + +3. 使用如下脚本完成自动安装: + + ``` + \#!/usr/bin/env bash + + # Variables + + vcpu=8 + memory=8 + drive="\$(ls \*.qcow2)" + fw1="RISCV\_VIRT\_CODE.fd" + fw2="RISCV\_VIRT\_VARS.fd" + ssh\_port=12055 + cdrom="new\.iso" + + cmd="qemu-system-riscv64 + -nographic + -machine virt,pflash0=pflash0,pflash1=pflash1,acpi=off + -smp \$vcpu -m \${memory}G + -blockdev node-name=pflash0,driver=file,read-only=on,filename=\$fw1 + -blockdev node-name=pflash1,driver=file,filename=\$fw2 + -drive file=\$drive,format=qcow2,id=hd0 + -device virtio-blk-device,drive=hd0,bootindex=1 + -device virtio-scsi-device,id=scsi0 + -drive if=none,file=\$cdrom,id=cdrom,media=cdrom,readonly=on + -device scsi-cd,drive=cdrom,bootindex=2 + -object rng-random,filename=/dev/urandom,id=rng0 + -device virtio-rng-device,rng=rng0 + -device virtio-net-device,netdev=net0 + -netdev user,id=net0,hostfwd=tcp::\$ssh\_port-:22" + + echo ":: Starting RISC-V VM with kickstart ISO..." + echo "vCPU: \$vcpu" + echo "Memory: \${memory}G" + echo "Disk: \$drive" + echo "ISO: \$cdrom" + echo "SSH Port: \$ssh\_port" + sleep 1 + + eval \$cmd + ``` ## FAQ @@ -365,11 +397,12 @@ kernel.aarch64 1. 增加缺少的包 - 1. 根据报错的提示整理缺少的 RPM 包列表 + 1. 根据报错的提示整理缺少的 RPM 包列表。 2. 将上述 RPM 包列表添加到配置文件 /etc/isocut/rpmlist 中。 - 3. 再次裁剪安装 iso 镜像 + 3. 再次裁剪安装 iso 镜像。 以问题描述中的缺包情况为例,修改 rpmlist 配置文件如下: + ```shell $ cat /etc/isocut/rpmlist kernel.aarch64 @@ -381,4 +414,3 @@ kernel.aarch64 grub2-efi-aa64.aarch64 dosfstools.aarch64 ``` - diff --git a/docs/zh/docs/Virtualization/LibcarePlus.md b/docs/zh/docs/Virtualization/LibcarePlus.md index 52f5fef43ad2e035748ac5ce8bd91f69cb7fac49..ce7cd7d736ef7cffba4a45508322d3192d136e92 100644 --- a/docs/zh/docs/Virtualization/LibcarePlus.md +++ b/docs/zh/docs/Virtualization/LibcarePlus.md @@ -6,6 +6,7 @@ - [安装 LibcarePlus](#安装-libcareplus) - [制作 LibcarePlus 热补丁](#制作-libcareplus-热补丁) - [应用 LibcarePlus 热补丁](#应用-libcareplus-热补丁) +- [使用 LibcarePlus 工具制作 qemu 热补丁](#使用-libcareplus-工具制作-qemu-热补丁) ## 概述 @@ -395,3 +396,98 @@ LibcarePlus 支持如下方式制作热补丁: Hello world! Hello world! ``` + +## 使用 LibcarePlus 工具制作 qemu 热补丁 + +制作方法如下: + +### 1.下载qemu制品仓代码,保持代码版本与openEuler环境中qemu版本一致 + ```shell +# 下载qemu源码并解压 +yum download --source qemu +rpm2cpio qemu-8.2.0-13.oe2403.src.rpm | cpio -id + ``` + +### 2.编译qemu制品仓代码 + +- 将解压后的qemu源码挪至/root/rpmbuild/SOURCES(由多个patch、一个qemu.spec、一个qemu-8.2.0.tar.xz组成) + +- 编译qemu.spec + + ```shell + rpmbuild -ba qemu.spec + ``` + +有两份成果物: +- /root/rpmbuild/BUILD/qemu-8.2.0中生成中间代码,为编译qemu对应代码。将代码拷贝到/home/abuild/rpmbuild/BUILD/qemu-8.2.0,编译环境的路径也会影响补丁地址的偏移。 +- /root/rpmbuild/RPMS/中生成qemu相关的rpm包。 + +### 3.制作热补丁所需的patch文件 + + 使用git format-patch指令制作patch即可。 + + ```shell + # cat 0001-hack-hmp-qtree-info.patch + From bb2f4e6fe43ca7b3d73026966ac3411b2d8342b9 Mon Sep 17 00:00:00 2001 + From: zhangsan + Date: Mon, 7 Mar 2022 20:53:41 +0800 + Subject: [PATCH 1/3] hack hmp qtree info + + --- + softmmu/qdev-monitor.c | 1 + + 1 file changed, 1 insertion(+) + + diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c + index 05e1d88d99..96fd596c2e 100644 + --- a/softmmu/qdev-monitor.c + +++ b/softmmu/qdev-monitor.c + @@ -833,6 +833,7 @@ static void qbus_print(Monitor *mon, BusState *bus, int indent) + + void hmp_info_qtree(Monitor *mon, const QDict *qdict) + { + + fprintf(stderr, "---------------you hack me---------------------"); + if (sysbus_get_default()) + qbus_print(mon, sysbus_get_default(), 0); + } + -- + 2.33.0 + + ``` + +### 3.配置/etc/libcare.conf + /etc/libcare.conf填上patch文件修改的函数,用于后续制作补丁时,过滤掉不相关的函数; + 当前修改内容如下: + + ```shell + # cat /etc/libcare.conf + hmp_info_qtree + ``` + +### 4.查看qemu buildID + + ```shell + # whereis qemu-kvm + qemu-kvm: /usr/bin/qemu-kvm /usr/libexec/qemu-kvm + # file /usr/libexec/qemu-kvm + /usr/libexec/qemu-kvm: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, BuildID[sha1]=68f4ec13e140d3a688f3e0fb93442b8c7a86be8b, for GNU/Linux 3.7.0, stripped + ``` +注:需保持制作热补丁的环境和制作qemu包环境一致,buildID可作为二者是否一致的判定标准。因用户无qemu版本的制作环境,故可以自行编包并安装,使用自编包中的/usr/libexec/qemu-kvm的buildID。 + +### 5.制作热补丁 + +在/home/abuild/rpmbuild/BUILD/qemu-8.2.0/build中执行热补丁制作指令,**注意是build目录!!!** + +```shell +# libcare-patch-make --clean -s ../ 0002-patch-hello-qdm.patch -i 0001 --buildid=68f4ec13e140d3a688f3e0fb93442b8c7a86be8b -j 64 +``` +参数说明: + +--clean 类似make clean + +-s ../ 指定源文件夹,这里是上层目录 + +-i 0001 热补丁id + +buildid=xxx 保持和系统中qemu-kvm buildid一致 + +-j 64 多线程编译 \ No newline at end of file diff --git "a/docs/zh/docs/Virtualization/\345\207\206\345\244\207\344\275\277\347\224\250\347\216\257\345\242\203.md" "b/docs/zh/docs/Virtualization/\345\207\206\345\244\207\344\275\277\347\224\250\347\216\257\345\242\203.md" index bb05c54bfbb483023f205d6bb60545122c3209c4..dae76320e5f6ef28cd1b6807084695e5b53ac3dd 100644 --- "a/docs/zh/docs/Virtualization/\345\207\206\345\244\207\344\275\277\347\224\250\347\216\257\345\242\203.md" +++ "b/docs/zh/docs/Virtualization/\345\207\206\345\244\207\344\275\277\347\224\250\347\216\257\345\242\203.md" @@ -13,7 +13,7 @@ 1. 使用root用户安装qemu-img软件包。 ```sh - # yum install -y qemu-img + yum install -y qemu-img ``` 2. 使用qemu-img工具的create命令,创建镜像文件,命令格式为: @@ -62,7 +62,7 @@ corrupt: false ``` -2. 修改镜像磁盘空间大小,命令如下,其中_imgFiLeName_为镜像名称,“+”和“-”分别表示需要增加或减小的镜像磁盘空间大小,单位为K、M、G、T,代表KiB、MiB、GiB、TiB。 +2. 修改镜像磁盘空间大小,命令如下,其中 _imgFiLeName_ 为镜像名称,“+”和“-”分别表示需要增加或减小的镜像磁盘空间大小,单位为K、M、G、T,代表KiB、MiB、GiB、TiB。 ```sh qemu-img resize [+|-] @@ -117,39 +117,39 @@ Linux网桥通常通过brctl工具管理,其对应的安装包为bridge-utils,安装命令如下: ```sh - # yum install -y bridge-utils + yum install -y bridge-utils ``` 2. 创建网桥br0。 ```sh - # brctl addbr br0 + brctl addbr br0 ``` 3. 将物理网卡eth0绑定到Linux网桥。 ```sh - # brctl addif br0 eth0 + brctl addif br0 eth0 ``` 4. eth0与网桥连接后,不再需要IP地址,将eth0的IP设置为0.0.0.0。 ```sh - # yum install -y net-tools - # ifconfig eth0 0.0.0.0 + yum install -y net-tools + ifconfig eth0 0.0.0.0 ``` 5. 设置br0的IP地址。 - 如果有DHCP服务器,可以通过dhclient设置动态IP地址。 ```sh - # dhclient br0 + dhclient br0 ``` - 如果没有DHCP服务器,给br0配置静态IP,例如设置静态IP为192.168.1.2,子网掩码为255.255.255.0。 ```sh - # ifconfig br0 192.168.1.2 netmask 255.255.255.0 + ifconfig br0 192.168.1.2 netmask 255.255.255.0 ``` ### 搭建Open vSwitch网桥 @@ -227,32 +227,32 @@ Open vSwitch网桥,具有更便捷的自动化编排能力。搭建Open vSwitc 1. 创建Open vSwitch网桥br0。 ```sh - # ovs-vsctl add-br br0 + ovs-vsctl add-br br0 ``` 2. 将物理网卡eth0添加到br0。 ```sh - # ovs-vsctl add-port br0 eth0 + ovs-vsctl add-port br0 eth0 ``` 3. eth0与网桥连接后,不再需要IP地址,将eth0的IP设置为0.0.0.0。 ```sh - # ifconfig eth0 0.0.0.0 + ifconfig eth0 0.0.0.0 ``` 4. 为OVS网桥br0分配IP。 - 如果有DHCP服务器,可以通过dhclient设置动态IP地址。 ```sh - # dhclient br0 + dhclient br0 ``` - 如果没有DHCP服务器,给br0配置静态IP,例如192.168.1.2。 ```sh - # ifconfig br0 192.168.1.2 + ifconfig br0 192.168.1.2 ``` ## 准备引导固件 @@ -272,13 +272,13 @@ Open vSwitch网桥,具有更便捷的自动化编排能力。搭建Open vSwitc 在AArch64架构下edk2的包名为edk2-aarch64 ```sh - # yum install -y edk2-aarch64 + yum install -y edk2-aarch64 ``` 在x86\_64架构下edk2的包名为edk2-ovmf ```sh - # yum install -y edk2-ovmf + yum install -y edk2-ovmf ``` 2. 查询edk软件是否安装成功,命令如下: @@ -331,13 +331,13 @@ openEuler虚拟化使用virsh管理虚拟机。如果希望在非root用户使 2. 将非root用户添加到libvirt用户组。 ```sh - # usermod -a -G libvirt userName + usermod -a -G libvirt userName ``` 3. 切换到非root用户。 ```sh - # su userName + su userName ``` 4. 配置非root用户的环境变量。使用vim打开~/.bashrc文件: @@ -358,8 +358,20 @@ openEuler虚拟化使用virsh管理虚拟机。如果希望在非root用户使 source ~/.bashrc ``` -5. 在虚拟机XML配置文件中的domain根元素中添加如下内容,使qemu-kvm进程可以访问磁盘镜像文件。 +5. 在虚拟机XML配置文件(/etc/libvirt/qemu/目录下)中的domain根元素中添加如下内容,使qemu-kvm进程可以访问磁盘镜像文件。 + 执行如下命令查询当前运行的虚拟机 + + ```sh + virsh list + ``` + 使用如下命令编辑对应虚拟机的XML,name参数为上一步查询到的需要修改的目标虚拟机名称 + + ```sh + virsh edit + ``` + 添加如下配置,编辑后保存即可生效 + ```xml ``` diff --git "a/docs/zh/docs/Virtualization/\347\203\255\350\277\201\347\247\273\350\231\232\346\213\237\346\234\272.md" "b/docs/zh/docs/Virtualization/\347\203\255\350\277\201\347\247\273\350\231\232\346\213\237\346\234\272.md" index ecf6a17c90562a37ba2b42ba1f484bc243b260c5..2bebb1592e32779a7281d59f9ea7dde541d33fc8 100644 --- "a/docs/zh/docs/Virtualization/\347\203\255\350\277\201\347\247\273\350\231\232\346\213\237\346\234\272.md" +++ "b/docs/zh/docs/Virtualization/\347\203\255\350\277\201\347\247\273\350\231\232\346\213\237\346\234\272.md" @@ -148,7 +148,7 @@ virsh qemu-monitor-command openEulerVM '{"execute":"query-dirty-rate"}' 1. 确认是否为共享存储。 ``` - # virsh domblklist + # virsh domblklist Target Source -------------------------------------------- sda /dev/mapper/open_euleros_disk diff --git "a/docs/zh/docs/Virtualization/\347\256\241\347\220\206\347\263\273\347\273\237\350\265\204\346\272\220.md" "b/docs/zh/docs/Virtualization/\347\256\241\347\220\206\347\263\273\347\273\237\350\265\204\346\272\220.md" index 1021dd4c648947e2796d2bbd61d3ea9e59c9a52a..7128d26331ac8562ccf1307e668c504ca081d2d0 100644 --- "a/docs/zh/docs/Virtualization/\347\256\241\347\220\206\347\263\273\347\273\237\350\265\204\346\272\220.md" +++ "b/docs/zh/docs/Virtualization/\347\256\241\347\220\206\347\263\273\347\273\237\350\265\204\346\272\220.md" @@ -196,36 +196,40 @@ QEMU主进程绑定特性是将QEMU主进程绑定到特定的物理CPU范围内 以上命令把虚拟机_open__Euler__VM_的vCPU0绑定到物理CPU0、2、3上,即限制了vCPU0只在这三个物理CPU上调度。**这一绑定关系的调整不会立即生效,在虚拟机下一次启动后才生效,并持久生效**。 -### CPU热插 +### CPU热插拔 #### 概述 -在线增加(热插)虚拟机CPU是指在虚拟机处于运行状态下,为虚拟机热插CPU而不影响虚拟机正常运行的方案。当虚拟机内部业务压力不断增大,会出现所有CPU均处于较高负载的情形。为了不影响虚拟机内的正常业务运行,可以使用CPU热插功能(在不关闭虚拟机情况下增加虚拟机的CPU数目),提升虚拟机的计算能力。 +在线增加或减少(热插拔)虚拟机CPU是指在虚拟机处于运行状态下,为虚拟机热插拔CPU而不影响虚拟机正常运行的方案。当虚拟机内部业务压力不断增大,会出现所有CPU均处于较高负载的情形。为了不影响虚拟机内的正常业务运行,可以使用CPU热插功能(在不关闭虚拟机情况下增加虚拟机的CPU数目),提升虚拟机的计算能力。当虚拟机内部业务压力下降时,可以使用CPU热拔功能(在不关闭虚拟机情况下减少虚拟机的CPU数目)去除多余的计算能力,降低业务成本。 + +注意:从2403版本开始,AArch64架构新增了CPU热拔功能,但实现上采用了新的主线社区方案,和之前版本的CPU热插协议不兼容。Guest版本和Host版本需匹配,即2403及将来版本的Guest需搭配2403及将来版本的Host,2403之前版本的Guest需搭配2403之前版本的Host,才能正常使用CPU热插(拔)功能。 #### 约束限制 -- 如果处理器为AArch64架构,创建虚拟机时指定的虚拟机芯片组类型\(machine\)需为virt-4.1或virt更高版本。如果处理器为x86\_64架构,创建虚拟机时指定的虚拟机芯片组类型\(machine\)需为pc-i440fx-1.5或pc更高版本。 -- 在配置Guest NUMA的场景中,必须把属于同一个socket的vcpu配置在同一vNode中,否则热插CPU后可能导致虚拟机softlockup,进而可能导致虚拟机panic。 -- 虚拟机在迁移、休眠唤醒、快照过程中均不支持CPU热插。 +- 如果处理器为AArch64架构,创建虚拟机时指定的虚拟机芯片组类型\(machine\)需为virt-4.2或virt更高版本。如果处理器为x86\_64架构,创建虚拟机时指定的虚拟机芯片组类型\(machine\)需为pc-i440fx-1.5或pc更高版本。 +- 对于AArch64架构虚拟机,初始启动时就存在的CPU不支持热插拔。 +- 在配置Guest NUMA的场景中,必须把属于同一个socket的vcpu配置在同一vNode中,否则热插拔CPU后可能导致虚拟机softlockup,进而可能导致虚拟机panic。 +- 虚拟机在迁移、休眠唤醒、快照过程中均不支持CPU热插拔。 - 虚拟机CPU热插是否自动上线取决于虚拟机操作系统自身逻辑,虚拟化层不保证热插CPU自动上线。 - CPU热插同时受限于Hypervisor和GuestOS支持的最大CPU数目。 - 虚拟机启动、关闭、重启过程中可能出现热插CPU失效的情况,但再次重启会生效。 -- 热插虚拟机CPU的时候,如果新增CPU数目不是虚拟机CPU拓扑配置项中Cores的整数倍,可能会导致虚拟机内部看到的CPU拓扑是混乱的,建议每次新增的CPU数目为Cores的整数倍。 -- 若需要热插CPU在线生效且在虚拟机重启后仍有效,virsh setvcpus接口中需要同时传入--config和--live选项, 将热插CPU动作持久化。 +- 虚拟机启动、关闭、重启过程中可能出现热拔CPU超时失败的情况,需等虚拟机回到正常运行状态重试。 +- 热插拔虚拟机CPU的时候,如果新增CPU数目不是虚拟机CPU拓扑配置项中Cores的整数倍,可能会导致虚拟机内部看到的CPU拓扑是混乱的,建议每次新增或减少的CPU数目为Cores的整数倍。 +- 若需要热插拔CPU在线生效且在虚拟机重启后仍有效,virsh setvcpus接口中需要同时传入--config和--live选项, 将热插拔CPU动作持久化。 #### 操作步骤 **一、配置虚拟机XML** -1. 使用CPU热插功能,需要在创建虚拟机时配置虚拟机当前的CPU数目、虚拟机所支持的最大CPU数目,以及虚拟机芯片组类型(对于AArch64架构,需为virt-4.1及以上版本。对于x86\_64架构,需为pc-i440fx-1.5及以上版本)。这里以AArch64架构虚拟机为例,配置模板如下: +1. 使用CPU热插拔功能,需要在创建虚拟机时配置虚拟机当前的CPU数目、虚拟机所支持的最大CPU数目,以及虚拟机芯片组类型(对于AArch64架构,需为virt-4.2及以上版本。对于x86\_64架构,需为pc-i440fx-1.5及以上版本)。这里以AArch64架构虚拟机为例,配置模板如下: ``` ... n - hvm + hvm ... @@ -242,7 +246,7 @@ QEMU主进程绑定特性是将QEMU主进程绑定到特定的物理CPU范围内 …… 64 - hvm + hvm …… ``` @@ -283,6 +287,24 @@ QEMU主进程绑定特性是将QEMU主进程绑定到特定的物理CPU范围内 >- --live: 选项,选填。在线生效。 +**三、热拔CPU** + +利用virsh工具进行虚拟机CPU热拔操作。例如给虚拟机openEulerVM热拔CPU到4,参考命令如下: + + ``` + virsh setvcpus openEulerVM 4 --live + ``` + + >![](./public_sys-resources/icon-note.gif) **说明:** + >virsh setvcpus 进行虚拟机CPU热拔操作的格式如下: + >``` + >virsh setvcpus [--config] [--live] + >``` + >- domain: 参数,必填。指定虚拟机名称。 + >- count: 参数,必填。指定目标CPU数目,即热拔后虚拟机CPU数目。 + >- --config: 选项,选填。虚拟机下次启动时仍有效。 + >- --live: 选项,选填。在线生效。 + ## 管理虚拟内存 ### NUMA简介 diff --git "a/docs/zh/docs/Virtualization/\347\256\241\347\220\206\350\231\232\346\213\237\346\234\272.md" "b/docs/zh/docs/Virtualization/\347\256\241\347\220\206\350\231\232\346\213\237\346\234\272.md" index 24fe2efb0d088971efe5ac5cf20978b4c1b90b36..3b00322d6dafdcb9add8b6e5d21fd9cc6021a082 100644 --- "a/docs/zh/docs/Virtualization/\347\256\241\347\220\206\350\231\232\346\213\237\346\234\272.md" +++ "b/docs/zh/docs/Virtualization/\347\256\241\347\220\206\350\231\232\346\213\237\346\234\272.md" @@ -103,7 +103,7 @@ virsh - _obj_:命令操作对象,如指定需要操作的虚拟机。 - _options_:命令选项,该参数可选。 -虚拟机生命周期管理各命令如[表1](#table389518422611)所示。其中VMInstanse为虚拟机名称、虚拟机ID或者虚拟机UUID,XMLFile是虚拟机XML配置文件,DumpFile为转储文件,请根据实际情况修改。 +虚拟机生命周期管理各命令如[表1](#table389518422611)所示。其中VMInstance为虚拟机名称、虚拟机ID或者虚拟机UUID,XMLFile是虚拟机XML配置文件,DumpFile为转储文件,请根据实际情况修改。 **表 1** 虚拟机生命周期管理命令 @@ -124,27 +124,27 @@ virsh

创建一个临时性虚拟机,创建完成后虚拟机处于运行状态

-

virsh start <VMInstanse>

+

virsh start <VMInstance>

启动虚拟机

-

virsh shutdown <VMInstanse>

+

virsh shutdown <VMInstance>

关闭虚拟机。启动虚拟机关机流程,若关机失败可使用强制关闭

-

virsh destroy <VMInstanse>

+

virsh destroy <VMInstance>

强制关闭虚拟机

-

virsh reboot <VMInstanse>

+

virsh reboot <VMInstance>

重启虚拟机

-

virsh save <VMInstanse> <DumpFile>

+

virsh save <VMInstance> <DumpFile>

将虚拟机的运行状态转储到文件中

@@ -154,17 +154,17 @@ virsh

从虚拟机状态转储文件恢复虚拟机

-

virsh suspend <VMInstanse>

+

virsh suspend <VMInstance>

暂停虚拟机的运行,使虚拟机处于paused状态

-

virsh resume <VMInstanse>

+

virsh resume <VMInstance>

唤醒虚拟机,将处于paused状态的虚拟机恢复到运行状态

-

virsh undefine <VMInstanse>

+

virsh undefine <VMInstance>

销毁持久性虚拟机,虚拟机生命周期完结,不能继续对该虚拟机继续操作

@@ -217,13 +217,13 @@ virsh - 若虚拟机启动时未使用nvram文件,销毁虚拟机命令如下: ``` - # virsh undefine + # virsh undefine ``` - 若虚拟机启动时使用了nvram文件,销毁该虚拟机需要指定nvram的处理策略,命令如下: ``` - # virsh undefine + # virsh undefine ``` 其中\为销毁虚拟机的策略,可取值: diff --git "a/docs/zh/docs/Virtualization/\347\256\241\347\220\206\350\231\232\346\213\237\346\234\272\345\217\257\347\273\264\346\212\244\346\200\247.md" "b/docs/zh/docs/Virtualization/\347\256\241\347\220\206\350\231\232\346\213\237\346\234\272\345\217\257\347\273\264\346\212\244\346\200\247.md" index 5b90254e7e63a43aab3a553a2adacc879912463e..f6fcdbec031cd12c22f144e5cb37620207b1d844 100644 --- "a/docs/zh/docs/Virtualization/\347\256\241\347\220\206\350\231\232\346\213\237\346\234\272\345\217\257\347\273\264\346\212\244\346\200\247.md" +++ "b/docs/zh/docs/Virtualization/\347\256\241\347\220\206\350\231\232\346\213\237\346\234\272\345\217\257\347\273\264\346\212\244\346\200\247.md" @@ -15,9 +15,6 @@ NMI Watchdog是一种用来检测Linux出现hardlockup(硬死锁)的机制 ### 操作步骤 针对ARM架构虚拟机配置NMI Watchdog的操作步骤如下: -1. 在虚拟机的引导配置文件grub.cfg中添加如下参数:nmi_watchdog=1 pmu_nmi_enable hardlockup_cpu_freq=auto irqchip.gicv3_pseudo_nmi=1 disable_sdei_nmi_watchdog -2. 检查虚拟机内部PMU Watchdog是否加载成功,如果加载成功,内核dmesg日志打印类似如下内容 - - ``` - [2.1173222] NMI watchdog: CPU0 freq probed as 2399999942 HZ. - ``` \ No newline at end of file + +1. 在虚拟机的引导配置文件grub.cfg中添加如下参数:`nmi_watchdog=1 pmu_nmi_enable hardlockup_cpu_freq=auto irqchip.gicv3_pseudo_nmi=1 disable_sdei_nmi_watchdog hardlockup_enable=1` +2. 检查虚拟机内部PMU Watchdog是否加载成功,如果加载成功,内核dmesg日志打印类似如下内容:`[2.1173222] NMI watchdog: CPU0 freq probed as 2399999942 HZ.` diff --git a/docs/zh/docs/X-diagnosis/X-diagnosis.md b/docs/zh/docs/X-diagnosis/X-diagnosis.md index 1d630e907036e5b333aa235f62476d2092a94680..298451b5c3e9801f3617199ef4994d06a8b73d42 100644 --- a/docs/zh/docs/X-diagnosis/X-diagnosis.md +++ b/docs/zh/docs/X-diagnosis/X-diagnosis.md @@ -374,12 +374,12 @@ EXAMPLES: -C, --clear Clear the screen -i, --interval=INTERVAL Refreash interval(secs), default 5s. -m, --mnt=MNTPOINT the special mount point - -o, --opcode=OPCODE Trace file r/w, defalut both. + -o, --opcode=OPCODE Trace file r/w, default both. -p, --pid=PID Trace the pid only -s, --sort=SORT Sort r/w/wb, default read -t, --times=TIMES Trace times -T, --top=TOP show the topN (1~8192) - -v, --view=VIEW p:pids view, f: files view, defaut file view + -v, --view=VIEW p:pids view, f: files view, default file view -?, --help Give this help list --usage Give a short usage message ``` diff --git "a/docs/zh/docs/astream/astream\345\272\224\347\224\250\344\272\216MySQL\346\214\207\345\257\274.md" "b/docs/zh/docs/astream/astream\345\272\224\347\224\250\344\272\216MySQL\346\214\207\345\257\274.md" index 8cd0789147a76ffff5e925b20a6abeda954b0a66..15bbff5179e5d98a38de2b0edaca2af95bcfc31f 100644 --- "a/docs/zh/docs/astream/astream\345\272\224\347\224\250\344\272\216MySQL\346\214\207\345\257\274.md" +++ "b/docs/zh/docs/astream/astream\345\272\224\347\224\250\344\272\216MySQL\346\214\207\345\257\274.md" @@ -312,7 +312,7 @@ deliveryWeight=4 stockLevelWeight=4 ``` -当前目录下再复制一个props.conf文件,重命令为props-2.conf,作为mysql实例2对应的配置文件。 +当前目录下再复制一个props.conf文件,重命名为props-2.conf,作为mysql实例2对应的配置文件。 ``` db=mysql diff --git a/docs/zh/docs/astream/overview.md b/docs/zh/docs/astream/overview.md index 809a80d3447ccffe5c6cd03a3b6530a95b1f4b1a..82e079959a6890b10f24541b8c307a2ac8041e3c 100644 --- a/docs/zh/docs/astream/overview.md +++ b/docs/zh/docs/astream/overview.md @@ -1,3 +1,3 @@ # astream用户指南 -astream是一款延长磁盘使用寿命的工具。它基于Linux提供的inotify机制进行目录监控,同时配合用户针对应用场景定义的流分配规则,为匹配到的文件在创建时设置流信息,而后通过内核透传流信息至已使能多流特性的NVMe SSD磁盘,最终使得文件的存储能够根据流信息的标识进行更优的分类存储,降低磁盘垃圾回收的工作量,从而降低磁盘的写放大水平,最终达到延长磁盘使用寿命。专注于具有明显具有相同或相似生命周期的workload特征的数据库场景应用,如MySQL。 \ No newline at end of file +astream是一款延长磁盘使用寿命的工具。它基于Linux提供的inotify机制进行目录监控,同时配合用户针对应用场景定义的流分配规则,为匹配到的文件在创建时设置流信息,而后通过内核透传流信息至已使用多流特性的NVMe SSD磁盘,最终使得文件的存储能够根据流信息的标识进行更优的分类存储,降低磁盘垃圾回收的工作量,从而降低磁盘的写放大水平,最终达到延长磁盘使用寿命的效果。专注于具有明显具有相同或相似生命周期的workload特征的数据库场景应用,如MySQL。 \ No newline at end of file diff --git "a/docs/zh/docs/astream/\345\256\211\350\243\205\344\270\216\344\275\277\347\224\250\346\226\271\346\263\225.md" "b/docs/zh/docs/astream/\345\256\211\350\243\205\344\270\216\344\275\277\347\224\250\346\226\271\346\263\225.md" index cd8c47239f6831cc9e900de423b27882d7a90f30..129056cb9f994a7dfa2b571ae2b9af9d091e915c 100644 --- "a/docs/zh/docs/astream/\345\256\211\350\243\205\344\270\216\344\275\277\347\224\250\346\226\271\346\263\225.md" +++ "b/docs/zh/docs/astream/\345\256\211\350\243\205\344\270\216\344\275\277\347\224\250\346\226\271\346\263\225.md" @@ -83,7 +83,7 @@ astream [options] | -l | 设置astream监控过程中的日志显示级别, debug(1), info(2), warn(3), error(4) | `astream -i /data/mysql/data -r /home/rule.txt -l 2` | | -i | 指定当前需要监控的目录,多个目录可以以空格间隔输入 | 该参数配合-r使用, 示例见下 | | -r | 指定监控目录对应的流分配规则文件,传入的个数取决于-i,互相对应 | `astream -i /data/mysql/data -r /home/rule.txt` | -| stop | 正常停止astream守护进程 | astream stop | +| stop | 正常停止astream守护进程 | `astream stop` | ## 约束限制 diff --git a/docs/zh/docs/desktop/Gnome_userguide.md b/docs/zh/docs/desktop/Gnome_userguide.md index 6ecbf987518f00a18f0ce1f20a8eb03443ece90a..af052362996ac6ce5fb53607506c4a4a70ed1a94 100644 --- a/docs/zh/docs/desktop/Gnome_userguide.md +++ b/docs/zh/docs/desktop/Gnome_userguide.md @@ -191,13 +191,13 @@ Gnome桌面比较干净,不摆放任何文件或者目录。桌面仅有顶部 设置项也是动态拓展的,例如当系统所在的硬件有wifi时,wifi的设置项将会出现在设置中。一些重要的设置项将在下文中举例。 -#### 3.3.4 锁定 +#### 3.3.5 锁定 点击"锁定"将立即回到锁屏界面并黑屏,鼠标移动立马亮屏,点击任意按键进入登录界面,并需要用户密码输入以实现再次登录。以下是锁屏界面。 ![图 20 锁屏界面-big](./figures/gnome-21.png) -#### 3.3.4 关机/注销 +#### 3.3.6 关机/注销 包括挂起、关机、重启、注销四种动作。其中挂起和锁定的区别在于挂起后直接黑屏,需要使用键盘唤醒到登录界面,时间较锁屏久。注销是登出当前用户,退回到登录界面并且不黑屏,以选择另外的用户登录或者相同用户再次登录。 diff --git "a/docs/zh/docs/desktop/HA\347\232\204\344\275\277\347\224\250\345\256\236\344\276\213.md" "b/docs/zh/docs/desktop/HA\347\232\204\344\275\277\347\224\250\345\256\236\344\276\213.md" index 91e06a2cce8a7d7ab1636a642c88f7d01fe57d12..87f2396b4208d7e98b8c005775b3a23bb79117f3 100644 --- "a/docs/zh/docs/desktop/HA\347\232\204\344\275\277\347\224\250\345\256\236\344\276\213.md" +++ "b/docs/zh/docs/desktop/HA\347\232\204\344\275\277\347\224\250\345\256\236\344\276\213.md" @@ -1,6 +1,6 @@ # HA使用实例 -本章介绍如何快速使用HA高可用集群,以及添加一个实例。若不了解怎么安装,请参考[HA的安装与部署文档](./HA的安装与部署.md\)。 +本章介绍如何快速使用HA高可用集群,以及添加一个实例。若不了解怎么安装,请参考[HA的安装与部署文档](./HA的安装与部署.md)。 ## 快速使用指南 @@ -111,12 +111,12 @@ #### 编辑资源 -- 启动资源:资源节点列表中选中一个目标资源,要求:该资源处于非运行状态。对该资源执行启动动作。 -- 停止资源:资源节点列表中选中一个目标资源,要求:该资源处于运行状态。对该资源执行停止操作。 +- 启动资源:资源节点列表中选中一个目标资源(要求:该资源处于非运行状态),执行启动动作。 +- 停止资源:资源节点列表中选中一个目标资源(要求:该资源处于运行状态),执行停止操作。 - 清理资源:资源节点列表中选中一个目标资源,对该资源执行清理操作。 -- 迁移资源:资源节点列表中选中一个目标资源,要求:该资源为处于运行状态的普通资源或者组资源,执行迁移操作可以将资源迁移到指定节点上运行。 -- 回迁资源:资源节点列表中选中一个目标资源,要求:该资源已经完成迁移动作,执行回迁操作,可以清除该资源的迁移设置,资源重新迁回到原来的节点上运行。 -点击按钮后,列表中该资源项的变化状态与启动资源时一致。 +- 迁移资源:资源节点列表中选中一个目标资源(要求:该资源为处于运行状态的普通资源或者组资源),执行迁移操作可以将资源迁移到指定节点上运行。 +- 回迁资源:资源节点列表中选中一个目标资源(要求:该资源已经完成迁移动作),执行回迁操作,可以清除该资源的迁移设置,资源重新迁回到原来的节点上运行。 +点击刷新按钮后,列表中该资源项的变化状态与启动资源时一致。 - 删除资源:资源节点列表中选中一个目标资源,对该资源执行删除操作。 #### 设置资源关系 @@ -433,8 +433,8 @@ Device: pcs quorum status命令显示仲裁运行时状态,表明仲裁设备正在使用中。每个集群节点的成员信息状态值的含义Qdevice如下: -- A/NA— quorum device 是否存活,表示qdevice和之间是否有心跳corosync。这应始终表明仲裁设备处于活动状态。 -- V/NV—V当仲裁设备给一个节点投票时设置。在此示例中,两个节点都设置为,V因为它们可以相互通信。如果将集群拆分为两个单节点集群,则其中一个节点将设置为V,另一个节点将设置为NV。 +- A/NA— quorum device 是否存活,表示qdevice和corosync之间是否有心跳。这应始终表明仲裁设备处于活动状态。 +- V/NV—V当仲裁设备给一个节点投票时设置。在此示例中,两个节点都设置为V,因为它们可以相互通信。如果将集群拆分为两个单节点集群,则其中一个节点将设置为V,另一个节点将设置为NV。 - MW/NMW— 内部仲裁设备标志已设置 ( MW) 或未设置 ( NMW)。默认情况下,未设置标志,值为NMW。 ```sh diff --git a/docs/zh/docs/desktop/Install_GNOME.md b/docs/zh/docs/desktop/Install_GNOME.md index dc8ed6e3e5932ccea5421510f76d08218a1fa6a9..f11292b78526bd5e5ec06274a6dea26222694eaf 100644 --- a/docs/zh/docs/desktop/Install_GNOME.md +++ b/docs/zh/docs/desktop/Install_GNOME.md @@ -1,6 +1,6 @@ # 在 openEuler 上安装 GNOME -GNOME是运行在类Unix操作系统中最常用桌面环境。是一个功能完善、操作简单,界面友好,集使用和开发为一身的桌面环境,是GNU计划的正式桌面。 +GNOME是运行在类Unix操作系统中的最常用的桌面环境。是一个功能完善、操作简单、界面友好、集使用和开发为一身的桌面环境,是GNU计划的正式桌面。 从用户的角度看,GNOME是一个集成桌面环境和应用程序的套件。从开发者的角度看,它是一个应用程序开发框架(由数目众多的实用函数库组成)。即使用户不运行GNOME桌面环境,用GNOME编写的应用程序也可以正常运行。 @@ -10,114 +10,114 @@ GNOME既包含文件管理器,应用商店,文本编辑器等基础软件, 1. [下载](https://openeuler.org/zh/download/)openEuler ISO镜像并安装系统,更新软件源(需要配置Everything源,以及EPOL源,下面命令是在最小化安装系统的情况下安装GNOME)。 -``` -sudo dnf update -``` + ``` bash + sudo dnf update + ``` 2. 安装字库。 -``` -sudo dnf install dejavu-fonts liberation-fonts gnu-*-fonts google-*-fonts -``` + ``` bash + sudo dnf install dejavu-fonts liberation-fonts gnu-*-fonts google-*-fonts + ``` 3. 安装Xorg。 -``` -sudo dnf install xorg-* -``` + ``` bash + sudo dnf install xorg-* + ``` -这可能会安装很多没用的包,可以使用下面的命令安装必要的xorg相关包。 + 这可能会安装很多没用的包,可以使用下面的命令安装必要的xorg相关包。 -``` -sudo dnf install xorg-x11-apps xorg-x11-drivers xorg-x11-drv-ati \ - xorg-x11-drv-dummy xorg-x11-drv-evdev xorg-x11-drv-fbdev xorg-x11-drv-intel \ - xorg-x11-drv-libinput xorg-x11-drv-nouveau xorg-x11-drv-qxl \ - xorg-x11-drv-synaptics-legacy xorg-x11-drv-v4l xorg-x11-drv-vesa \ - xorg-x11-drv-vmware xorg-x11-drv-wacom xorg-x11-fonts xorg-x11-fonts-others \ - xorg-x11-font-utils xorg-x11-server xorg-x11-server-utils xorg-x11-server-Xephyr \ - xorg-x11-server-Xspice xorg-x11-util-macros xorg-x11-utils xorg-x11-xauth \ - xorg-x11-xbitmaps xorg-x11-xinit xorg-x11-xkb-utils -``` + ``` bash + sudo dnf install xorg-x11-apps xorg-x11-drivers xorg-x11-drv-ati \ + xorg-x11-drv-dummy xorg-x11-drv-evdev xorg-x11-drv-fbdev xorg-x11-drv-intel \ + xorg-x11-drv-libinput xorg-x11-drv-nouveau xorg-x11-drv-qxl \ + xorg-x11-drv-synaptics-legacy xorg-x11-drv-v4l xorg-x11-drv-vesa \ + xorg-x11-drv-vmware xorg-x11-drv-wacom xorg-x11-fonts xorg-x11-fonts-others \ + xorg-x11-font-utils xorg-x11-server xorg-x11-server-utils xorg-x11-server-Xephyr \ + xorg-x11-server-Xspice xorg-x11-util-macros xorg-x11-utils xorg-x11-xauth \ + xorg-x11-xbitmaps xorg-x11-xinit xorg-x11-xkb-utils + ``` 4. 安装GNOME及组件。 -``` -sudo dnf install adwaita-icon-theme atk atkmm at-spi2-atk at-spi2-core baobab \ - abattis-cantarell-fonts cheese clutter clutter-gst3 clutter-gtk cogl dconf \ - dconf-editor devhelp eog epiphany evince evolution-data-server file-roller folks \ - gcab gcr gdk-pixbuf2 gdm gedit geocode-glib gfbgraph gjs glib2 glibmm24 \ - glib-networking gmime30 gnome-autoar gnome-backgrounds gnome-bluetooth \ - gnome-boxes gnome-builder gnome-calculator gnome-calendar gnome-characters \ - gnome-clocks gnome-color-manager gnome-contacts gnome-control-center \ - gnome-desktop3 gnome-disk-utility gnome-font-viewer gnome-getting-started-docs \ - gnome-initial-setup gnome-keyring gnome-logs gnome-menus gnome-music \ - gnome-online-accounts gnome-online-miners gnome-photos gnome-remote-desktop \ - gnome-screenshot gnome-session gnome-settings-daemon gnome-shell \ - gnome-shell-extensions gnome-software gnome-system-monitor gnome-terminal \ - gnome-tour gnome-user-docs gnome-user-share gnome-video-effects \ - gnome-weather gobject-introspection gom grilo grilo-plugins \ - gsettings-desktop-schemas gsound gspell gssdp gtk3 gtk4 gtk-doc gtkmm30 \ - gtksourceview4 gtk-vnc2 gupnp gupnp-av gupnp-dlna gvfs json-glib libchamplain \ - libdazzle libgdata libgee libgnomekbd libgsf libgtop2 libgweather libgxps libhandy \ - libmediaart libnma libnotify libpeas librsvg2 libsecret libsigc++20 libsoup \ - mm-common mutter nautilus orca pango pangomm libphodav python3-pyatspi \ - python3-gobject rest rygel simple-scan sushi sysprof tepl totem totem-pl-parser \ - tracker3 tracker3-miners vala vte291 yelp yelp-tools \ - yelp-xsl zenity -``` + ``` bash + sudo dnf install adwaita-icon-theme atk atkmm at-spi2-atk at-spi2-core baobab \ + abattis-cantarell-fonts cheese clutter clutter-gst3 clutter-gtk cogl dconf \ + dconf-editor devhelp eog epiphany evince evolution-data-server file-roller folks \ + gcab gcr gdk-pixbuf2 gdm gedit geocode-glib gfbgraph gjs glib2 glibmm24 \ + glib-networking gmime30 gnome-autoar gnome-backgrounds gnome-bluetooth \ + gnome-boxes gnome-builder gnome-calculator gnome-calendar gnome-characters \ + gnome-clocks gnome-color-manager gnome-contacts gnome-control-center \ + gnome-desktop3 gnome-disk-utility gnome-font-viewer gnome-getting-started-docs \ + gnome-initial-setup gnome-keyring gnome-logs gnome-menus gnome-music \ + gnome-online-accounts gnome-online-miners gnome-photos gnome-remote-desktop \ + gnome-screenshot gnome-session gnome-settings-daemon gnome-shell \ + gnome-shell-extensions gnome-software gnome-system-monitor gnome-terminal \ + gnome-tour gnome-user-docs gnome-user-share gnome-video-effects \ + gnome-weather gobject-introspection gom grilo grilo-plugins \ + gsettings-desktop-schemas gsound gspell gssdp gtk3 gtk4 gtk-doc gtkmm30 \ + gtksourceview4 gtk-vnc2 gupnp gupnp-av gupnp-dlna gvfs json-glib libchamplain \ + libdazzle libgdata libgee libgnomekbd libgsf libgtop2 libgweather libgxps libhandy \ + libmediaart libnma libnotify libpeas librsvg2 libsecret libsigc++20 libsoup \ + mm-common mutter nautilus orca pango pangomm libphodav python3-pyatspi \ + python3-gobject rest rygel simple-scan sushi sysprof tepl totem totem-pl-parser \ + tracker3 tracker3-miners vala vte291 yelp yelp-tools \ + yelp-xsl zenity + ``` 5. 启动gdm显示管理器。 -``` -sudo systemctl enable gdm -``` + ``` bash + sudo systemctl enable gdm + ``` 6. 设置系统默认以图形界面登录。 -``` -sudo systemctl set-default graphical.target -``` + ``` bash + sudo systemctl set-default graphical.target + ``` -重启验证。 + 重启验证。 -``` -sudo reboot -``` + ``` bash + sudo reboot + ``` 7. 当gdm不能工作 -如果默认安装了gdm,则停用gdm + 如果默认安装了gdm,则停用gdm -``` -sudo systemctl disable gdm -``` + ``` bash + sudo systemctl disable gdm + ``` -安装lightdm显示管理器替代 + 安装lightdm显示管理器替代 -``` -sudo dnf install lightdm lightdm-gtk -``` + ``` bash + sudo dnf install lightdm lightdm-gtk + ``` -设置默认桌面为GNOME,通过root权限用户设置 + 设置默认桌面为GNOME,通过root权限用户设置 -``` -echo 'user-session=gnome' >> /etc/lightdm/lightdm.conf.d/60-lightdm-gtk-greeter.conf -``` + ``` bash + echo 'user-session=gnome' >> /etc/lightdm/lightdm.conf.d/60-lightdm-gtk-greeter.conf + ``` -启动lightdm显示管理器 + 启动lightdm显示管理器 -``` -sudo systemctl enable lightdm -``` + ``` bash + sudo systemctl enable lightdm + ``` -设置系统默认以图形界面登录 + 设置系统默认以图形界面登录 -``` -sudo systemctl set-default graphical.target -``` + ``` bash + sudo systemctl set-default graphical.target + ``` -重启验证 + 重启验证 -``` -sudo reboot -``` + ``` bash + sudo reboot + ``` diff --git a/docs/zh/docs/desktop/Install_XFCE.md b/docs/zh/docs/desktop/Install_XFCE.md index f0cd8dca28d72786925e26cbafb158e6e457029c..97811968818c388076a94705ee50ea5c14f6d1d8 100644 --- a/docs/zh/docs/desktop/Install_XFCE.md +++ b/docs/zh/docs/desktop/Install_XFCE.md @@ -70,10 +70,4 @@ XFCE支持x86_64和aarch64两种架构。 ```sh # sudo reboot ``` - -9. FAQ - -Q:为什么lightdm登录界面背景是黑色的? -A:登录界面是黑色的是因为lightdm-gtk默认配置文件/etc/lightdm/lightdm-gtk-greeter.conf中没有设置background。 -可以在该配置文件最后的[greeter]段中设置 background=/usr/share/backgrounds/xfce/xfce-blue.jpg -然后使用“systemctl restart lightdm”命令就可以看到背景了。 + \ No newline at end of file diff --git a/docs/zh/docs/desktop/dde.md b/docs/zh/docs/desktop/dde.md index cf094d5fcb0ac4b863f34946f09464ec94906d67..777fb3ca65862c214acc0a9703113a4554679e5c 100644 --- a/docs/zh/docs/desktop/dde.md +++ b/docs/zh/docs/desktop/dde.md @@ -1,23 +1,3 @@ # DDE 用户指南 -本节主要描述 DDE 桌面环境的安装和使用。 - -## FAQ 常见问题及解答 - -### 1.安装DDE后,root帐户登录桌面无计算机和回收站图标? - -* 问题表现 - - 安装DDE后,root帐户登录桌面无计算机和回收站图标 - -![img](./figures/dde-1.png) - -* 问题原因 - - 由于root用户在安装DDE前已创建,而DDE在安装时不会对已经创建的用户进行新增桌面图标操作。DDE安装后新建用户无此问题。 - -* 解决方案 - - 用户可通过启动器中右键对应图标发送到桌面即可,无任何功能差异。 - - ![img](./figures/dde-2.png) +本章主要描述 DDE 桌面环境的安装和使用。 diff --git a/contribute/figures/.keep b/docs/zh/docs/epkg/.keep similarity index 100% rename from contribute/figures/.keep rename to docs/zh/docs/epkg/.keep diff --git "a/docs/zh/docs/epkg/create_repo\344\275\277\347\224\250\346\214\207\345\215\227.md" "b/docs/zh/docs/epkg/create_repo\344\275\277\347\224\250\346\214\207\345\215\227.md" new file mode 100644 index 0000000000000000000000000000000000000000..f3bab1e4517d8d5216288a706d710889669d163e --- /dev/null +++ "b/docs/zh/docs/epkg/create_repo\344\275\277\347\224\250\346\214\207\345\215\227.md" @@ -0,0 +1,68 @@ +# create_repo 使用指南 + +## 介绍 + +本文介绍create_repo软件包转换工具的简单使用。本文涉及操作结果示例均以root用户为例,无需安装。支持将epkg包目录结构生成本地repo源 + +## 下载 + +```bash +git clone https://gitee.com/openeuler/epkg.git +``` + +## 快速上手 + +下载epkg仓库后直接进入create_repo目录下使用 + +```shell +cd epkg/create_repo +python3 create_repo.py --help +``` + +## 前置条件 + +输入目录是一个包目录结构,结构如下 + +```txt +# tree store/ +store/ +|-- 45 +| `-- 45dqn3vzum73pf7igmmu6zbcxndqqebr__glibc-devel__2.38__29.oe2403.epkg +|-- at +| `-- atqwhznwbp6lzvur5stgb4jjem6tzllf__redis__4.0.14__6.oe2403.epkg +|-- bt +| `-- btblk472ob4teixd522qgv6b2c7tk4v4__ncurses-base__5.9+20140118__1ubuntu1.epkg +|-- f7 +| `-- f7ealc3ghq6tdmvrh22l5vlxycgndwam__atlas__3.10.3__10.oe1.epkg +|-- jl +| `-- jlrwn3rcjb4gbdx4uf77lslxg37rodyf__glibc__2.38__29.oe2403.epkg +|-- kc +| `-- kclugzl6mtkqeqkgbmpf2vq4kpkeleqb__atlas-devel__3.10.3__10.oe1.epkg +`-- of + `-- ofdjbysy76gs5tzzgxulaoumgqjfe6d2__audit__4.0.3__1.epkg + +8 directories, 7 files +``` + +## 参数解析 + +```txt +usage: create_repo.py [-h] -s STORE -c CONFIG + +create repo参数 + +optional arguments: + -h, --help 查看命令参数使用 + -s STORE, --store STORE + 输入epkg包仓的store目录 + -c CONFIG, --config CONFIG + 输入repo清单配置文件的地址 +``` + +## 运行案例 + +```shell + cd epkg/x2epkg + python3 create_repo.py -s /root/store -c /root/config.yaml + ls /root/repodata # 查看生成结果,输出所在路径与store仓库所在路径一致 +``` diff --git "a/docs/zh/docs/epkg/epkg\344\275\277\347\224\250\346\214\207\345\215\227.md" "b/docs/zh/docs/epkg/epkg\344\275\277\347\224\250\346\214\207\345\215\227.md" new file mode 100644 index 0000000000000000000000000000000000000000..c6db483a5301b4afef58d811636e810b00027cc1 --- /dev/null +++ "b/docs/zh/docs/epkg/epkg\344\275\277\347\224\250\346\214\207\345\215\227.md" @@ -0,0 +1,322 @@ +# 介绍 + +本文介绍EPKG包管理器工作环境如何初始化,以及基本功能如何使用。本文涉及操作结果示例均以非root用户为例。 + +## 快速上手 + +下面的实例介绍了安装不同软件包版本的方式 + +```bash +# curl 方式安装epkg +# 安装时可选user/global安装模式,user模式仅当前安装用户可用,global模式全局用户可用 +# 仅root用户可使用global安装模式 +wget https://repo.oepkgs.net/openeuler/epkg/rootfs/epkg-installer.sh +bash epkg-installer.sh + +# 卸载epkg +wget https://repo.oepkgs.net/openeuler/epkg/rootfs/epkg-uninstaller.sh +bash epkg-uninstaller.sh + +# 初始化epkg +# user模式安装:自动初始化 +# global模式安装:root用户自动初始化,其他用户需要手动初始化 +epkg init +bash // 重新执行.bashrc, 获得新的PATH + +# 创建环境t1 +epkg env create t1 +epkg install tree +tree --version +which tree + +# 查看repo +[root@vbox ~]# epkg repo list +EPKG_ACTIVE_ENV: +------------------------------------------------------------------------------------------------------------------------------------------------------ +channel | repo | url +------------------------------------------------------------------------------------------------------------------------------------------------------ +openEuler-20.03-LTS-SP4 | everything | https://repo.oepkgs.net/openeuler/epkg/channel/openEuler-20.03-LTS-SP4/everything/ +openEuler-22.03-LTS-SP4 | everything | https://repo.oepkgs.net/openeuler/epkg/channel/openEuler-22.03-LTS-SP4/everything/ +openEuler-24.03-LTS | everything | https://repo.oepkgs.net/openeuler/epkg/channel/openEuler-24.03-LTS/everything/ +openEuler-24.09 | everything | https://repo.oepkgs.net/openeuler/epkg/channel/openEuler-24.09/everything/ +------------------------------------------------------------------------------------------------------------------------------------------------------ + +# 创建环境2, 指定repo +epkg env create t2 --repo openEuler-22.03-LTS-SP3 +epkg install tree +tree --version +which tree + +# 切换回环境1 +epkg env activate t1 +``` + +## EPKG包管理器使用说明 + +```bash +Usage: +    epkg install +    epkg remove [-y] +    epkg upgrade (开发中...) +    +    epkg list + +    epkg env list +    epkg env create [--repo ] +    epkg env remove +    epkg env activate [--pure] +    epkg env deactivate +    epkg env register|unregister +    epkg env history +    epkg env rollback +``` + +### 安装软件 + +功能描述: + 在当前activate的环境中安装软件 + 若无环境激活,默认安装到main环境中:`epkg env activate ` + +命令: + `epkg install ` + +示例: + +```bash +[root@vbox ~]# epkg env create t1 +EPKG_ACTIVE_ENV: +Environment t1 not exist. +Environment 't1' has been created. +Environment 't1' activated. +[root@vbox ~]# epkg install tree +EPKG_ACTIVE_ENV: t1 +Attention: Install success: 8jkd3nbg9td5jnc738yhrz5yjwy5qzha__openEuler-repos__1.0__3.7.oe2403 2px41kqhx9matg9e5zgy36s06qqdn3nj__glibc-all-langpacks__2.38__29.oe24.... +[root@vbox ~]# epkg install htop +EPKG_ACTIVE_ENV: t1 +Warning: The following packages are already installed and will be skipped: +- 6sgyzx3s7624r0x7rpe4w8642p2d181r__fuse__2.9.9__11.oe2403 +- 3gypc46xq6mqd37ya3mhztz2zfkjghw1__libsigsegv__2.14__1.oe2403 +.... +Attention: Install success: v0wrq5sv9r5znsgtgxkbax24r7f6nq80__htop__3.3.0__1.oe2403 +[root@vbox ~]# +``` + +### 卸载软件 + +功能描述: + 在当前activate的环境中安装软件 + 若无环境激活,默认安装到main环境中:`epkg env activate ` + +命令: + `epkg remove ` + +示例: + +```bash +[root@vbox ~]# epkg env activate t1 +Environment 't1' activated. +[root@vbox ~]# epkg remove htop +Packages to remove: +- v0wrq5sv9r5znsgtgxkbax24r7f6nq80__htop__3.3.0__1.oe2403 +Do you want to continue with uninstallation? (y/n): +y +Attention: Remove success: v0wrq5sv9r5znsgtgxkbax24r7f6nq80__htop__3.3.0__1.oe2403 +[root@vbox ~]# +``` + +### 列出环境 + +功能描述: + 列出当前epkg所有环境,及激活和注册的环境 + +命令: + `epkg env list` + +示例: + +```bash +[root@vbox ~]# epkg env list +EPKG_ACTIVE_ENV: t1 +Environment Status +----------------------------------- +t1 activated +main registered +``` + +### 创建环境 + +功能描述: + 创建新环境,默认激活创建的环境 + +命令: + `epkg env create ` + +示例: + +```bash +[root@vbox ~]# epkg env create t2 +EPKG_ACTIVE_ENV: t1 +Environment t2 not exist. +Environment 't2' has been created. +Environment 't2' activated. +[root@vbox ~]# epkg env list +EPKG_ACTIVE_ENV: t2 +Environment Status +----------------------------------- +t2 activated +t1 +main registered +``` + +### 删除环境 + +功能描述: + 删除环境 + +命令: + `epkg env remove ` + +示例: + +```bash +[root@vbox ~]# epkg env remove t2 +EPKG_ACTIVE_ENV: t2 +Environment t2 exist. +Environment t2 not registered. +Environment t2 has been removed. +[root@vbox ~]# epkg env list +EPKG_ACTIVE_ENV: +Environment Status +----------------------------------- +t1 +main registered +``` + +### 激活环境 + +功能描述: + 激活指定的环境,刷新PATH,并将激活环境设为第一优先级 + +命令: + `epkg env activate ` + +示例: + +```bash +[root@vbox ~]# epkg env activate main +Environment 'main' activated. +[root@vbox ~]# epkg env list +EPKG_ACTIVE_ENV: main +Environment Status +----------------------------------- +t1 +main activated|registered +[root@vbox ~]# echo $PATH +/root/.epkg/envs/main/profile-current/usr/app-bin:/root/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin +``` + +### 去激活环境 + +功能描述: + 去激活环境,去激活当前已激活的环境,刷新PATH + +命令: + `epkg env deactivate` + +示例: + +```bash +[root@vbox ~]# epkg env activate t1 +Environment 't1' activated. +[root@vbox ~]# echo $PATH +/root/.epkg/envs/t1/profile-current/usr/app-bin:/root/.epkg/envs/main/profile-current/usr/app-bin:/root/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin +[root@vbox ~]# epkg env deactivate +Environment 't1' deactivated. +[root@vbox ~]# echo $PATH +/root/.epkg/envs/main/profile-current/usr/app-bin:/root/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin +``` + +### 注册环境 + +功能描述: + 持久化注册指定环境,刷新PATH + 注册的环境在新的shell中依然生效 + +命令: + `epkg env register ` + +示例: + +```bash +[root@vbox ~]# epkg env register t1 +EPKG_ACTIVE_ENV: +Environment t1 exist. +Environment 't1' has been registered. +[root@vbox ~]# echo $PATH +/root/.epkg/envs/t1/profile-current/usr/app-bin:/root/.epkg/envs/main/profile-current/usr/app-bin:/root/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin +[root@vbox ~]# epkg env list +EPKG_ACTIVE_ENV: +Environment Status +----------------------------------- +t1 registered +main registered +``` + +### 去注册环境 + +功能描述: + 持久化去注册指定环境,刷新PATH + +命令: + `epkg env unregister ` + +示例: + +```bash +[root@vbox ~]# epkg env unregister t1 +EPKG_ACTIVE_ENV: +Environment t1 exist. +Environment t1 had been registered. +Environment 't1' has been unregistered from PATH. +``` + +### 环境历史 + +功能描述: + 查看当前激活环境的历史记录 + +命令: + `epkg env history` + +示例: + +```bash +[root@vbox ~]# epkg env activate t1 +Environment 't1' activated. +[root@vbox ~]# epkg env history +-------------------------------------------------- t1 env history -------------------------------------------------- +id | timestamp | action | new_packages | del_packages | command line +----+----------------------------+------------+--------------+--------------+----------------------------------------- +1 | 2025-03-06 20:23:31 +08:00 | install | 70 | 0 | /opt/epkg/users/public/envs/common/profile-current/usr/bin/epkg install tree +2 | 2025-03-06 20:23:38 +08:00 | install | 1 | 0 | /opt/epkg/users/public/envs/common/profile-current/usr/bin/epkg install htop +3 | 2025-03-06 20:23:45 +08:00 | remove | 0 | 1 | /opt/epkg/users/public/envs/common/profile-current/usr/bin/epkg remove htop +``` + +### 环境回退 + +功能描述: +    回退激活环境,history_id即epkg env history中查询的id列 + +命令: +    `epkg env rollback ` + +示例: + +```bash +[root@vbox ~]# epkg env rollback 2 +-------------------------------------- Rollback information --------------------------------------- +action | hash | pkg | version | release | dist +-------+----------------------------------+----------------------+------------+---------+------------ +new | v0wrq5sv9r5znsgtgxkbax24r7f6nq80 | htop | 3.3.0 | 1 | 1.oe2403 +Rollback success! +``` diff --git "a/docs/zh/docs/epkg/x2epkg\344\275\277\347\224\250\346\214\207\345\215\227.md" "b/docs/zh/docs/epkg/x2epkg\344\275\277\347\224\250\346\214\207\345\215\227.md" new file mode 100644 index 0000000000000000000000000000000000000000..801c7b90546fd15c16e49a2090efe8be900d05f9 --- /dev/null +++ "b/docs/zh/docs/epkg/x2epkg\344\275\277\347\224\250\346\214\207\345\215\227.md" @@ -0,0 +1,41 @@ +# x2epkg 使用指南 + +## 介绍 + +本文介绍x2epkg软件包转换工具的简单使用。本文涉及操作结果示例均以root用户为例,无需安装。支持将rpm/deb/pkg.tar.zst安装包转换为[epkg](https://gitee.com/qiu-tangke/docs/blob/master/docs/zh/docs/epkg/epkg%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97.md)安装包 + +## 下载 + +```bash +git clone https://gitee.com/openeuler/epkg.git +``` + +## 快速上手 + +下载epkg仓库后直接进入x2epkg目录下使用 + +```shell +cd epkg/x2epkg +./x2epkg.sh --help +``` + +## 参数解析 + +```txt +Usage: + ./x2epkg xxx.rpm # 单个rpm包的转换 + ./x2epkg xxx.deb # 单个debian包的转换 + ./x2epkg xxx.pkg.tar.zst # 单个archlinux包的转换 + ./x2epkg file_path/*.rpm # 多个安装包的转换,同样适用于deb和pkg.tar.zst文件 + ./x2epkg xxx.rpm --out-dir PATH # 加上out-dir参数可以指明输出目录,如果不加则输出到包的同级目录下 +``` + +## 运行案例 + +```shell + cd /root + wget https://mirrors.huaweicloud.com/archlinux/core/os/x86_64/fakeroot-1.37.1-1-x86_64.pkg.tar.zst + cd epkg/x2epkg + ./x2epkg.sh /root/fakeroot-1.37.1-1-x86_64.pkg.tar.zst + ls /root/store/4t/4tmfsi5yikkq32rrulae6oi6u4txr5zu__fakeroot__1.37.1__1.epkg # 查看生成结果 +``` diff --git a/docs/zh/docs/memsafety/utshell/utshell_guide.md b/docs/zh/docs/memsafety/utshell/utshell_guide.md index 9e165806a94b46a4dea1e8565d13ac844572b183..65a02a46f73e2e9358d9079ce45716894bf3ba66 100644 --- a/docs/zh/docs/memsafety/utshell/utshell_guide.md +++ b/docs/zh/docs/memsafety/utshell/utshell_guide.md @@ -98,7 +98,7 @@ func 1 #### 给函数传递参数 -调用函数时,在函数名后面直接已空格分割参数: +调用函数时,在函数名后面直接以空格分割参数: func firstParam secondParam diff --git a/docs/zh/docs/oeAware/figures/dep.png b/docs/zh/docs/oeAware/figures/dep.png new file mode 100644 index 0000000000000000000000000000000000000000..493f118a9a822fa16f8c8375ba9261c1e10ac935 Binary files /dev/null and b/docs/zh/docs/oeAware/figures/dep.png differ diff --git "a/docs/zh/docs/oeAware/oeAware\347\224\250\346\210\267\346\214\207\345\215\227.md" "b/docs/zh/docs/oeAware/oeAware\347\224\250\346\210\267\346\214\207\345\215\227.md" new file mode 100644 index 0000000000000000000000000000000000000000..c3abadc1c4a0fc1f51e0fb144a87121d41519551 --- /dev/null +++ "b/docs/zh/docs/oeAware/oeAware\347\224\250\346\210\267\346\214\207\345\215\227.md" @@ -0,0 +1,637 @@ +# oeAware用户指南 + +## 简介 + +oeAware是在openEuler上实现低负载采集感知调优的框架,目标是动态感知系统行为后智能使能系统的调优特性。传统调优特性都以独立运行且静态打开关闭为主,oeAware将调优拆分采集、感知和调优三层,每层通过订阅方式关联,各层采用插件式开发尽可能复用。 + +## 安装 + +配置openEuler的yum源,使用yum命令安装。在openEuler-22.03-LTS-SP4版本中会默认安装。 + +```shell +yum install oeAware-manager +``` + +## 使用方法 + +首先启动oeaware服务,然后通过`oeawarectl`命令进行使用。 + +### 服务启动 + +通过systemd服务启动。安装完成后会默认启动。 + +```shell +systemctl start oeaware +``` + +### 配置文件 + +配置文件路径:/etc/oeAware/config.yaml + +```yaml +log_path: /var/log/oeAware #日志存储路径 +log_level: 1 #日志等级 1:DEBUG 2:NFO 3:WARN 4:ERROR +enable_list: #默认使能插件 + - name: libtest.so #只配置插件,使能本插件的所有实例 + - name: libtest1.so #配置插件实例,使能配置的插件实例 + instances: + - instance1 + - instance2 + ... + ... +plugin_list: #可支持下载的包 + - name: test #名称需要唯一,如果重复取第一个配置 + description: hello world + url: https://gitee.com/openeuler/oeAware-manager/raw/master/README.md #url非空 + ... +``` + +修改配置文件后,通过以下命令重启服务。 + +```shell +systemctl restart oeaware +``` + +### 插件说明 + +**插件定义**:一个插件对应一个.so文件,插件分为采集插件、感知插件和调优插件。 + +**实例定义**:服务中的调度单位是实例,一个插件中包括多个实例。例如,一个采集插件包括多个采集项,每个采集项是一个实例。 + +### 插件加载 + +服务会默认加载插件存储路径下的插件。 + +插件路径:/usr/lib64/oeAware-plugin/ + +另外也可以通过手动加载的方式加载插件。 + +```shell +oeawarectl -l | --load <插件名> +``` + +示例 + +```shell +[root@localhost ~]# oeawarectl -l libthread_collect.so +Plugin loaded successfully. +``` + +失败返回错误说明。 + +### 插件卸载 + +```shell +oeawarectl -r <插件名> | --remove <插件名> +``` + +示例 + +```shell +[root@localhost ~]# oeawarectl -r libthread_collect.so +Plugin remove successfully. +``` + +失败返回错误说明。 + +### 插件查询 + +#### 查询插件状态信息 + +```shell +oeawarectl -q #查询系统中已经加载的所有插件 +oeawarectl --query <插件名> #查询指定插件 +``` + +示例 + +```shell +[root@localhost ~]# oeawarectl -q +Show plugins and instances status. +------------------------------------------------------------ +libsystem_tune.so + stealtask_tune(available, close, count: 0) + smc_tune(available, close, count: 0) + xcall_tune(available, close, count: 0) + seep_tune(available, close, count: 0) +libpmu.so + pmu_counting_collector(available, close, count: 0) + pmu_sampling_collector(available, close, count: 0) + pmu_spe_collector(available, close, count: 0) + pmu_uncore_collector(available, close, count: 0) +libdocker_tune.so + docker_cpu_burst(available, close, count: 0) +libthread_scenario.so + thread_scenario(available, close, count: 0) +libsystem_collector.so + thread_collector(available, close, count: 0) + kernel_config(available, close, count: 0) + command_collector(available, close, count: 0) +libdocker_collector.so + docker_collector(available, close, count: 0) +libub_tune.so + unixbench_tune(available, close, count: 0) +libanalysis_oeaware.so + analysis_aware(available, close, count: 0) +------------------------------------------------------------ +format: +[plugin] + [instance]([dependency status], [running status], [enable cnt]) +dependency status: available means satisfying dependency, otherwise unavailable. +running status: running means that instance is running, otherwise close. +enable cnt: number of instances enabled. +``` + +失败返回错误说明。 + +#### 查询调优实例信息 + +```shell +oeawarectl --info +``` + +显示调优实例描述信息及运行状态。 + +#### 查询运行实例订阅关系 + +```shell +oeawarectl -Q #查询所有运行实例的订阅关系图 +oeawarectl --query-dep= <插件实例> #查询运行实例订阅关系图 +``` + +在当前目录下生成dep.png,显示订阅关系。 + +实例未运行,不会显示订阅关系。 + +示例 + +```sh +oeawarectl -e thread_scenario +oeawarectl -Q +``` + +![img](./figures/dep.png) + +### 插件实例使能 + +#### 使能插件实例 + +```shell +oeawarectl -e | --enable <插件实例> +``` + +使能某个插件实例,会将其订阅的topic实例一起使能。 + +失败返回错误说明。 + +推荐使能插件列表: + +- libsystem_tune.so:stealtask_tune,smc_tune,xcall_tune,seep_tune。 +- libub_tune.so:unixbench_tune。 +- libtune_numa.so:tune_numa_mem_access。 + +其他插件主要用来提供数据,可通过sdk获取插件数据。 + +#### 关闭插件实例 + +```shell +oeawarectl -d | --disable <插件实例> +``` + +关闭某个插件实例,会将其订阅的topic实例一起关闭。 + +失败返回错误说明。 + +### 插件下载安装 + +通过`--list`命令查询支持下载的rpm包和已安装的插件。 + +```shell +oeawarectl --list +``` + +查询结果如下。 + +```shell +Supported Packages: #可下载的包 +[name1] #config中配置的plugin_list +[name2] +... +Installed Plugins: #已安装的插件 +[name1] +[name2] +... +``` + +通过`--install`命令下载安装rpm包。 + +```shell +oeawarectl -i | --install #指定--list下查询得到的包名称(Supported Packages下的包) +``` + +失败返回错误说明。 + +### 分析模式 + +```sh +oeawarectl analysis -h +usage: oeawarectl analysis [options]... + options + -t|--time set analysis duration in seconds(default 30s), range from 1 to 100. + -r|--realtime show real time report. + -v|--verbose show verbose information. + -h|--help show this help message. + --l1-miss-threshold set l1 tlbmiss threshold. + --l2-miss-threshold set l2 tlbmiss threshold. +``` + +--l1-miss-threshold用于设置l1-tlb—miss阈值,超过这个阈值miss率为high。 + +--l2-miss-threshold用于设置l2-tlb—miss阈值,超过这个阈值miss率为high。 + +示例 + +执行以下命令,输出系统分析报告。 + +```sh +oeawarectl analysis -t 10 +``` + +报告分为三部分: + +- Data Analysis:根据系统运行状态,给出系统性能数据分析。 +- Analysis Conclusion:给出系统分析结论。 +- Analysis Suggestion:给出具体调优方法。 + +### 帮助 + +通过`--help`查看帮助。 + +```shell +usage: oeawarectl [options]... + options + analysis run analysis mode. + -l|--load [plugin] load plugin. + -r|--remove [plugin] remove plugin from system. + -e|--enable [instance] enable the plugin instance. + -d|--disable [instance] disable the plugin instance. + -q query all plugins information. + --query [plugin] query the plugin information. + -Q query all instances dependencies. + --query-dep [instance] query the instance dependency. + --list the list of supported plugins. + --info the list of InfoCmd plugins. + -i|--install [plugin] install plugin from the list. + --help show this help message. +``` + +## 插件开发说明 + +### 基础数据结构 + +```c++ +typedef struct { + char *instanceName; // 实例名称 + char *topicName; // 主题名称 + char *params; // 参数 +} CTopic; + +typedef struct { + CTopic topic; + unsigned long long len; // data数组的长度 + void **data; // 存储的数据 +} DataList; + +const int OK = 0; +const int FAILED = -1; + +typedef struct { + int code; // 成功返回OK,失败返回FAILED + char *payload; // 附带信息 +} Result; + +``` + +### 实例基类 + +```c++ +namespace oeaware { +// Instance type. +const int TUNE = 0b10000; +const int SCENARIO = 0b01000; +const int RUN_ONCE = 0b00010; +class Interface { +public: + virtual Result OpenTopic(const Topic &topic) = 0; + virtual void CloseTopic(const Topic &topic) = 0; + virtual void UpdateData(const DataList &dataList) = 0; + virtual Result Enable(const std::string ¶m = "") = 0; + virtual void Disable() = 0; + virtual void Run() = 0; +protected: + std::string name; + std::string version; + std::string description; + std::vector supportTopics; + int priority; + int type; + int period; +} +} +``` + +实例开发继承实例基类,实现6个虚函数,并对类的7个属性赋值。 + +实例采用订阅发布模式,通过Subscribe获取数据,通过Publish接口发布数据。 + +### 属性说明 + +| 属性 | 类型 | 说明 | +| --- | --- | --- | +| name | string | 实例名称 | +| version | string | 实例版本(预留) | +| description | string | 实例描述 | +| supportTopics | vector\ | 支持的topic | +| priority | int | 实例执行的优先级 (调优 > 感知 > 采集)| +| type | int | 实例类型,通过比特位标识,第二位表示单次执行实例,第三位表示采集实例,第四位表示感知实例,第5位表示调优实例| +| period | int | 实例执行周期,单位ms,period为10的倍数 | + +### 接口说明 + +| 函数名 | 参数 | 返回值 | 说明 | +| --- | --- | --- | --- | +|Result OpenTopic(const Topic &topic) | topic:打开的主题 | | 打开对应的topic | +| void CloseTopic(const Topic &topic) | topic:关闭的主题| |关闭对应的topic | +| void UpdateData(const DataList &dataList) | dataList:订阅的数据 | | 当订阅topic时,被订阅的topic每周期会通过UpdateData更新数据 | +| Result Enable(const std::string ¶m = "") | param:预留 | | 使能本实例 | +| void Disable() | | | 关闭本实例 | +| void Run() | | | 每周期会执行run函数 | + +### 实例示例 + +```C++ +#include +#include + +class Test : public oeaware::Interface { +public: + Test() { + name = "TestA"; + version = "1.0"; + description = "this is a test plugin"; + supportTopics; + priority = 0; + type = 0; + period = 20; + } + oeaware::Result OpenTopic(const oeaware::Topic &topic) override { + return oeaware::Result(OK); + } + void CloseTopic(const oeaware::Topic &topic) override { + + } + void UpdateData(const DataList &dataList) override { + for (int i = 0; i < dataList.len; ++i) { + ThreadInfo *info = static_cast(dataList.data[i]); + INFO(logger, "pid: " << info->pid << ", name: " << info->name); + } + } + oeaware::Result Enable(const std::string ¶m = "") override { + Subscribe(oeaware::Topic{"thread_collector", "thread_collector", ""}); + return oeaware::Result(OK); + } + void Disable() override { + + } + void Run() override { + DataList dataList; + oeaware::SetDataListTopic(&dataList, "test", "test", ""); + dataList.len = 1; + dataList.data = new void* [1]; + dataList.data[0] = &pubData; + Publish(dataList); + } +private: + int pubData = 1; +}; + +extern "C" void GetInstance(std::vector> &interfaces) +{ + interfaces.emplace_back(std::make_shared()); +} +``` + +## 内部插件 + +### libpmu.so + +| 实例名称 | 架构 | 说明 | topic | +| --- | --- | --- | --- | +| pmu_counting_collector | aarch64 | 采集count相关事件 |cycles,net:netif_rx,L1-dcache-load-misses,L1-dcache-loads,L1-icache-load-misses,L1-icache-loads,branch-load-misses,branch-loads,dTLB-load-misses,dTLB-loads,iTLB-load-misses,iTLB-loads,cache-references,cache-misses,l2d_tlb_refill,l2d_cache_refill,l1d_tlb_refill,l1d_cache_refill,inst_retired,instructions | +| pmu_sampling_collector | aarch64 | 采集sample相关事件 | cycles, skb:skb_copy_datagram_iovec,net:napi_gro_receive_entry | +| pmu_spe_collector | aarch64 | 采集spe事件 | spe | +| pmu_uncore_collector | aarch64 | 采集uncore事件 | uncore | + +#### 限制条件 + +采集spe事件需要依赖硬件能力,此插件运行依赖 BIOS 的 SPE,运行前需要将 SPE 打开。 + +运行perf list | grep arm_spe查看是否已经开启SPE,如果开启,则有如下显示: + +```sh +arm_spe_0// [Kernel PMU event] +``` + +如果没有开启,则按下述步骤开启。 + +检查BIOS配置项 MISC Config --> SPE 的状态, 如果状态为 Disable,则需要更改为 Enable。如果找不到这个选项,可能是BIOS版本过低。 + +进入系统 vim /boot/efi/EFI/openEuler/grub.cfg,定位到内核版本对应的开机启动项,在末尾增加“kpti=off”。例如: + +```sh +linux /vmlinuz-4.19.90-2003.4.0.0036.oe1.aarch64 root=/dev/mapper/openeuler-root ro rd.lvm.lv=openeuler/root rd.lvm.lv=openeuler/swap video=VGA-1:640x480-32@60me rhgb quiet smmu.bypassdev=0x1000:0x17 smmu.bypassdev=0x1000:0x15 crashkernel=1024M,high video=efifb:off video=VGA-1:640x480-32@60me kpti=off +``` + +按“ESC”,输入“:wq”,按“Enter”保存并退出。执行reboot命令重启服务器。 + +### libsystem_collector.so + +系统信息采集插件。 +| 实例名称 | 架构 | 说明 | topic | +| --- | --- | --- | --- | +| thread_collector | aarch64/x86 | 采集系统中的线程信息 | thread_collector | +| kernel_config | aarch64/x86| 采集内核相关参数,包括sysctl所有参数、lscpu、meminfo等 | get_kernel_config,get_cmd,set_kernel_config | +| command_collector | aarch64/x86 | 采集sysstat相关数据 | mpstat,iostat,vmstat,sar,pidstat | + +### libdocker_collector.so + +docker信息采集插件。 +| 实例名称 | 架构 | 说明 | topic | +| --- | --- | --- | --- | +| docker_collector | aarch64/x86 | 采集docker相关信息 | docker_collector | + +### libthread_scenario.so + +线程感知插件。 +| 实例名称 | 架构 | 说明 | 订阅 | +| --- | --- | --- | --- | +| thread_scenario | aarch64/x86 | 通过配置文件获取对应线程信息 | thread_collector::thread_collector | + +#### 配置文件 + +thread_scenario.conf + +```sh +redis +fstime +fsbuffer +fsdisk +``` + +### libanalysis_oeaware.so + +| 实例名称 | 架构 | 说明 | 订阅 | +| --- | --- | --- | --- | +| analysis_aware | 分析当前环境的业务特征,并给出优化建议 | aarch64 | pmu_spe_collector::spe, pmu_counting_collector::net:netif_rx, pmu_sampling_collector::cycles, pmu_sampling_collector::skb:skb_copy_datagram_iovec, pmu_sampling_collector::net:napi_gro_receive_entry | + +### libsystem_tune.so + +系统调优插件。 +| 实例名称 | 架构 | 说明 | 订阅 | +| --- | --- | --- | --- | +| stealtask_tune | aarch64 | 高负载场景下,通过轻量级搜索算法,实现多核间快速负载均衡,最大化cpu资源利用率 | 无 | +| smc_tune | aarch64 | 使能smc加速,对使用tcp协议的连接无感加速 | 无 | +| xcall_tune | aarch64 | 通过减少系统调用底噪,提升系统性能 | thread_collector::thread_collector | +| seep_tune | aarch64 | 使能智能功耗模式,降低系统能耗 | 无 | +| transparent_hugepage_tune | aarch64/x86 | 开启透明大页,降低tlbmiss | 无 | +| preload_tune | aarch64 | 无感加载动态库 | 无 | + +#### 配置文件 + +xcall.yaml + +``` yaml +redis: # 线程名称 + - xcall_1: 1 #xcall_1表示xcall优化方式,目前只有xcall_1; 1表示需要优化系统调用号 +mysql: + - xcall_1: 1 +node: + - xcall_1: 1 +``` + +preload.yaml + +路径:/etc/oeAware/preload.yaml + +```yaml +- appname: "" + so: "" +``` + +通过执行oeawarectl -e preload_tune命令, 根据配置文件给对应进程加载so。 + +#### 限制条件 + +xcall_tune依赖内核特性,需要开启FAST_SYSCALL编译内核,并且在cmdline里增加xcall字段。 + +### libub_tune.so + +unixbench调优插件。 +| 实例名称 | 架构 | 说明 | 订阅 | +| --- | --- | --- | --- | +| unixbench_tune | aarch64/x86 | 通过减少远端内存访问,优化ub性能 | thread_collector::thread_collector | + +### libdocker_tune.so + +| 实例名称 | 架构 | 说明 | 订阅 | +| --- | --- | --- | --- | +| docker_cpu_burst | aarch64 | 在出现突发负载时,CPUBurst可以为容器临时提供额外的CPU资源,缓解CPU限制带来的性能瓶颈 | pmu_counting_collector::cycles,docker_collector::docker_collector | + +## 外部插件 + +外部插件需要通过以下命令安装,例如安装numafast相关插件。 + +```sh +oeawarectl -i numafast +``` + +### libscenario_numa.so + +| 实例名称 | 架构 | 说明 | 订阅 | topic | +| --- | --- | --- | --- | --- | +| scenario_numa | aarch64 | 感知当前环境跨NUMA访存比例,用于实例或sdk订阅(无法单独使能) | pmu_uncore_collector::uncore | system_score | + +### libtune_numa.so + +| 实例名称 | 架构 | 说明 | 订阅 | +| --- | --- | --- | --- | +| tune_numa_mem_access | aarch64 | 周期性迁移线程和内存,减少跨NUMA内存访问 | scenario_numa::system_score, pmu_spe_collector::spe, pmu_counting_collector::cycles | + +## SDK使用说明 + +```C +typedef int(*Callback)(const DataList *); +int OeInit(); // 初始化资源,与server建立链接 +int OeSubscribe(const CTopic *topic, Callback callback); // 订阅topic,异步执行callback +int OeUnsubscribe(const CTopic *topic); // 取消订阅topic +int OePublish(const DataList *dataList); // 发布数据到server +void OeClose(); // 释放资源 +``` + +**示例** + +```C +#include "oe_client.h" +#include "command_data.h" +int f(const DataList *dataList) +{ + int i = 0; + for (; i < dataList->len; i++) { + CommandData *data = (CommandData*)dataList->data[i]; + for (int j = 0; j < data->attrLen; ++j) { + printf("%s ", data->itemAttr[j]); + } + printf("\n"); + } + return 0; +} +int main() { + OeInit(); + CTopic topic = { + "command_collector", + "sar", + "-q 1", + }; + if (OeSubscribe(&topic, f) < 0) { + printf("failed\n"); + } else { + printf("success\n"); + } + sleep(10); + OeClose(); +} +``` + +## 约束限制 + +### 功能约束 + +oeAware默认集成了arm的微架构采集libkperf模块,该模块同一时间只能有一个进程进行调用,如其他进程调用或者使用perf命令可能存在冲突。 + +### 操作约束 + +当前oeAware仅支持root组用户进行操作,sdk支持root组和oeaware组用户使用。 + +## 注意事项 + +oeAware的配置文件和插件用户组和权限有严格校验,不要对oeAware的相关文件进行权限和用户组进行修改。 + +权限说明: + +- 插件文件:440 + +- 客户端执行文件:750 + +- 服务端执行文件:750 + +- 服务配置文件:640 diff --git a/docs/zh/docs/oeDeploy/Command.md b/docs/zh/docs/oeDeploy/Command.md new file mode 100644 index 0000000000000000000000000000000000000000..47c919023f31099f14ef4879d15ffa9ecc7998b5 --- /dev/null +++ b/docs/zh/docs/oeDeploy/Command.md @@ -0,0 +1,57 @@ +# oedp 命令行参数说明 + +## `oedp` + +| 选项 | 选项简写 | 功能说明 | +| ------------- | -------- | ---------- | +| `--version` | `-v` | 查询版本号 | + +## `oedp info` + +查看项目的详细信息,默认为当前路径 + +| 选项 | 简写 | 是否必需 | 功能说明 | +| -------------------- | ------ | -------- | ---------------------- | +| `--project [path]` | `-p` | N | 指定一个路径为项目路径 | + +## `oedp run [action]` + +执行项目的方法,默认为当前路径;`[action]`为插件可使用的方法,可通过 `oedp info`命令查询 + +| 选项 | 简写 | 是否必需 | 功能说明 | +| --------------------- | ------ | -------- | ---------------------- | +| `--project [path]` | `-p` | N | 指定一个路径为项目路径 | +| `--debug`(开发中) | `-d` | N | 以debug模式运行 | + +## `oedp list` + +列举源中可用的插件 + +| 选项 | 简写 | 是否必需 | 功能说明 | +| ------------------ | ------ | -------- | -------------------- | +| `--local [path]` | `-l` | N | 指定一个路径为本地源 | + +## `oedp check [action]`(开发中) + +检查项目中指定方法的检查项,默认为当前路径 + +| 选项 | 简写 | 是否必需 | 功能说明 | +| -------------------- | ------ | -------- | ---------------------- | +| `--project [path]` | `-p` | N | 指定一个路径为项目路径 | + +## `oedp init [plugin]`(开发中) + +插件初始化, `[plugin]`为插件名,可通过 `oedp list`命令查询 + +| 选项 | 简写 | 是否必需 | 功能说明 | +| -------------------- | ------ | -------- | ---------------------------------------------------------------- | +| `--project [path]` | `-p` | Y | 指定初始化路径 | +| `--local [path]` | `-l` | N | 指定一个路径为本地源 | +| `--force` | `-f` | N | 强制覆盖路径;如果路径存在,会先删除该路径中的所有文件,再初始化 | + +# oedp 工具相关路径 + ++ `/var/oedp/log/`:日志文件路径 ++ `/var/oedp/plugin/`:插件缓存路径 ++ `/usr/lib/oedp/src/`:源码路径 ++ `/etc/oedp/config/`:配置文件路径 diff --git a/docs/zh/docs/oeDeploy/DevelopGuide.md b/docs/zh/docs/oeDeploy/DevelopGuide.md new file mode 100644 index 0000000000000000000000000000000000000000..55f879801df104457858caae6d33b57bc7f42368 --- /dev/null +++ b/docs/zh/docs/oeDeploy/DevelopGuide.md @@ -0,0 +1,146 @@ +# oeDeploy 插件开发指南 + +## 1 oeDeploy 插件介绍 + +oeDeploy 插件(plugin)是 oeDeploy 工具中提供自动化部署能力的组件,通过将复杂的部署流程 ansible 化来实现自动化部署。插件中可能会集成多种部署操作(action),例如安装、卸载、环境清理等,每一个部署操作都会对应一个或多个 ansible playbook。插件的所有可配置项都应当集中配置,以降低使用者的学习成本和开发者的维护成本。 + +## 2 插件目录结构 + +插件开发者在开发插件时应当遵循以下目录结构: + +```text +{ plugin_name } +|-- main.yaml +|-- config.yaml +|-- doc/ +`-- workspace/ +``` + +| 文件或者目录名 | 介绍 | +| -------------- | ------------------------------------------------------------ | +| config.yaml | 包含主机相关的配置,如 ip、密码、密钥、端口号等,还包含了应用的一些部署相关的配置,支持 jinja2 语法 | +| main.yaml | oedp 识别应用部署流程的主配置文件 | +| doc(可选) | 插件相关的文档目录 | +| workspace | 应用的部署能力库 | + +其中,`plugin_name`有以下约束: + ++ 该插件部署的软件名称为`name`,版本为`version`。 ++ `plugin_name`必须是以下两种之一: + + `{name}-{version}` + + `{name}-{version}-xxx` ++ 例如,一个插件用于部署 kubernetes 软件,版本为 1.31.1,那么该插件的名称可以是:kubernetes-1.31.1,kubernetes-1.31.1-20240101,kubernetes-1.31.1-offline-20240101 等。 + +## 3 main.yaml + +main.yaml 主要用于记录插件的关键信息,包括:名称(name)、版本(version)、介绍(description)、操作(action)等,当用户执行`oedp info`命令时,oedp 工具会读取并解析该文件,然后向用户展示其详细信息。 + +在`action`项中,应当是一个字典(key-value map),每一个 key 将作为操作的名称,对应的 value 中记录了该操作的详情。 + +操作详情是一个字典,其中的`description`项是该操作的说明,用于在执行`oedp info`命令时向用户展示,而`tasks`项中则记录该操作的具体步骤,为一个列表,执行该操作时,将按顺序执行每一项步骤。 + +在步骤中,开发者应当指定该步骤需要执行的`playbook`的路径,如果有需要,也可以在`vars`中指定变量文件的路径。所有路径都是相对`workspace`的相对路径。此外,可以指定`scope`,即该步骤需要执行的主机组,默认为 all。 + +```yaml +name: kubernetes +version: 1.31.1 +description: install kubernetes 1.31.1 +action: + install: + description: install kubernetes + tasks: + - name: install kubernetes + playbook: init-k8s.yml + vars: variables.yml + scope: all + delete: + description: delete kubernetes + tasks: + - name: delete kubernetes + playbook: delete-k8s.yml + vars: variables.yml + scope: all + clean: + description: clean cache files + tasks: + - name: clean cache files + playbook: clean-k8s.yml + scope: all +``` + +## 4 config.yaml + +config.yaml 是插件中的用户配置文件,主要包含对主机组的配置和一些其他的全局配置,遵循 ansible 的 inventory 文件配置规则,在执行 ansible playbook 时可直接作为 inventory 传入。 + +```yaml +all: + children: + masters: + hosts: + HOST_IP1: # e.g. 192.168.10.1 + ansible_host: HOST_IP1 # e.g. 192.168.10.1 + ansible_port: 22 + ansible_user: root + ansible_password: "" + architecture: amd64 # e.g. [ amd64, arm64 ] + oeversion: 22.03-LTS # e.g. [ 22.03-LTS, 24.03-LTS ] + workers: + hosts: + HOST_IP2: + ansible_host: HOST_IP2 + ansible_port: 22 + ansible_user: root + ansible_password: "" + architecture: amd64 + oeversion: 22.03-LTS + HOST_IP3: + ansible_host: HOST_IP3 + ansible_port: 22 + ansible_user: root + ansible_password: "" + architecture: amd64 + oeversion: 22.03-LTS + vars: + init_cluster_force: "true" # e.g. [ "true", "false" ] 强制初始化集群 + service_cidr: 10.96.0.0/16 # 服务网段 + pod_cidr: 10.244.0.0/16 # pod ip 网段 + certs_expired: 3650 # 证书过期时间 + has_deployed_containerd: "false" # e.g. [ "true", "false" ] 是否已有 containerd +``` + +## 5 workspace + +workspace 目录中承载了部署脚本的主体内容,目录结构不做限制,需要与 main.yaml 和 config.yaml 中的各参数对应。 + +workspace 目录视为整个插件的根目录。 + +当前示例中,workspace 中的目录结构为: + +```text +workspace +|-- roles +| `-- ... +|-- init-k8s.yml +|-- delete-k8s.yml +|-- clean-k8s.yml +|-- variables.yml +`-- ... +``` + +## 6 插件打包 + +如果要发布插件供用户使用,需要将插件打包成`{plugin_name}.tar.gz`的格式,压缩包的名称和包内目录的名称要对应,且解压后应当仅生成一个目录,例如: + +```text +kubernetes-1.31.1.tar.gz +`-- kubernetes-1.31.1 + |-- main.yaml + |-- config.yaml + `-- workspace/ +``` + +当前示例中,使用如下命令行完成打包: + +````bash +tar zcvf kubernetes-1.31.1.tar.gz kubernetes-1.31.1/ +```` diff --git a/docs/zh/docs/oeDeploy/Feature.md b/docs/zh/docs/oeDeploy/Feature.md new file mode 100644 index 0000000000000000000000000000000000000000..4c269cd2f6e33ff8b472ed0745f31dd47da763af --- /dev/null +++ b/docs/zh/docs/oeDeploy/Feature.md @@ -0,0 +1,19 @@ +# 开发中特性 + +- Debug 模式,支持执行指定的 task。 +- 部署插件初始化功能。 +- 部署插件检查模块。 +- 插件源管理模块,根据插件名称自动下载、解压插件,插件源可配置。 +- oeDeploy Web页面,支持自定义部署任务、节点信息管理、部署流程可视化。 + +# 已规划特性 + +- 部署插件商店,页面展示插件列表,支持页面创建部署任务。 +- 兼容 Helm 部署项目。 + +# 已发布特性 + +## v1.0.1 + +- 使用 ansible 作为分布式节点的命令下发平台。 +- 支持 playbook 粒度的流程编排。 diff --git a/docs/zh/docs/oeDeploy/Introduction.md b/docs/zh/docs/oeDeploy/Introduction.md new file mode 100644 index 0000000000000000000000000000000000000000..a269fff7345a7b3b70ab7b710defcbb23f678ff5 --- /dev/null +++ b/docs/zh/docs/oeDeploy/Introduction.md @@ -0,0 +1,21 @@ +# 简介 / Introduction + +oeDeploy 是一款轻量级的软件部署工具,旨在帮助开发者快速、高效地完成各类软件环境部署,对单节点与分布式场景均可适配。 + +- **通用的全场景支持**:同时支持单节点与集群环境等多种场景。 +- **主流软件一键部署**:内置常见软件的标准化部署方案,开发团队也将持续引入其它主流插件,不断提升 oeDeploy 的部署能力。 +- **灵活的插件化管理**:oeDeploy 提供可扩展架构,支持开发者基于实际需求,使用自定义编写的定制插件,精准匹配自身业务特性。 +- **高效开发体验**:oeDeploy 已支持命令行,并将提供可视化工具;开发者仅需关注步骤编排与核心功能开发,用更少的代码,实现更高效的软件部署。 + +# 下载 / Download + +- [命令行工具 oedp(aarch64)](https://repo.oepkgs.net/openEuler/rpm/openEuler-24.03-LTS/contrib/oedp/aarch64/Packages/oedp-1.0.1-1.oe2503.aarch64.rpm) +- [命令行工具 oedp(x86_64)](https://repo.oepkgs.net/openEuler/rpm/openEuler-24.03-LTS/contrib/oedp/x86_64/Packages/oedp-1.0.1-1.oe2503.x86_64.rpm) +- [oeDeploy 部署插件](https://repo.oepkgs.net/openEuler/rpm/openEuler-24.03-LTS/contrib/oedp/plugins/) + +# 文档 / Docs + +- [命令行工具 oedp 使用指南](./Command.md) +- [oeDeploy 工具特性](./Feature.md) +- [oeDeploy 应用案例](./UseCase.md) +- [oeDeploy 插件开发指南](./DevelopGuide.md) diff --git a/docs/zh/docs/oeDeploy/UseCase.md b/docs/zh/docs/oeDeploy/UseCase.md new file mode 100644 index 0000000000000000000000000000000000000000..9fd8827302ad6c723af7b45448e730c0530cae1b --- /dev/null +++ b/docs/zh/docs/oeDeploy/UseCase.md @@ -0,0 +1,84 @@ +# oeDeploy 应用案例 + +## 应用案例 1:kubernetes 一键部署 + +准备 3 个 2U4G 的虚拟机环境(三层网络互通),使用的 OS 版本为 openEuler 24.03-LTS-SP1,目标是部署由 1 个 master、2 个 worker 构成的 k8s 集群。 + +在任意节点上,下载并安装 oeDeploy 的命令行工具 oedp。 + +````bash +wget https://repo.oepkgs.net/openEuler/rpm/openEuler-24.03-LTS/contrib/oedp/x86_64/Packages/oedp-1.0.1-1.oe2503.x86_64.rpm +yum install -y oedp-1.0.1-1.oe2503.x86_64.rpm +```` + +执行以下命令,获取并解压插件包,确保当前目录下出现了目录`kubernetes-1.31.1`。 + +```shell +wget https://repo.oepkgs.net/openEuler/rpm/openEuler-24.03-LTS/contrib/oedp/plugins/kubernetes-1.31.1.tar.gz +tar -zxvf kubernetes-1.31.1.tar.gz +``` + +执行`info`命令以查看插件详细信息: + +```shell +oedp info -p kubernetes-1.31.1 +``` + +修改项目配置文件,根据实际情况配置节点信息: + +```shell +vim kubernetes-1.31.1/config.yaml +``` + +````yaml +all: + children: + masters: + hosts: + 172.27.76.114: # master node IP + ansible_host: 172.27.76.114 # master node IP + ansible_port: 22 + ansible_user: root + ansible_password: + architecture: amd64 # amd64 or arm64 + oeversion: 24.03-LTS # 22.03-LTS or 24.03-LTS + workers: + hosts: + 172.27.70.60: # worker node IP + ansible_host: 172.27.70.60 # worker node IP + ansible_port: 22 + ansible_user: root + ansible_password: + architecture: amd64 + oeversion: 24.03-LTS + 172.27.72.90: + ansible_host: 172.27.72.90 + ansible_port: 22 + ansible_user: root + ansible_password: + architecture: amd64 + oeversion: 24.03-LTS + vars: + init_cluster_force: "true" + service_cidr: 10.96.0.0/16 + pod_cidr: 10.244.0.0/16 + certs_expired: 3650 + has_deployed_containerd: "false" + ansible_ssh_common_args: "-o StrictHostKeyChecking=no" +```` + +> 注意:须确保节点间 ssh 可联通,支持密码登录和密钥登录,如果使用密钥登录,则不需要配置密码。 + +执行以下命令以开始自动化部署: + +```shell +oedp run install -p kubernetes-1.31.1 +``` + +执行以下命令以卸载kubernetes: + +```shell +oedp run delete -p kubernetes-1.31.1 +``` + +> -p 参数表示解压后的文件目录。如果进入 kubernetes-1.31.1 插件根目录,执行 oedp 命令时无需 -p 参数。 diff --git a/docs/zh/docs/oncn-bwm/overview.md b/docs/zh/docs/oncn-bwm/overview.md index 52d72ec7602e546f49b4c1e1cbd3d7d882aaf6d8..efff74c6338482707a62f9b26d7f592b46bba278 100644 --- a/docs/zh/docs/oncn-bwm/overview.md +++ b/docs/zh/docs/oncn-bwm/overview.md @@ -4,7 +4,7 @@ 随着云计算、大数据、人工智能、5G、物联网等技术的迅速发展,数据中心的建设越来越重要。然而,数据中心的服务器资源利用率很低,造成了巨大的资源浪费。为了提高服务器资源利用率,oncn-bwm 应运而生。 -oncn-bwm 是一款适用于离线业务混合部署场景的 Pod 带宽管理工具,它会根据 QoS 分级对节点内的网络资源进行合理调度,保障在线业务服务体验的同时,大幅提升节点整体的网络带宽利用率。 +oncn-bwm 是一款适用于在线、离线业务混合部署场景的 Pod 带宽管理工具,它会根据 QoS 分级对节点内的网络资源进行合理调度,保障在线业务服务体验的同时,大幅提升节点整体的网络带宽利用率。 oncn-bwm 工具支持如下功能: diff --git "a/docs/zh/docs/secGear/\344\275\277\347\224\250secGear\345\267\245\345\205\267.md" "b/docs/zh/docs/secGear/\344\275\277\347\224\250secGear\345\267\245\345\205\267.md" index 02741d79ae4753d4c10ed2bc20f80f09d9f48f6d..8c5f2092cf9935bea9360fa966c818a7dcf7a9f1 100644 --- "a/docs/zh/docs/secGear/\344\275\277\347\224\250secGear\345\267\245\345\205\267.md" +++ "b/docs/zh/docs/secGear/\344\275\277\347\224\250secGear\345\267\245\345\205\267.md" @@ -6,13 +6,13 @@ secGear 提供了一套工具集,方便用户开发应用程序。本章介绍 ### 简介 -secGear codegener 是基于 intel SGX SDK edger8r 开发的工具,用于解析 EDL 文件生成中间 C 代码,即辅助生成安全测与非安全侧文件互相调用的代码。 +secGear codegener 是基于 intel SGX SDK edger8r 开发的工具,用于解析 EDL 文件生成中间 C 代码,即辅助生成安全侧与非安全侧文件互相调用的代码。 secGear codegener 定义的 EDL 文件格式与 intel SGX SDK edger8r 相同,但是不支持 Intel 的完整语法定义: - 只能在方法中使用 public,不加 public 的函数声明默认为 private - 不支持从非安全侧到安全侧,以及安全侧到非安全侧的 Switchless Calls -- OCALL(Outside call) 不支持部分调用模式(如 cdecl,stdcall,fastcall) +- OCALL(Outside call) 不支持部分调用模式(如 cdecl,stdcall,fastcall) EDL 文件语法为类 C 语言语法,这里主要描述与 C 语言的差异部分: @@ -23,7 +23,7 @@ EDL 文件语法为类 C 语言语法,这里主要描述与 C 语言的差异 | untrusted | 声明 TA 侧可用不安全函数 | | return_type | 定义返回值类型 | | parameter_type | 定义参数类型 | -| [in , size = len] | 对ecall而言,表示该参数需要将数据从非安全侧传入安全侧,ocall反之(指针类型需要使用此参数,其中 size 表示实际使用的 buffer) | +| [in, size = len] | 对ecall而言,表示该参数需要将数据从非安全侧传入安全侧,ocall反之(指针类型需要使用此参数,其中 size 表示实际使用的 buffer) | | [out, size = len] | 对ecall而言,表示该参数需要将数据从安全侧传出到非安全侧,ocall反之(指针类型需要使用此参数,其中 size 表示实际使用的 buffer) | @@ -38,7 +38,7 @@ codegen 的命令格式如下: **codegen_x86_64** < --trustzone | --sgx > [--trusted-dir | **--untrusted-dir** | --trusted | --untrusted ] edlfile -ARM 架构: +- ARM 架构: **codegen_arm64** < --trustzone | --sgx > [--trusted-dir | **--untrusted-dir** | --trusted | --untrusted ] edlfile @@ -95,7 +95,7 @@ $ codegen_x86_64 --sgx helloworld.edl secGear sign_tool 是一款命令行工具,包含编译工具链和签名工具,用于 enclave 签名。sign_tool 有两种签名形式: - 单步签名:仅适用于 debug 调试模式 -- 两步签名:商用场景。需要从第三方平台或者独立的安全设备获取签名私钥,对 envlave 进行签名 +- 两步签名:商用场景。需要从第三方平台或者独立的安全设备获取签名私钥,对 enclave 进行签名 @@ -118,7 +118,7 @@ sign_tool 包含 sign 指令(对 enclave 进行签名)和 digest 指令( | -f | OTRP_FLAG,是否支持 OTRP 标准协议,默认为 0 | 可选 | | -i | 待签名的库文件 | 必选 | | -k | 单步签名所需私钥(pem文件) | 仅 SGX 类型必选 | -| -m | 安全配置文件 mainfest.txt,由用户自行配置 | 仅 iTrustee 类型必选 | +| -m | 安全配置文件 manifest.txt,由用户自行配置 | 仅 iTrustee 类型必选 | | -o | 输出文件 | 必选 | | -p | 两步签名所需的签名服务器公钥证书(pem文件) | 必选 | | -s | 两步签名所需的已签名摘要值 | 必选 | diff --git "a/docs/zh/docs/secGear/\345\256\211\350\243\205secGear.md" "b/docs/zh/docs/secGear/\345\256\211\350\243\205secGear.md" index 3b9e91810552745e64a71216b13b3c2f69f7a9ef..95ae295ef4c11a1a75f376e566e94f23229491b1 100644 --- "a/docs/zh/docs/secGear/\345\256\211\350\243\205secGear.md" +++ "b/docs/zh/docs/secGear/\345\256\211\350\243\205secGear.md" @@ -30,14 +30,14 @@ openEuler 22.03 LTS及以上 ### 环境准备 - 参考鲲鹏官网[环境要求](https://www.hikunpeng.com/document/detail/zh/kunpengcctrustzone/fg-tz/kunpengtrustzone_04_0006.html)和[搭建步骤](https://www.hikunpeng.com/document/detail/zh/kunpengcctrustzone/fg-tz/kunpengtrustzone_04_0007.html)。 + 参考鲲鹏官网[环境要求](https://www.hikunpeng.com/document/detail/zh/kunpengcctrustzone/fg-tz/kunpengtrustzone_20_0018.html)和[搭建步骤](https://www.hikunpeng.com/document/detail/zh/kunpengcctrustzone/fg-tz/kunpengtrustzone_20_0019.html)。 ### 安装操作 1. 配置openEuler yum源,在线yum源或通过ISO挂载配置本地yum源,配置在线源如下(仅以22.03-LTS举例,其他版本需要使用版本对应的yum源)。 ```shell - vi openEuler.repo + vi /etc/yum.repo/openEuler.repo [osrepo] name=osrepo baseurl=http://repo.openeuler.org/openEuler-22.03-LTS/everything/aarch64/ diff --git "a/docs/zh/docs/secGear/\350\256\244\350\257\206secGear.md" "b/docs/zh/docs/secGear/\350\256\244\350\257\206secGear.md" index 165b3712ba0ebcecdec8b5a7116a3007a4dc50ce..3d9e16ae1197e7b0e6e097ed5b78711848a11e28 100644 --- "a/docs/zh/docs/secGear/\350\256\244\350\257\206secGear.md" +++ "b/docs/zh/docs/secGear/\350\256\244\350\257\206secGear.md" @@ -2,11 +2,11 @@ ## 概述 -随着云计算的快速发展,越来越多的企业把计算业务部署到云上,面对第三方云基础设施,云上用户数据安全面临着巨大的挑战。机密计算是一种基于硬件可信执行环境的隐私保护技术,旨在依赖最底层硬件,构建最小信任依赖,将操作系统、Hypervisor、基础设施、系统管理员、服务提供商等都从信任实体列表中删除,视为未经授权的实体,从而减少潜在的风险,保护可信执行环境中数据的机密性、完整性。然而随着机密计算技术的兴起,业界机密计算技术种类繁多(如主流的Intel SGX、ARM Trustzone、RSIC-V keystone等),各技术SDK也千差万别,给开发者带来较大的开发维护成本,长远考虑,还造成了机密计算应用生态隔离。为方便开发者快速构建保护云上数据安全的机密计算解决方案,openEuler推出机密计算统一开发框架secGear。 +随着云计算的快速发展,越来越多的企业把计算业务部署到云上,面对第三方云基础设施,云上用户数据安全面临着巨大的挑战。机密计算是一种基于硬件可信执行环境的隐私保护技术,旨在依赖最底层硬件,构建最小信任依赖,将操作系统、Hypervisor、基础设施、系统管理员、服务提供商等都从信任实体列表中删除,视为未经授权的实体,从而减少潜在的风险,保护可信执行环境中数据的机密性、完整性。然而随着机密计算技术的兴起,业界机密计算技术种类繁多(如主流的Intel SGX、ARM Trustzone、RISC-V keystone等),各技术SDK也千差万别,给开发者带来较大的开发维护成本,长远考虑,还造成了机密计算应用生态隔离。为方便开发者快速构建保护云上数据安全的机密计算解决方案,openEuler推出机密计算统一开发框架secGear。 ## 架构介绍 -![](./figures/secGear_arch.png) +![](./figures/secGear_arch.png) secGear机密计算统一开发框架技术架构如图所示,主要包括三层,共同组成openEuler机密计算软件生态底座。 @@ -14,49 +14,51 @@ secGear机密计算统一开发框架技术架构如图所示,主要包括三 - Middleware Layer:通用组件层,机密计算软件货架,无需从头造轮子,帮助用户快速构建机密计算解决方案。 - Server Layer:机密计算服务层,提供典型场景机密计算解决方案。 - - ## 关键特性 ### 零切换 -#### 客户痛点 +#### 用户痛点 + 传统应用做机密计算拆分改造后,REE侧逻辑存在频繁调用TEE侧逻辑时或REE与TEE存在频繁大块数据交互时。由于REE与TEE之间的每次调用,都需要经过REE用户态 、REE内核态、驱动、TEE内核态、TEE用户态之间的上下文切换,调用传递的大块数据也要经过多次拷贝,并且驱动底层数据块大小限制等因素,频繁的REE与TEE交互性能直线下降,严重影响机密计算应用的落地。 #### 解决方案 -[零切换](https://gitee.com/openeuler/secGear#switchless%E7%89%B9%E6%80%A7)是一种通过共享内存减少REE与TEE上下文切换及数据拷贝次数,优化REE与TEE交互性能的技术。 + +[零切换](https://gitee.com/openeuler/secGear#switchless%E7%89%B9%E6%80%A7)是一种通过共享内存减少REE与TEE上下文切换及数据拷贝次数,优化REE与TEE交互性能的技术。 #### 使用方法 -1. 创建enclave时启用零切换 +1.创建enclave时启用零切换 - 零切换配置项及说明如下。 + 零切换配置项及说明如下。 ```c - typedef struct { - uint32_t num_uworkers; - uint32_t num_tworkers; - uint32_t switchless_calls_pool_size; - uint32_t retries_before_fallback; - uint32_t retries_before_sleep; - uint32_t parameter_num; - uint32_t workers_policy; - uint32_t rollback_to_common; - } cc_sl_config_t; +typedef struct { + uint32_t num_uworkers; + uint32_t num_tworkers; + uint32_t switchless_calls_pool_size; + uint32_t retries_before_fallback; + uint32_t retries_before_sleep; + uint32_t parameter_num; + uint32_t workers_policy; + uint32_t rollback_to_common; + cpu_set_t num_cores; +} cc_sl_config_t; ``` - | 配置项 | 说明 | - | -------------------------- | ------------------------------------------------------------ | - | num_uworkers | 非安全侧代理工作线程数,用于执行switchless OCALL,当前该字段仅在SGX平台生效,ARM平台可以配置,但是因ARM平台暂不支持OCALL,所以配置后不会生效。
规格:
ARM:最大值:512;最小值:1;缺省值:8(配置为0时)
SGX:最大值:4294967295;最小值:1 | - | num_tworkers | 安全侧代理工作线程数,用于执行switchless ECALL。
规格:
ARM:最大值:512;最小值:1;缺省值:8(配置为0时)
SGX:最大值:4294967295;最小值:1 | - | switchless_calls_pool_size | switchless调用任务池的大小,实际可容纳switchless_calls_pool_size * 64个switchless调用任务(例:switchless_calls_pool_size=1,可容纳64个switchless调用任务)。
规格:
ARM:最大值:8;最小值:1;缺省值:1(配置为0时)
SGX:最大值:8;最小值:1;缺省值:1(配置为0时) | - | retries_before_fallback | 执行retries_before_fallback次汇编pause指令后,若switchless调用仍没有被另一侧的代理工作线程执行,就回退到switch调用模式,该字段仅在SGX平台生效。
规格:SGX:最大值:4294967295;最小值:1;缺省值:20000(配置为0时) | - | retries_before_sleep | 执行retries_before_sleep次汇编pause指令后,若代理工作线程一直没有等到有任务来,则进入休眠状态,该字段仅在SGX平台生效。
规格: SGX:最大值:4294967295;最小值:1;缺省值:20000(配置为0时) | - | parameter_num | switchless函数支持的最大参数个数,该字段仅在ARM平台生效。
规格: ARM:最大值:16;最小值:0 | - | workers_policy | switchless代理线程运行模式,该字段仅在ARM平台生效。
规格: ARM: WORKERS_POLICY_BUSY:代理线程一直占用CPU资源,无论是否有任务需要处理,适用于对性能要求极高且系统软硬件资源丰富的场景; WORKERS_POLICY_WAKEUP:代理线程仅在有任务时被唤醒,处理完任务后进入休眠,等待再次被新任务唤醒 | - | rollback_to_common | 异步switchless调用失败时是否回退到普通调用,该字段仅在ARM平台生效。
规格: ARM:0:否,失败时仅返回相应错误码;其他:是,失败时回退到普通调用,此时返回普通调用的返回值 | +| 配置项 | 说明 | +| -------------------------- | ------------------------------------------------------------ | +| num_uworkers | 非安全侧代理工作线程数,用于执行switchless OCALL,当前该字段仅在SGX平台生效,ARM平台可以配置,但是因ARM平台暂不支持OCALL,所以配置后不会生效。
规格:
ARM:最大值:512;最小值:1;缺省值:8(配置为0时)
SGX:最大值:4294967295;最小值:1 | +| num_tworkers | 安全侧代理工作线程数,用于执行switchless ECALL。
规格:
ARM:最大值:512;最小值:1;缺省值:8(配置为0时)
SGX:最大值:4294967295;最小值:1 | +| switchless_calls_pool_size | switchless调用任务池的大小,实际可容纳switchless_calls_pool_size * 64个switchless调用任务(例:switchless_calls_pool_size=1,可容纳64个switchless调用任务)。
规格:
ARM:最大值:8;最小值:1;缺省值:1(配置为0时)
SGX:最大值:8;最小值:1;缺省值:1(配置为0时) | +| retries_before_fallback | 执行retries_before_fallback次汇编pause指令后,若switchless调用仍没有被另一侧的代理工作线程执行,就回退到switch调用模式,该字段仅在SGX平台生效。
规格:SGX:最大值:4294967295;最小值:1;缺省值:20000(配置为0时) | +| retries_before_sleep | 执行retries_before_sleep次汇编pause指令后,若代理工作线程一直没有等到有任务来,则进入休眠状态,该字段仅在SGX平台生效。
规格: SGX:最大值:4294967295;最小值:1;缺省值:20000(配置为0时) | +| parameter_num | switchless函数支持的最大参数个数,该字段仅在ARM平台生效。
规格: ARM:最大值:16;最小值:0 | +| workers_policy | switchless代理线程运行模式,该字段仅在ARM平台生效。
规格: ARM: WORKERS_POLICY_BUSY:代理线程一直占用CPU资源,无论是否有任务需要处理,适用于对性能要求极高且系统软硬件资源丰富的场景; WORKERS_POLICY_WAKEUP:代理线程仅在有任务时被唤醒,处理完任务后进入休眠,等待再次被新任务唤醒 | +| rollback_to_common | 异步switchless调用失败时是否回退到普通调用,该字段仅在ARM平台生效。
规格: ARM:0:否,失败时仅返回相应错误码;其他:是,失败时回退到普通调用,此时返回普通调用的返回值 | +| num_cores | 用于设置安全侧线程绑核
规格: 最大值为当前环境CPU核数 | -2. 定义EDL文件中接口时添加零切换标识transition_using_threads +2.定义EDL文件中接口时添加零切换标识transition_using_threads ```ocaml enclave { @@ -70,17 +72,20 @@ secGear机密计算统一开发框架技术架构如图所示,主要包括三 }; ``` +### 安全传输 +#### 用户痛点 -### 安全通道 -#### 客户痛点 -数据拥有者在请求云上机密计算服务时,需要把待处理数据上传到云上TEE环境中处理,由于TEE没有网络,用户数据需要经过网络先传输到REE,REE接收到数据的明文后,再传入TEE中。用户数据的明文暴露在REE内存中,存在安全风险。 +数据拥有者在请求云上机密计算服务时,需要把待处理数据上传到云上TEE环境中处理,在传输过程中存在数据泄露风险。针对不同网络访问能力的TEE环境,可采用如下解决方案。 -#### 解决方案 -安全通道是一种结合机密计算远程证明,实现数据拥有者与云上TEE之间安全的密钥协商技术,协商出仅数据拥有者与云上TEE拥有的sessionkey,再通过sessionkey加密用户数据,网络传输的是sessionkey加密后的数据,REE接收到密文数据,再传入TEE中解密,处理。 +#### 解决方案1:安全通道 + +该方案针对TEE没有网络的场景,用户数据需要经过网络先传输到REE,由REE再传入TEE中。该方案结合机密计算远程证明,实现数据拥有者与云上TEE之间安全的密钥协商技术,协商出仅数据拥有者与云上TEE拥有的sessionkey,再通过sessionkey加密用户数据,网络传输的是sessionkey加密后的数据,REE接收到密文数据,再传入TEE中解密、处理,该方案称为安全通道。 #### 使用方法 + 安全通道以lib库方式提供,分为客户端、服务端host、服务端enclave三部分,分别由业务程序的客户端、服务端CA、服务端TA调用。 + | 模块 | 头文件 | 库文件 | 依赖 | |------------|--------------------------|-----------------------|---------| | 客户端 | secure_channel_client.h | libcsecure_channel.so | openssl | @@ -88,6 +93,7 @@ secGear机密计算统一开发框架技术架构如图所示,主要包括三 | 服务端enclave | secure_channel_enclave.h | libtsecure_channel.so | TEE及TEE软件栈 | ##### 接口列表 + | 接口名 | 所属头文件、库 | 功能 | 备注 | |----------------------------------------------------------------------------------------------------------------------------------------------|-----------------------|--------------|----| | cc_sec_chl_client_init | secure_channel_client.h libcsecure_channel.so | 安全通道客户端初始化 | 调用前需初始化参数ctx中网络连接和消息发送钩子函数 | @@ -95,15 +101,111 @@ secGear机密计算统一开发框架技术架构如图所示,主要包括三 | cc_sec_chl_client_callback | secure_channel_client.h libcsecure_channel.so | 安全通道协商消息处理函数 | 处理安全通道协商过程中,服务端发送给客户端的消息。在客户端消息接收处调用 | | cc_sec_chl_client_encrypt | secure_channel_client.h libcsecure_channel.so | 安全通道客户端的加密接口 | 无 | | cc_sec_chl_client_decrypt | secure_channel_client.h libcsecure_channel.so | 安全通道客户端的解密接口 | 无 | -| int (*cc_conn_opt_funcptr_t)(void *conn, void *buf, size_t count); | secure_channel.h | 消息发送钩子函数原型 | 由用户客户端和服务端实现,实现中指定安全通道协商消息类型,负责发送安全通道协商消息到对端 | +| int (*cc_conn_opt_funcptr_t)(void*conn, void *buf, size_t count); | secure_channel.h | 消息发送钩子函数原型 | 由用户客户端和服务端实现,实现中指定安全通道协商消息类型,负责发送安全通道协商消息到对端 | | cc_sec_chl_svr_init | secure_channel_host.h libusecure_channel.so | 安全通道服务端初始化 | 调用前需初始化ctx中enclave_ctx | | cc_sec_chl_svr_fini | secure_channel_host.h libusecure_channel.so | 安全通道服务端销毁 | 销毁安全通道服务端以及所有客户端信息 | | cc_sec_chl_svr_callback | secure_channel_host.h libusecure_channel.so | 安全通道协商消息处理函数 | 处理安全通道协商过程中,客户端发送给服务端的消息。在服务端消息接收处调用,调用前需初始化与客户端的网络连接和发送消息函数,详见[样例](https://gitee.com/openeuler/secGear/blob/master/examples/secure_channel/host/server.c#:~:text=conn_ctx.conn_kit.send)。 | | cc_sec_chl_enclave_encrypt | secure_channel_enclave.h libtsecure_channel.so | 安全通道enclave中的加密接口 | 无 | | cc_sec_chl_enclave_decrypt | secure_channel_enclave.h libtsecure_channel.so | 安全通道enclave中的解密接口 | 无 | + ##### 注意事项 + 安全通道仅封装密钥协商过程、加解密接口,不建立网络连接,协商过程复用业务的网络连接。其中客户端和服务端的网络连接由业务建立和维护,在安全通道客户端和服务端初始化时传入消息发送钩子函数和网络连接指针。 详见[安全通道样例](https://gitee.com/openeuler/secGear/tree/master/examples/secure_channel)。 + +#### 解决方案2:RA_TLS + +该方案针对TEE具备网络通信能力的场景,例如:机密虚机/机密容器,具体过程:TA使用自签发证书,证书中包含远程证明材料,在TLS握手过程中使用远程证明服务,对证书中包含的证明材料校验,验证失败则结束握手,否则正常执行握手动作,该方案称为RA_TLS。 +该方案较方案1取消中间数据接收者,同时增加远程证明过程,既实现对TEE环境的校验,又能实现数据加密传输到TA。 + +#### 使用方法 + +RA_TLS以lib库形式提供,使用样例参考[RA_TLS样例](https://gitee.com/openeuler/secGear/tree/master/examples/ra_tls) + +| 头文件 | 库文件 | 依赖 | +|-----------|--------------|---------------------| +| ra_tls.h | libra_tls.so | cjson,curl,TLS库(例如openssl) | + +##### 接口列表 + +| 接口名 | 所属头文件 | 功能 | 备注 | +|-----------------------------|-----------------------|------------------------|---- | +|ra_tls_generate_certificate |ra_tls.h |TA生成自签名证书 |- | +|ra_tls_set_addr |ra_tls.h |设置远程证明Agent地址 |- | +|ra_tls_cert_extension_expired|ra_tls.h |护照模式下检查证书是否过期|仅用于护照模式| +|ra_tls_verify_callback |ra_tls.h |用于握手过程中回调校验证书|- | + +### 远程证明 + +#### 用户痛点 + +随着机密计算技术的发展,逐渐形成几大主流技术(如Arm Trustzone/CCA、Intel SGX/TDX、擎天Enclave、海光CSV等),产品解决方案中可能存在多种机密计算硬件,甚至不同TEE之间的协同,其中远程证明是任何一种机密计算技术信任链的重要一环,每种技术的远程证明报告格式及验证流程各有差异,用户对接不同的TEE,需要集成不同TEE证明报告的验证流程,增加了用户的集成负担,并且不利于扩展新的TEE类型。 + +#### 解决方案 + +secGear远程证明统一框架是机密计算远程证明相关的关键组件,屏蔽不同TEE远程证明差异,提供Attestation Agent和Attestation Service两个组件,Agent供用户集成获取证明报告,对接证明服务;Service可独立部署,支持iTrustee、virtCCA远程证明报告的验证。 + +#### 功能描述 + +远程证明统一框架聚焦机密计算相关功能,部署服务时需要的服务运维等相关能力由服务部署第三方提供。远程证明统一框架的关键技术如下: + +- 报告校验插件框架:支持运行时兼容iTrustee、vritCCA、CCA等不同TEE平台证明报告检验,支持扩展新的TEE报告检验插件。 +- 证书基线管理:支持对不同TEE类型的TCB/TA基线值管理及公钥证书管理,集中部署到服务端,对用户透明。 +- 策略管理:提供默认策略(易用)、用户定制策略(灵活)。 +- 身份令牌:支持对不同TEE签发身份令牌,由第三方信任背书,实现不同TEE类型相互认证。 +- 证明代理:支持对接证明服务/点对点互证,兼容TEE报告获取,身份令牌验证等,易集成,使用户聚焦业务。 + +根据使用场景,支持点对点验证和证明服务验证两种模式。 + +证明服务验证流程如下: + +1.用户(普通节点或TEE)对TEE平台发起挑战。 + +2.TEE平台通过证明代理获取TEE证明报告,并返回给用户。 + +3.用户端证明代理将报告转发到远程证明服务。 + +4.远程证明服务完成报告校验,返回由第三方信任背书的统一格式身份令牌。 + +5.证明代理验证身份令牌,并解析得到证明报告校验结果。 + +6.得到通过的校验结果后,建立安全连接。 + +点对点验证流程(无证明服务)如下: + +1.用户向TEE平台发起挑战,TEE平台返回证明报告给用户。 + +2.用户使用本地点对点TEE校验插件完成报告验证。 + +> ![](./public_sys-resources/icon-note.gif) **说明:** +> +> 点对点验证和远程证明服务验证时的证明代理不同,在编译时可通过编译选项,决定编译有证明服务和点对点模式的证明代理。 +> +#### 应用场景 + +在金融、AI等场景下,基于机密计算保护运行中的隐私数据安全时,远程证明是校验机密计算环境及应用合法性的技术手段,远程证明统一框架提供了易集成、易部署的组件,帮助用户快速使能机密计算远程证明能力。 + +### 密钥托管 + +#### 用户痛点 + +机密容器作为云原生与机密计算技术融合的创新型安全方案,通过加密镜像全生命周期防护,有效应对合规性审查、供应链攻击防御及知识产权防泄漏等核心安全诉求。该方案依赖密钥托管为基础,重点构建覆盖密钥安全存储、动态细粒度授权、跨环境协同分发的管理体系,并借助零信任策略与自动化审计能力,在确保数据机密性与操作可追溯性的同时,实现密钥治理复杂度与运维成本的最优平衡,为云原生环境提供“默认加密、按需解密”的一体化防护能力。 + +#### 解决方案 + +secGear的密钥托管方案通过可信硬件认证与动态策略控制构建多层防御体系,并基于远程证明框架实现密钥全生命周期保护。该方案通过远程证明协议验证TEE环境完整性,结合自签名公私钥证书算法,在确保密钥存储安全、传输抗截获、使用可追溯的同时,支持跨云协同与边缘安全场景,实现每秒万级密钥分发的业务吞吐。 + +#### 功能描述 + +针对密钥管理领域的安全性与可信验证需求,secGear框架整合远程证明技术构建分层密钥托管体系: + +1. **证明服务**:通过构建集中式密钥托管服务,基于机密执行环境(TEE)远程证明机制实现对加密镜像密钥的安全存储与生命周期管理,并面向授权用户提供精细化策略配置接口; +2. **证明代理**:在机密计算节点内部署轻量级证明代理组件,提供本地restAPI接口。机密容器运行时通过调用证明代理接口完成机密执行环境的完整性验证,并与服务端建立动态会话实现密钥的安全传输。 + +#### 应用场景 + +secGear的密钥托管功能与Kuasar容器运行时形成完整的机密容器解决方案,适用于任何需要高度数据安全和隐私保护的场景,尤其是在金融、医疗、政府、云计算、物联网等领域。通过容器镜像加密和密钥托管功能,可以有效保护容器镜像的完整性,减少容器数据泄露风险,防止供应链攻击,提升用户对云原生厂商的信任程度。 + ## 缩略语 | 缩略语 | 英文全名 | 中文解释 | @@ -111,3 +213,6 @@ secGear机密计算统一开发框架技术架构如图所示,主要包括三 | REE | Rich Execution Environment | 富执行环境 | | TEE | Trusted Execution Environment | 可信执行环境 | | EDL | Enclave Description Language | 安全应用描述语言 | +| TA | Trusted Application | 可信应用 | +| RA | Remote Attestation | 远程证明 | +| TLS | Transport Layer Security | 传输层安全 | diff --git "a/docs/zh/docs/sysMaster/sysmaster\344\275\277\347\224\250\350\257\264\346\230\216.md" "b/docs/zh/docs/sysMaster/sysmaster\344\275\277\347\224\250\350\257\264\346\230\216.md" index e49a236af6b7b9e91dda7dd9741962edaa8c4a9b..b39bef3db4da92c84ccb577a41a7130aac0a138b 100644 --- "a/docs/zh/docs/sysMaster/sysmaster\344\275\277\347\224\250\350\257\264\346\230\216.md" +++ "b/docs/zh/docs/sysMaster/sysmaster\344\275\277\347\224\250\350\257\264\346\230\216.md" @@ -5,8 +5,6 @@ * 如何创建 `service`服务单元配置文件。 * 如何管理单元服务,例如启动、停止、查看服务。 -更多可以查阅[官方手册](http://sysmaster.online/man/all/)。 - ## 创建单元配置文件 用户可以在 `/usr/lib/sysmaster/system/`目录下创建单元配置文件。 @@ -76,7 +74,7 @@ WantedBy="multi-user.target" 使用以下命令可以启动 `sshd`服务和运行 `ExecStart`所配置的命令。 ```bash -# sctl start sshd.service +sctl start sshd.service ``` ### 停止服务 @@ -84,7 +82,7 @@ WantedBy="multi-user.target" 使用以下命令可以停止 `sshd`服务,杀死 `ExecStart`所运行的进程。 ```bash -# sctl stop sshd.service +sctl stop sshd.service ``` ### 重启服务 @@ -92,7 +90,7 @@ WantedBy="multi-user.target" 使用以下命令可以重启 `sshd`服务,该命令会先停止后启动服务。 ```bash -# sctl restart sshd.service +sctl restart sshd.service ``` ### 查看服务状态 @@ -100,5 +98,5 @@ WantedBy="multi-user.target" 使用以下命令可以查看服务 `sshd`运行状态,用户可以查看服务的状态来获取服务是否正常运行。 ```bash -# sctl status sshd.service +sctl status sshd.service ``` diff --git "a/docs/zh/docs/sysmonitor/figures/sysmonitor\345\212\237\350\203\275\345\210\227\350\241\250.png" "b/docs/zh/docs/sysmonitor/figures/sysmonitor\345\212\237\350\203\275\345\210\227\350\241\250.png" new file mode 100644 index 0000000000000000000000000000000000000000..701e925d66a8771774e1bb38fdf70edd982913bf Binary files /dev/null and "b/docs/zh/docs/sysmonitor/figures/sysmonitor\345\212\237\350\203\275\345\210\227\350\241\250.png" differ diff --git "a/docs/zh/docs/sysmonitor/sysmonitor-\344\275\277\347\224\250\346\211\213\345\206\214.md" "b/docs/zh/docs/sysmonitor/sysmonitor-\344\275\277\347\224\250\346\211\213\345\206\214.md" new file mode 100644 index 0000000000000000000000000000000000000000..a5759d7c6dc5ddb357c553c88386e2287240a8e9 --- /dev/null +++ "b/docs/zh/docs/sysmonitor/sysmonitor-\344\275\277\347\224\250\346\211\213\345\206\214.md" @@ -0,0 +1,799 @@ +# sysmonitor + +## 介绍 + +System Monitor Daemon + +sysmonitor 负责监控 OS 系统运行过程中的异常,将监控到的异常记录到系统日志(`/var/log/sysmonitor.log`)中。sysmonitor 以服务的形式提供,可以通过 `systemctl start|stop|restart|reload sysmonitor` 启动、关闭、重启、重载服务。建议产品部署 sysmonitor 调测软件,便于定位系统异常问题。 + +![](./figures/sysmonitor功能列表.png) + +### 注意事项 + +- sysmonitor 不支持并发执行。 +- 各配置文件须合法配置,否则可能造成监控框架异常。 +- sysmonitor 服务操作和配置文件修改,日志查询需要 root 权限。root 用户具有系统最高权限,在使用 root 用户进行操作时,请严格按照操作指导进行操作,避免不规范操作造成系统管理及安全风险。 + +### 配置总览 + +sysmonitor 有一个主配置文件(`/etc/sysconfig/sysmonitor`),用于配置各监控项的监控周期、是否需要监控。配置项的=和"之间不能有空格,如`PROCESS_MONITOR="on"`。 + +配置说明 + +| 配置项 | 配置项说明 | 是否必配 | 默认值 | +| ------------------------- | ------------------------------------------------------------ | -------- | -------------------------------------- | +| PROCESS_MONITOR | 设定是否开启关键进程监控,on为开启,off为关闭 | 否 | on | +| PROCESS_MONITOR_PERIOD | 设置关键进程监控的周期,单位秒 | 否 | 3s | +| PROCESS_RECALL_PERIOD | 关键进程恢复失败后再次尝试拉起周期,单位分,取值范围为1到1440之间的整数 | 否 | 1min | +| PROCESS_RESTART_TIMEOUT | 关键进程服务异常恢复过程中超时时间,单位秒,取值范围为30至300之间的整数 | 否 | 90s | +| PROCESS_ALARM_SUPRESS_NUM | 设置关键进程监控配置使用告警命令上报告警时的告警抑制次数,取值范围为正整数 | 否 | 5 | +| FILESYSTEM_MONITOR | 设定是否开启 ext3/ext4 文件系统监控,on 为开启,off 为关闭 | 否 | on | +| DISK_MONITOR | 设定是否开启磁盘分区监控,on为开启,off 为关闭 | 否 | on | +| DISK_MONITOR_PERIOD | 设定磁盘监控周期,单位秒 | 否 | 60s | +| INODE_MONITOR | 设定是否开启磁盘 inode 监控,on 为开启, off 为关闭 | 否 | on | +| INODE_MONITOR_PERIOD | 设定磁盘 inode 监控周期,单位秒 | 否 | 开启 | +| NETCARD_MONITOR | 设定是否开启网卡监控,on 为开启, off 为关闭 | 否 | on | +| FILE_MONITOR | 设定是否开启文件监控,on为开启, off 为关闭 | 否 | on | +| CPU_MONITOR | 设定是否开启 cpu 监控,on 为开启, off 为关闭 | 否 | on | +| MEM_MONITOR | 设定是否开启内存监控,on 为开启, off 为关闭 | 否 | on | +| PSCNT_MONITOR | 设定是否开启进程数监控,on为开启,off 为关闭 | 否 | on | +| FDCNT_MONITOR | 设定是否开启 fd 总数监控,on 为开启,off 为关闭 | 否 | on | +| CUSTOM_DAEMON_MONITOR | 用户自定义的 daemon类型的监控项,on为开启,off为关闭 | 否 | on | +| CUSTOM_PERIODIC_MONITOR | 用户自定义的 periodic 类型的监控项,on为开启, off 为关闭 | 否 | on | +| IO_DELAY_MONITOR | 本地磁盘 IO 延时监控开关,on 为开启,off 为关闭 | 否 | off | +| PROCESS_FD_NUM_MONITOR | 设定是否开启单个进程句柄数监控,on为开启,off 为关闭 | 否 | on | +| PROCESS_MONITOR_DELAY | sysmonitor 启动时,是否等待所有的监控项都正常,on为等待,off为不等待 | 否 | on | +| NET_RATE_LIMIT_BURST | 网卡监控路由信息打印抑制频率,即一秒内打印多少条日志 | 否 | 5
有效范围是 0-100,默认为5 | +| FD_MONITOR_LOG_PATH | 文件句柄监控日志文件 | 否 | 默认配置路径为 /var/log/sysmonitor.log | +| ZOMBIE_MONITOR | 僵尸进程监控开关 | 否 | off | +| CHECK_THREAD_MONITOR | 内部线程自愈开关,on为开启,off为关闭 | 否 | on
若不配置,默认值为开启 | +| CHECK_THREAD_FAILURE_NUM | 内部线程自愈的周期检查次数 | 否 | 默认值为3,范围为【2,10】 | + +- 修改 `/etc/sysconfig/sysmonitor` 配置文件后,需要重启 sysmonitor 服务生效。 +- 配置文件中,如果某一项没有配置,默认为监控项开启。 +- 内部线程自愈开启后,当监控项子线程卡住,且超过配置的周期检查次数,会重启 sysmonitor 服务,进行恢复,会重新加载配置,对于配置的关键进程监控和自定义监控,会重新拉起执行。如果对于用户使用有影响,可以选择关闭该功能。 + +### 命令参考 + +- 启动监控服务 + +``` shell +systemctl start sysmonitor +``` + +- 关闭监控服务 + +``` shell +systemctl stop sysmonitor +``` + +- 重启监控服务 + +``` shell +systemctl restart sysmonitor +``` + +- 修改监控项的配置文件后,重载监控服务可使修改后的配置动态生效 + +``` shell +systemctl reload sysmonitor +``` + +### 监控日志 + +在默认情况下,为了防止 sysmonitor.log 文件过大,提供了切分转储日志的机制。日志将被转储到磁盘目录下,这样就能够保持一定量的日志。 + +配置文件为`/etc/rsyslog.d/sysmonitor.conf`,因为增加了rsyslog配置文件,第一次安装 sysmonitor 后,需要重启 rsyslog 服务生效 sysmonitor 日志配置。 + +``` shell +$template sysmonitorformat,"%TIMESTAMP:::date-rfc3339%|%syslogseverity-text%|%msg%\n" + +$outchannel sysmonitor, /var/log/sysmonitor.log, 2097152, /usr/libexec/sysmonitor/sysmonitor_log_dump.sh +if ($programname == 'sysmonitor' and $syslogseverity <= 6) then { +:omfile:$sysmonitor;sysmonitorformat +stop +} + +if ($msg contains 'Time has been changed') then { +:omfile:$sysmonitor;sysmonitorformat +stop +} + +if ($programname == 'sysmonitor' and $syslogseverity > 6) then { +/dev/null +stop +} +``` + +## ext3/ext4 文件系统监控 + +### 简介 + +当文件系统出现故障时会导致 IO 操作异常从而引发操作系统一系列问题。通过文件系统故障检测及时发现,以便于系统管理员或用户及时处理故障,修复问题。 + +### 配置文件说明 + +无 + +### 异常日志 + +对于增加了 errors=remount-ro 挂载选项的文件系统,如果监控到 ext3/ext4文件系统故障,sysmonitor.log 中打印异常信息示例如下: + +``` shell +info|sysmonitor[127]: loop0 filesystem error. Remount filesystem read-only. +``` + +其他异常场景下,如果监控到 ext3/ext4 文件系统故障,sysmonitor.log 中打印异常信息示例如下: + +``` shell +info|sysmonitor[127]: fs_monitor_ext3_4: loop0 filesystem error. flag is 1879113728. +``` + +## 关键进程监控 + +### 简介 + +定期监控系统中关键进程,当系统内关键进程异常退出时,自动尝试恢复关键进程。如果恢复失败并需要告警,可上报告警。系统管理员能被及时告知进程异常退出事件,以及进程是否被恢复拉起。问题定位人员能从日志中定位进程异常退出的时间。 + +### 配置文件说明 + +配置目录为`/etc/sysmonitor/process`, 每个进程或模块一个配置文件。 + +``` shell +USER=root +NAME=irqbalance +RECOVER_COMMAND=systemctl restart irqbalance +MONITOR_COMMAND=systemctl status irqbalance +STOP_COMMAND=systemctl stop irqbalance +``` + +各配置项如下: + +| 配置项 | 配置项说明 | 是否必配 | 默认值 | +| ---------------------- | ------------------------------------------------------------ | -------- | --------------------------------------------------- | +| NAME | 进程或模块名 | 是 | 无 | +| RECOVER_COMMAND | 恢复命令 | 否 | 无 | +| MONITOR_COMMAND | 监控命令
命令返回值为0视为进程正常,命令返回大于 0视为进程异常 | 否 | pgrep -f $(which xxx) "xxx"为NAME字段中配置的进程名 | +| STOP_COMMAND | 停止命令 | 否 | 无 | +| USER | 用户名
使用指定的用户执行、监控、恢复、停止命令或脚本 | 否 | 如果配置项为空,则默认使用 root | +| CHECK_AS_PARAM | 参数传递开关
开关设置为 on 时,在执行 RECOVER_COMMAND 命令时,会将 MONITOR_COMMAND 的返回值作为入参,传给 RECOVER_COMMAND 命令或脚本。 开关为 off 或其他时,功能关闭 | 否 | 无 | +| MONITOR_MODE | 监控模式
- 配置为 parallel,并行监控
- 配置为 serial,串行监控 | 否 | serial | +| MONITOR_PERIOD | 监控周期
- 并行监控监控周期
- 监控模块配置为 serial,该配置项不生效 | 否 | 3 | +| USE_CMD_ALARM | 告警模式
配置为 on 或 ON,则使用告警命令上报告警 | 否 | 无 | +| ALARM_COMMAND | 上报告警命令 | 否 | 无 | +| ALARM_RECOVER_COMMAND | 恢复告警命令 | 否 | 否 | + +- 修改关键进程监控的配置文件后,须执行 `systemctl reload sysmonitor`, 新的配置在一个监控周期后生效。 +- 恢复命令和监控命令不阻塞,否则会造成关键进程监控线程异常。 +- 当恢复命令执行超过 90 s时,会调用停止命令终止进程。 +- 当恢复命令配置为空或不配置时,监控命令检查到关键进程异常时,不会尝试进行拉起。 +- 当关键进程异常时,并且尝试拉起三次都不成功,最终会按照全局配置文件中配置的 PROCESS_RECALL_PERIOD 周期进行拉起。 +- 当监控的进程不是 daemon 进程,MONITOR_COMMAND 必配。 +- 若配置的关键服务在当前系统上不存在,则该监控不会生效,日志中会有相应提示;其他配置项,出现致命性错误,将使用默认配置,不报错。 +- 配置文件权限为 600,监控项建议为 systemd 中的 service类型(如 MONITOR_COMMAND=systemctl status irqbalance), 若监控的为进程,请确保 NAME 字段为绝对路径。 +- sysmonitor 重启(restart)、重载(reload)、退出(stop)都不会影响所监控的进程或服务。 +- 若 USE_CMD_ALARM 的配置为 on,ALARM_COMMAND、ALARM_RECOVER_COMMAND 的配置由用户保障。ALARM_COMMAND、ALARM_RECOVER_COMMAND 为空或没有配置,则不上报告警。 +- 对于用户自行配置的命令,如监控命令,恢复命令,停止命令,上报告警命令,恢复告警命令等,命令的安全性由用户保证。命令由 root 权限执行,建议脚本命令权限设置为仅供 root 使用,避免普通用户提权风险。 +- 配置监控命令的长度不大于200,大于 200,添加进程监控失败。 +- 当恢复命令配置为 systemd 的重启服务命令时(如`RECOVER_COMMAND=systemctl restart irqbalance`),需注意是否与开源 systemd 恢复服务的机制冲突,否则可能会影响关键进程异常后的行为模式。 +- 由 sysmonitor 恢复拉起的进程将和 sysmonitor 服务在同一个 Cgroup 当中,无法单独进行资源限制,因此建议优先使用开源 systemd 机制进行恢复。 + +### 异常日志 + +- 配置 RECOVER_COMMAND + + 如果监控到进程或模块异常,/var/log/sysmonitor.log 中打印异常信息示例如下: + + ``` shell + info|sysmonitor[127]: irqbalance is abnormal, check cmd return 1, use "systemctl restart irqbalance" to recover + ``` + + 如果监控到进程或模块恢复正常,/var/log/sysmonitor.log 中打印日志示例如下: + + ``` shell + info|sysmonitor[127]: irqbalance is recovered + ``` + +- 不配置 RECOVER_COMMAND + + 如果监控到进程或模块异常,/var/log/sysmonitor.log 中打印异常信息示例如下: + + ``` shell + info|sysmonitor[127]: irqbalance is abnormal, check cmd return 1, recover cmd is null, will not recover + ``` + + 如果监控到进程或模块恢复正常,/var/log/sysmonitor.log 中打印日志示例如下: + + ``` shell + info|sysmonitor[127]: irqbalance is recovered + ``` + +## 文件监控 + +### 简介 + +系统关键文件被意外删除后,会导致系统运行异常甚至崩溃。通过文件监控可以及时获知系统中关键文件被删除或者有恶意文件被添加,以便管理员和用户及时获知并处理故障。 + +### 配置文件说明 + +配置文件为 `/etc/sysmonitor/file`。每个监控配置项为一行,监控配置项包含两个内容:监控文件(目录)和监控事件。监控文件(目录)是绝对路径,监控文件(目录)和监控事件中间由一个或多个空格隔开。 + +配置文件支持在`/etc/sysmonitor/file.d` 目录下增加文件监控项配置,配置方法与 `/etc/sysmonitor/file` 相同。 + +- 由于日志长度限制,建议配置的文件和目录绝对路径长度小于 223。如果配置的监控对象绝对路径长度超过223,可能会有日志打印不完整的现象出现。 + +- 请用户自行确保监控文件路径正确,如果配置文件不存在或路径错误则无法监控到该文件。 + +- 由于系统路径长度限制,监控的文件或目录绝对路径长度必须小于 4096。 + +- 支持监控目录和常规文件,/proc 和 /proc/* /dev和/dev/* /sys和/sys/* 管道文件 socket 文件等均不支持监控。 + +- /var/log 和 /var/log/* 均只支持删除事件。 + +- 当配置文件中存在多个相同路径的时候,以第一条合法配置为准,其他相同配置均不生效。在日志文件中可以查看到其他相同配置被忽略的提示。 + +- 不支持对软链接配置监控;当配置硬链接文件的删除事件时,需删除该文件和它的全部硬链接才会打印文件删除事件。 + +- 当文件添加监控成功及监控的事件发生时,监控日志打印的是配置文件中路径的绝对路径。 + +- 目前暂不支持目录递归监控,只能监控配置文件中的目录,子目录不会监控。 + +- 监控文件(目录)采用了位图的方式配置要监控的事件,对文件或目录进行监控的事件位图如下所示: + +``` shell + ------------------------------- + | 11~32 | 10 | 9 | 1~8 | + ------------------------------- +``` + +事件位图每一位代表一个事件,第N位如果置1,则表示监控第n位对应的事件;如果第 n 位置 0,则表示不监控第 n 位对应的事件。监控位图对应的 16 进制数,即是写到配置文件中的监控事件项。 + +| 配置项 | 配置项说明 | 是否必配 | +| ------ | ------------------ | -------- | +| 1~8 | 保留 | 否 | +| 9 | 文件、目录添加事件 | 是 | +| 10 | 文件、目录删除事件 | 是 | +| 11~32 | 保留 | 否 | + +- 修改文件监控的配置文件后,须执行`systemctl reload sysmonitor`,新的配置在最多60秒后生效。 +- 监控事件需要严格遵守上述规则,如果配置有误,则无法监控;如果配置项中监控事件为空,则默认只监控删除事件,即0x200。 +- 文件或目录删除后,只有当所有打开该文件的进程都停止后才会上报删除事件。 +- 监控的文件通过 vi、sed 等操作修改后会在监控日志中打印 File "XXX" may have been changed。 +- 文件监控目前实现了对添加和删除事件的监控,即第9位和第10位有效,其他位为保留位,暂不生效。如果配置了保留位,监控日志会提示监控事件配置错误。 + +**示例** + +配置对 /home 下子目录的增加和删除事件监控,低12 位位图为:001100000000,则可以配置如下: + +``` shell +/home 0x300 +``` + +配置对 /etc/ssh/sshd_config 文件的删除事件监控,低12位位图为:001000000000,则可以配置如下: + +``` shell +/etc/sshd/sshd_config 0x200 +``` + +### 异常日志 + +如果监控文件有配置的事件发生,/var/log/sysmonitor.log 中打印日志示例如下: + +``` shell +info|sysmonitor[127]: 1 events queued +info|sysmonitor[127]: 1th events handled +info|sysmonitor[127]: Subfile "111" under "/home" was added. +``` + +## 磁盘分区监控 + +### 简介 + +定期监控系统中挂载的磁盘分区空间,当磁盘分区使用率大于或等于用户设置的告警阈值时,记录磁盘空间告警。当磁盘分区使用率小于用户设置的告警恢复阈值时,记录磁盘空间恢复告警。 + +### 配置文件说明 + +配置文件为 `/etc/sysmonitor/disk`。 + +``` shell +DISK="/var/log" ALARM="90" RESUME="80" +DISK="/" ALARM="95" RESUME="85" +``` + +| 配置项 | 配置项说明 | 是否必配 | 默认值 | +| ------ | ---------------------- | -------- | ------ | +| DISK | 磁盘挂载目录名 | 是 | 无 | +| ALARM | 整数,磁盘空间告警阈值 | 否 | 90 | +| RESUME | 整数,磁盘空间恢复阈值 | 否 | 80 | + +- 修改磁盘空间监控的配置文件后,须执行 systemctl reload sysmonitor,新的配置在一个监控周期后生效。 +- 重复配置的挂载目录,最后一个配置项生效。 +- ALARM 值应该大于 RESUME 值。 +- 只能针对挂载点或被挂载点的磁盘分区做监控。 +- 在 CPU 和 IO 高压场景下,df 命令执行超时,会导致磁盘利用率获取不到。 +- 当多个挂载点对应同一个磁盘分区时,以挂载点为准来上报告警。 + +### 异常日志 + +如果监控到磁盘空间告警,`/var/log/sysmonitor.log`中打印信息示例如下: + +``` shell +warning|sysmonitor[127]: report disk alarm, /var/log used:90% alarm:90% +info|sysmonitor[127]: report disk recovered, /var/log used:4% resume:10% +``` + +## 网卡状态监控 + +### 简介 + +系统运行过程中可能出现人为原因或异常而导致网卡状态或 IP 发生改变,对网卡状态和 IP 变化进行监控,以便及时感知到异常并方便定位异常原因。 + +### 配置文件说明 + +配置文件为 `/etc/sysmonitor/network`。 + +``` shell +#dev event +eth1 UP +``` + +各配置项说明如下表 +| 配置项 | 配置项说明 | 是否必配 | 默认值 | +| ------ | ------------------------------------------------------------ | -------- | ------------------------------------------------- | +| dev | 网卡名 | 是 | 无 | +| event | 侦听事件,可取 UP, DOWN,NEWADDR, DELADDR.
- UP: 网卡 UP
- DOWN: 网卡 DOWN
- NEWADDR: 增加 ip 地址
- DELADDR: 删除 ip 地址 | 否 | 若侦听事件为空则 UP,DOWN,NEWADDR,DELADDR都监控 | + +- 修改网卡监控的配置文件后,执行 `systemctl reload sysmonitor`,新的配置生效。 +- 不支持虚拟网卡 UP 和 DOWN 状态监控。 +- 请确保网卡监控的配置文件每行少于 4096 个字符,若超过4096个字符会在监控日志中打印配置错误的提示信息。 +- 默认监控所有网卡的所有事件信息,即不配置任何网卡,默认监控所有网卡的 UP,DOWN,NEWADDR,DELADDR 事件。 +- 如果配置网卡,不配置事件,则默认监控改网卡的所有事件。 +- 增加路由信息,默认一秒五条,可通过/etc/sysconfig/sysmonitor 的 NET_RATE_LIMIT_BURST 配置选项配置一秒钟打印路由信息数量。 + +### 异常日志 + +如果监控到配置的网卡事件,`/var/log/sysmonitor.log` 中打印信息示例如下: + +``` shell +info|sysmonitor[127]: lo: ip[::1] prefixlen[128] is added, comm: (ostnamed)[1046], parent comm: syst emd[1] +info|sysmonitor[127]: lo: device is up, comm: (ostnamed)[1046], parent comm: systemd[1] +``` + +如果监控到路由事件, `/var/log/sysmonitor.log` 中打印信息示例如下: + +``` shell +info|sysmonitor[881]: Fib4 replace table=255 192.168.122.255/32, comm: daemon-init[1724], parent com m: systemd[1] +info|sysmonitor[881]: Fib4 replace table=254 192.168.122.0/24, comm: daemon-init[1724], parent comm: systemd[1] +info|sysmonitor[881]: Fib4 replace table=255 192.168.122.0/32, comm: daemon-init[1724], parent comm: systemd[1] +info|sysmonitor[881]: Fib6 replace fe80::5054:ff:fef6:b73e/128, comm: kworker/1:3[209], parent comm: kthreadd[2] +``` + +## cpu 监控 + +### 简介 + +监控系统全局或指定域内 cpu 的占用情况,当 cpu 使用率超出用户设置的告警阈值时,执行用户配置的日志收集命令。 + +### 配置文件说明 + +配置文件为`/etc/sysmonitor/cpu`。 + +当监控系统全局 cpu 时,配置文件示例如下: + +``` shell +# cpu usage alarm percent +ALARM="90" + +# cpu usage alarm resume percent +RESUME="80" + +# monitor period (second) +MONITOR_PERIOD="60" + +# stat period (second) +STAT_PERIOD="300" + +# command executed when cpu usage exceeds alarm percent +REPORT_COMMAND="" +``` + +当监控系统指定域 cpu 时,配置文件示例如下: + +``` shell +# monitor period (second) +MONITOR_PERIOD="60" + +# stat period (second) +STAT_PERIOD="300" + +DOMAIN="0,1" ALARM="90" RESUME="80" +DOMAIN="2,3" ALARM="50" RESUME="40" + +# command executed when cpu usage exceeds alarm percent +REPORT_COMMAND="" +``` + +| 配置项 | 配置项说明 | 是否必配 | 默认值 | +| -------------- | ------------------------------------------------------------ | -------- | ------ | +| ALARM | 大于0,cpu 使用率告警阈值 | 否 | 90 | +| RESUME | 大于等于0,cpu 使用率恢复阈值 | 否 | 80 | +| MONITOR_PERIOD | 监控周期(秒),取值大于0 | 否 | 60 | +| STAT_PERIOD | 统计周期(秒),取值大于0 | 否 | 300 | +| DOMAIN | 域内的 cpu 信号,cpu 号均以十进制数字表示
- 可以通过列举方式指定,cpu 号之间通过逗号分隔,例如:1,2,3。也可以通过范围方式指定,格式 X-Y(X- 每个监控域单独一个配置项,每个项支持最多配置 256 个 cpu,域内以及域之间 cpu 号均不能重复 | 否 | 无 | +| REPORT_COMMAND | cpu 使用率超过告警阈值后的日志收集命令 | 否 | 无 | + +- 修改 cpu 监控的配置文件后,须执行 systemctl reload sysmonitor, 新的配置在一个监控周期后生效。 +- ALARM 值应该大于 RESUME 值。 +- 当配置监控 cpu 域后,不再对系统全局 cpu 平均使用率进行监控,单独配置的 ALARM、RESUME 值不生效。 +- 如果某个监控域的配置存在非法,则整个 cpu 监控不执行。 +- DOMAIN 内配置的 cpu 必须全部处于在线工作状态,否则对该域的监控无法正常进行。 +- REPORT_COMMAND 项的命令不能包含 &、;、> 等不安全字符且总长度不能超过 159个字符,否则命令无法生效。 +- REPORT_COMMAND 项的命令安全性、有效性由用户自己保证,sysmonitor 只负责以 root 用户执行该命令。 +- REPORT_COMMAND 项的命令不能阻塞,当该命令执行时间超过 60s后,sysmonitor 会强行终止执行。 +- 每轮监控即使有多个域 cpu 使用率超过阈值,REPORT_COMMAND 也仅会执行一次。 + +### 异常日志 + +如果监控到全局 cpu 使用率告警或恢复且配置了日志收集命令,`/var/log/sysmonitor.log` 中打印信息示例如下: + +``` shell +info|sysmonitor[127]: CPU usage alarm: 91.3% +info|sysmonitor[127]: cpu monitor: execute REPORT_COMMAND[sysmoniotrcpu] successfully +info|sysmonitor[127]: CPU usage resume 70.1% +``` + +如果监控到某个域的 cpu 平均使用率告警或恢复且配置了日志收集命令,`/var/log/sysmonitor.log` 中打印信息示例如下: + +``` shell +info|sysmonitor[127]: CPU 1,2,3 usage alarm: 91.3% +info|sysmonitor[127]: cpu monitor: execute REPORT_COMMAND[sysmoniotrcpu] successfully +info|sysmonitor[127]: CPU 1,2,3 usage resume 70.1% +``` + +## 内存监控 + +### 简介 + +监控系统内存占用情况,当内存使用率超出或低于阈值时,记录日志。 + +### 配置文件说明 + +配置文件为 `/etc/sysmonitor/memory`。 + +``` shell +# memory usage alarm percent +ALARM="90" + +# memory usage alarm resume percent +RESUME="80" + +# monitor period(second) +PERIOD="60" +``` + +### 配置项说明 + +| 配置项 | 配置项说明 | 是否必配 | 默认值 | +| ------ | ----------------------------- | -------- | ------ | +| ALARM | 大于0,内存占用率告警阈值 | 否 | 90 | +| RESUME | 大于等于0,内存占用率恢复阈值 | 否 | 80 | +| PERIOD | 监控周期(秒),取值大于 0 | 否 | 60 | + +- 修改内存监控的配置文件后,须执行 `systemctl reload sysmonitor`,新的配置在一个监控周期后生效。 +- ALARM 值应该大于 RESUME值。 +- 取三个监控周期的内存占用的平均值,来作为是否上报发生告警或恢复告警的依据。 + +### 异常日志 + +如果监控到内存告警,sysmonitor 获取 `/proc/meminfo`信息,打印到`/var/log/sysmonitor.log`中,信息如下: + +``` shell +info|sysmonitor[127]: memory usage alarm: 90% +info|sysmonitor[127]:---------------show /proc/meminfo: --------------- +info|sysmonitor[127]:MemTotal: 3496388 kB +info|sysmonitor[127]:MemFree: 2738100 kB +info|sysmonitor[127]:MemAvailable: 2901888 kB +info|sysmonitor[127]:Buffers: 165064 kB +info|sysmonitor[127]:Cached: 282360 kB +info|sysmonitor[127]:SwapCached: 4492 kB +...... +info|sysmonitor[127]:---------------show_memory_info end. --------------- +``` + +sysmonitor 有如下打印信息时,表示 sysmonitor 会调用 "echo m > /proc/sysrq-trigger" 命令导出内存分配的信息(可以在 /var/log/messages 中进行查看)。 + +``` shell +info|sysmonitor[127]: sysrq show memory ifno in message。 +``` + +告警恢复时,打印信息如下: + +``` shell +info|sysmonitor[127]: memory usage resume: 4.6% +``` + +## 进程数/线程数监控 + +### 简介 + +监控系统进程数目和线程数目,当进程总数或线程总数超出或低于阈值时,记录日志或上报告警。 + +### 配置文件说明 + +配置文件为 `/etc/sysmonitor/pscnt`。 + +``` shell +# number of processes(include threads) when alarm occur +ALARM="1600" + +# number of processes(include threads) when alarm resume +RESUME="1500" + +# monitor period(second) +PERIOD="60" + +# process count usage alarm percent +ALARM_RATIO="90" + +# process count usage resume percent +RESUME_RATIO="80" + +# print top process info with largest num of threads when threads alarm +# (range: 0-1024, default: 10, monitor for thread off:0) +SHOW_TOP_PROC_NUM="10" +``` + +| 配置项 | 配置项说明 | 是否必配 | 默认值 | +| ----------------- | ------------------------------------------------------------ | -------- | ------ | +| ALARM | 大于 0 的整数,进程总数告警阈值 | 否 | 1600 | +| RESUME | 大于等于0的整数,进程总数恢复阈值 | 否 | 1500 | +| PERIOD | 监控周期(秒),取值大于0 | 否 | 60 | +| ALARM_RATIO | 大于0小于等于100的值,可以为小数。进程使用率告警阈值 | 否 | 90 | +| RESUME_RATIO | 大于等于0小于100的值,可以为小数。进程使用率恢复阈值,必须必告警阈值小。 | 否 | 80 | +| SHOW_TOP_PROC_NUM | 使用线程数量最新 TOP 的进程信息 | 否 | 10 | + +- 修改进程数监控的配置文件后,须执行`systemctl reload sysmonitor`,新的配置在一个监控周期后生效。 +- ALARM 值应该大于 RESUME 值。 +- 进程数告警产生阈值取 ALARM 值与 `/proc/sys/kernel/pid_max` 的 ALARM_RATIO 中的最大值,告警恢复阈值取 RESUME 值与 `/proc/sys/kernel/pid_max` 的 RESUME_RATIO 中的最大值。 +- 线程数告警产生阈值取 ALARM 值与 `/proc/sys/kernel/threads-max` 的 ALARM_RATIO 中的最大值,告警恢复阈值取 RESUME 值与 `/proc/sys/kernel/threads-max` 的 RESUME_RATIO 中的最大值。 +- SHOW_TOP_PROC_NUM 的取值范围为0-1024,为0时,表示不启用线程监控;当设置值较大时,如 1024,在环境中产生线程告警,且告警阈值较高时,会有性能影响,建议设置为默认值 10 及更小值,若影响较大,建议设置为 0,不启动线程监控。 +- 线程监控启动时,由 `/etc/sysconfig/sysmonitor` 中 `PSCNT_MONITOR` 项和 `/etc/sysmonitor/pscnt` 中 `SHOW_TOP_PROC_NUM` 项设置。 +- `PSCNT_MONITOR` 为 on,且 `SHOW_TOP_PROC_NUM` 设置为合法值时,为启动。 +- `PSCNT_MONITOR` 为 on, `SHOW_TOP_PROC_NUM` 为 0时,为关闭。 +- `PSCNT_MONITOR`为 off,为关闭。 +- 进程数量告警时,增加打印系统句柄使用信息和内存信息(/proc/meminfo)。 +- 线程数量告警时,会记录线程总数信息,TOP 进程信息,当前环境进程数量信息,系统句柄数信息,内存信息(/proc/meminfo)。 +- 监控项监控周期到达前,若系统出现资源不足(如线程数超过系统最大线程数),则监控告警本身将由于资源受限无法正常运行,进而无法进行告警。 + +### 异常日志 + +如果监控到进程数告警,`/var/log/sysmonitor.log` 中打印信息示例如下: + +``` shell +info|sysmonitor[127]:---------------process count alarm start: --------------- +info|sysmonitor[127]: process count alarm:1657 +info|sysmonitor[127]: process count alarm, show sys fd count: 2592 +info|sysmonitor[127]: process count alarm, show mem info +info|sysmonitor[127]:---------------show /proc/meminfo: --------------- +info|sysmonitor[127]:MemTotal: 3496388 kB +info|sysmonitor[127]:MemFree: 2738100 kB +info|sysmonitor[127]:MemAvailable: 2901888 kB +info|sysmonitor[127]:Buffers: 165064 kB +info|sysmonitor[127]:Cached: 282360 kB +info|sysmonitor[127]:SwapCached: 4492 kB +...... +info|sysmonitor[127]:---------------show_memory_info end. --------------- +info|sysmonitor[127]:---------------process count alarm end: --------------- +``` + +如果监控到进程数恢复告警,`/var/log/sysmonitor.log` 中打印信息示例如下: + +``` shell +info|sysmonitor[127]: process count resume: 1200 +``` + +如果监控到线程数告警,`/var/log/sysmonitor.log` 中打印信息示例如下: + +``` shell +info|sysmonitor[127]:---------------threads count alarm start: --------------- +info|sysmonitor[127]:threads count alarm: 273 +info|sysmonitor[127]:open threads most 10 processes is [top1:pid=1756900,openthreadsnum=13,cmd=/usr/bin/sysmonitor --daemon] +info|sysmonitor[127]:open threads most 10 processes is [top2:pid=3130,openthreadsnum=13,cmd=/usr/lib/gassproxy -D] +..... +info|sysmonitor[127]:---------------threads count alarm end. --------------- +``` + +## 系统句柄总数监控 + +### 简介 + +监控系统文件句柄(fd)数目,当系统文件句柄总数超过或低于阈值时,记录日志。 + +### 配置文件说明 + +配置文件为 `/etc/sysmonitor/sys_fd_conf`。 + +``` shell +# system fd usage alarm percent +SYS_FD_ALARM="80" +# system fd usage alarm resume percent +SYS_FD_RESUME="70" +# monitor period (second) +SYS_FD_PERIOD="600" +``` + +配置项说明: + +| 配置项 | 配置项说明 | 是否必配 | 默认值 | +| ------------- | --------------------------------------------------------- | -------- | ------ | +| SYS_FD_ALARM | 大于0小于100的整数,fd总数与系统最大 fd数百分比的告警阈值 | 否 | 80% | +| SYS_FD_RESUME | 大于0小于100的整数,fd 总数与系统最大fd数百分比的恢复阈值 | 否 | 70% | +| SYS_FD_PERIOD | 监控周期(秒),取值为100~86400 之间的整数 | 否 | 600 | + +- 修改fd 总数监控的配置文件后,须执行 `systemctl reload sysmonitor`,新的配置在一个监控周期后生效。 +- `SYS_FD_ALARM` 值应该大于 `SYS_FD_RESUME` 值,当配置非法时,会使用默认值,并打印日志。 + +### 异常日志 + +如果监控到 fd 总数告警,在监控日志中打印告警。`/var/log/sysmonitor.log` 中打印信息示例如下: + +``` shell +info|sysmonitor[127]: sys fd count alarm: 259296 +``` + +系统句柄使用告警时,会打印前三个使用句柄数最多的进程: + +``` shell +info|sysmonitor[127]:open fd most three processes is:[top1:pid=23233,openfdnum=5000,cmd=/home/openfile] +info|sysmonitor[127]:open fd most three processes is:[top2:pid=23267,openfdnum=5000,cmd=/home/openfile] +info|sysmonitor[127]:open fd most three processes is:[top3:pid=30144,openfdnum=5000,cmd=/home/openfile] +``` + +## 磁盘 inode 监控 + +### 简介 + +定期监控系统中挂载的磁盘分区 inode,当磁盘分区 inode 使用率大于或等于用户设置的告警阈值,记录磁盘 inode 告警。发生告警后,当磁盘分区 inode 使用率小于用户设置的告警恢复阈值,记录磁盘 inode 恢复告警。 + +### 配置文件说明 + +配置文件为 `/etc/sysmonitor/inode`。 + +``` shell +DISK="/" +DISK="/var/log" +``` + +| 配置项 | 配置项说明 | 是否必配 | 默认值 | +| ------ | ------------------------- | -------- | ------ | +| DISK | 磁盘挂载目录名 | 是 | 无 | +| ALARM | 整数,磁盘 inode 告警阈值 | 否 | 90 | +| RESUME | 整数,磁盘 inode 恢复阈值 | 否 | 80 | + +- 修改磁盘 inode 监控的配置文件后,须执行 `systemctl reload sysmonitor`,新的配置在一个监控周期后生效。 +- 重复配置的挂载目录,最后一个配置项生效。 +- ALARM 值应该大于 RESUME 值。 +- 只能针对挂载点或被挂载的磁盘分区做监控。 +- 在 CPU 和 IO 高压场景下,df 执行命令超时,会导致磁盘 inode 利用率获取不到。 +- 当多个挂载点对应同一个磁盘分区,以挂载点为准来上报告警。 + +### 异常日志 + +如果监控到磁盘 inode 告警,`/var/log/sysmonitor.log`中打印信息示例如下: + +``` shell +info|sysmonitor[4570]:report disk inode alarm, /var/log used:90% alarm:90% +info|sysmonitor[4570]:report disk inode recovered, /var/log used:79% alarm:80% +``` + +## 本地磁盘 io 延时监控 + +### 简介 + +每5秒读取一次本地磁盘 io 延时数据,每五分钟对在该五分钟内60组数据进行统计,如果有多于30次(一半)的数据大于配置的最大 IO 延时数据,则记录该磁盘的 IO 延时过大日志。 + +### 配置文件说明 + +配置文件为 `/etc/sysmonitor/iodelay`。 + +``` shell +DELAY_VALUE="500" +``` + +| 配置项 | 配置项说明 | 是否必配 | 默认值 | +| ----------- | -------------------- | -------- | ------ | +| DELAY_VALUE | 磁盘 IO 延时的最大值 | 是 | 500 | + +### 异常日志 + +如果监控到本地磁盘 IO 延时过大告警,`/var/log/sysmonitor.log` 中打印信息示例如下: + +``` shell +info|sysmonitor[127]:local disk sda IO delay is too large, I/O delay threshold is 70. +info|sysmonitor[127]:disk is sda, io delay data: 71 72 75 87 99 29 78 ...... +``` + +如果监控到本地磁盘 IO 延时告警恢复,`/var/log/sysmonitor.log` 中打印信息示例如下: + +``` shell +info|sysmonitor[127]:local disk sda IO delay is normal, I/O delay threshold is 70. +info|sysmonitor[127]:disk is sda, io delay data: 11 22 35 8 9 29 38 ...... +``` + +## 僵尸进程监控 + +### 简介 + +监控系统僵尸进程数量,大于告警阈值,记录告警日志。当系统僵尸进程数小于恢复阈值时,告警恢复。 + +### 配置文件说明 + +配置文件为`/etc/sysmonitor/zombie`。 + +``` shell +# Ceiling zombie process counts of alarm +ALARM="500" + +# Floor zombie process counts of resume +RESUME="400" + +# Periodic (second) +PERIOD="600" +``` + +| 配置项 | 配置项说明 | 是否必配 | 默认值 | +| ------ | ------------------------------- | -------- | ------ | +| ALARM | 大于0,僵尸进程个数告警阈值 | 否 | 500 | +| RESUME | 大于等于0,僵尸进程个数恢复阈值 | 否 | 400 | +| PERIOD | 监控周期(秒),取值大于0 | 否 | 60 | + +### 异常日志 + +如果监控到僵尸进程个数告警,`/var/log/sysmonitor.log`中打印信息如下: + +``` shell +info|sysmonitor[127]: zombie process count alarm: 600 +info|sysmonitor[127]: zombie process count resume: 100 +``` + +## 自定义监控 + +### 简介 + +用户可以自定义监控项,监控框架读取配置文件内容,解析配置文件各监控属性,在监控框架里调用用户要执行的监控动作。监控模块仅提供监控框架,不感知用户在监控的内容以及如何监控,不负责上报告警。 + +### 配置文件说明 + +配置文件位于`/etc/sysmonitor.d/`路径下,每个进程或模块对应一个配置文件。 + +``` shell +MONITOR_SWITCH="on" +TYPE="periodic" +EXECSTART="/usr/sbin/iomonitor_daemon" +PERIOD="1800" +``` + +| 配置项 | 配置项说明 | 是否必配 | 默认值 | +| -------------- | ------------------------------------------------------------ | --------------------- | ------ | +| MONITOR_SWITCH | 监控开关 | 否 | off | +| TYPE | 自定义监控项的类型
daemon:后台运行
periodic:周期运行 | 是 | 无 | +| EXECSTART | 执行监控命令 | 是 | 无 | +| ENVIROMENTFILE | 环境变量存放文件 | 否 | 无 | +| PERIOD | 若 type 为 periodic 类型,此为必配项,为自定义监控的周期,取值为大于0的整数 | periodic 类型为必配项 | 无 | + +- 配置文件名称,环境变量文件名称,加上绝对路径总长度不能超过127个字符。环境变量文件必须为绝对路径和实际路径,不能是软链接路径。 +- EXECSTART项的命令总长度不能超过159个字符,关键字段配置不能有空格。 +- 周期性监控的执行命令不能超时,否则对自定义监控框架产生影响。 +- 目前支持配置的环境变量最多为256个。 +- daemon 类型的自定义监控每间隔10s会统一查询是否有 reload 命令下发,或者是否有 daemon 进程异常退出;如果有reload 命令下发,需要等待 10s 后才会重新加载新的配置,如果有 daemon 进程异常退出,需要等待 10s才会重新拉起。 +- ENVIROMENTFLE 对应的文件中的内容发生变化,如新增环境变量,或环境变量的值发生变化,需要重启 sysmonitor 服务,新的环境变量才能生效。 +- `/etc/sysmonitor.d/`目录下的配置文件权限建议为 600, EXECSTART 项中若只配置了执行文件,则执行文件的权限建议为 550。 +- daemon 进程异常退出后,sysmonitor 会重新加载该 daemon进程的配置文件。 + +### 异常日志 + +如果 daemon 类型监控项异常退出,/var/log/sysmonitor.log 中会有如下记录: + +``` shell +info|sysmonitor[127]: custom daemon monitor: child process[11609] name unetwork_alarm exit code[127],[1] times. +``` diff --git a/docs/zh/docs/thirdparty_migration/openstack.md b/docs/zh/docs/thirdparty_migration/openstack.md index 05dd965ac5ea6eaa293805b3ab2ce0478d298e4e..12a6cbce8d096144d41d64509786a741dde07888 100644 --- a/docs/zh/docs/thirdparty_migration/openstack.md +++ b/docs/zh/docs/thirdparty_migration/openstack.md @@ -1,3 +1,3 @@ # openEuler OpenStack -openEuler OpenStack相关文档已迁移至[OpenStack SIG官网文档](https://openeuler.gitee.io/openstack/)。请访问链接获取详细信息。 +openEuler OpenStack相关文档已迁移至[OpenStack SIG官网文档](https://openstack-sig.readthedocs.io/zh/latest/)。请访问链接获取详细信息。 diff --git a/docs/zh/docs/userguide/images/packagemanagement.png b/docs/zh/docs/userguide/images/packagemanagement.png index 6d314e2c6ad6bafd321d9f76cd6aa5f17a8cb394..915001f44cb143c26b10e9e71bcfaaf6ee3aef06 100644 Binary files a/docs/zh/docs/userguide/images/packagemanagement.png and b/docs/zh/docs/userguide/images/packagemanagement.png differ diff --git a/docs/zh/docs/userguide/patch-tracking.md b/docs/zh/docs/userguide/patch-tracking.md index 7bc864e6e1e03f58afc88bd9305cd54ab563b0cc..86a34288196f4287841c24eeaddf07e98f41e301 100644 --- a/docs/zh/docs/userguide/patch-tracking.md +++ b/docs/zh/docs/userguide/patch-tracking.md @@ -288,19 +288,3 @@ rpm 包获取地址:[https://repo.openeuler.org/](https://repo.openeuler.org/) ### 码云查看 issue 及 PR 登录Gitee上进行跟踪的软件项目,在该项目的Issues和Pull Requests页签下,可以查看到名为`[patch tracking] TIME`,例如`[patch tracking] 20200713101548`的条目,该条目即是刚生成的补丁文件的issue和对应PR。 - -## FAQ - -### 访问 api.github.com Connection refused 异常 - -#### 问题描述 - -patch-tracking 运行过程中,可能会出现如下报错: - -``` - 9月 21 22:00:10 localhost.localdomain patch-tracking[36358]: 2020-09-21 22:00:10,812 - patch_tracking.util.github_api - WARNING - HTTPSConnectionPool(host='api.github.com', port=443): Max retries exceeded with url: /user (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) -``` - -#### 原因分析 - -以上问题是 patch-tracking 与 GitHub API 服务之间网络访问不稳定导致,请确保在与 GitHub API 服务之间网络稳定的环境中(如使用[华为云ECS弹性云服务器](https://console.huaweicloud.com/))运行 patch-tracking。 diff --git a/docs/zh/menu/index.md b/docs/zh/menu/index.md index 2e38023f639f5a63ca7272079b91a7f1e4f72a44..13e9639901e18277d1c36eaf9e60b2b9bdde12bf 100644 --- a/docs/zh/menu/index.md +++ b/docs/zh/menu/index.md @@ -23,12 +23,10 @@ headless: true - [安装方式介绍]({{< relref "./docs/Installation/安装方式介绍.md" >}}) - [安装指导]({{< relref "./docs/Installation/安装指导.md" >}}) - [使用kickstart自动化安装]({{< relref "./docs/Installation/使用kickstart自动化安装.md" >}}) - - [FAQ]({{< relref "./docs/Installation/FAQ.md" >}}) - [安装在树莓派]({{< relref "./docs/Installation/安装在树莓派.md" >}}) - [安装准备]({{< relref "./docs/Installation/安装准备-1.md" >}}) - [安装方式介绍]({{< relref "./docs/Installation/安装方式介绍-1.md" >}}) - [安装指导]({{< relref "./docs/Installation/安装指导-1" >}}) - - [FAQ]({{< relref "./docs/Installation/FAQ-1.md" >}}) - [更多资源]({{< relref "./docs/Installation/更多资源.md" >}}) - [RISC-V安装指南]({{< relref "./docs/Installation/riscv.md" >}}) - [虚拟机安装]({{< relref "./docs/Installation/riscv_qemu.md" >}}) @@ -44,9 +42,13 @@ headless: true - [管理进程]({{< relref "./docs/Administration/管理进程.md" >}}) - [管理内存]({{< relref "./docs/Administration/overview.md" >}}) - [etmem用户指南]({{< relref "./docs/Administration/memory-management.md" >}}) - - [GMEM用户指南]({{< relref "./docs/GMEM/认识GMEM" >}}) + - [GMEM用户指南]({{< relref "./docs/GMEM/认识GMEM.md" >}}) - [安装与部署]({{< relref "./docs/GMEM/安装与部署.md" >}}) - [使用方法]({{< relref "./docs/GMEM/使用说明.md" >}}) + - [HSAK开发者指南]({{< relref "./docs/HSAK/introduce_hsak.md" >}}) + - [使用HSAK开发应用程序]({{< relref "./docs/HSAK/develop_with_hsak.md" >}}) + - [HSAK工具使用说明]({{< relref "./docs/HSAK/hsak_tools_usage.md" >}}) + - [HSAK接口说明]({{< relref "./docs/HSAK/hsak_interface.md" >}}) - [配置网络]({{< relref "./docs/Administration/配置网络.md" >}}) - [使用LVM管理硬盘]({{< relref "./docs/Administration/使用LVM管理硬盘.md" >}}) - [使用KAE加速引擎]({{< relref "./docs/Administration/使用KAE加速引擎.md" >}}) @@ -56,7 +58,10 @@ headless: true - [搭建web服务器]({{< relref "./docs/Administration/搭建web服务器.md" >}}) - [搭建数据库服务器]({{< relref "./docs/Administration/搭建数据库服务器.md" >}}) - [可信计算]({{< relref "./docs/Administration/可信计算.md" >}}) - - [FAQ]({{< relref "./docs/Administration/FAQ-54.md" >}}) + - [内核完整性度量(IMA)]({{< relref "./docs/Administration/内核完整性度量(IMA).md" >}}) + - [动态完整性度量(DIM)]({{< relref "./docs/Administration/动态完整性度量(DIM).md" >}}) + - [远程证明(鲲鹏安全库)]({{< relref "./docs/Administration/远程证明(鲲鹏安全库).md" >}}) + - [可信平台控制模块(TPCM)]({{< relref "./docs/Administration/可信平台控制模块(TPCM).md" >}}) - [运维指南]({{< relref "./docs/ops_guide/overview.md" >}}) - [运维概述]({{< relref "./docs/ops_guide/运维概述.md" >}}) - [系统资源与性能]({{< relref "./docs/ops_guide/系统资源与性能.md" >}}) @@ -88,16 +93,16 @@ headless: true - [gala-anteater使用手册]({{< relref "./docs/A-Ops/gala-anteater使用手册.md" >}}) - [gala-spider使用手册]({{< relref "./docs/A-Ops/gala-spider使用手册.md" >}}) - [社区热补丁制作发布流程]({{< relref "./docs/A-Ops/社区热补丁制作发布流程.md" >}}) + - [自动化运维服务使用手册]({{< relref "./docs/A-Ops/自动化运维服务使用手册.md" >}}) - [内核热升级指南]({{< relref "./docs/KernelLiveUpgrade/KernelLiveUpgrade.md" >}}) - [安装与部署]({{< relref "./docs/KernelLiveUpgrade/安装与部署.md" >}}) - [使用方法]({{< relref "./docs/KernelLiveUpgrade/使用方法.md" >}}) - - [常见问题与解决方法]({{< relref "./docs/KernelLiveUpgrade/常见问题与解决方法.md" >}}) - [SysCare用户指南]({{< relref "./docs/SysCare/SysCare用户指南.md" >}}) - [认识SysCare]({{< relref "./docs/SysCare/认识SysCare.md" >}}) - [安装SysCare]({{< relref "./docs/SysCare/安装SysCare.md" >}}) - [使用SysCare]({{< relref "./docs/SysCare/使用SysCare.md" >}}) - [约束限制]({{< relref "./docs/SysCare/约束限制.md" >}}) - - [常见问题与解决方法]({{< relref "./docs/SysCare/常见问题与解决方法.md" >}}) + - [sysmonitor用户指南]({{< relref "./docs/sysmonitor/sysmonitor-使用手册.md" >}}) - [HA 用户指南]({{< relref "./docs/thirdparty_migration/ha.md" >}}) - [部署 HA]({{< relref "./docs/thirdparty_migration/installha.md" >}}) - [HA 使用实例]({{< relref "./docs/thirdparty_migration/usecase.md" >}}) @@ -121,18 +126,32 @@ headless: true - [开发secGear应用程序]({{< relref "./docs/secGear/开发secGear应用程序.md" >}}) - [CVE-ease设计指南]({{< relref "./docs/CVE-ease/CVE-ease设计介绍.md" >}}) - [CVE-ease介绍和安装说明]({{< relref "./docs/CVE-ease/CVE-ease介绍和安装说明.md" >}}) + - [证书签名]({{< relref "./docs/CertSignature/总体概述.md" >}}) + - [签名证书介绍]({{< relref "./docs/CertSignature/签名证书介绍.md" >}}) + - [安全启动]({{< relref "./docs/CertSignature/安全启动.md" >}}) + - [国密]({{< relref "./docs/ShangMi/概述.md" >}}) + - [磁盘加密]({{< relref "./docs/ShangMi/磁盘加密.md" >}}) + - [内核模块签名]({{< relref "./docs/ShangMi/内核模块签名.md" >}}) + - [算法库]({{< relref "./docs/ShangMi/算法库.md" >}}) + - [文件完整性保护]({{< relref "./docs/ShangMi/文件完整性保护.md" >}}) + - [用户身份鉴别]({{< relref "./docs/ShangMi/用户身份鉴别.md" >}}) + - [证书]({{< relref "./docs/ShangMi/证书.md" >}}) + - [安全启动]({{< relref "./docs/ShangMi/安全启动.md" >}}) + - [SSH协议栈]({{< relref "./docs/ShangMi/SSH协议栈.md" >}}) + - [TLCP协议栈]({{< relref "./docs/ShangMi/TLCP协议栈.md" >}}) + - [RPM支持国密签名验签]({{< relref "./docs/ShangMi/RPM签名验签.md" >}}) - [性能](#) - [A-Tune用户指南]({{< relref "./docs/A-Tune/A-Tune.md" >}}) - [认识A-Tune]({{< relref "./docs/A-Tune/认识A-Tune.md" >}}) - [安装与部署]({{< relref "./docs/A-Tune/安装与部署.md" >}}) - [使用方法]({{< relref "./docs/A-Tune/使用方法.md" >}}) - [native-turbo特性]({{< relref "./docs/A-Tune/native-turbo.md" >}}) - - [常见问题与解决方法]({{< relref "./docs/A-Tune/常见问题与解决方法.md" >}}) - [附录]({{< relref "./docs/A-Tune/附录.md" >}}) - [sysBoost用户指南]({{< relref "./docs/sysBoost/sysBoost.md" >}}) - [认识sysBoost]({{< relref "./docs/sysBoost/认识sysBoost.md" >}}) - [安装与部署]({{< relref "./docs/sysBoost/安装与部署.md" >}}) - [使用方法]({{< relref "./docs/sysBoost/使用方法.md" >}}) + - [TLBi优化特性使用指南]({{< relref "./docs/Kernel/TLBi优化特性使用指南.md" >}}) - [桌面](#) - [UKUI]({{< relref "./docs/desktop/ukui.md" >}}) - [安装 UKUI]({{< relref "./docs/desktop/安装UKUI.md" >}}) @@ -150,7 +169,7 @@ headless: true - [安装 Kiran]({{< relref "./docs/desktop/kiran安装手册.md" >}}) - [Kiran 用户指南]({{< relref "./docs/desktop/Kiran_userguide.md" >}}) - [嵌入式](#) - - [openEuler Embedded用户指南](https://openeuler.gitee.io/yocto-meta-openeuler/master/index.html) + - [openEuler Embedded用户指南](https://pages.openeuler.openatom.cn/embedded/docs/build/html/master/index.html) - [UniProton用户指南]({{< relref "./docs/Embedded/UniProton/UniProton用户指南-概述.md" >}}) - [UniProton功能设计]({{< relref "./docs/Embedded/UniProton/UniProton功能设计.md" >}}) - [UniProton接口说明]({{< relref "./docs/Embedded/UniProton/UniProton接口说明.md" >}}) @@ -198,7 +217,8 @@ headless: true - [支持CNI网络]({{< relref "./docs/Container/支持CNI网络.md" >}}) - [容器资源管理]({{< relref "./docs/Container/容器资源管理.md" >}}) - [特权容器]({{< relref "./docs/Container/特权容器.md" >}}) - - [CRI接口]({{< relref "./docs/Container/CRI接口.md" >}}) + - [CRI-v1alpha2接口]({{< relref "./docs/Container/CRI-v1alpha2接口.md" >}}) + - [CRI-v1接口]({{< relref "./docs/Container/CRI-v1接口.md" >}}) - [镜像管理]({{< relref "./docs/Container/镜像管理.md" >}}) - [容器健康状态检查]({{< relref "./docs/Container/容器健康状态检查.md" >}}) - [查询信息]({{< relref "./docs/Container/查询信息.md" >}}) @@ -206,6 +226,9 @@ headless: true - [支持OCI hooks]({{< relref "./docs/Container/支持OCI-hooks.md" >}}) - [本地卷管理]({{< relref "./docs/Container/本地卷管理.md" >}}) - [iSulad shim v2 对接 StratoVirt]({{< relref "./docs/Container/iSula-shim-v2对接stratovirt.md" >}}) + - [iSulad支持cgroup v2]({{< relref "./docs/Container/iSulad支持cgroup v2.md" >}}) + - [iSulad支持CDI]({{< relref "./docs/Container/iSulad支持CDI.md" >}}) + - [iSulad支持NRI]({{< relref "./docs/Container/iSulad支持NRI.md" >}}) - [附录]({{< relref "./docs/Container/附录.md" >}}) - [系统容器]({{< relref "./docs/Container/系统容器.md" >}}) - [安装指导]({{< relref "./docs/Container/安装指导.md" >}}) @@ -239,9 +262,12 @@ headless: true - [镜像管理]({{< relref "./docs/Container/镜像管理-4.md" >}}) - [统计信息]({{< relref "./docs/Container/统计信息-4.md" >}}) - [容器镜像构建]({{< relref "./docs/Container/isula-build构建工具.md" >}}) + - [使用指南]({{< relref "./docs/Container/isula-build使用指南.md" >}}) + - [附录]({{< relref "./docs/Container/isula-build附录.md" >}}) - [Kuasar多沙箱容器运行时]({{< relref "./docs/Container/kuasar多沙箱运行时.md" >}}) - [安装与配置]({{< relref "./docs/Container/kuasar安装与配置.md" >}}) - [使用指南]({{< relref "./docs/Container/kuasar使用指南.md" >}}) + - [iSulad+Kuasar机密容器部署指南]({{< relref "./docs/Container/isulad+kuasar-confidential-containers-deployment-guide.md" >}}) - [附录]({{< relref "./docs/Container/kuasar附录.md" >}}) - [容器OS升级用户指南]({{< relref "./docs/KubeOS/overview.md" >}}) - [认识容器OS升级]({{< relref "./docs/KubeOS/认识容器OS升级.md" >}}) @@ -261,13 +287,17 @@ headless: true - [部署集群]({{< relref "./docs/Kubernetes/eggo部署集群.md" >}}) - [拆除集群]({{< relref "./docs/Kubernetes/eggo拆除集群.md" >}}) - [运行测试pod]({{< relref "./docs/Kubernetes/运行测试pod.md" >}}) + - [基于containerd部署集群]({{< relref "./docs/Kubernetes/Kubernetes集群部署指南 - containerd.md" >}}) + - [iSulad+k8s集群部署]({{< relref "./docs/ClusterDeployment/iSulad+k8s集群部署.md" >}}) + - [iSulad+k8s环境部署]({{< relref "./docs/ClusterDeployment/iSulad+k8s环境部署.md" >}}) + - [gitlab部署]({{< relref "./docs/ClusterDeployment/gitlab部署.md" >}}) + - [gitlab-runner部署]({{< relref "./docs/ClusterDeployment/gitlab-runner部署.md" >}}) - [云原生混合部署rubik用户指南]({{< relref "./docs/rubik/overview.md" >}}) - [安装与部署]({{< relref "./docs/rubik/安装与部署.md" >}}) - [http接口文档]({{< relref "./docs/rubik/http接口文档.md" >}}) - [混部隔离示例]({{< relref "./docs/rubik/混部隔离示例.md" >}}) - - [NestOS用户指南]({{< relref "./docs/NestOS/overview.md" >}}) - - [安装与部署]({{< relref "./docs/NestOS/安装与部署.md" >}}) - - [使用方法]({{< relref "./docs/NestOS/使用方法.md" >}}) + - [NestOS云底座操作系统]({{< relref "./docs/NestOS/overview.md" >}}) + - [NestOS For Container用户指南]({{< relref "./docs/NestOS/NestOS For Container用户指南.md" >}}) - [功能特性描述]({{< relref "./docs/NestOS/功能特性描述.md" >}}) - [CTinspector用户指南]({{< relref "./docs/CTinspector/认识CTinspector.md" >}}) - [安装与部署]({{< relref "./docs/CTinspector/安装与部署.md" >}}) @@ -282,8 +312,11 @@ headless: true - [认识Kmesh]({{< relref "./docs/Kmesh/认识Kmesh.md" >}}) - [安装与部署]({{< relref "./docs/Kmesh/安装与部署.md" >}}) - [使用方法]({{< relref "./docs/Kmesh/使用方法.md" >}}) - - [常见问题与解决办法]({{< relref "./docs/Kmesh/常见问题与解决办法.md" >}}) - [附录]({{< relref "./docs/Kmesh/附录.md" >}}) + - [Autopkg用户指南]({{< relref "./docs/Autopkg/autopkg.md" >}}) + - [epkg使用指南]({{< relref "./docs/epkg/epkg使用指南.md" >}}) + - [x2epkg使用指南]({{< relref "./docs/epkg/x2epkg使用指南.md" >}}) + - [create_repo使用指南]({{< relref "./docs/epkg/create_repo使用指南.md" >}}) - [边缘计算](#) - [KubeEdge部署指南]({{< relref "./docs/KubeEdge/overview.md" >}}) - [KubeEdge使用文档]({{< relref "./docs/KubeEdge/KubeEdge使用文档.md" >}}) @@ -293,7 +326,7 @@ headless: true - [认识ROS]({{< relref "./docs/ROS/认识ROS.md" >}}) - [安装与部署]({{< relref "./docs/ROS/安装与部署.md" >}}) - [使用方法]({{< relref "./docs/ROS/使用方法.md" >}}) - - [常见问题与解决办法]({{< relref "./docs/ROS/常见问题与解决方法.md" >}}) + - [常见问题与解决方法]({{< relref "./docs/ROS/常见问题与解决方法.md" >}}) - [附录]({{< relref "./docs/ROS/附录.md" >}}) - [openEuler DevKit](#) - [isocut 使用指南]({{< relref "./docs/TailorCustom/isocut使用指南.md" >}}) @@ -306,6 +339,32 @@ headless: true - [openEuler DevOps](#) - [patch-tracking]({{< relref "./docs/userguide/patch-tracking.md" >}}) - [pkgship]({{< relref "./docs/userguide/pkgship.md" >}}) +- [AI](#) + - [openEuler Copilot System]({{< relref "./docs/AI/openEuler_Copilot_System/README.md" >}}) + - [使用指南](#) + - [Gitee AI 线上服务](#) + - [前言]({{< relref "./docs/AI/openEuler_Copilot_System/使用指南/线上服务/前言.md" >}}) + - [注册与登录]({{< relref "./docs/AI/openEuler_Copilot_System/使用指南/线上服务/注册与登录.md" >}}) + - [智能问答使用指南]({{< relref "./docs/AI/openEuler_Copilot_System/使用指南/线上服务/智能问答使用指南.md" >}}) + - [智能插件简介]({{< relref "./docs/AI/openEuler_Copilot_System/使用指南/线上服务/智能插件简介.md" >}}) + - [命令行客户端](#) + - [获取 API Key]({{< relref "./docs/AI/openEuler_Copilot_System/使用指南/命令行客户端/获取 API Key.md" >}}) + - [命令行助手使用指南]({{< relref "./docs/AI/openEuler_Copilot_System/使用指南/命令行客户端/命令行助手使用指南.md" >}}) + - [智能调优]({{< relref "./docs/AI/openEuler_Copilot_System/使用指南/命令行客户端/智能调优.md" >}}) + - [智能诊断]({{< relref "./docs/AI/openEuler_Copilot_System/使用指南/命令行客户端/智能诊断.md" >}}) + - [应用开发框架工具使用指南]({{< relref "./docs/AI/openEuler_Copilot_System/使用指南/应用开发框架工具使用指南.md" >}}) + - [部署指南](#) + - [网络环境下部署指南]({{< relref "./docs/AI/openEuler_Copilot_System/部署指南/网络环境下部署指南.md" >}}) + - [无网络环境下部署指南]({{< relref "./docs/AI/openEuler_Copilot_System/部署指南/无网络环境下部署指南.md" >}}) + - [本地资产库构建指南]({{< relref "./docs/AI/openEuler_Copilot_System/部署指南/本地资产库构建指南.md" >}}) + - [sysHAX部署指南]({{< relref "./docs/AI/openEuler_Copilot_System/部署指南/sysHAX部署指南.md" >}}) + - [插件部署指南](#) + - [智能调优]({{< relref "./docs/AI/openEuler_Copilot_System/部署指南/插件部署指南/智能调优/插件—智能调优部署指南.md" >}}) + - [智能诊断]({{< relref "./docs/AI/openEuler_Copilot_System/部署指南/插件部署指南/智能诊断/插件—智能诊断部署指南.md" >}}) + - [AI容器栈]({{< relref "./docs/AI/openEuler_Copilot_System/部署指南/插件部署指南/AI容器栈/插件—AI容器栈部署指南.md" >}}) + - [AI大模型服务镜像使用指南]({{< relref "./docs/AI/AI大模型服务镜像使用指南.md" >}}) + - [AI容器镜像用户指南]({{< relref "./docs/AI/AI容器镜像用户指南.md" >}}) + - [智能化漏洞修补用户指南]({{< relref "./docs/AI/智能化漏洞修补用户指南.md" >}}) - [应用开发](#) - [应用开发指南]({{< relref "./docs/ApplicationDev/application-development.md" >}}) - [开发环境准备]({{< relref "./docs/ApplicationDev/开发环境准备.md" >}}) @@ -314,7 +373,27 @@ headless: true - [使用make编译]({{< relref "./docs/ApplicationDev/使用make编译.md" >}}) - [使用JDK编译]({{< relref "./docs/ApplicationDev/使用JDK编译.md" >}}) - [构建RPM包]({{< relref "./docs/ApplicationDev/构建RPM包.md" >}}) - - [FAQ]({{< relref "./docs/ApplicationDev/FAQ.md" >}}) - - [GCC用指南]({{< relref "./docs/GCC/overview.md" >}}) + - [GCC用户指南]({{< relref "./docs/GCC/overview.md" >}}) - [内核反馈优化特性用户指南]({{< relref "./docs/GCC/内核反馈优化特性用户指南.md" >}}) - + - [链接时优化特性用户指南]({{< relref "./docs/GCC/链接时优化特性用户指南.md" >}}) + - [GCC优化特性用户指南]({{< relref "./docs/GCC/GCC优化特性用户指南.md" >}}) + - [动态反馈优化框架用户指南]({{< relref "./docs/GCC/动态反馈优化框架用户指南.md" >}}) + - [DevStation](#) + - [DevStation安装指南]({{< relref "./docs/DevStation/DevStation安装指南.md" >}}) + - [在VirtulBox上安装DevStation]({{< relref "./docs/DevStation/在VirtualBox上安装DevStation" >}}) + - [安装准备]({{< relref "./docs/DevStation/安装准备.md" >}}) + - [安装指导]({{< relref "./docs/DevStation/安装指导.md" >}}) + - [在个人PC上裸机安装DevStation]({{< relref "./docs/DevStation/在个人PC上双系统安装DevStation" >}}) + - [安装准备]({{< relref "./docs/DevStation/安装准备-1.md" >}}) + - [安装指导]({{< relref "./docs/DevStation/安装指导-1.md" >}}) + - [oeGitExt用户指南]({{< relref "./docs/DevStation/oeGitExt/oeGitExt.md" >}}) + - [安装指导]({{< relref "./docs/DevStation/oeGitExt/安装指导.md" >}}) + - [使用指导]({{< relref "./docs/DevStation/oeGitExt/使用指导.md" >}}) + - [oeDeploy用户指南]({{< relref "./docs/oeDeploy/Introduction.md" >}}) + - [命令行工具oedp使用指南]({{< relref "./docs/oeDeploy/Command.md" >}}) + - [oeDeploy工具特性]({{< relref "./docs/oeDeployt/Feature.md" >}}) + - [oeDeploy应用案例]({{< relref "./docs/oeDeploy/UseCase.md" >}}) + - [oeDeploy插件开发指南]({{< relref "./docs/oeDeploy/DevelopGuide.md" >}}) + - [oeDevPlugin用户指南]({{< relref "./docs/DevStation/oeGitExt/oeGitExt.md" >}}) + - [oeDevPlugin用户指南]({{< relref "./docs/DevStation/oeDevPlugin/oeDevPlugin.md" >}}) + - [oeDevPlugin使用指导]({{< relref "./docs/DevStation/oeDevPlugin/使用指导.md" >}}) diff --git "a/others/certification/openEuler\346\212\200\346\234\257\346\265\213\350\257\204\346\214\207\345\257\274\344\271\246.md" "b/others/certification/openEuler\346\212\200\346\234\257\346\265\213\350\257\204\346\214\207\345\257\274\344\271\246.md" index 3c086f7b02433148b1d30844855b2d0b981c3a7f..a79c1b0973a3955fb8b2464fd1d520f87d93c5d3 100644 --- "a/others/certification/openEuler\346\212\200\346\234\257\346\265\213\350\257\204\346\214\207\345\257\274\344\271\246.md" +++ "b/others/certification/openEuler\346\212\200\346\234\257\346\265\213\350\257\204\346\214\207\345\257\274\344\271\246.md" @@ -476,10 +476,9 @@ openEuler是面向商业软件、硬件、操作系统发行版及开发openEule 2. 执行扫描。 - ```shell - - x2openEuler scan [-batch] [-arch ARCH] [-os_name OS_NAME] [-target_os_name TARGET_OS_NAME] {filename \| directoryname} - ``` + ```shell + x2openEuler scan [-batch] [-arch ARCH] [-os_name OS_NAME] [-target_os_name TARGET_OS_NAME] {filename \| directoryname} + ``` | **命令** | **参数选项** | **说明** | | ---------------- | ------------------------ | ------------------------------------------------------------ | @@ -729,7 +728,7 @@ openEuler是面向商业软件、硬件、操作系统发行版及开发openEule | ------------ | --------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------ | | 工具检测 | 核心包 | 核心包一致性比例 | 名称、小版本完全一致,核心包包括核心包内容一致性,内核、gcc、glibc、qemu、docker、openJDK、systemd、openssh、lvm2、busybox、initscripts核心模块一致性,JDK如果没有,则不会纳入比较项。 | 必选 | | 工具检测 | 软件包 | L1/L2 软件包一致性比例 | L1 100%兼容,L2 95%以上兼容,参考社区等级清单定义(附上链接)。 | 必选 | -| 工具检测 | 内核KABI接口 | OSV内核KABI接口白名单与openEuler内核KABI接口白名单一致性比例 | 内核-KABI白名单 90%以上兼容。 | 可选 | +| 工具检测 | 内核KABI接口 | OSV内核KABI接口白名单与openEuler内核KABI接口白名单一致性比例 | 内核-KABI白名单 90%以上兼容。 | 必选 | | 工具检测 | 用户态ABI接口 | OSV软件包ABI接口与openEuler软件包ABI一致性比例 | L1 100%兼容,L2 95%以上兼容,参考社区等级清单定义。 | 必选 | | 工具检测 | Service默认配置 | OSV软件包Service文件与openEuler软件包Service文件一致性比例 | 全量默认配置一致性90%以上。 | 可选 | | 工具检测 | 软件包默认配置 | OSV软件包配置文件与openEuler软件包配置文件一致性比例 | 全量默认配置一致性90%以上,目前对于OSV厂商新增的配置,不会作为差异比较。 | 可选 |