解决-增加系统支持范围(三)
repoinfo 专题
本章节修改的代码位置如下:
ambari-server/src/main/resources/stacks/BIGTOP/3.2.0/repos/repoinfo.xml
# 一、背景与目标 镜像源植入
在前两节中,我们已经完成:
- OSCheck 模块 —— 识别 Kylin 系统类型;
- os_family.json —— 建立 Kylin 与 RedHat 的继承关系。
但 Ambari 的“家族识别”只是基础。
要让安装界面真正出现 Kylin 10 的镜像源,还需要修改仓库定义文件:
repoinfo.xml。

# 二、修改位置与作用
repoinfo.xml 是 Ambari 在 选择操作系统镜像源 时的关键配置文件。
它定义了每个 OS 家族与对应仓库的映射关系。
例如:
<reposinfo>
<os family="redhat7">
<repo>
<baseurl>http://your-repo/</baseurl>
<repoid>BIGTOP-3.2.0</repoid>
<reponame>bigtop</reponame>
</repo>
</os>
<os family="redhat8">
<repo>
<baseurl>http://your-repo/</baseurl>
<repoid>BIGTOP-3.2.0</repoid>
<reponame>bigtop</reponame>
</repo>
</os>
<os family="ubuntu22">
<repo>
<baseurl>http://your-repo/</baseurl>
<repoid>BIGTOP-3.2.0</repoid>
<reponame>bigtop</reponame>
</repo>
</os>
</reposinfo>
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<reposinfo>
...
<os family="kylin10">
<repo>
<baseurl>http://your-repo/</baseurl>
<repoid>BIGTOP-3.2.0</repoid>
<reponame>bigtop</reponame>
</repo>
</os>
</reposinfo>
2
3
4
5
6
7
8
9
10
11
// Make sure to add code blocks to your code group
新增的 os family="kylin10" 节点告诉 Ambari:
当检测到系统类型为 Kylin 10 时,从该节点读取镜像配置。
# 三、为什么是 kylin10?源自 Python 层识别
这个 family 值并不是随便写的。
它来自于我们在 Python 层中 OSCheck.get_os_type() 与 get_os_version() 的拼接逻辑:
return OSCheck.get_alias(OSCheck._get_os_type(), OSCheck._get_os_version())[0]
示例结果:
os_type = kylin
os_version = 10
family = kylin10
2
3
所以,这里 <os family="kylin10"> 必须与 Python 输出完全一致,否则前端不会识别到镜像源。
# 四、完整配置参考
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<reposinfo>
<os family="redhat7">
<repo>
<baseurl>http://your-repo/</baseurl>
<repoid>BIGTOP-3.2.0</repoid>
<reponame>bigtop</reponame>
</repo>
</os>
<os family="redhat8">
<repo>
<baseurl>http://your-repo/</baseurl>
<repoid>BIGTOP-3.2.0</repoid>
<reponame>bigtop</reponame>
</repo>
</os>
<os family="ubuntu22">
<repo>
<baseurl>http://your-repo/</baseurl>
<repoid>BIGTOP-3.2.0</repoid>
<reponame>bigtop</reponame>
</repo>
</os>
<os family="kylin10">
<repo>
<baseurl>http://your-repo/</baseurl>
<repoid>BIGTOP-3.2.0</repoid>
<reponame>bigtop</reponame>
</repo>
</os>
</reposinfo>
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Make sure to add code blocks to your code group
核心逻辑
Ambari 前端会根据 server 返回的 os_family 值,
自动从 repoinfo.xml 匹配相同 family 节点,渲染镜像配置页面。
# 五、常见问题与错误分析
# 1. family 名称能否随意填写?
❌ 不行。 family 名称必须与
OSCheck输出保持一致,否则无法匹配。
# 2. 是否支持通配符或逗号分隔?
❌ 不支持。 Ambari 读取时会严格进行字符串匹配,不支持模式匹配。
# 3. 为什么 agent 注册时报错?
在安装 Agent 阶段,如果出现如下错误:

Cannot register host with not supported os type serverOsType= agentOsType=
说明 服务端与 Agent 的系统家族识别不一致。
serverOsType来源于ambari.properties;agentOsType来自心跳注册时发送的主机系统信息。

服务端通过 OSCheck 比对两者,一旦不匹配,就会拒绝注册。
解决建议
确保 server 和 agent 端的 os_family、os_type 均为 "kylin",
并在 repoinfo.xml 中定义了对应的 family="kylin10" 节点。
# 六、匹配流程原理解析 深度理解
Ambari 在执行系统比对时,会经过以下步骤:
Agent 心跳注册 Agent 调用
register(),上报自身系统信息:os_type=kylin os_family=kylin os_release=101
2
3Server 校验 Server 侧从配置中读取
os_family, 并根据os_family.json推导出该系统的继承链。仓库匹配 Server 返回家族类型 → 前端 UI 读取
repoinfo.xml→ 渲染镜像选项。注册完成 若匹配成功,则进入安装阶段,否则返回 “unsupported os type”。

点击展开:匹配过程时序图(简化版)
Agent ---> Server (register with os_type=kylin, os_release=10)
↓
Server 调用 OSCheck.get_os_family() → kylin
↓
Server 比对 repoinfo.xml 中 family="kylin10"
↓
匹配成功 → 返回镜像信息
2
3
4
5
6
7
下一节预告
接下来我们将讲解 链接系统版本与metainfo.xml的桥梁。
- 01
- Ambari开启Kerberos认证加密类型错误 Kylin V1011-05
- 02
- KERBEROS SERVICE CHECK 报错11-04