Initiating HDFS failover using the Cloudera Manager API
Steps to initiate failover of HDFS using the Cloudera Manager API.
- Determine the ID of the Active and Standby NameNode roles. Run
the following
command:
For example:curl -X GET "http://myCluster-1:7180/api/v<API VERSION>/clusters/cluster_name/services/HDFS_service_name/roles?view=summary" -H "accept: application/json"
curl -X GET "http://myCluster-1:7180/api/v43/clusters/Cluster%201/services/HDFS-1/roles?view=summary" -H "accept: application/json"
A data structure is returned that contains the NameNode IDs. Look for output similar to the following:
In the response above, the line"name": "HDFS-1-NAMENODE-b520c25b659296aea5c8249c96a41b79", "type": "NAMENODE", "serviceRef": { "clusterName": "Cluster 1", "serviceName": "HDFS-1", "serviceDisplayName": "HDFS-1", "serviceType": "HDFS" }, "hostRef": { "hostId": "dd503ff5-4c27-4261-b0f1-d9273ad6b510", "hostname": "nightly7x-cmha-4.nightly7x-cmha.root.hwx.site" }, "roleUrl": "http://nightly7x-cmha-4.nightly7x-cmha.root.hwx.site:7180/cmf/roleRedirect/HDFS-1-NAMENODE-b520c25b659296aea5c8249c96a41b79", "roleState": "STARTED", "healthSummary": "GOOD", "configStalenessStatus": "FRESH", "haStatus": "ACTIVE", "maintenanceMode": false, "commissionState": "COMMISSIONED", "roleConfigGroupRef": { "roleConfigGroupName": "HDFS-1-NAMENODE-BASE" },
"haStatus": "ACTIVE"
indicates that this block defines the Active NameNode. The NameNode ID is the value of the "name" property, in this case the ID isHDFS-1-NAMENODE-b520c25b659296aea5c8249c96a41b79
. You will use this value in the next step.
In the response above, the line"name": "HDFS-1-NAMENODE-f9c734734bb24fb4af93576ebeb13ad9", "type": "NAMENODE", "serviceRef": { "clusterName": "Cluster 1", "serviceName": "HDFS-1", "serviceDisplayName": "HDFS-1", "serviceType": "HDFS" }, "hostRef": { "hostId": "5dc7ce94-9db0-4a50-bd82-f0bb64da624b", "hostname": "nightly7x-cmha-1.nightly7x-cmha.root.hwx.site" }, "roleUrl": "http://nightly7x-cmha-4.nightly7x-cmha.root.hwx.site:7180/cmf/roleRedirect/HDFS-1-NAMENODE-f9c734734bb24fb4af93576ebeb13ad9", "roleState": "STARTED", "healthSummary": "GOOD", "configStalenessStatus": "FRESH", "haStatus": "STANDBY", "maintenanceMode": false, "commissionState": "COMMISSIONED", "roleConfigGroupRef": { "roleConfigGroupName": "HDFS-1-NAMENODE-BASE" },
"haStatus": "STANDBY"
indicates that this block defines the Standby NameNode. The NameNode ID is the value of the "name" property, in this case the ID isHDFS-1-NAMENODE-f9c734734bb24fb4af93576ebeb13ad9
. You will use this value in the next step. - Run the following command to initiate the HDFS failover,
substituting the NameNode IDs of the Active and Standby NameNodes
:
For example:curl -X POST "Cloudera_Manager_hostname:Cloudera_Manager_port/api/v<API VERSION>/clusters/cluster_name/services/HDFS_service_name/commands/hdfsFailover?force=true|false" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"items\": [ \"Active_NameNode_ID\", \"Standby_NameNode_ID\" ]}"
curl -X POST “http://myCluster-1.com:7180/api/v43/clusters/Cluster%201/services/HDFS-1/commands/hdfsFailover?force=true” -H “accept: application/json” -H “Content-Type: application/json” -d “{ \“items\“: [ \“HDFS-1-NAMENODE-b520c25b659296aea5c8249c96a41b79\“, \“HDFS-1-NAMENODE-f9c734734bb24fb4af93576ebeb13ad9\” ]}”