CHD-Cloudera Manager API 详解

发布时间:2024年01月12日


前言

Cloudera Manager是一个用于管理和监控Hadoop集群的强大工具。它提供了一套REST API,使用户能够通过编程方式与Cloudera Manager进行交互,并执行各种操作,如创建集群、添加服务、配置角色等。


一、Cloudera Manager 概念

1. 集群(Cluster)

集群是一组运行相互依赖服务的主机。集群中的所有服务具有相同的 CDH 版本。一个 Cloudera Manager 可以安装多个集群,它们通过不同的名称唯一标识。

Cloudera Manager可以管理多个集群,但是每个集群只能与单个Cloudera Manager Server或Cloudera Manager HA对相关联。一旦成功安装了第一个集群,就可以添加其他集群,运行相同或不同版本的CDH。然后,您可以独立管理每个集群及其服务。

2. 服务(Service)

服务是在集群中提供抽象功能的实体。服务的例子包括 HDFS、MapReduce、YARN 和 HBase。服务通常是分布式的,并包含一组物理运行在集群上的角色。服务具有自己的配置、状态和角色。您可以针对服务或批量针对角色发布命令。此外,HDFS 服务有名称服务,MapReduce 服务有活动。

所有服务都属于一个集群(除了 Cloudera 管理服务),并在 Cloudera Manager 安装中具有唯一的名称。服务的类型取决于集群的 CDH 版本。

3. 角色(Role)

角色为服务执行特定操作,并分配给主机。它通常作为守护进程运行,如 DataNode 或 TaskTracker。(当然也有例外,并非所有角色都是守护进程。)角色一旦创建,便不能重新分配到其他主机。如果想重新分配到其他主机,需要删除并重新创建这个角色。

角色拥有自己的配置和状态。角色上的 API 命令总是在服务级别以批量方式发布。

4. 角色类型(Role Type)

角色类型指的是角色所属的类。例如,HBase 服务有 Master 角色类型和 RegionServer 角色类型。不同服务类型具有不同的角色类型集合。不要将其与角色混淆,角色指的是物理分配给主机的特定角色实例。

您可以指定角色类型的配置,该配置由该类型的所有角色实例继承。

5. 主机(Host)

Cloudera Manager 代理运行在由 Cloudera Manager 管理的主机上。您可以为主机分配服务角色。

6. Cloudera Manager

与 Cloudera Manager 操作相关的所有内容都可在资源下找到。这包括全局命令、系统配置和 Cloudera 管理服务。

7. Cloudera 管理服务(Cloudera Management Service)

在企业版中提供 Hadoop 集群的监控、诊断和报告功能。该服务的操作与其他 Hadoop 服务类似,但管理服务不属于集群。

8. 指标(Metrics)

指标是衡量实体或活动状态的属性,例如打开的文件描述符数量或 CPU 利用率百分比。通过 Cloudera Manager API /timeseries/schema 端点可以获取完整的指标模式列表。

Cloudera Manager 可以使用名为 tsquery 的语言检索指标数据。

9. 调试 API

您可以在 Cloudera Manager 中启用调试功能,以查看 API 相关活动的详细日志。调试设置在 Cloudera Manager 管理控制台中的“启用 API 调试”页面。启用后,Cloudera Manager 服务器日志将包含所有 API 请求和响应的完整跟踪以及请求处理调试。由于可能生成大量日志数据,建议仅在开发过程中启用。


二、Cloudera Manager REST API

1. 介绍

1.1 返回数据视图介绍

  • 可以使用两种视图之一来列出集合中的条目:summary(默认视图)或 full
    • summary 视图提供了关于每个条目的核心信息。
    • full 视图提供了每个条目的完全展开视图。
  • 视图由名为 view 的查询参数控制,例如:
    curl -u admin:admin -X GET --header 'Accept: application/json' 'http://localhost:7180/api/v33/users?view=full'
    

1.2 错误代码介绍

在出现错误时,API会返回400和500系列的HTTP代码:

  • 400 — 无效的请求参数;格式错误的请求
  • 401 — 认证失败
  • 403 — 授权失败
  • 404 — 未找到对象
  • 500 — 内部API错误
  • 503 — 响应暂时不可用;调用者稍后重试

2. API版本

可以通过向/versionURL发送GET请求来查询API支持的最高版本。返回的字符串包含了最高支持的版本(例如,“v2”)。

curl -u admin:admin -X GET --header 'Accept: application/json' 'http://localhost:7180/api/version'

