cm_api.api_client.ApiException: (error 404)

一开始是这样遇到时,根据 https://blog.csdn.net/joomlaer/article/details/50073669 处理还是有错 

api = ApiResource(cm_host, cm_port, version=1, username="admin", password="***")

结果 

Traceback (most recent call last):
  File "hdfs.py", line 37, in 
    Test()
  File "hdfs.py", line 29, in Test
    result = api.query_timeseries(query, from_time, to_time)
  File "/usr/lib/python2.6/site-packages/cm_api/api_client.py", line 295, in query_timeseries
    return timeseries.query_timeseries(self, query, from_time, to_time, by_post=by_post)
  File "/usr/lib/python2.6/site-packages/cm_api/endpoints/timeseries.py", line 75, in query_timeseries
    ApiTimeSeriesResponse, True, params=params, data=data)
  File "/usr/lib/python2.6/site-packages/cm_api/endpoints/types.py", line 139, in call
    ret = method(path, params=params)
  File "/usr/lib/python2.6/site-packages/cm_api/resource.py", line 110, in get
    return self.invoke("GET", relpath, params)
  File "/usr/lib/python2.6/site-packages/cm_api/resource.py", line 73, in invoke
    headers=headers)
  File "/usr/lib/python2.6/site-packages/cm_api/http_client.py", line 183, in execute
    raise self._exc_class(ex)
cm_api.api_client.ApiException:  (error 404)

多次复查,找到官方解决方法

https://community.cloudera.com/t5/Cloudera-Manager-Installation/CM-Python-API/td-p/60338

访问的cm地址  http://host:port/api/version 

cm_api.api_client.ApiException: (error 404)_第1张图片

找到CDH版本所对应的api版本,修改version参数

api = ApiResource(cm_host, cm_port, version=12, username="admin", password="***")

搞定

你可能感兴趣的:(CDH,CDH)