Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

stop/start datanode and Tasktracker using specific hostname using Cloudera Manager API

stop/start datanode and Tasktracker using specific hostname using Cloudera Manager API

New Contributor

I am wanting to start or stop datanode or tasktracker using CM API for a specific hostname. The only thing I am able to find is to start or stop datanode or tasktracker mentioning clustername. eg (

I am looking in Curl and python based answers. I am not sure if I am looking at things properly.  Thanks for the help.

2 REPLIES 2

Re: stop/start datanode and Tasktracker using specific hostname using Cloudera Manager API

Explorer

This is the correct syntax from the command line from the master node for HDFS

 

# curl -u username:password 'http://localhost:7180/api/v10/clusters{MYCLUSTERNAME}/services/{hdfs}/commands'

 

all commands listed here:

 

http://cloudera.github.io/cm_api/apidocs/v10/index.html

 

 

My problem is this:

 

The following command returns an empty JSON.  I'm trying to use the START and STOP commands.  Do I need to enable something for this to work?

 

# curl -u admin:admin 'http://localhost:7180/api/v10/clusters/{IBI-Cluster}/commands'

{

"items" : [ ]

}

 

However, this works so I know I'm connected and getting a response:

 

#curl -u admin:admin 'http://localhost:7180/api/v10/clusters/{IBI-Cluster}'

 

{

"name" : "cluster",

"displayName" : "IBI-Cluster",

"version" : "CDH5",

"fullVersion" : "5.4.7",

"maintenanceMode" : false,

"maintenanceOwners" : [ ],

"clusterUrl" : "http://hadp-inv-ibi-m.c.investopedia-1062.internal:7180/cmf/clusterRedirect/cluster"

}

 

I am using cloudera express.  Any ideas  

Gord

Re: stop/start datanode and Tasktracker using specific hostname using Cloudera Manager API

Super Collaborator

Seems that you're looking to 'restart a service role instance'

In curl, these are the steps;

 

below example for MAPREDUCE-1 service

 

1a. Find your role instance 

curl -u 'admin:admin' -X GET http://mko-1.vpc.cloudera.com:7180/api/v7/clusters/Cluster%201/services/MAPREDUCE-1/roles
{
    "name" : "MAPREDUCE-1-TASKTRACKER-beefbeefbeefbeefbeefbeefbeefbeef",
    "type" : "TASKTRACKER",
    "serviceRef" : {
      "clusterName" : "Cluster 1",
      "serviceName" : "MAPREDUCE-1"
    },
    "hostRef" : {
      "hostId" : "beefbeef-beef-beef-beef-beefbeefbeef"
    },

1b. Verify your hostId associated with the service role, to confirm you're restarting the right role-instance on the right host.

curl -u 'admin:admin' -X GET http://mko-1.vpc.cloudera.com:7180/api/v7/hosts
 "beefbeef-beef-beef-beef-beefbeefbeef",
    "ipAddress" : "1.3.3.7",
    "hostname" : "mko-1.vpc.cloudera.com",

2. Restart/Start/Stop role instance

# Restart
curl -u 'admin:admin' -X POST -H "Content-Type:application/json" -d '{"items":["MAPREDUCE-1-TASKTRACKER-beefbeefbeefbeefbeefbeefbeefbeef"]}' 'http://mko-1.vpc.cloudera.com:7180/api/v7/clusters/Cluster%201/services/MAPREDUCE-1/roleCommands/restart'
# Start
curl -u 'admin:admin' -X POST -H "Content-Type:application/json" -d '{"items":["MAPREDUCE-1-TASKTRACKER-beefbeefbeefbeefbeefbeefbeefbeef]}' 'http://mko-1.vpc.cloudera.com:7180/api/v7/clusters/Cluster%201/services/MAPREDUCE-1/roleCommands/start'
# Stop
curl -u 'admin:admin' -X POST -H "Content-Type:application/json" -d '{"items":["MAPREDUCE-1-TASKTRACKER-beefbeefbeefbeefbeefbeefbeefbeef"]}' 'http://mko-1.vpc.cloudera.com:7180/api/v7/clusters/Cluster%201/services/MAPREDUCE-1/roleCommands/stop'