3. REST API 资源

资源的API前缀:http://localhost:7180/api/v33

  • v33:API版本号
  • clusterName:集群名称,可以通过curl -u admin:admin -X GET --header 'Accept: application/json' 'http://localhost:7180/api/v33/clusters' 命令查看集群信息,其中包含了集群名称、版本等信息。
  • serviceName:服务名称,可以通过curl -u admin:admin -X GET --header 'Accept: application/json' 'http://localhost:7180/api/v33/clusters/Cluster/services' | grep name 查看集群中有哪些服务。

3.1 活动API

路径请求方法
/clusters/{clusterName}/services/{serviceName}/activitiesGET
/clusters/{clusterName}/services/{serviceName}/activities/{activityId}GET
/clusters/{clusterName}/services/{serviceName}/activities/{activityId}/childrenGET
/clusters/{clusterName}/services/{serviceName}/activities/{activityId}/metricsGET
/clusters/{clusterName}/services/{serviceName}/activities/{activityId}/similarGET

3.2 所有主机API

路径请求方法
/cm/allHosts/configGET, PUT

3.3 审计API

路径请求方法
/auditsGET
/audits/streamGET

3.4 角色身份验证元数据API

路径请求方法
/authRoleMetadatasGET

3.5 身份验证服务API

身份验证服务用于管理单点登录功能。

此服务尚未对一般用户开放。

控制身份验证服务的API基本上与控制MGMT服务的API相同。两者都不与集群关联,代表CM管理的资源。

路径请求方法
/cm/authServiceDELETE, GET, PUT
/cm/authService/autoAssignRolesPUT
/cm/authService/autoConfigurePUT
/cm/authService/commandsGET
/cm/authService/configGET, PUT
/cm/authService/roleTypesGET
/cm/authService/commands/enterMaintenanceModePOST
/cm/authService/commands/exitMaintenanceModePOST
/cm/authService/commands/restartPOST
/cm/authService/commands/startPOST
/cm/authService/commands/stopPOST

3.6 身份验证服务角色命令API

路径请求方法
/cm/authService/roleCommands/restartPOST
/cm/authService/roleCommands/startPOST
/cm/authService/roleCommands/stopPOST

3.7 身份验证服务角色配置组API

路径请求方法
/cm/authService/roleConfigGroupsGET
/cm/authService/roleConfigGroups/{roleConfigGroupName}GET, PUT
/cm/authService/roleConfigGroups/{roleConfigGroupName}/configGET, PUT
/cm/authService/roleConfigGroups/{roleConfigGroupName}/rolesGET

3.8 身份验证服务角色API

路径请求方法
/cm/authService/rolesGET, POST
/cm/authService/roles/{roleName}DELETE, GET
/cm/authService/roles/{roleName}/commandsGET
/cm/authService/roles/{roleName}/configGET, PUT
/cm/authService/roles/{roleName}/commands/enterMaintenanceModePOST
/cm/authService/roles/{roleName}/commands/exitMaintenanceModePOST
/cm/authService/roles/{roleName}/logs/fullGET
/cm/authService/roles/{roleName}/logs/stacksGET
/cm/authService/roles/{roleName}/logs/stacksBundleGET
/cm/authService/roles/{roleName}/logs/stderrGET
/cm/authService/roles/{roleName}/logs/stdoutGET

3.9 批处理API

路径请求方法
/batchPOST

3.10 Cloudera Manager API

路径请求方法
/cm/commandsGET
/cm/configGET, PUT
/cm/deploymentGET, PUT
/cm/importClusterTemplatePOST
/cm/kerberosInfoGET
/cm/kerberosPrincipalsGET
/cm/licenseGET, POST
/cm/licensedFeatureUsageGET
/cm/logGET
/cm/scmDbInfoGET
/cm/shutdownReadinessGET
/cm/versionGET
/cm/commands/addCustomCertsPOST
/cm/commands/clustersPerfInspectorPOST
/cm/commands/collectDiagnosticDataPOST
/cm/commands/deleteCredentialsPOST
/cm/commands/generateCmcaPOST
/cm/commands/generateCredentialsPOST
/cm/commands/hostInstallPOST
/cm/commands/hostsDecommissionPOST
/cm/commands/hostsOfflineOrDecommissionPOST
/cm/commands/hostsPerfInspectorPOST
/cm/commands/hostsRecommissionPOST
/cm/commands/hostsRecommissionAndExitMaintenanceModePOST
/cm/commands/hostsRecommissionWithStartPOST
/cm/commands/hostsStartRolesPOST
/cm/commands/importAdminCredentialsPOST
/cm/commands/importKerberosPrincipalPOST
/cm/commands/inspectHostsPOST
/cm/commands/refreshParcelReposPOST
/cm/trial/beginPOST
/cm/trial/endPOST

