THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Stop components on hosts.
Code Block language bash 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 language bash { "href" : "http://c7301.ambari.apache.org:8080/api/v1/clusters/MyCluster/requests/40", "Requests" : { "id" : 40, "status" : "Accepted" } }
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 language bash 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)"
Result of a successful delete
Code Block language bash { "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" } } ] }
Error when trying to delete running components
Code Block language bash { "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}" } } ] }
...