Ambari-Metrics Monitor 启动失败kylin10
# 一、先看结论 已复现&修复

在 Kylin V10 上,ambari-metrics-monitor 启动失败的直接原因是 运行期编译 psutil 时依赖的
distutils/archive_util 缺失(Python2 环境),而 Kylin 的 Python2 标准库默认位于 /usr/lib64/python2.7。按下文回填后可直接恢复启动。
# 二、再看问题 启动失败
启动 ambari-metrics-monitor 时,运行期编译 psutil 失败,导致服务退出。

stderr:
NoneType: None
The above exception was the cause of the following exception:
Traceback (most recent call last):
File "/var/lib/ambari-agent/cache/common-services/AMBARI_METRICS/3.0.0/package/scripts/metrics_monitor.py", line 86, in <module>
AmsMonitor().execute()
File "/usr/lib/ambari-agent/lib/resource_management/libraries/script/script.py", line 413, in execute
method(env)
File "/var/lib/ambari-agent/cache/common-services/AMBARI_METRICS/3.0.0/package/scripts/metrics_monitor.py", line 47, in start
ams_service("monitor", action="start")
File "/usr/lib/ambari-agent/lib/ambari_commons/os_family_impl.py", line 91, in thunk
return fn(*args, **kwargs)
File "/var/lib/ambari-agent/cache/common-services/AMBARI_METRICS/3.0.0/package/scripts/ams_service.py", line 114, in ams_service
Execute(daemon_cmd, user=params.ams_user)
File "/usr/lib/ambari-agent/lib/resource_management/core/base.py", line 168, in __init__
self.env.run()
File "/usr/lib/ambari-agent/lib/resource_management/core/environment.py", line 171, in run
self.run_action(resource, action)
File "/usr/lib/ambari-agent/lib/resource_management/core/environment.py", line 137, in run_action
provider_action()
File "/usr/lib/ambari-agent/lib/resource_management/core/providers/system.py", line 350, in action_run
returns=self.resource.returns,
File "/usr/lib/ambari-agent/lib/resource_management/core/shell.py", line 95, in inner
result = function(command, **kwargs)
File "/usr/lib/ambari-agent/lib/resource_management/core/shell.py", line 161, in checked_call
returns=returns,
File "/usr/lib/ambari-agent/lib/resource_management/core/shell.py", line 278, in _call_wrapper
result = _call(command, **kwargs_copy)
File "/usr/lib/ambari-agent/lib/resource_management/core/shell.py", line 493, in _call
raise ExecutionFailed(err_msg, code, out, err)
resource_management.core.exceptions.ExecutionFailed: Execution of '/usr/sbin/ambari-metrics-monitor --config /etc/ambari-metrics-monitor/conf start' returned 255. ls: cannot access '/usr/lib/python2.6/site-packages/resource_monitoring/psutil/build': No such file or directory
Building psutil...
Traceback (most recent call last):
File "setup.py", line 17, in <module>
from distutils.core import setup, Extension
File "/usr/lib64/python2.7/distutils/core.py", line 20, in <module>
from distutils.cmd import Command
File "/usr/lib64/python2.7/distutils/cmd.py", line 11, in <module>
from distutils import util, dir_util, file_util, archive_util, dep_util
ImportError: cannot import name archive_util
Verifying Python version compatibility...
Using python /usr/bin/python2
Checking for previously running Metric Monitor...
/var/run/ambari-metrics-monitor/ambari-metrics-monitor.pid found with no process. Removing 2349439...
Starting ambari-metrics-monitor
Verifying ambari-metrics-monitor process status with PID : 2354844
Output of PID check :
ERROR: ambari-metrics-monitor start failed. For more details, see /var/log/ambari-metrics-monitor/ambari-metrics-monitor.out:
====================
for dir in os.walk(path).next()[1]:
StopIteration
--------------------------Building psutil--------------------------
----------------------Finished building psutil---------------------
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/resource_monitoring/main.py", line 26, in <module>
from core.controller import Controller
File "/usr/lib/python2.6/site-packages/resource_monitoring/core/__init__.py", line 29, in <module>
for dir in os.walk(path).next()[1]:
StopIteration
====================
Monitor out at: /var/log/ambari-metrics-monitor/ambari-metrics-monitor.out
stdout:
2025-10-09 17:10:46,401 - Stack Feature Version Info: Cluster Stack=3.2.0, Command Stack=None, Command Version=3.2.0 -> 3.2.0
2025-10-09 17:10:46,414 - Using hadoop conf dir: /etc/hadoop/conf
2025-10-09 17:10:46,862 - Stack Feature Version Info: Cluster Stack=3.2.0, Command Stack=None, Command Version=3.2.0 -> 3.2.0
2025-10-09 17:10:46,864 - Using hadoop conf dir: /etc/hadoop/conf
2025-10-09 17:10:46,864 - Skipping param: datanode_max_locked_memory, due to Configuration parameter 'dfs.datanode.max.locked.memory' was not found in configurations dictionary!
2025-10-09 17:10:46,865 - Skipping param: dfs_ha_namenode_ids, due to Configuration parameter 'dfs.ha.namenodes' was not found in configurations dictionary!
2025-10-09 17:10:46,865 - Skipping param: falcon_user, due to Configuration parameter 'falcon-env' was not found in configurations dictionary!
2025-10-09 17:10:46,865 - Skipping param: gmetad_user, due to Configuration parameter 'ganglia-env' was not found in configurations dictionary!
2025-10-09 17:10:46,865 - Skipping param: gmond_user, due to Configuration parameter 'ganglia-env' was not found in configurations dictionary!
2025-10-09 17:10:46,865 - Skipping param: hbase_user, due to Configuration parameter 'hbase-env' was not found in configurations dictionary!
2025-10-09 17:10:46,865 - Skipping param: nfsgateway_heapsize, due to Configuration parameter 'nfsgateway_heapsize' was not found in configurations dictionary!
2025-10-09 17:10:46,866 - Skipping param: oozie_user, due to Configuration parameter 'oozie-env' was not found in configurations dictionary!
2025-10-09 17:10:46,866 - Skipping param: ranger_group, due to Configuration parameter 'ranger-env' was not found in configurations dictionary!
2025-10-09 17:10:46,866 - Skipping param: ranger_user, due to Configuration parameter 'ranger-env' was not found in configurations dictionary!
2025-10-09 17:10:46,866 - Skipping param: repo_info, due to Configuration parameter 'repoInfo' was not found in configurations dictionary!
2025-10-09 17:10:46,866 - Skipping param: tez_am_view_acls, due to Configuration parameter 'tez-site' was not found in configurations dictionary!
2025-10-09 17:10:46,866 - Skipping param: tez_user, due to Configuration parameter 'tez-env' was not found in configurations dictionary!
2025-10-09 17:10:46,866 - Skipping param: zeppelin_group, due to Configuration parameter 'zeppelin-env' was not found in configurations dictionary!
2025-10-09 17:10:46,866 - Skipping param: zeppelin_user, due to Configuration parameter 'zeppelin-env' was not found in configurations dictionary!
2025-10-09 17:10:46,867 - Group['hdfs'] {}
2025-10-09 17:10:46,869 - Group['hadoop'] {}
2025-10-09 17:10:46,871 - User['zookeeper'] {'uid': None, 'gid': 'hadoop', 'groups': ['hadoop'], 'fetch_nonlocal_groups': True}
2025-10-09 17:10:46,875 - User['ams'] {'uid': None, 'gid': 'hadoop', 'groups': ['hadoop'], 'fetch_nonlocal_groups': True}
2025-10-09 17:10:46,877 - User['ambari-qa'] {'uid': None, 'gid': 'hadoop', 'groups': ['hadoop'], 'fetch_nonlocal_groups': True}
2025-10-09 17:10:46,879 - User['hdfs'] {'uid': None, 'gid': 'hadoop', 'groups': ['hdfs', 'hadoop'], 'fetch_nonlocal_groups': True}
2025-10-09 17:10:46,881 - File['/var/lib/ambari-agent/tmp/changeUid.sh'] {'content': StaticFile('changeToSecureUid.sh'), 'mode': 0o555}
2025-10-09 17:10:46,883 - Execute['/var/lib/ambari-agent/tmp/changeUid.sh ambari-qa /tmp/hadoop-ambari-qa,/tmp/hsperfdata_ambari-qa,/home/ambari-qa,/tmp/ambari-qa,/tmp/sqoop-ambari-qa 0'] {'not_if': '(test $(id -u ambari-qa) -gt 1000) || (false)'}
2025-10-09 17:10:46,896 - Skipping Execute['/var/lib/ambari-agent/tmp/changeUid.sh ambari-qa /tmp/hadoop-ambari-qa,/tmp/hsperfdata_ambari-qa,/home/ambari-qa,/tmp/ambari-qa,/tmp/sqoop-ambari-qa 0'] due to not_if
2025-10-09 17:10:46,898 - User['hdfs'] {'fetch_nonlocal_groups': True}
2025-10-09 17:10:46,901 - User['hdfs'] {'groups': ['hdfs', 'hadoop'], 'fetch_nonlocal_groups': True}
2025-10-09 17:10:46,902 - FS Type: HDFS
2025-10-09 17:10:46,903 - Directory['/etc/hadoop'] {'mode': 0o755}
2025-10-09 17:10:46,924 - File['/etc/hadoop/conf/hadoop-env.sh'] {'owner': 'hdfs', 'group': 'hadoop', 'content': InlineTemplate(...)}
2025-10-09 17:10:46,925 - Writing File['/etc/hadoop/conf/hadoop-env.sh'] because contents don't match
2025-10-09 17:10:46,926 - Changing owner for /tmp/tmp1760001046.9258115_445 from 0 to hdfs
2025-10-09 17:10:46,926 - Changing group for /tmp/tmp1760001046.9258115_445 from 0 to hadoop
2025-10-09 17:10:46,926 - Moving /tmp/tmp1760001046.9258115_445 to /etc/hadoop/conf/hadoop-env.sh
2025-10-09 17:10:46,937 - Directory['/var/lib/ambari-agent/tmp/hadoop_java_io_tmpdir'] {'owner': 'hdfs', 'group': 'hadoop', 'mode': 0o1777}
2025-10-09 17:10:46,977 - Skipping param: hdfs_user_keytab, due to Configuration parameter 'hdfs_user_keytab' was not found in configurations dictionary!
2025-10-09 17:10:46,977 - Skipping param: mapred_user, due to Configuration parameter 'mapred-env' was not found in configurations dictionary!
2025-10-09 17:10:46,977 - Skipping param: yarn_user, due to Configuration parameter 'yarn-env' was not found in configurations dictionary!
2025-10-09 17:10:46,978 - Execute[('setenforce', '0')] {'only_if': 'test -f /selinux/enforce', 'not_if': '(! which getenforce ) || (which getenforce && getenforce | grep -q Disabled)', 'sudo': True}
2025-10-09 17:10:46,992 - Skipping Execute[('setenforce', '0')] due to not_if
2025-10-09 17:10:46,993 - Directory['/var/log/hadoop'] {'create_parents': True, 'owner': 'root', 'group': 'hadoop', 'mode': 0o775, 'cd_access': 'a'}
2025-10-09 17:10:46,996 - Directory['/var/run/hadoop'] {'create_parents': True, 'owner': 'root', 'group': 'root', 'cd_access': 'a'}
2025-10-09 17:10:46,997 - Directory['/var/run/hadoop/hdfs'] {'owner': 'hdfs', 'cd_access': 'a'}
2025-10-09 17:10:46,997 - Directory['/tmp/hadoop-hdfs'] {'create_parents': True, 'owner': 'hdfs', 'cd_access': 'a'}
2025-10-09 17:10:47,002 - File['/etc/hadoop/conf/commons-logging.properties'] {'owner': 'hdfs', 'content': Template('commons-logging.properties.j2')}
2025-10-09 17:10:47,003 - Writing File['/etc/hadoop/conf/commons-logging.properties'] because contents don't match
2025-10-09 17:10:47,003 - Changing owner for /tmp/tmp1760001047.0034757_186 from 0 to hdfs
2025-10-09 17:10:47,003 - Moving /tmp/tmp1760001047.0034757_186 to /etc/hadoop/conf/commons-logging.properties
2025-10-09 17:10:47,015 - File['/etc/hadoop/conf/health_check'] {'owner': 'hdfs', 'content': Template('health_check.j2')}
2025-10-09 17:10:47,016 - Writing File['/etc/hadoop/conf/health_check'] because contents don't match
2025-10-09 17:10:47,016 - Changing owner for /tmp/tmp1760001047.0167623_896 from 0 to hdfs
2025-10-09 17:10:47,017 - Moving /tmp/tmp1760001047.0167623_896 to /etc/hadoop/conf/health_check
2025-10-09 17:10:47,033 - File['/etc/hadoop/conf/log4j.properties'] {'mode': 0o644, 'group': 'hadoop', 'owner': 'hdfs', 'content': InlineTemplate(...)}
2025-10-09 17:10:47,034 - Writing File['/etc/hadoop/conf/log4j.properties'] because contents don't match
2025-10-09 17:10:47,034 - Changing owner for /tmp/tmp1760001047.0341876_210 from 0 to hdfs
2025-10-09 17:10:47,034 - Changing group for /tmp/tmp1760001047.0341876_210 from 0 to hadoop
2025-10-09 17:10:47,034 - Moving /tmp/tmp1760001047.0341876_210 to /etc/hadoop/conf/log4j.properties
2025-10-09 17:10:47,045 - File['/var/lib/ambari-agent/lib/fast-hdfs-resource.jar'] {'mode': 0o644, 'content': StaticFile('fast-hdfs-resource.jar')}
2025-10-09 17:10:47,095 - File['/etc/hadoop/conf/hadoop-metrics2.properties'] {'owner': 'hdfs', 'group': 'hadoop', 'content': InlineTemplate(...)}
2025-10-09 17:10:47,096 - Writing File['/etc/hadoop/conf/hadoop-metrics2.properties'] because contents don't match
2025-10-09 17:10:47,096 - Changing owner for /tmp/tmp1760001047.0962162_38 from 0 to hdfs
2025-10-09 17:10:47,096 - Changing group for /tmp/tmp1760001047.0962162_38 from 0 to hadoop
2025-10-09 17:10:47,096 - Moving /tmp/tmp1760001047.0962162_38 to /etc/hadoop/conf/hadoop-metrics2.properties
2025-10-09 17:10:47,106 - File['/etc/hadoop/conf/task-log4j.properties'] {'content': StaticFile('task-log4j.properties'), 'mode': 0o755}
2025-10-09 17:10:47,107 - File['/etc/hadoop/conf/configuration.xsl'] {'owner': 'hdfs', 'group': 'hadoop'}
2025-10-09 17:10:47,113 - File['/etc/hadoop/conf/topology_mappings.data'] {'content': Template('topology_mappings.data.j2'), 'owner': 'hdfs', 'group': 'hadoop', 'mode': 0o644, 'only_if': 'test -d /etc/hadoop/conf'}
2025-10-09 17:10:47,121 - Writing File['/etc/hadoop/conf/topology_mappings.data'] because contents don't match
2025-10-09 17:10:47,121 - Changing owner for /tmp/tmp1760001047.1217203_752 from 0 to hdfs
2025-10-09 17:10:47,122 - Changing group for /tmp/tmp1760001047.1217203_752 from 0 to hadoop
2025-10-09 17:10:47,122 - Moving /tmp/tmp1760001047.1217203_752 to /etc/hadoop/conf/topology_mappings.data
2025-10-09 17:10:47,132 - File['/etc/hadoop/conf/topology_script.py'] {'content': StaticFile('topology_script.py'), 'mode': 0o755, 'only_if': 'test -d /etc/hadoop/conf'}
2025-10-09 17:10:47,141 - Skipping unlimited key JCE policy check and setup since the Java VM is not managed by Ambari
2025-10-09 17:10:47,149 - Skipping stack-select on AMBARI_METRICS because it does not exist in the stack-select package structure.
2025-10-09 17:10:47,622 - Using hadoop conf dir: /etc/hadoop/conf
2025-10-09 17:10:47,624 - checked_call['hostid'] {}
2025-10-09 17:10:47,633 - checked_call returned (0, '000ac363')
2025-10-09 17:10:47,635 - Skipping param: hbase_drain_only, due to Configuration parameter 'mark_draining_only' was not found in configurations dictionary!
2025-10-09 17:10:47,635 - Skipping param: hbase_excluded_hosts, due to Configuration parameter 'excluded_hosts' was not found in configurations dictionary!
2025-10-09 17:10:47,635 - Skipping param: hbase_included_hosts, due to Configuration parameter 'included_hosts' was not found in configurations dictionary!
2025-10-09 17:10:47,636 - Skipping param: hdfs_principal_name, due to Configuration parameter 'hdfs_principal_name' was not found in configurations dictionary!
2025-10-09 17:10:47,636 - Skipping param: hdfs_user_keytab, due to Configuration parameter 'hdfs_user_keytab' was not found in configurations dictionary!
2025-10-09 17:10:47,636 - Directory['/etc/ambari-metrics-monitor/conf'] {'owner': 'ams', 'group': 'hadoop', 'create_parents': True}
2025-10-09 17:10:47,638 - Directory['/var/log/ambari-metrics-monitor'] {'owner': 'ams', 'group': 'hadoop', 'mode': 0o755, 'create_parents': True}
2025-10-09 17:10:47,639 - Execute['ambari-sudo.sh chown -R ams:hadoop /var/log/ambari-metrics-monitor'] {}
2025-10-09 17:10:47,651 - Directory['/var/run/ambari-metrics-monitor'] {'owner': 'ams', 'group': 'hadoop', 'cd_access': 'a', 'mode': 0o755, 'create_parents': True}
2025-10-09 17:10:47,653 - Directory['/usr/lib/python3.9/site-packages/resource_monitoring/psutil/build'] {'owner': 'ams', 'group': 'hadoop', 'cd_access': 'a', 'mode': 0o755, 'create_parents': True}
2025-10-09 17:10:47,653 - Execute['ambari-sudo.sh chown -R ams:hadoop /usr/lib/python3.9/site-packages/resource_monitoring'] {}
2025-10-09 17:10:47,666 - TemplateConfig['/etc/ambari-metrics-monitor/conf/metric_monitor.ini'] {'owner': 'ams', 'group': 'hadoop', 'template_tag': None}
2025-10-09 17:10:47,676 - File['/etc/ambari-metrics-monitor/conf/metric_monitor.ini'] {'owner': 'ams', 'group': 'hadoop', 'mode': None, 'content': Template('metric_monitor.ini.j2')}
2025-10-09 17:10:47,677 - Writing File['/etc/ambari-metrics-monitor/conf/metric_monitor.ini'] because contents don't match
2025-10-09 17:10:47,678 - Changing owner for /tmp/tmp1760001047.6779175_259 from 0 to ams
2025-10-09 17:10:47,678 - Changing group for /tmp/tmp1760001047.6779175_259 from 0 to hadoop
2025-10-09 17:10:47,678 - Moving /tmp/tmp1760001047.6779175_259 to /etc/ambari-metrics-monitor/conf/metric_monitor.ini
2025-10-09 17:10:47,688 - TemplateConfig['/etc/ambari-metrics-monitor/conf/metric_groups.conf'] {'owner': 'ams', 'group': 'hadoop', 'template_tag': None}
2025-10-09 17:10:47,690 - File['/etc/ambari-metrics-monitor/conf/metric_groups.conf'] {'owner': 'ams', 'group': 'hadoop', 'mode': None, 'content': Template('metric_groups.conf.j2')}
2025-10-09 17:10:47,691 - Writing File['/etc/ambari-metrics-monitor/conf/metric_groups.conf'] because contents don't match
2025-10-09 17:10:47,691 - Changing owner for /tmp/tmp1760001047.6913588_960 from 0 to ams
2025-10-09 17:10:47,691 - Changing group for /tmp/tmp1760001047.6913588_960 from 0 to hadoop
2025-10-09 17:10:47,691 - Moving /tmp/tmp1760001047.6913588_960 to /etc/ambari-metrics-monitor/conf/metric_groups.conf
2025-10-09 17:10:47,707 - File['/etc/ambari-metrics-monitor/conf/ams-env.sh'] {'owner': 'ams', 'content': InlineTemplate(...)}
2025-10-09 17:10:47,708 - Writing File['/etc/ambari-metrics-monitor/conf/ams-env.sh'] because contents don't match
2025-10-09 17:10:47,708 - Changing owner for /tmp/tmp1760001047.7083614_803 from 0 to ams
2025-10-09 17:10:47,709 - Moving /tmp/tmp1760001047.7083614_803 to /etc/ambari-metrics-monitor/conf/ams-env.sh
2025-10-09 17:10:47,719 - Directory['/etc/security/limits.d'] {'create_parents': True, 'owner': 'root', 'group': 'root'}
2025-10-09 17:10:47,722 - File['/etc/security/limits.d/ams.conf'] {'owner': 'root', 'group': 'root', 'mode': 0o644, 'content': Template('ams.conf.j2')}
2025-10-09 17:10:47,723 - Writing File['/etc/security/limits.d/ams.conf'] because contents don't match
2025-10-09 17:10:47,723 - Moving /tmp/tmp1760001047.7233393_707 to /etc/security/limits.d/ams.conf
2025-10-09 17:10:47,735 - Execute['/usr/sbin/ambari-metrics-monitor --config /etc/ambari-metrics-monitor/conf start'] {'user': 'ams'}
2025-10-09 17:10:50,062 - Execute['find /var/log/ambari-metrics-monitor -maxdepth 1 -type f -name '*' -exec echo '==> {} <==' \; -exec tail -n 40 {} \;'] {'logoutput': True, 'ignore_failures': True, 'user': 'ams'}
==> /var/log/ambari-metrics-monitor/ambari-metrics-monitor.out <==
--------------------------Building psutil--------------------------
----------------------Finished building psutil---------------------
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/resource_monitoring/main.py", line 26, in <module>
from core.controller import Controller
File "/usr/lib/python2.6/site-packages/resource_monitoring/core/__init__.py", line 29, in <module>
for dir in os.walk(path).next()[1]:
StopIteration
--------------------------Building psutil--------------------------
----------------------Finished building psutil---------------------
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/resource_monitoring/main.py", line 26, in <module>
from core.controller import Controller
File "/usr/lib/python2.6/site-packages/resource_monitoring/core/__init__.py", line 29, in <module>
for dir in os.walk(path).next()[1]:
StopIteration
--------------------------Building psutil--------------------------
----------------------Finished building psutil---------------------
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/resource_monitoring/main.py", line 26, in <module>
from core.controller import Controller
File "/usr/lib/python2.6/site-packages/resource_monitoring/core/__init__.py", line 29, in <module>
for dir in os.walk(path).next()[1]:
StopIteration
--------------------------Building psutil--------------------------
----------------------Finished building psutil---------------------
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/resource_monitoring/main.py", line 26, in <module>
from core.controller import Controller
File "/usr/lib/python2.6/site-packages/resource_monitoring/core/__init__.py", line 29, in <module>
for dir in os.walk(path).next()[1]:
StopIteration
2025-10-09 17:10:50,246 - Skipping stack-select on AMBARI_METRICS because it does not exist in the stack-select package structure.
Command failed after 1 tries
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
核心报错要点
ImportError: cannot import name archive_util- 系统的
distutils模块不完整,缺少archive_util.py - Kylin 上 Python2 标准库在 /usr/lib64/python2.7,而不是
/usr/lib/python2.7
# 三、环境差异点梳理 Kylin 目录结构
为什么在 Kylin 上更容易踩坑?
Kylin V10 基于 RPM 系,很多 64 位库位于 /usr/lib64。Ambari 的老旧 Python2 脚本在路径探测上较“死板”,一旦把参考文章里基于
Rocky/CentOS 的 /usr/lib/python2.7 命令原样粘贴,就会 复制到错误目录,导致问题持续存在。
路径/包管理差异对照
| 维度 | Rocky/CentOS 常见路径 | Kylin V10 实际路径 | 备注 |
|---|---|---|---|
| Python2 标准库 | /usr/lib/python2.7/ | /usr/lib64/python2.7/ | distutils 应回填到此 |
| resource_monitoring 旧路径探测 | /usr/lib/python2.6/site-packages/... | /usr/lib/python3.9/site-packages/...(Agent 日志亦会尝试创建此目录) | Ambari 组件兼容分支混用 py2/py3 路径,见日志 |
| 包管理器 | yum/dnf | yum/dnf | Kylin 默认可用 yum,按需 dnf |
# 四、闭环修复步骤 最小可行
强提醒
Kylin 请一律回填到 /usr/lib64/python2.7/,不要写成 /usr/lib/python2.7/。
# 1) 安装 Python2 及开发头文件(Kylin V10)
yum install -y python2 python2-minimal python2-devel # 缺哪个装哪个
# 2) 下载官方 CPython 2.7.18 源码并解压
cd /opt/modules
wget https://ghfast.top/https://github.com/python/cpython/archive/refs/tags/v2.7.18.tar.gz
tar zxvf v2.7.18.tar.gz
cd cpython-2.7.18/Lib/
# 3) 回填 distutils 模块(Kylin 是 /usr/lib64/python2.7)
cp -r distutils /usr/lib64/python2.7/
# 4) 校验 archive_util 是否存在
ls /usr/lib64/python2.7/distutils/archive_util.py
# 5) 测试导入(无报错即正常)
python2 - <<'PY'
from distutils import archive_util
print("OK: archive_util import success")
PY
# 6) 清理上次失败的残留 build 目录(可选)
rm -rf /usr/lib/python3.9/site-packages/resource_monitoring/psutil/build || true
rm -rf /usr/lib64/python2.7/site-packages/resource_monitoring/psutil/build || true
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
复测
完成以上步骤后,重新启动 Ambari-Metrics Monitor:
ambari-metrics-monitor --config /etc/ambari-metrics-monitor/conf start
1
# 五、过程要点与踩坑记录 必读
# 1、为什么是 distutils?
- AMS Monitor 启动时会尝试 运行期编译 psutil。
setup.py依赖distutils的若干工具函数(例如archive_util),缺失就会直接ImportError。
# 2、StopIteration 的根因
resource_monitoring/core/__init__.py里会对插件目录做os.walk(...).next();目录不存在或为空时可能触发StopIteration。先解决 distutils/psutil,再看是否还有残留目录问题。
# 3、路径判定小技巧
- 根据 Agent 日志可见它既创建了 /usr/lib/python3.9/site-packages/resource_monitoring 也引用了 /usr/lib/python2.6/site-packages/ 的旧路径。不需要跟着它“跑偏”,Kylin 的 Python2 标准库位于 /usr/lib64 ,照此回填就行。

- 01
- Ambari开启Kerberos认证加密类型错误 Kylin V1011-05
- 02
- KERBEROS SERVICE CHECK 报错11-04