Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Stop components on hosts.

    Code Block
    languagebash
    curl -k -u admin:admin -H "X-Requested-By:ambari" 
    -X PUT "$HTTP_PROTOCOL://$CONSOLE_NODE:$PORT/api/v1/clusters/$CLUSTER/host_components?HostRoles/component_name.in(DATANODE,HBASE_REGIONSERVER)&HostRoles/host_name.in(c7301.ambari.apache.org,c7302.ambari.apache.org)" 
    --data 
    '{
       "RequestInfo":{
          "context":"Stop components on hosts"
       },
       "Body":{
          "HostRoles":{
             "state":"INSTALLED"
          }
       }
    }' "$HTTP_PROTOCOL://$CONSOLE_NODE:$PORT/api/v1/clusters/$CLUSTER/host_components?HostRoles/component_name.in(DATANODE,HBASE_REGIONSERVER)&HostRoles/host_name.in(c7301.ambari.apache.org,c7302.ambari.apache.org)"


    Ambari returns a request status URL to be polled for execution results. You can also review the result from Ambari web UI.

    Code Block
    languagebash
    {
      "href" : "http://c7301.ambari.apache.org:8080/api/v1/clusters/MyCluster/requests/40",
      "Requests" : {
        "id" : 40,
        "status" : "Accepted"
      }
    }
  2. Delete components on hosts once the components are stopped. You will receive an error message from Ambari server if you attempt to delete components that are still running.

    Code Block
    languagebash
    curl -k -u admin:admin -H "X-Requested-By: ambari" -X DELETE 
    "$HTTP_PROTOCOL://$CONSOLE_NODE:$PORT/api/v1/clusters/$CLUSTER/host_components?HostRoles/component_name.in(DATANODE,HBASE_REGIONSERVER)&HostRoles/host_name.in(c7301.ambari.apache.org,c7302.ambari.apache.org)"

     

    1. Result of a successful delete

      Code Block
      languagebash
      {
        "deleteResult" : [
          {
            "deleted" : {
              "key" : "c7301.ambari.apache.org/DATANODE"
            }
          },
          {
            "deleted" : {
              "key" : "c7302.ambari.apache.org/DATANODE"
            }
          },
          {
            "deleted" : {
              "key" : "c7302.ambari.apache.org/HBASE_REGIONSERVER"
            }
          },
          {
            "deleted" : {
              "key" : "c7301.ambari.apache.org/HBASE_REGIONSERVER"
            }
          }
        ]
      }
      
      
    2. Error when trying to delete running components

      Code Block
      languagebash
      {
        "deleteResult" : [
          {
            "error" : {
              "key" : "c7301.ambari.apache.org/DATANODE",
              "code" : 500,
             
       "message" : "org.apache.ambari.server.AmbariException: Host Component 
      cannot be removed, clusterName=MyCluster, serviceName=HDFS, 
      componentName=DATANODE, hostname=c7301.ambari.apache.org, request={ clusterName=MyCluster, serviceName=HDFS, componentName=DATANODE, hostname=c7301.ambari.apache.org,
       publicHostname=null, desiredState=null, state=null, 
      desiredStackId=null, staleConfig=null, adminState=null, 
      maintenanceState=null}"
            }
          },
          {
            "error" : {
              "key" : "c7302.ambari.apache.org/DATANODE",
              "code" : 500,
             
       "message" : "org.apache.ambari.server.AmbariException: Host Component 
      cannot be removed, clusterName=MyCluster, serviceName=HDFS, 
      componentName=DATANODE, hostname=c7302.ambari.apache.org, request={ clusterName=MyCluster, serviceName=HDFS, componentName=DATANODE, hostname=c7302.ambari.apache.org,
       publicHostname=null, desiredState=null, state=null, 
      desiredStackId=null, staleConfig=null, adminState=null, 
      maintenanceState=null}"
            }
          },
          {
            "error" : {
              "key" : "c7302.ambari.apache.org/HBASE_REGIONSERVER",
              "code" : 500,
             
       "message" : "org.apache.ambari.server.AmbariException: Host Component 
      cannot be removed, clusterName=MyCluster, serviceName=HBASE, 
      componentName=HBASE_REGIONSERVER, hostname=c7302.ambari.apache.org, request={ clusterName=MyCluster, serviceName=HBASE, componentName=HBASE_REGIONSERVER, hostname=c7302.ambari.apache.org,
       publicHostname=null, desiredState=null, state=null, 
      desiredStackId=null, staleConfig=null, adminState=null, 
      maintenanceState=null}"
            }
          },
          {
            "error" : {
              "key" : "c7301.ambari.apache.org/HBASE_REGIONSERVER",
              "code" : 500,
             
       "message" : "org.apache.ambari.server.AmbariException: Host Component 
      cannot be removed, clusterName=MyCluster, serviceName=HBASE, 
      componentName=HBASE_REGIONSERVER, hostname=c7301.ambari.apache.org, request={ clusterName=MyCluster, serviceName=HBASE, componentName=HBASE_REGIONSERVER, hostname=c7301.ambari.apache.org,
       publicHostname=null, desiredState=null, state=null, 
      desiredStackId=null, staleConfig=null, adminState=null, 
      maintenanceState=null}"
            }
          }
        ]
      }

...