3.11 集群API

路径请求方法
/clustersGET, POST
/clusters/{clusterName}DELETE, GET, PUT
/clusters/{clusterName}/autoAssignRolesPUT
/clusters/{clusterName}/autoConfigurePUT
/clusters/{clusterName}/clientConfigGET
/clusters/{clusterName}/commandsGET
/clusters/{clusterName}/dfsServicesGET
/clusters/{clusterName}/exportGET
/clusters/{clusterName}/hostsDELETE, GET, POST
/clusters/{clusterName}/kerberosInfoGET
/clusters/{clusterName}/serviceTypesGET
/clusters/{clusterName}/utilizationGET
/clusters/{clusterName}/commands/configureAutoTlsServicesPOST
/clusters/{clusterName}/commands/configureForKerberosPOST
/clusters/{clusterName}/commands/deleteCredentialsPOST
/clusters/{clusterName}/commands/deployClientConfigPOST
/clusters/{clusterName}/commands/deployClusterClientConfigPOST
/clusters/{clusterName}/commands/enterMaintenanceModePOST
/clusters/{clusterName}/commands/exitMaintenanceModePOST
/clusters/{clusterName}/commands/expireLogsPOST
/clusters/{clusterName}/commands/firstRunPOST
/clusters/{clusterName}/commands/inspectHostsPOST
/clusters/{clusterName}/commands/perfInspectorPOST
/clusters/{clusterName}/commands/poolsRefreshPOST
/clusters/{clusterName}/commands/preUpgradeCheckPOST
/clusters/{clusterName}/commands/refreshPOST
/clusters/{clusterName}/commands/restartPOST
/clusters/{clusterName}/commands/rollingRestartPOST
/clusters/{clusterName}/commands/rollingUpgradePOST
/clusters/{clusterName}/commands/startPOST
/clusters/{clusterName}/commands/stopPOST
/clusters/{clusterName}/commands/upgradeCdhPOST
/clusters/{clusterName}/commands/upgradeServicesPOST
/clusters/{clusterName}/hosts/{hostId}DELETE

3.12 Cloudera Manager 对等节点API

路径请求方法
/cm/peersGET, POST
/cm/peers/{peerName}DELETE, GET, PUT
/cm/peers/{peerName}/commands/testPOST

3.13 命令API

路径请求方法
/commands/{commandId}GET
/commands/{commandId}/abortPOST
/commands/{commandId}/retryPOST

3.14 仪表板API

路径请求方法
/timeseries/dashboardsGET, POST
/timeseries/dashboards/{dashboardName}DELETE, GET

3.15 数据上下文API

路径请求方法
/dataContextsGET, POST
/dataContexts/{dataContextName}DELETE, GET

3.16 事件API

路径请求方法
/eventsGET
/events/{eventId}GET

3.17 外部账户API

管理各种Cloudera Manager功能使用的外部帐户,用于执行外部任务。

路径请求方法
/externalAccounts/createPOST
/externalAccounts/supportedCategoriesGET
/externalAccounts/updatePUT
/externalAccounts/account/{name}GET
/externalAccounts/accountByDisplayName/{displayName}GET
/externalAccounts/delete/{name}DELETE
/externalAccounts/supportedTypes/{categoryName}GET
/externalAccounts/type/{typeName}GET
/externalAccounts/account/{name}/configGET, PUT
/externalAccounts/typeInfo/{typeName}/commandsByNameGET
/externalAccounts/account/{name}/commands/{commandName}POST

3.18 外部用户映射API

路径请求方法
/externalUserMappingsGET, POST
/externalUserMappings/{uuid}DELETE, GET, PUT

3.19 主机模版API

路径请求方法
/clusters/{clusterName}/hostTemplatesGET, POST
/clusters/{clusterName}/hostTemplates/{hostTemplateName}DELETE, GET, PUT
/clusters/{clusterName}/hostTemplates/{hostTemplateName}/commands/applyHostTemplatePOST

3.20 主机API

