我尝试使用Cloudera Manager Python API在Hadoop群集上安装CDH5 parcel。我使用以下代码执行此操作:
test_cluster = ... # configuring cluster
# adding hosts ...
for parcel in test_cluster.get_all_parcels():
if parcel.product == 'CDH' and 'cdh5':
parcel.start_download().wait()
parcel.start_distribution().wait()
success = parcel.activate().wait().success
但是我发现了这样的错误:
cm_api.api_client.ApiException: Parcel for CDH : 5.8.0-1.cdh5.8.0.p0.42 is not available on UBUNTU_TRUSTY. (error 400)
CDH 5.8.0-1.cdh5.8.0.p0.42
位于AVAILABLE_REMOTELY
,我们可以看到是否在此地块上打印字符串表示:
<ApiParcel>: CDH-5.8.0-1.cdh5.8.0.p0.42 (stage: AVAILABLE_REMOTELY) (state: None) (cluster: TestCluster)
执行代码后,parcel将其阶段更改为DOWNLOADED
。
看来,我应该添加一个新的parcel存储库,与Ubuntu Trusty(14.04)兼容。但我不知道使用Cloudera Manager API做到这一点。
如何指定新存储库以安装正确的CDH?
答案 0 :(得分:2)
您可能希望更加具体地了解您所采取行动的地块。我出于同样的目的使用这样的东西,问题的重要部分是对parcel.version
和parcel.product
的综合检查。之后(是的,我在输出中详细)我打印包裹列表以验证我是否只想安装我想要的1个包裹。
我确定你一直在这里,但如果不是,cm_api github site也有一些有用的例子。
cdh_version = "CDH5"
cdh_version_number = "5.6.0"
# CREATE THE LIST OF PARCELS TO BE INSTALLED (CDH)
parcels_list = []
for parcel in cluster.get_all_parcels():
if parcel.version.startswith(cdh_version_number) and parcel.product == "CDH":
parcels_list.append(parcel)
for parcel in parcels_list:
print "WILL INSTALL " + parcel.product + ' ' + parcel.version
# DISTRIBUTE THE PARCELS
print "DISTRIBUTING PARCELS..."
for p in parcels_list:
cmd = p.start_distribution()
if not cmd.success:
print "PARCEL DISTRIBUTION FAILED"
exit(1)
# MAKE SURE THE DISTRIBUTION FINISHES
for p in parcels_list:
while p.stage != "DISTRIBUTED":
sleep(5)
p = get_parcel(api, p.product, p.version, cluster_name)
print p.product + ' ' + p.version + " DISTRIBUTED"
# ACTIVATE THE PARCELS
for p in parcels_list:
cmd = p.activate()
if not cmd.success:
print "PARCEL ACTIVATION FAILED"
exit(1)
# MAKE SURE THE ACTIVATION FINISHES
for p in parcels_list:
while p.stage != "ACTIVATED":
p = get_parcel(api, p.product, p.version, cluster_name)
print p.product + ' ' + p.version + " ACTIVATED"