Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

creat script that stop hive on My cluster

Solved Go to solution
Highlighted

creat script that stop hive on My cluster

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

Accepted Solutions
Highlighted

Re: creat script that stop hive on My cluster

Super Mentor

@yassine sihi

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.

View solution in original post

9 REPLIES 9
Highlighted

Re: creat script that stop hive on My cluster

Super Mentor

@yassine sihi

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.

View solution in original post

Highlighted

Re: creat script that stop hive on My cluster

Expert Contributor

@Jay Kumar SenSharma

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

Highlighted

Re: creat script that stop hive on My cluster

Super 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

.

Highlighted

Re: creat script that stop hive on My cluster

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

.

Highlighted

Re: creat script that stop hive on My cluster

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

Highlighted

Re: creat script that stop hive on My cluster

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

Highlighted

Re: creat script that stop hive on My cluster

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

Highlighted

Re: creat script that stop hive on My cluster

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


Re: creat script that stop hive on My cluster

Expert Contributor
Don't have an account?
Coming from Hortonworks? Activate your account here