Support Questions
Find answers, ask questions, and share your expertise

How to auto start the zookeeper , when it goes down

Highlighted

How to auto start the zookeeper , when it goes down

Explorer

Hi ,

We have 5 node zookeeper Quorum. What is the best way to auto start, if zookeeper service goes down on one of the node.

I really appreciate, if someone has the script to monitor zookeeper services and autostart the zookeeper , when it goes down (please share with me)

Thanks

Jacqualin

3 REPLIES 3
Highlighted

Re: How to auto start the zookeeper , when it goes down

Explorer

I dont think that there is a autostart script...rather you would have to go and start it from..Ambari...Scripting wise, it is better to run a while true script and contingent on the fact that ZK is not up and running, start it and send an email also

Highlighted

Re: How to auto start the zookeeper , when it goes down

@Jacqualin jasmin you can run some supervisor process to supervise zookeeper, e.g.

monit to monitor a process

https://mmonit.com/wiki/Monit/FAQ#pidfile

the other option is to run Supervisord which can do process restart if it died.

Highlighted

Re: How to auto start the zookeeper , when it goes down

Super Mentor

@Jacqualin jasmin

You can try the following:

Create a shell script with the use of ambari API to start the Zookeeper and the put it inside the "/etc/rc.d/rc.local" as following:

curl -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"RequestInfo":{"context":"Start ZooKeeper Server","operation_level":{"level":"HOST_COMPONENT","cluster_name":"ErieCluster","host_name":"erie3.example.com","service_name":"ZOOKEEPER"}},"Body":{"HostRoles":{"state":"STARTED"}}}' http://erie1.example.com:8080/api/v1/clusters/ErieCluster/hosts/erie3.example.com/host_components/ZO...?

Here "erie3.example.com" is the host in which zookeeper need to be started. You can use the shell script logic to dynamically find the host name as well. like echo `hostname -f`

erie1.example.com: is the ambari server hostname

.

For more information please see the article:

https://community.hortonworks.com/content/kbentry/71748/how-do-i-enable-automatic-restart-recovery-o...

And

the new feature of ambari 2.4 for

"recovery_enabled" : "true"

https://cwiki.apache.org/confluence/display/AMBARI/Recovery%3A+auto+start+components#Recovery:autost...

Don't have an account?