Traceback (most recent call last):
File "/var/lib/ambari-agent/cache/stacks/DIF/3.0/services/AMBARI_METRICS/package/scripts/metrics_monitor.py", line 78, in <module>
AmsMonitor().execute()
File "/usr/lib/ambari-agent/lib/resource_management/libraries/script/script.py", line 352, in execute
method(env)
File "/var/lib/ambari-agent/cache/stacks/DIF/3.0/services/AMBARI_METRICS/package/scripts/metrics_monitor.py", line 43, in start
action = 'start'
File "/usr/lib/ambari-agent/lib/ambari_commons/os_family_impl.py", line 89, in thunk
return fn(*args, **kwargs)
File "/var/lib/ambari-agent/cache/stacks/DIF/3.0/services/AMBARI_METRICS/package/scripts/ams_service.py", line 109, in ams_service
user=params.ams_user
File "/usr/lib/ambari-agent/lib/resource_management/core/base.py", line 166, in __init__
self.env.run()
File "/usr/lib/ambari-agent/lib/resource_management/core/environment.py", line 160, in run
self.run_action(resource, action)
File "/usr/lib/ambari-agent/lib/resource_management/core/environment.py", line 124, in run_action
provider_action()
File "/usr/lib/ambari-agent/lib/resource_management/core/providers/system.py", line 269, in action_run
returns=self.resource.returns)
File "/usr/lib/ambari-agent/lib/resource_management/core/shell.py", line 72, in inner
result = function(command, **kwargs)
File "/usr/lib/ambari-agent/lib/resource_management/core/shell.py", line 102, in checked_call
tries=tries, try_sleep=try_sleep, timeout_kill_strategy=timeout_kill_strategy, returns=returns)
File "/usr/lib/ambari-agent/lib/resource_management/core/shell.py", line 150, in _call_wrapper
result = _call(command, **kwargs_copy)
File "/usr/lib/ambari-agent/lib/resource_management/core/shell.py", line 314, 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. psutil build directory is not empty, continuing...
Verifying Python version compatibility...
Using python /usr/bin/python2.7
Checking for previously running Metric Monitor...
/var/run/ambari-metrics-monitor/ambari-metrics-monitor.pid found with no process. Removing 543...
Starting ambari-metrics-monitor
Verifying ambari-metrics-monitor process status with PID : 1842
Output of PID check :
ERROR: ambari-metrics-monitor start failed. For more details, see /var/log/ambari-metrics-monitor/ambari-metrics-monitor.out:
====================
from metric_collector import MetricsCollector
File "/usr/lib/python2.6/site-packages/resource_monitoring/core/metric_collector.py", line 23, in <module>
from host_info import HostInfo
File "/usr/lib/python2.6/site-packages/resource_monitoring/core/host_info.py", line 25, in <module>
import psutil
File "/usr/lib/python2.6/site-packages/resource_monitoring/psutil/build/lib.linux-x86_64-2.7/psutil/__init__.py", line 89, in <module>
import psutil._pslinux as _psplatform
File "/usr/lib/python2.6/site-packages/resource_monitoring/psutil/build/lib.linux-x86_64-2.7/psutil/_pslinux.py", line 20, in <module>
from psutil import _common
ImportError: cannot import name _common
====================
Monitor out at: /var/log/ambari-metrics-monitor/ambari-metrics-monitor.out
解决办法:
先写解决方法:
cd /usr/lib/python2.6/site-packages/resource_monitoring/psutil
python setup.py build # 如果报gcc编译错误,请自行安装、升级gcc\gcc-c++
python setup.py install
问题原因:
Ambari安装过程会安装一个目录 /usr/lib/python2.6 ,因为系统是CentOS 7.3,默认使用的是 python 2.7.5,不应该有 python2.6的依赖的。
查看系统python命令,下图红框中的命令是ambari生成的
ll /usr/bin/|grep python
[root@ambari-server psutil]$ cat /usr/bin/python-wrap
#!/usr/bin/env bash
# Copyright (c) 2011-2017, Hortonworks Inc. All rights reserved.
# Except as expressly permitted in a written agreement between you
# or your company and Hortonworks, Inc, any use, reproduction,
# modification, redistribution, sharing, lending or other exploitation
# of all or any part of the contents of this file is strictly prohibited.
PY_PACKAGES_DIR=site-packages
OS_DIST=`cat /etc/issue 2>/dev/null`
if [[ $OS_DIST == *Ubuntu* ]] || [[ $OS_DIST == *Debian* ]] ; then
PY_PACKAGES_DIR=dist-packages
fi
export PYTHONPATH=/usr/lib/python2.6/$PY_PACKAGES_DIR:$PYTHONPATH
# reset settings
unset PYTHON
# checking for preferable python versions
if [ -a /usr/bin/python2.7 ] && [ -z "$PYTHON" ]; then
PYTHON=/usr/bin/python2.7
fi
if [ -a /usr/bin/python2.6 ] && [ -z "$PYTHON" ]; then
PYTHON=/usr/bin/python2.6
fi
# if no preferable python versions found, try to use system one
if [[ -z "$PYTHON" ]]; then
PYTHON=/usr/bin/python
fi
# execute script
$PYTHON "$@"
从这个命令脚本中可心看出 ambari 使用的还是 python2.7 只是重新设置了 PYTHONPATH 依赖库,依赖库中是有psutil这个module的,但只是安装目录。启动 ambari-metrics 的报错日志中会有一条命令(我这里没有记录下来),大致意思是“命令执行中没有发现 psutil build 目录”,那么,按照通用python包安装命令执行:
yum -y install python-devel.x86_64
或者
sudo yum install g+±multilib python-devel
安装报错依赖问题可以通过强制安装来解决
rpm -ivh python-devel-2.7.5-92.el7_9.x86_64.rpm --nodeps --force
然后在执行
python setup.py build
python setup.py install
至此,问题解决,启动 ambari-collecator ,已经可以起来了。
https://blog.csdn.net/qq_43614355/article/details/100579541
©著作权归作者所有:来自51CTO博客作者FanoLi的原创作品,请联系作者获取转载授权,否则将追究法律责任
HDP-2.6.5 & ambari-2.6.2 安装配置
https://blog.51cto.com/784687488/2329891