Support Questions

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

creat script that stop hive on My cluster

avatar
Expert Contributor

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?

1 ACCEPTED SOLUTION

avatar
Master Mentor
hide-solution

This problem has been solved!

Want to get a detailed solution you have to login/registered on the community

Register/Login
9 REPLIES 9

avatar
Master Mentor
hide-solution

This problem has been solved!

Want to get a detailed solution you have to login/registered on the community

Register/Login

avatar
Expert Contributor

@Jay Kumar SenSharma

is there some alternative to stop the whole service "hive service" on one command??

avatar
Master Mentor

@yassine sihi

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

.

avatar
Master Mentor

@yassine sihi

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...?

.

avatar
Expert Contributor

@Jay Kumar SenSharma

do I need to run the both command to stop hive, isn't there one command that can do this??

avatar
Master Mentor

@Yassine

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.

avatar
Expert Contributor

@Jay Kumar SenSharma

Do I need to run the both command to stop hive service, isn't there one line command that can do this??

avatar
Master Mentor

@yassine sihi

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
.


avatar
Expert Contributor