路径请求方法
/hostsDELETE, GET, POST
/hosts/{hostId}DELETE, GET, PUT
/hosts/{hostId}/configGET, PUT
/hosts/{hostId}/metricsGET
/hosts/{hostId}/commands/enterMaintenanceModePOST
/hosts/{hostId}/commands/exitMaintenanceModePOST
/hosts/{hostId}/commands/generateHostCertsPOST
/hosts/{hostId}/commands/migrateRolesPOST

3.21 Impala查询API

路径请求方法
/clusters/{clusterName}/services/{serviceName}/impalaQueriesGET
/clusters/{clusterName}/services/{serviceName}/impalaQueries/attributesGET
/clusters/{clusterName}/services/{serviceName}/impalaQueries/{queryId}GET
/clusters/{clusterName}/services/{serviceName}/impalaQueries/{queryId}/cancelPOST

3.22 管理角色命令API

路径请求方法
/cm/service/roleCommands/jmapDumpPOST
/cm/service/roleCommands/jmapHistoPOST
/cm/service/roleCommands/jstackPOST
/cm/service/roleCommands/lsofPOST
/cm/service/roleCommands/restartPOST
/cm/service/roleCommands/startPOST
/cm/service/roleCommands/stopPOST

3.23 管理角色配置组API

路径请求方法
/cm/service/roleConfigGroupsGET
/cm/service/roleConfigGroups/{roleConfigGroupName}GET, PUT
/cm/service/roleConfigGroups/{roleConfigGroupName}/configGET, PUT
/cm/service/roleConfigGroups/{roleConfigGroupName}/rolesGET

3.24 管理角色API

路径请求方法
/cm/service/rolesGET, POST
/cm/service/roles/{roleName}DELETE, GET
/cm/service/roles/{roleName}/commandsGET
/cm/service/roles/{roleName}/configGET, PUT
/cm/service/roles/{roleName}/commands/enterMaintenanceModePOST
/cm/service/roles/{roleName}/commands/exitMaintenanceModePOST
/cm/service/roles/{roleName}/logs/fullGET
/cm/service/roles/{roleName}/logs/stacksGET
/cm/service/roles/{roleName}/logs/stacksBundleGET
/cm/service/roles/{roleName}/logs/stderrGET
/cm/service/roles/{roleName}/logs/stdoutGET

3.25 管理服务API

路径请求方法
/cm/serviceDELETE, GET, PUT
/cm/service/autoAssignRolesPUT
/cm/service/autoConfigurePUT
/cm/service/commandsGET
/cm/service/configGET, PUT
/cm/service/roleTypesGET
/cm/service/commands/enterMaintenanceModePOST
/cm/service/commands/exitMaintenanceModePOST
/cm/service/commands/restartPOST
/cm/service/commands/startPOST
/cm/service/commands/stopPOST

3.26 名称服务API

路径请求方法
/clusters/{clusterName}/services/{serviceName}/nameservicesGET
/clusters/{clusterName}/services/{serviceName}/nameservices/{nameservice}GET
/clusters/{clusterName}/services/{serviceName}/nameservices/{nameservice}/metricsGET

3.27 Parcels API

路径请求方法
/clusters/{clusterName}/parcelsGET
/clusters/{clusterName}/parcels/usageGET
/clusters/{clusterName}/parcels/products/{product}/versions/{version}GET
/clusters/{clusterName}/parcels/products/{product}/versions/{version}/commands/activatePOST
/clusters/{clusterName}/parcels/products/{product}/versions/{version}/commands/cancelDistributionPOST
/clusters/{clusterName}/parcels/products/{product}/versions/{version}/commands/cancelDownloadPOST
/clusters/{clusterName}/parcels/products/{product}/versions/{version}/commands/deactivatePOST
/clusters/{clusterName}/parcels/products/{product}/versions/{version}/commands/removeDownloadPOST
/clusters/{clusterName}/parcels/products/{product}/versions/{version}/commands/startDistributionPOST
/clusters/{clusterName}/parcels/products/{product}/versions/{version}/commands/startDownloadPOST
/clusters/{clusterName}/parcels/products/{product}/versions/{version}/commands/startRemovalOfDistributionPOST

3.28 进程API

路径请求方法
/clusters/{clusterName}/services/{serviceName}/roles/{roleName}/processGET
/clusters/{clusterName}/services/{serviceName}/roles/{roleName}/process/configFiles/{configFileName}GET

3.29 副本API

