restart jobtracker through cloudera manager API

2019-08-24 13:57发布

问题:

I am trying to restart Mapreduce Jobtracker through Cloudera Manager API. Stats for Jobtracker is as follows :

local-iMac-399:$ curl -u 'admin:admin' 'http://hadoop-namenode.dev.com:7180/api/v6/clusters/Cluster%201/services/mapreduce/roles/mapreduce-JOBTRACKER-0675ebab2b87e3869e0d90167cf4bf86'
{
  "name" : "mapreduce-JOBTRACKER-0675ebab2b87e3869e0d90167cf4bf86",
  "type" : "JOBTRACKER",
  "serviceRef" : {
    "clusterName" : "cluster",
    "serviceName" : "mapreduce"
  },
  "hostRef" : {
    "hostId" : "24259373-7e71-4089-8251-faf055e42ad7"
  },
  "roleUrl" : "http://hadoop-namenode.dev.com:7180/cmf/roleRedirect/mapreduce-JOBTRACKER-0675ebab2b87e3869e0d90167cf4bf86",
  "roleState" : "STARTED",
  "healthSummary" : "GOOD",
  "healthChecks" : [ {
  "name" : "JOB_TRACKER_FILE_DESCRIPTOR",
  "summary" : "GOOD"
}, {
"name" : "JOB_TRACKER_GC_DURATION",
"summary" : "GOOD"
}, {
"name" : "JOB_TRACKER_HOST_HEALTH",
"summary" : "GOOD"
}, {
"name" : "JOB_TRACKER_LOG_DIRECTORY_FREE_SPACE",
"summary" : "GOOD"
}, {
"name" : "JOB_TRACKER_SCM_HEALTH",
"summary" : "GOOD"
}, {
"name" : "JOB_TRACKER_UNEXPECTED_EXITS",
"summary" : "GOOD"
}, {
"name" : "JOB_TRACKER_WEB_METRIC_COLLECTION",
"summary" : "GOOD"
} ],
"configStalenessStatus" : "STALE",
"haStatus" : "ACTIVE",
"maintenanceMode" : false,
"maintenanceOwners" : [ ],
"commissionState" : "COMMISSIONED",
"roleConfigGroupRef" : {
"roleConfigGroupName" : "mapreduce-JOBTRACKER-BASE"
}
}
local-iMac-399:$ 

Dont know How do I use API to restart just Jobtracker ?

I tried to restart Hive service using following command but got some error

local-iMac-399:$curl -X POST -u 'admin:admin'  'http://hadoop-namenode.dev.com:7180/api/v6/clusters/Cluster%201/services/hive/roleCommands/restart'
{
 "message" : "No content to map due to end-of-input\n at [Source: org.apache.cxf.transport.http.AbstractHTTPDestination$1@4169c499; line: 1, column: 1]"
 }

I would appreciate if someone help in understanding how to use Cloudera Manager API

回答1:

Based on the information provided, this is how you'd invoke the CM API JobTracker restart

curl -u 'admin:admin' -X POST -H "Content-Type:application/json" -d '{"items":["mapreduce-JOBTRACKER-0675ebab2b87e3869e0d90167cf4bf86"]}' 'http://hadoop-namenode.dev.com:7180/api/v6/clusters/Cluster%201/services/mapreduce/roleCommands/restart'