ZooKeeper 构建(缺少 hostname 命令)Kylin10
# 一、报错现象
在 Kylin v10 环境下执行 ZooKeeper 构建时,日志提示如下:
06:36:28.584 [QUIET] [system.out] [INFO] Apache ZooKeeper ................................... FAILURE [ 4.115 s]
06:36:28.584 [QUIET] [system.out] [INFO] Apache ZooKeeper - Documentation ................... SKIPPED
06:36:28.585 [QUIET] [system.out] [INFO] Apache ZooKeeper - Jute ............................ SKIPPED
06:36:28.585 [QUIET] [system.out] [INFO] Apache ZooKeeper - Server .......................... SKIPPED
06:36:28.585 [QUIET] [system.out] [INFO] Apache ZooKeeper - Client .......................... SKIPPED
06:36:28.585 [QUIET] [system.out] [INFO] Apache ZooKeeper - Client - C ...................... SKIPPED
06:36:28.585 [QUIET] [system.out] [INFO] Apache ZooKeeper - Recipes ......................... SKIPPED
06:36:28.585 [QUIET] [system.out] [INFO] Apache ZooKeeper - Recipes - Election .............. SKIPPED
06:36:28.585 [QUIET] [system.out] [INFO] Apache ZooKeeper - Recipes - Lock .................. SKIPPED
06:36:28.585 [QUIET] [system.out] [INFO] Apache ZooKeeper - Recipes - Queue ................. SKIPPED
06:36:28.585 [QUIET] [system.out] [INFO] Apache ZooKeeper - Assembly ........................ SKIPPED
06:36:28.585 [QUIET] [system.out] [INFO] Apache ZooKeeper - Contrib ......................... SKIPPED
06:36:28.585 [QUIET] [system.out] [INFO] Apache ZooKeeper - Contrib - Loggraph .............. SKIPPED
06:36:28.585 [QUIET] [system.out] [INFO] Apache ZooKeeper - Contrib - Rest .................. SKIPPED
06:36:28.585 [QUIET] [system.out] [INFO] Apache ZooKeeper - Contrib - ZooInspector .......... SKIPPED
06:36:28.585 [QUIET] [system.out] [INFO] ------------------------------------------------------------------------
06:36:28.585 [QUIET] [system.out] [INFO] BUILD FAILURE
06:36:28.585 [QUIET] [system.out] [INFO] ------------------------------------------------------------------------
06:36:28.585 [QUIET] [system.out] [INFO] Total time: 4.277 s
06:36:28.585 [QUIET] [system.out] [INFO] Finished at: 2025-09-26T06:36:28Z
06:36:28.585 [QUIET] [system.out] [INFO] ------------------------------------------------------------------------
06:36:28.586 [QUIET] [system.out] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.8:run (default) o
n project parent: An Ant BuildException has occured: Execute failed: java.io.IOException: Cannot run program "hostname": error=2,
No such file or directory
06:36:28.587 [QUIET] [system.out] [ERROR] around Ant part ...<exec outputproperty="host.name" executable="hostname"/>... @ 5:59 i
n /opt/modules/bigtop/build/zookeeper/rpm/BUILD/apache-zookeeper-3.5.9/target/antrun/build-main.xml
06:36:28.587 [QUIET] [system.out] [ERROR] -> [Help 1]
06:36:28.587 [QUIET] [system.out] [ERROR]
06:36:28.587 [QUIET] [system.out] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
06:36:28.587 [QUIET] [system.out] [ERROR] Re-run Maven using the -X switch to enable full debug logging.
06:36:28.587 [QUIET] [system.out] [ERROR]
06:36:28.587 [QUIET] [system.out] [ERROR] For more information about the errors and possible solutions, please read the following
articles:
06:36:28.587 [QUIET] [system.out] [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
06:36:28.605 [QUIET] [system.out]
06:36:28.605 [ERROR] [system.err] error: Bad exit status from /var/tmp/rpm-tmp.UTpWbM (%build)
06:36:28.605 [QUIET] [system.out]
06:36:28.606 [ERROR] [system.err] Bad exit status from /var/tmp/rpm-tmp.UTpWbM (%build)
06:36:28.606 [QUIET] [system.out] RPM build errors:
06:36:28.608 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: FAILED
1
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
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

报错关键信息
Cannot run program "hostname"error=2, No such file or directory- Ant
<exec executable="hostname"/>无法执行
# 二、原因分析
结论先行
这是 系统缺少 hostname 命令 导致的构建失败,而不是 Maven 或 ZooKeeper 源码问题。
- ZooKeeper 构建脚本使用
maven-antrun-plugin调用 Ant,Ant 脚本里通过<exec executable="hostname"/>获取主机名; - 在 Kylin v10 的最小化安装环境下,
hostname工具并未默认安装; - 当 Ant 执行时无法找到该二进制文件,直接抛出
java.io.IOException: error=2,最终导致构建失败。
注意
很多企业内网或 CI/CD 容器环境都会遇到类似问题,因为镜像精简后往往缺少常用命令。
# 三、解决办法
# 1、一条命令修复
直接安装缺失的 hostname 工具:
yum install -y hostname
1
安装完成后再次执行构建即可恢复正常。
# 2、验证是否安装成功
which hostname
hostname
1
2
2
正常情况下会输出 /usr/bin/hostname 路径以及当前机器名。
# 3、构建重新执行
重新运行 ZooKeeper 构建链路:
gradle zookeeper-pkg \
-PparentDir=/usr/bigtop \
-Dbuildwithdeps=true \
-PpkgSuffix
1
2
3
4
5
2
3
4
5
此时不再报错,ZooKeeper 模块可顺利通过。
- 01
- Ambari开启Kerberos认证加密类型错误 Kylin V1011-05
- 02
- KERBEROS SERVICE CHECK 报错11-04