Created 02-20-2018 10:11 AM
I need to create a script shell that stops the Hive Metastore and Hive Server2 from any node of cluster and I need to know where the hive is hosted in My cluster in order to run this command:
ssh nodename:ps aux | awk '{print $1,$2}' | grep hive | awk '{print $2}' | xargs kill >/dev/null 2>&1
how can I know where nodes hive is hosted?
Created 02-20-2018 10:37 AM
If you have Ambari managed cluster then you can find that information just by a simple API call:
1. To findout Hive metastore host:
# curl -u admin:admin -H "X-Requested-By: ambari" -X GET http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/services/HIVE/components/HIVE_METASTOR... | grep 'host_name' | awk '{print $NF}'
2. To findout Hive Server2 host.
# curl -u admin:admin -H "X-Requested-By: ambari" -X GET http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/services/HIVE/components/HIVE_SERVER | grep 'host_name' | awk '{print $NF}'
.
You will need to replace "amb25101.example.com" with Ambari Server Hostname. Also the "plain_ambari" with your Ambari cluster name.
Created 02-20-2018 10:37 AM
If you have Ambari managed cluster then you can find that information just by a simple API call:
1. To findout Hive metastore host:
# curl -u admin:admin -H "X-Requested-By: ambari" -X GET http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/services/HIVE/components/HIVE_METASTOR... | grep 'host_name' | awk '{print $NF}'
2. To findout Hive Server2 host.
# curl -u admin:admin -H "X-Requested-By: ambari" -X GET http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/services/HIVE/components/HIVE_SERVER | grep 'host_name' | awk '{print $NF}'
.
You will need to replace "amb25101.example.com" with Ambari Server Hostname. Also the "plain_ambari" with your Ambari cluster name.
Created 02-20-2018 10:40 AM
is there some alternative to stop the whole service "hive service" on one command??
Created 02-20-2018 10:44 AM
To stop whole "Hive Service"
# curl -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"RequestInfo":{"context":"_PARSE_.START.HIVE","operation_level":{"level":"SERVICE","cluster_name":"plain_ambari","service_name":"HIVE"}},"Body":{"ServiceInfo":{"state":"INSTALLED"}}}' http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/services/HIVE
.
To start whole "Hive Service"
# curl -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"RequestInfo":{"context":"_PARSE_.START.HIVE","operation_level":{"level":"SERVICE","cluster_name":"plain_ambari","service_name":"HIVE"}},"Body":{"ServiceInfo":{"state":"STARTED"}}}' http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/services/HIVE
Created 02-20-2018 10:41 AM
Similarly you can use the following API calls to stop the HIveServer2 & Metastore:
To stop HiveServer2 on host "amb25103.example.com"
# curl -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"RequestInfo":{"context":"Stop HiveServer2","operation_level":{"level":"HOST_COMPONENT","cluster_name":"plain_ambari","host_name":"amb25103.example.com","service_name":"HIVE"}},"Body":{"HostRoles":{"state":"INSTALLED"}}}' http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/hosts/amb25103.example.com/host_compon...?
To stop HiveMetastore on host "amb25103.example.com"
# curl -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"RequestInfo":{"context":"Stop Hive Metastore","operation_level":{"level":"HOST_COMPONENT","cluster_name":"plain_ambari","host_name":"amb25103.example.com","service_name":"HIVE"}},"Body":{"HostRoles":{"state":"INSTALLED"}}}' http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/hosts/amb25103.example.com/host_compon...?
.
Created 02-20-2018 10:44 AM
do I need to run the both command to stop hive, isn't there one command that can do this??
Created 02-25-2018 08:34 PM
If this answers your query then please mark this thread as answered by clicking on the "Accepted" button that way other HCC users can quickly browser the answered queries.
Created 02-20-2018 10:53 AM
Do I need to run the both command to stop hive service, isn't there one line command that can do this??
Created 02-20-2018 10:58 AM
One command is to To stop HiveServer2 on host "amb25103.example.com"
And the other command is to To stop HiveMetastore on host "amb25103.example.com"
.
If you want to stop the Whole Hive Service then please refer to my previous command in same thread:
To stop whole "Hive Service"
# curl -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"RequestInfo":{"context":"_PARSE_.START.HIVE","operation_level":{"level":"SERVICE","cluster_name":"plain_ambari","service_name":"HIVE"}},"Body":{"ServiceInfo":{"state":"INSTALLED"}}}' http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/services/HIVE
.
To start whole "Hive Service"
# curl -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"RequestInfo":{"context":"_PARSE_.START.HIVE","operation_level":{"level":"SERVICE","cluster_name":"plain_ambari","service_name":"HIVE"}},"Body":{"ServiceInfo":{"state":"STARTED"}}}' http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/services/HIVE.
Created 02-20-2018 11:39 AM
ok thanks @Jay Kumar SenSharma