# !/usr/local/bin/python
import cm_client
# Configure HTTP basic authorization: basic
# configuration = cm_client.Configuration()
cm_client.configuration.username = 'admin'
cm_client.configuration.password = 'admin'
# Create an instance of the API class
api_client = cm_client.ApiClient("http://your-cdh-cluster-cm-host:7180/api/v30")
# create an instance of the ServicesResourceApi class
service_api_instance = cm_client.ServicesResourceApi(api_client)
# create an instance of the HostsResourceApi class
host_api_instance = cm_client.HostsResourceApi(api_client)
# find KUDU_MASTER roles in the CDH cluster
cluster_roles = service_api_instance.read_roles("Cluster 1", "KUDU-1")
for role in cluster_roles.items:
if role.type == "KUDU_MASTER":
role_host = host_api_instance.read_host(role.host_ref.host_id, view="full")
print("Kudu master is located on %s\n" % role_host.hostname)
3条答案
按热度按时间xe55xuns1#
我知道这不是一个最好的方法,但它是一个快速的方法。假设我们已经有了一个kudu表(即使您没有通过impala创建一个测试/临时表),只需对该表进行一次描述即可。您将得到一堆详细信息,包括kudu master details(主机名),其中端口将是8051。我相信,一旦您了解了主机和端口的详细信息,就可以为您的sparkDataframe探索许多。
临时表语法:
创建表kudu\ no\ partition\ by\ u子句(id bigint primary key,s string,b boolean)存储为kudu;
descripe语法:descripe格式化表\名称;
财年:
kudu网站管理详细信息:https://kudu.apache.org/releases/0.6.0/docs/administration.html
kudu和spark示例:https://kudu.apache.org/docs/developing.html
干杯!!
kd3sttzy2#
下面是一个使用cloudera manager java客户端的非常基本的示例(https://cloudera.github.io/cm_api/docs/java-client-swagger/)
p5cysglq3#
下面是使用python客户机v3的python示例(https://cloudera.github.io/cm_api/docs/python-client-swagger/):