Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

API + how to delete all component from worker machine

avatar

how to remove the following component by API from worker machine

we need to remove these component since ambari GUI not have the option to delete this component /component clients from worker machine

curl -u admin:admin -H "X-Requested-By: ambari" -X GET  http://master02:8080/api/v1/clusters/HDP/hosts/worker04.sys45.com | grep component_name


  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 24661  100 24661    0     0   164k      0 --:--:-- --:--:-- --:--:--  164k
        "component_name" : "DATANODE",
        "component_name" : "HCAT",
        "component_name" : "HDFS_CLIENT",
        "component_name" : "HIVE_CLIENT",
        "component_name" : "METRICS_MONITOR",
        "component_name" : "NODEMANAGER",
        "component_name" : "PIG",
        "component_name" : "SLIDER",
        "component_name" : "SPARK2_CLIENT",
        "component_name" : "TEZ_CLIENT",
        "component_name" : "YARN_CLIENT",
        "component_name" : "ZOOKEEPER_CLIENT",
Michael-Bronson
1 ACCEPTED SOLUTION

avatar
Master Mentor

@Michael Bronson

You can stop the Components and then delete them as following: (for example DataNode)

Stop DataNode (or desired component)

curl -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"RequestInfo":{"context":"Stop Datanode","operation_level":{"level":"HOST_COMPONENT","cluster_name":"HDP","host_name":"worker04.sys45.com","service_name":"HDFS"}},"Body":{"HostRoles":{"state":"INSTALLED"}}}' http://master02:8080/api/v1/clusters/HDP/hosts/worker04.sys45.com/host_components/DATANODE

.
Delete DataNode:

curl -u admin:admin -H "X-Requested-By: ambari" -X DELETE  
http://master02:8080/api/v1/clusters/HDP/hosts/worker04.sys45.com/host_components/DATANODE

.

Similarly you can do the same for other components as well like NodeManager .../etc

View solution in original post

7 REPLIES 7

avatar
Master Mentor

@Michael Bronson

You can stop the Components and then delete them as following: (for example DataNode)

Stop DataNode (or desired component)

curl -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"RequestInfo":{"context":"Stop Datanode","operation_level":{"level":"HOST_COMPONENT","cluster_name":"HDP","host_name":"worker04.sys45.com","service_name":"HDFS"}},"Body":{"HostRoles":{"state":"INSTALLED"}}}' http://master02:8080/api/v1/clusters/HDP/hosts/worker04.sys45.com/host_components/DATANODE

.
Delete DataNode:

curl -u admin:admin -H "X-Requested-By: ambari" -X DELETE  
http://master02:8080/api/v1/clusters/HDP/hosts/worker04.sys45.com/host_components/DATANODE

.

Similarly you can do the same for other components as well like NodeManager .../etc

avatar

after we delete the components by API I still see the component in the worker machine ( even after ambari-server restart and ambari agent restart , what need to do ?

42925-capture.png

Michael-Bronson

avatar
Master Mentor

@Michael Bronson

For AMS monitor process please run the DELETE command twice:

.

Example:

# curl -u admin:admin -H "X-Requested-By: ambari" -X DELETE http://master02:8080/api/v1/clusters/HDP/hosts/worker04.sys45.com/host_components/METRICS_MONITOR

# curl -u admin:admin -H "X-Requested-By: ambari" -X DELETE http://master02:8080/api/v1/clusters/HDP/hosts/worker04.sys45.com/host_components/METRICS_MONITOR

.

The check the Ambari UI. Please try the same for other client components as well.

avatar

after we delete the component from the API we see the components still from the ambari GUI ( and after ambari-server restart )

how it can be?

42929-capture.png

Michael-Bronson

avatar
Master Mentor

@Michael Bronson

If you still see the components in your AMbari UI then please check the "ambari-server.log" you must see some errors during the Deletion of those components in the log. The error will tell us the cause.

So please try the following:

1. Put the ambari-server.log in "tail" to see any latest error:

# tail -f  /var/log/ambari-server/ambari-server.log 

2. Now try deleting the problematic components and observe the "ambari-server.log" if there are any errors?

# curl -u admin:admin -H "X-Requested-By: ambari" -X DELETE http://master02:8080/api/v1/clusters/HDP/hosts/worker04.sys45.com/host_components/METRICS_MONITOR

.

Try opening the Browser in "Incognito" (Private) mode to isolate any browser caching issue.

.


avatar

this is the complete syntax but I get error that cant understand ,

curl -u admin:admin -H "X-Requested-By: ambari" -X DELETE http://master02.dddns.com:8080/api/v1/clusters/HDP/hosts/worker04.dddns.com/host_components/METRICS_...

{ "status" : 404, "message" : "org.apache.ambari.server.controller.spi.NoSuchResourceException: The specified resource doesn't exist: ServiceComponentHost not found, clusterName=HDP, serviceName=AMBARI_METRICS, serviceComponentName=METRICS_MONITOR, hostName=worker04.dddns.com"
Michael-Bronson

avatar
Master Mentor

@Michael Bronson

In your first update the Hostname was not complete for ambari host. (Is that a typo "master02.dddns.com" or it should be "master02" )

curl -u admin:admin -H "X-Requested-By: ambari" -X DELETE http://master02.dddns.com:8080/api/v1/clusters/HDP/hosts/worker04.dddns.com/host_components/METRICS_...

.

Also the hostname of worker is different "worker04.dddns.com" (or it should be "worker04.sys45.com")

Are you sure that your host "worker04.dddns.com" really has AMS monitor installed to it? Please confirm the same using GET command to see if MONITOR is listed int eh output of the following API call?

curl -u admin:admin -H "X-Requested-By: ambari" -X GET http://master02.dddns.com:8080/api/v1/clusters/HDP/hosts/worker04.dddns.com/host_components