Cloudera Manager API
The Cloudera Manager API provides configuration and service lifecycle management, service health information and metrics, and allows you to configure Cloudera Manager itself. The API is served on the same host and port as the Cloudera Manager Admin Console, and does not require an extra process or extra configuration. The API supports HTTP Basic Authentication, accepting the same users and credentials as the Cloudera Manager Admin Console.
Continue reading:
Obtaining Configuration Files
- Obtain the list of a service's roles:
http://cm_server_host:7180/api/v10/clusters/clusterName/services/serviceName/roles
- Obtain the list of configuration files a process is using:
http://cm_server_host:7180/api/v10/clusters/clusterName/services/serviceName/roles/roleName/process
- Obtain the content of any particular file:
http://cm_server_host:7180/api/v10/clusters/clusterName/services/serviceName/roles/roleName/process/ configFiles/configFileName
For example:http://cm_server_host:7180/api/v10/clusters/Cluster%201/services/OOZIE-1/roles/ OOZIE-1-OOZIE_SERVER-e121641328fcb107999f2b5fd856880d/process/configFiles/oozie-site.xml
Retrieving Service and Host Properties
http://cm_server_host:7180/api/v10/clusters/Cluster%201/services/service_name/config?view=FULL
{ "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" }
http://cm_server_host:7180/api/v10/hosts
This should return host objects of the form:
{ "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 }Then obtain the host properties by including one of the returned host IDs in the URL:
http://cm_server_host:7180/api/v10/hosts/2c2e951c-adf2-4780-a69f-0382181f1821?view=FULL
Backing Up and Restoring the Cloudera Manager Configuration
You can use the Cloudera Manager REST API to export and import all of its configuration data. The API exports a JSON document that contains configuration data for the Cloudera Manager instance. You can use this JSON document to back up and restore a Cloudera Manager deployment.
Minimum Required Role: Cluster Administrator (also provided by Full Administrator)
Exporting the Cloudera Manager Configuration
- Log in to the Cloudera Manager server host as the root user.
- Run the following command:
# curl -u admin_uname:admin_pass "http://cm_server_host:7180/api/v10/cm/deployment" > path_to_file/cm-deployment.json
Where:- admin_uname is a username with either the Full Administrator or Cluster Administrator role.
- admin_pass is the password for the admin_uname username.
- cm_server_host is the hostname of the Cloudera Manager server.
- path_to_file is the path to the file where you want to save the configuration.
Restoring the Cloudera Manager Configuration
Using a previously saved JSON document that contains the Cloudera Manager configuration data, you can restore that configuration to a running cluster.
- Using the Cloudera Manager Administration Console, stop all running services in your cluster:
- On the Home page, click to the right of the cluster name and select Stop.
- Click Stop in the confirmation screen. The Command Details window shows the progress of stopping services.
When All services successfully stopped appears, the task is complete and you can close the Command Details window.
- Log in to the Cloudera Manager server host as the root user.
- Run the following command:
# curl --upload-file path_to_file/cm-deployment.json -u admin_uname:admin_pass http://cm_server_host:7180/api/v10/cm/deployment?deleteCurrentDeployment=true
Where:- admin_uname is a username with either the Full Administrator or Cluster Administrator role.
- admin_pass is the password for the admin_uname username.
- cm_server_host is the hostname of the Cloudera Manager server.
- path_to_file is the path to the file containing the JSON configuration file.
- Restart the Cloudera Manager Server.
- RHEL 7, SLES 12, Debian 8, Ubuntu 16.04
-
sudo systemctl restart cloudera-scm-server
- RHEL 5 or 6, SLES 11, Debian 6 or 7, Ubuntu 12.04, 14.04
-
sudo service cloudera-scm-server restart