本帖最后由 nettman 于 2014-9-11 22:52 编辑
问题导读:
1.如何通过显示的名称获取服务的属性?
2.如果获取主机属性?
3.如何通过The Cloudera Manager API获取用户角色列表?
The Cloudera Manager API配置和管理服务的生命周期、运行状况和指标,允许配置The Cloudera Manager。这个 API服务于相同的主机和端口像Cloudera Manager 控制台一样( Cloudera Manager Admin Console),不需要额外的进程和配置。这个API支持HTTP基本认证,像Cloudera Manager 控制台一样,接受相同的用户和凭证
获取配置文件
1.获取用户角色列表
- http://cm_server_host:7180/api/v6/clusters/clusterName/services/serviceName/roles
复制代码
2.获取配置文件正在使用的一个进程:
- http://cm_server_host:7180/api/v6/clusters/clusterName/services/serviceName/roles/roleName/process
复制代码
3.获得任何特定文件的内容:
- http://cm_server_host:7180/api/v6/clusters/clusterName/services/serviceName/roles/roleName/process/
- configFiles/configFileName
复制代码
举例:
- http://cm_server_host:7180/api/v6/clusters/Cluster%201/services/OOZIE-1/roles/
- OOZIE-1-OOZIE_SERVER-e121641328fcb107999f2b5fd856880d/process/configFiles/oozie-site.xml
复制代码
检索服务和主机属性
为了封信服务属性使用Cloudera Manager APIs,你需要知道服务属性的名字,不只是显示的名字。如果你知道属性的显示名而不是属性名称本身,你可以检索文档请求带有查询字符串 view=FULL的配置对象追加到url。举例:
- http://cm_server_host:7180/api/v6/clusters/Cluster%201/services/service_name/config?view=FULL
复制代码
搜索到显示名称对应的属性的结果。例如,搜索显示名为:
HDFS Service Environment Advanced Configuration Snippet (Safety Valve)
下面展示了对应的属性名字为:
hdfs_service_env_safety_valve:
- {
- "name" : "hdfs_service_env_safety_valve",
- "require" : false,
- "displayName" : "HDFS Service Environment Advanced Configuration Snippet (Safety Valve)",
- "description" : "For advanced use onlyu, key/value pairs (one on each line) to be inserted into a roles
- environment. Applies to configurations of all roles in this service except client configuration.",
- "relatedName" : "",
- "validationState" : "OK"
- }
复制代码
类似寻找服务属性,你可以寻找主机属性。首先通过集群url,获取主机IDs
- http://cm_server_host:7180/api/v6/hosts
复制代码
返回内容如下
{
"hostId" : "2c2e951c-aaf2-4780-a69f-0382181f1821",
"ipAddress" : "10.30.195.116",
"hostname" : "cm_server_host",
"rackId" : "/default",
"hostUrl" : "http://cm_server_host:7180/cmf/hostRedirect/2c2e951c-adf2-4780-a69f-0382181f1821",
"maintenanceMode" : false,
"maintenanceOwners" : [ ],
"commissionState" : "COMMISSIONED",
"numCores" : 4,
"totalPhysMemBytes" : 10371174400
}
获取主机属性,通过url中返回的 host IDs
http://cm_server_host:7180/api/v6/hosts/2c2e951c-adf2-4780-a69f-0382181f1821?view=FULL
相关资源推荐:
Quick Start
Cloudera Manager API tutorial
Cloudera Manager API documentation
Python client
Using the Cloudera Manager Java API for Cluster Automation
|