【问题标题】:decommission host through cm_api (gracefully)通过 cm_api 停用主机(优雅地)
【发布时间】:2015-10-07 18:46:16
【问题描述】:

我正在尝试使用 cm_api(优雅地)从 cloudera 管理器中停用主机。 我尝试了以下操作,但它正在删除角色并突然停止在其上运行的 YARN 容器

#!/usr/bin/env python2.6
my_cluster = "cluster"
cloudera_manager = "1.2.3.4"
cloudera_username = "admin"
cloudera_password = "admin"

import time
from datetime import datetime, timedelta
from cm_api.api_client import ApiResource
from cm_api.endpoints.cms import ClouderaManager
from cm_api.endpoints.clusters import ApiCluster
from cm_api.endpoints.hosts import get_host, delete_host

api = ApiResource(cloudera_manager, username=cloudera_username, password=cloudera_password)
cl = ApiCluster(api, my_cluster)
hosts = []
roles = []
ha = get_host(api, "$INSTANCE_ID")

for r in ha.roleRefs:
    roles.append((r.serviceName, r.roleName))

for srv_name, role_name in roles:
    service = cl.get_service(srv_name)
    service.delete_role(role_name)

有谁知道我们如何使用 cm_api 停用 cloudera manager 中的主机?

【问题讨论】:

    标签: python api automation cloudera cloudera-manager


    【解决方案1】:

    这是因为您只是删除代码中的角色。要停用主机,您需要使用 ClouderaManager 类的 hosts_decommission 函数。

    在此链接http://cloudera.github.io/cm_api/epydoc/5.4.0/index.html中搜索ClouderaManager类和hosts_decommission函数

    您将使用类似以下的内容:

    cm = ClouderaManager(api)
    # Get all the hosts to decommission and save it in hosts array
    hosts = ['host1','host2','host3']
    
    for h in hosts:
        cm.hosts_decommission(h)
    

    【讨论】:

      猜你喜欢
      • 2010-11-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-12
      • 2018-09-27
      • 2019-11-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多