Created on 02-03-2020 06:52 AM - last edited on 02-03-2020 07:15 AM by cjervis
hi all
how to verify if specific service required restart?
for example - HDFS service
in case HDFS service required restart then ambari will show this as
is it possible by rest api to understand if service required restart or not?
for example for - YARN / HIVE , etc
Created on 02-03-2020 12:57 PM - edited 02-03-2020 01:00 PM
If you just want to find out specific services like HDFS / HIVE /SPARK2 to know whether they require restart or not then you can do this using filtering option service_name.in(xxx,yyy,zzz)
# curl -u admin:admin -H "X-Requested-By: ambari" -X GET "ttp://kerlatest1.example.com:8080/api/v1/clusters/KerLatest/host_components?HostRoles/stale_configs=true&HostRoles/service_name.in(HIVE,HDFS,SPARK2)"
Various Options to get Stale Config Component/Service details.
Similarly there are few other variants of the API call to find out and list the Services/Individual components which require restart.
# curl -u admin:admin -H "X-Requested-By: ambari" -X GET "ttp://kerlatest1.example.com:8080/api/v1/clusters/KerLatest/host_components?HostRoles/stale_configs=true&fields=HostRoles/service_name,HostRoles/host_name"
# curl -u admin:admin -H "X-Requested-By: ambari" -X GET "ttp://kerlatest1.example.com:8080/api/v1/clusters/KerLatest/host_components?HostRoles/stale_configs=true"
# curl -u admin:admin -H "X-Requested-By: ambari" -X GET "ttp://kerlatest1.example.com:8080/api/v1/clusters/KerLatest/host_components?HostRoles/stale_configs=true&fields=HostRoles/service_name"
How to restart All Stale Configurations using API call.
# 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"}]}' "ttp://kerlatest1.example.com:8080/api/v1/clusters/KerLatest/requests"
.
Please change the Ambari Hostname/port and Cluster name in the above API calls.
I have changed "http://" to "ttp://" Please correct that protocol prefix before using the above mentioned API calls.
Created 02-03-2020 07:17 AM
Created on 02-03-2020 07:20 AM - edited 02-03-2020 07:30 AM
but I am asking diff , we want API that ask about specific service as HDFS or YARN , etc
this post that you mentioned ( https://community.cloudera.com/t5/Support-Questions/how-to-know-if-any-service-in-ambari-cluster-nee... ) is about all services that required restart
note - what we want is API that ask the specific service if required restart or not
Created 02-03-2020 08:36 AM
Can you run the below it should give the desired response
curl -u admin:admin -H "X-Requested-By:ambari" -X GET "http://<ambari-server>:<port>/api/v1/clusters/<clustername>/host_components?HostRoles/stale_configs=false&fields=HostRoles/service_name
Please let me know
Created 02-03-2020 09:48 AM
I get A long list of all services , , any way not see there the HDFS
but what we want is to verify only specific one service
Created 02-03-2020 11:08 AM
I will not have access to my environment for 4 days as I am traveling but I think you can filter using
service_name=HDFS
I need to test that but that's the way
Created 02-03-2020 11:23 AM
Dear Shelton ,
enjoy your vacation , and be careful from the corona -:)
Created 02-03-2020 11:32 AM
any way just for your information we get that
curl -u admin:admin -H "X-Requested-By:ambari" -X GET "http://master_node:8080/api/v1/clusters/HDP/host_components?HostRoles/stale_configs=false&fields=HostRoles/service_name=HDFS"
{
"status" : 400,
"message" : "Unable to compile query predicate: Invalid Query Token: token='=', previous token type=VALUE_OPERAND"
Created on 02-03-2020 12:57 PM - edited 02-03-2020 01:00 PM
If you just want to find out specific services like HDFS / HIVE /SPARK2 to know whether they require restart or not then you can do this using filtering option service_name.in(xxx,yyy,zzz)
# curl -u admin:admin -H "X-Requested-By: ambari" -X GET "ttp://kerlatest1.example.com:8080/api/v1/clusters/KerLatest/host_components?HostRoles/stale_configs=true&HostRoles/service_name.in(HIVE,HDFS,SPARK2)"
Various Options to get Stale Config Component/Service details.
Similarly there are few other variants of the API call to find out and list the Services/Individual components which require restart.
# curl -u admin:admin -H "X-Requested-By: ambari" -X GET "ttp://kerlatest1.example.com:8080/api/v1/clusters/KerLatest/host_components?HostRoles/stale_configs=true&fields=HostRoles/service_name,HostRoles/host_name"
# curl -u admin:admin -H "X-Requested-By: ambari" -X GET "ttp://kerlatest1.example.com:8080/api/v1/clusters/KerLatest/host_components?HostRoles/stale_configs=true"
# curl -u admin:admin -H "X-Requested-By: ambari" -X GET "ttp://kerlatest1.example.com:8080/api/v1/clusters/KerLatest/host_components?HostRoles/stale_configs=true&fields=HostRoles/service_name"
How to restart All Stale Configurations using API call.
# 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"}]}' "ttp://kerlatest1.example.com:8080/api/v1/clusters/KerLatest/requests"
.
Please change the Ambari Hostname/port and Cluster name in the above API calls.
I have changed "http://" to "ttp://" Please correct that protocol prefix before using the above mentioned API calls.
Created 02-03-2020 01:28 PM
Dear Jay
what to say
excellent answer , you are really one of the best here