路径请求方法
/clusters/{clusterName}/services/{serviceName}/replicationsDELETE, GET, POST
/clusters/{clusterName}/services/{serviceName}/replications/hdfsCopyListingPOST
/clusters/{clusterName}/services/{serviceName}/replications/replicationStateGET
/clusters/{clusterName}/services/{serviceName}/replications/{scheduleId}DELETE, GET, PUT
/clusters/{clusterName}/services/{serviceName}/replications/{scheduleId}/collectDiagnosticDataPOST
/clusters/{clusterName}/services/{serviceName}/replications/{scheduleId}/historyGET
/clusters/{clusterName}/services/{serviceName}/replications/{scheduleId}/runPOST

3.30 角色命令API

路径请求方法
/clusters/{clusterName}/services/{serviceName}/roleCommands/hdfsBootstrapStandByPOST
/clusters/{clusterName}/services/{serviceName}/roleCommands/hdfsEnterSafemodePOST
/clusters/{clusterName}/services/{serviceName}/roleCommands/hdfsFinalizeMetadataUpgradePOST
/clusters/{clusterName}/services/{serviceName}/roleCommands/hdfsFormatPOST
/clusters/{clusterName}/services/{serviceName}/roleCommands/hdfsInitializeAutoFailoverPOST
/clusters/{clusterName}/services/{serviceName}/roleCommands/hdfsInitializeSharedDirPOST
/clusters/{clusterName}/services/{serviceName}/roleCommands/hdfsLeaveSafemodePOST
/clusters/{clusterName}/services/{serviceName}/roleCommands/hdfsSaveNamespacePOST
/clusters/{clusterName}/services/{serviceName}/roleCommands/hueSyncDbPOST
/clusters/{clusterName}/services/{serviceName}/roleCommands/jmapDumpPOST
/clusters/{clusterName}/services/{serviceName}/roleCommands/jmapHistoPOST
/clusters/{clusterName}/services/{serviceName}/roleCommands/jstackPOST
/clusters/{clusterName}/services/{serviceName}/roleCommands/lsofPOST
/clusters/{clusterName}/services/{serviceName}/roleCommands/refreshPOST
/clusters/{clusterName}/services/{serviceName}/roleCommands/restartPOST
/clusters/{clusterName}/services/{serviceName}/roleCommands/startPOST
/clusters/{clusterName}/services/{serviceName}/roleCommands/stopPOST
/clusters/{clusterName}/services/{serviceName}/roleCommands/zooKeeperCleanupPOST
/clusters/{clusterName}/services/{serviceName}/roleCommands/zooKeeperInitPOST
/clusters/{clusterName}/services/{serviceName}/roleCommands/{commandName}POST

3.31 角色配置组API

路径请求方法
/clusters/{clusterName}/services/{serviceName}/roleConfigGroupsGET, POST
/clusters/{clusterName}/services/{serviceName}/roleConfigGroups/rolesPUT
/clusters/{clusterName}/services/{serviceName}/roleConfigGroups/{roleConfigGroupName}DELETE, GET, PUT
/clusters/{clusterName}/services/{serviceName}/roleConfigGroups/{roleConfigGroupName}/configGET, PUT
/clusters/{clusterName}/services/{serviceName}/roleConfigGroups/{roleConfigGroupName}/rolesGET, PUT

3.32 角色配置组API

路径请求方法
/clusters/{clusterName}/services/{serviceName}/rolesGET, POST
/clusters/{clusterName}/services/{serviceName}/roles/bulkDeletePOST
/clusters/{clusterName}/services/{serviceName}/roles/{roleName}DELETE, GET
/clusters/{clusterName}/services/{serviceName}/roles/{roleName}/commandsGET
/clusters/{clusterName}/services/{serviceName}/roles/{roleName}/commandsByNameGET
/clusters/{clusterName}/services/{serviceName}/roles/{roleName}/configGET, PUT
/clusters/{clusterName}/services/{serviceName}/roles/{roleName}/metricsGET
/clusters/{clusterName}/services/{serviceName}/roles/{roleName}/commands/enterMaintenanceModePOST
/clusters/{clusterName}/services/{serviceName}/roles/{roleName}/commands/exitMaintenanceModePOST
/clusters/{clusterName}/services/{serviceName}/roles/{roleName}/commands/impalaDiagnosticsPOST
/clusters/{clusterName}/services/{serviceName}/roles/{roleName}/logs/fullGET
/clusters/{clusterName}/services/{serviceName}/roles/{roleName}/logs/stacksGET
/clusters/{clusterName}/services/{serviceName}/roles/{roleName}/logs/stacksBundleGET
/clusters/{clusterName}/services/{serviceName}/roles/{roleName}/logs/stderrGET
/clusters/{clusterName}/services/{serviceName}/roles/{roleName}/logs/stdoutGET

