Apache ZooKeeper is a centralized, reliable, service for maintaining
configuration information, naming, providing distributed
synchronization, and group services. All of these kinds of services
are used in some form or another by distributed applications.
In order to install and configure Apache HBase and other Hadoop ecosystem
components, you must start the ZooKeeper service.
Apache ZooKeeper is a high-performance coordination service for distributed
applications. It exposes common services such as naming, configuration
management, synchronization, and group services in a simple interface so you
don't have to write them from scratch. You can use it off-the-shelf to
implement consensus, group management, leader election, and presence protocols.
Deploy a Zookeeper unit. With only one unit, the service will be running in
juju deploy apache-zookeeper zookeeper
Running ZooKeeper in standalone mode is convenient for evaluation, some
development, and testing. But in production, you should run ZooKeeper in
replicated mode. A replicated group of servers in the same application is
called a quorum, and in replicated mode, all servers in the quorum have
copies of the same configuration file.
Scaling Zookeeper to create a quorum is trivial. The following will add two
additional Zookeeper units and will automatically configure them with knowledge
of the other quorum members based on their peer relation to one another:
juju add-unit -n 2 zookeeper
Test if the Zookeeper service is running by using the zkServer.sh script:
juju run --service=zookeeper '/usr/lib/zookeeper/bin/zkServer.sh status'
A successful deployment will report the service mode as either standalone
(if only one Zookeeper unit has been deployed) or leader / follower (if
a Zookeeper quorum has been formed).
Zookeeper REST Api can be enabled/disabled either through an action or
via a config variable:
juju action do zookeeper/0 start-rest
juju action do zookeeper/0 stop-rest
juju set zookeeper rest=true
1) Add following lines to your charm's metadata.yaml:
2) Add a zookeeper-relation-changed hook to your charm. Example contents:
from charmhelpers.core.hookenv import relation_get
ZK_hostname = relation_get('private-address')
ZK_port = relation_get('port')