Support Questions
Find answers, ask questions, and share your expertise
Announcements
Check out our newest addition to the community, the Cloudera Innovation Accelerator group hub.

API + restart the services that restart is required

after adding new parameter and value to the ambari cluster , we need to restart the service to take affect

from ambari GUI restart the service is required , and we can see that because restart button is colored with orange

so my question is

we need API command that restart only the services that restart is required?

Michael-Bronson
1 ACCEPTED SOLUTION

Super Mentor

@uri ben-ari

Please pardon me 😞

The URL should end with "requests" instead of "request"

.

Example:

 #  curl  -u admin:admin -H "X-Requested-By: ambari" -X POST  -d '{"RequestInfo":{"command":"RESTART","context":"Restart all required services","operation_level":"host_component"},"Requests/resource_filters":[{"hosts_predicate":"HostRoles/stale_configs=true"}]}' http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/requests

{
  "href" : "http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/requests/132",
  "Requests" : {
    "id" : 132,
    "status" : "Accepted"
  }
}

.

View solution in original post

14 REPLIES 14

Super Mentor

@uri ben-ari

Please try this:

# curl -iv -u admin:admin -H "X-Requested-By: ambari" -X POST  -d '{"RequestInfo":{"command":"RESTART","context":"Restart all required services","operation_level":"host_component"},"Requests/resource_filters":[{"hosts_predicate":"HostRoles/stale_configs=true"}]}' http://$AMBARI_SERVER:8080/api/v1/clusters/$CLUSTER_NAME/reques

.

Please replace the $AMBARI_SERVER with ambari FQDN

$CLUSTER_NAME = clustername.

.

thank you very much - I will test it on my ambari cluster

Michael-Bronson

btw - regarding my previews question , how to find the config type for the parameter , can we talk about this ?

Michael-Bronson

Super Mentor

from some reason I get - HTTP/1.1 404 Not Found

Michael-Bronson

Super Mentor

@uri ben-ari

The "Restart all required services" feature is available from ambari 2.5 onwards only.

If you are getting 404 in Ambari 2.5 then you might be doing something wrong in the URL.

In my case i missed "t" at the end of th URL. The "request" became "reques" Please correct it as following:

# curl -iv -u admin:admin -H "X-Requested-By: ambari" -X POST  -d '{"RequestInfo":{"command":"RESTART","context":"Restart all required services","operation_level":"host_component"},"Requests/resource_filters":[{"hosts_predicate":"HostRoles/stale_configs=true"}]}' http://$AMBARI_SERVER:8080/api/v1/clusters/$CLUSTER_NAME/request

.

I change the hostname and the cluster name maybe something else in the syntax

Michael-Bronson

* Trying 109.164.35.62... * Connected to master.urns.com (109.164.35.62) port 8080 (#0) * Server auth using Basic with user 'admin' > POST /api/v1/clusters/HDP01/request HTTP/1.1 > Authorization: Basic YWRtaW46YWRtaW4= > User-Agent: curl/7.29.0 > Host: master.urns.com:8080 > Accept: */* > X-Requested-By: ambari > Content-Length: 195 > Content-Type: application/x-www-form-urlencoded > * upload completely sent off: 195 out of 195 bytes < HTTP/1.1 404 Not Found HTTP/1.1 404 Not Found < X-Frame-Options: DENY X-Frame-Options: DENY < X-XSS-Protection: 1; mode=block X-XSS-Protection: 1; mode=block < X-Content-Type-Options: nosniff X-Content-Type-Options: nosniff < Cache-Control: no-store Cache-Control: no-store < Pragma: no-cache Pragma: no-cache < Set-Cookie: AMBARISESSIONID=1kmyjqsidore28zeh3nxu88c5;Path=/;HttpOnly Set-Cookie: AMBARISESSIONID=1kmyjqsidore28zeh3nxu88c5;Path=/;HttpOnly < Expires: Thu, 01 Jan 1970 00:00:00 GMT Expires: Thu, 01 Jan 1970 00:00:00 GMT < User: admin User: admin < Content-Length: 0 Content-Length: 0 < Server: Jetty(8.1.19.v20160209) Server: Jetty(8.1.19.v20160209)

Michael-Bronson

as you can see from the log hostname is ok ans the cluster name

Michael-Bronson

I test it again , hostname for sure is ok and the cluster name is correct , what chuld be the problem

Michael-Bronson

Super Mentor

@uri ben-ari

Please pardon me 😞

The URL should end with "requests" instead of "request"

.

Example:

 #  curl  -u admin:admin -H "X-Requested-By: ambari" -X POST  -d '{"RequestInfo":{"command":"RESTART","context":"Restart all required services","operation_level":"host_component"},"Requests/resource_filters":[{"hosts_predicate":"HostRoles/stale_configs=true"}]}' http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/requests

{
  "href" : "http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/requests/132",
  "Requests" : {
    "id" : 132,
    "status" : "Accepted"
  }
}

.

now command its works , but in the ambari cluster the service hive and the service spark2 still have the button restart in orange ( so seems command works on linux ) but not refreshed the service , the target of my quastion was to restart/refreshed all services that need to be restart

Michael-Bronson

Super Mentor

@uri ben-ari

Please check the progress of the request ID ... to see if it is completed or stuck:?

Example:

curl  -u admin:admin -H "X-Requested-By: ambari" -X GET http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/requests/132

.

every thing is ok now thx

Michael-Bronson