3.33 服务API

路径请求方法
/clusters/{clusterName}/servicesGET, POST
/clusters/{clusterName}/services/{serviceName}DELETE, GET, PUT
/clusters/{clusterName}/services/{serviceName}/clientConfigGET
/clusters/{clusterName}/services/{serviceName}/commandsGET
/clusters/{clusterName}/services/{serviceName}/commandsByNameGET
/clusters/{clusterName}/services/{serviceName}/configGET, PUT
/clusters/{clusterName}/services/{serviceName}/impalaUtilizationGET
/clusters/{clusterName}/services/{serviceName}/metricsGET
/clusters/{clusterName}/services/{serviceName}/roleTypesGET
/clusters/{clusterName}/services/{serviceName}/yarnUtilizationGET
/clusters/{clusterName}/services/{serviceName}/commands/createOozieDbPOST
/clusters/{clusterName}/services/{serviceName}/commands/createSolrHdfsHomeDirPOST
/clusters/{clusterName}/services/{serviceName}/commands/createSqoopUserDirPOST
/clusters/{clusterName}/services/{serviceName}/commands/decommissionPOST
/clusters/{clusterName}/services/{serviceName}/commands/deployClientConfigPOST
/clusters/{clusterName}/services/{serviceName}/commands/disableJtHaPOST
/clusters/{clusterName}/services/{serviceName}/commands/disableRmHaPOST
/clusters/{clusterName}/services/{serviceName}/commands/disableSentryHaPOST
/clusters/{clusterName}/services/{serviceName}/commands/enableJtHaPOST
/clusters/{clusterName}/services/{serviceName}/commands/enableRmHaPOST
/clusters/{clusterName}/services/{serviceName}/commands/enableSentryHaPOST
/clusters/{clusterName}/services/{serviceName}/commands/enterMaintenanceModePOST
/clusters/{clusterName}/services/{serviceName}/commands/exitMaintenanceModePOST
/clusters/{clusterName}/services/{serviceName}/commands/firstRunPOST
/clusters/{clusterName}/services/{serviceName}/commands/hbaseCreateRootPOST
/clusters/{clusterName}/services/{serviceName}/commands/hbaseUpgradePOST
/clusters/{clusterName}/services/{serviceName}/commands/hdfsCreateTmpDirPOST
/clusters/{clusterName}/services/{serviceName}/commands/hdfsDisableAutoFailoverPOST
/clusters/{clusterName}/services/{serviceName}/commands/hdfsDisableHaPOST
/clusters/{clusterName}/services/{serviceName}/commands/hdfsDisableNnHaPOST
/clusters/{clusterName}/services/{serviceName}/commands/hdfsEnableAutoFailoverPOST
/clusters/{clusterName}/services/{serviceName}/commands/hdfsEnableHaPOST
/clusters/{clusterName}/services/{serviceName}/commands/hdfsEnableNnHaPOST
/clusters/{clusterName}/services/{serviceName}/commands/hdfsFailoverPOST
/clusters/{clusterName}/services/{serviceName}/commands/hdfsFinalizeRollingUpgradePOST
/clusters/{clusterName}/services/{serviceName}/commands/hdfsRollEditsPOST
/clusters/{clusterName}/services/{serviceName}/commands/hdfsUpgradeMetadataPOST
/clusters/{clusterName}/services/{serviceName}/commands/hiveCreateHiveUserDirPOST
/clusters/{clusterName}/services/{serviceName}/commands/hiveCreateHiveWarehousePOST
/clusters/{clusterName}/services/{serviceName}/commands/hiveCreateMetastoreDatabasePOST
/clusters/{clusterName}/services/{serviceName}/commands/hiveCreateMetastoreDatabaseTablesPOST
/clusters/{clusterName}/services/{serviceName}/commands/hiveUpdateMetastoreNamenodesPOST
/clusters/{clusterName}/services/{serviceName}/commands/hiveUpgradeMetastorePOST
/clusters/{clusterName}/services/{serviceName}/commands/hiveValidateMetastoreSchemaPOST
/clusters/{clusterName}/services/{serviceName}/commands/hueCreateHiveWarehousePOST
/clusters/{clusterName}/services/{serviceName}/commands/hueDumpDbPOST
/clusters/{clusterName}/services/{serviceName}/commands/hueLoadDbPOST
/clusters/{clusterName}/services/{serviceName}/commands/hueSyncDbPOST
/clusters/{clusterName}/services/{serviceName}/commands/impalaCreateCatalogDatabasePOST
/clusters/{clusterName}/services/{serviceName}/commands/impalaCreateCatalogDatabaseTablesPOST
/clusters/{clusterName}/services/{serviceName}/commands/impalaCreateUserDirPOST
/clusters/{clusterName}/services/{serviceName}/commands/impalaDisableLlamaHaPOST
/clusters/{clusterName}/services/{serviceName}/commands/impalaDisableLlamaRmPOST
/clusters/{clusterName}/services/{serviceName}/commands/impalaEnableLlamaHaPOST
/clusters/{clusterName}/services/{serviceName}/commands/impalaEnableLlamaRmPOST
/clusters/{clusterName}/services/{serviceName}/commands/importMrConfigsIntoYarnPOST
/clusters/{clusterName}/services/{serviceName}/commands/initSolrPOST
/clusters/{clusterName}/services/{serviceName}/commands/installMrFrameworkJarsPOST
/clusters/{clusterName}/services/{serviceName}/commands/installOozieShareLibPOST
/clusters/{clusterName}/services/{serviceName}/commands/migrateToSentryPOST
/clusters/{clusterName}/services/{serviceName}/commands/offlinePOST
/clusters/{clusterName}/services/{serviceName}/commands/oozieCreateEmbeddedDatabasePOST
/clusters/{clusterName}/services/{serviceName}/commands/oozieDisableHaPOST
/clusters/{clusterName}/services/{serviceName}/commands/oozieDumpDatabasePOST
/clusters/{clusterName}/services/{serviceName}/commands/oozieEnableHaPOST
/clusters/{clusterName}/services/{serviceName}/commands/oozieLoadDatabasePOST
/clusters/{clusterName}/services/{serviceName}/commands/oozieUpgradeDbPOST
/clusters/{clusterName}/services/{serviceName}/commands/recommissionPOST
/clusters/{clusterName}/services/{serviceName}/commands/recommissionWithStartPOST
/clusters/{clusterName}/services/{serviceName}/commands/restartPOST
/clusters/{clusterName}/services/{serviceName}/commands/rollingRestartPOST
/clusters/{clusterName}/services/{serviceName}/commands/sentryCreateDatabasePOST
/clusters/{clusterName}/services/{serviceName}/commands/sentryCreateDatabaseTablesPOST
/clusters/{clusterName}/services/{serviceName}/commands/sentryUpgradeDatabaseTablesPOST
/clusters/{clusterName}/services/{serviceName}/commands/solrBootstrapCollectionsPOST
/clusters/{clusterName}/services/{serviceName}/commands/solrBootstrapConfigPOST
/clusters/{clusterName}/services/{serviceName}/commands/solrConfigBackupPOST
/clusters/{clusterName}/services/{serviceName}/commands/solrMigrateSentryPrivilegesCommandPOST
/clusters/{clusterName}/services/{serviceName}/commands/solrReinitializeStateForUpgradePOST
/clusters/{clusterName}/services/{serviceName}/commands/solrValidateMetadataPOST
/clusters/{clusterName}/services/{serviceName}/commands/sqoopCreateDatabaseTablesPOST
/clusters/{clusterName}/services/{serviceName}/commands/sqoopUpgradeDbPOST
/clusters/{clusterName}/services/{serviceName}/commands/startPOST
/clusters/{clusterName}/services/{serviceName}/commands/stopPOST
/clusters/{clusterName}/services/{serviceName}/commands/switchToMr2POST
/clusters/{clusterName}/services/{serviceName}/commands/yarnApplicationDiagnosticsCollectionPOST
/clusters/{clusterName}/services/{serviceName}/commands/yarnCreateCmContainerUsageInputDirCommandPOST
/clusters/{clusterName}/services/{serviceName}/commands/yarnCreateJobHistoryDirCommandPOST
/clusters/{clusterName}/services/{serviceName}/commands/yarnFormatStateStorePOST
/clusters/{clusterName}/services/{serviceName}/commands/yarnNodeManagerRemoteAppLogDirCommandPOST
/clusters/{clusterName}/services/{serviceName}/commands/zooKeeperCleanupPOST
/clusters/{clusterName}/services/{serviceName}/commands/zooKeeperInitPOST
/clusters/{clusterName}/services/{serviceName}/commands/{commandName}POST
/clusters/{clusterName}/services/{serviceName}/reports/hdfsUsageReportGET
/clusters/{clusterName}/services/{serviceName}/reports/mrUsageReportGET

3.34 快照API

路径请求方法
/clusters/{clusterName}/services/{serviceName}/snapshots/policiesGET, POST
/clusters/{clusterName}/services/{serviceName}/snapshots/policies/{policyName}DELETE, GET, PUT
/clusters/{clusterName}/services/{serviceName}/snapshots/policies/{policyName}/historyGET

3.35 时间序列API

路径请求方法
/timeseriesGET, POST
/timeseries/entityTypeAttributesGET
/timeseries/entityTypesGET
/timeseries/schemaGET

3.36 工具API

路径请求方法
/tools/echoGET
/tools/echoErrorGET

3.37 用户API

路径请求方法
/usersGET, POST
/users/sessionsGET
/users/{userName}DELETE, GET, PUT
/users/expireSessions/{userName}POST

3.38 监视目录API

路径请求方法
/clusters/{clusterName}/services/{serviceName}/watcheddirGET, POST
/clusters/{clusterName}/services/{serviceName}/watcheddir/{directoryPath}DELETE

3.39 YARN应用程序API

路径请求方法
/clusters/{clusterName}/services/{serviceName}/yarnApplicationsGET
/clusters/{clusterName}/services/{serviceName}/yarnApplications/attributesGET
/clusters/{clusterName}/services/{serviceName}/yarnApplications/{applicationId}/killPOST

三、API 用法示例

1. 获取CDH的API版本

curl -u admin:admin -X GET --header 'Accept: application/json' 'http://localhost:7180/api/version'

2. 查看集群信息

这会显示CDH集群的信息,包括名称、版本等。

curl -u admin:admin -X GET --header 'Accept: application/json' 'http://localhost:7180/api/v33/clusters'
  • v33:API的版本号

返回结果示例如下:

{
  "items": [
    {
      "name": "Cluster",
      "version": "CDH4"
      ...
    },
    ...
  ]
}
  • name:集群的名称属性,这里的集群名称为Cluster

3. 查看群集中运行的服务

这会显示群集中运行的服务,以及状态和运行状况 信息(在企业版中)。

curl -u admin:admin -X GET --header 'Accept: application/json' 'http://localhost:7180/api/v33/clusters/Cluster/services'
  • Cluster:集群名称

查看集群中运行的服务的名称:

curl -u admin:admin -X GET --header 'Accept: application/json' 'http://localhost:7180/api/v33/clusters/Cluster/services' | grep name

4. 查看impala服务中的角色

这会查看impala服务中的角色信息

curl -u admin:admin -X GET --header 'Accept: application/json' 'http://localhost:7180/api/v33/clusters/Cluster/services/impala/roles'

5. 查看impala服务配置

这会显示了impala服务中所有角色的自定义配置类型。具有默认值的配置参数被排除在外。

curl -u admin:admin -X GET --header 'Accept: application/json' 'http://localhost:7180/api/v33/clusters/Cluster/services/impala/config'

显示完整配置视图的所有参数和描述:

curl -u admin:admin -X GET --header 'Accept: application/json' 'http://localhost:7180/api/v33/clusters/Cluster/services/impala/config?view=full'

6. 查询指标数据

这会获取impala服务的 health_bad_rate,health_concerning_rate 和 health_disabled_rate 指标数据。

curl -u admin:admin -X GET --header 'Accept: application/json' 'http://localhost:7180/api/v33/timeseries?query=select%20health_bad_rate,%20health_concerning_rate,%20health_disabled_rate%20where%20entityName=impala'

总结

在本文中,我们详细地介绍了 Cloudera Manager 的 REST API。首先,我们对 Cloudera Manager 的基础概念进行了说明,包括集群(cluster),服务(service) 和 角色(role)。紧接着,我们列举出所有可用的 REST 资源以及相应的请求方法。每个资源都有对应的路径和请求方法。

此外,文章还提供了一些实际示例来演示如何使用这些 API 进行特定操作。您可以根据自己需要选择合适的资源和方法来管理和监控您的 Cloudera Manager 集群。

希望本教程对您有所帮助!如有任何疑问或问题,请随时在评论区留言。感谢阅读!

参考链接:

文章来源:https://blog.csdn.net/zcs2312852665/article/details/135550253
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。