Installing Apache ZooKeeper
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. And you can build on it for your own, specific needs.
When WSO2 MB is configured to use an external ZooKeeper server, that external ZooKeeper server should be setup like below.
Installation Prerequisites
- ZooKeeper runs on Java, release 1.6 or higher (JDK 6 or greater).
- It runs as an ensemble of ZooKeeper servers. Three ZooKeeper servers is the minimum recommended size for an ensemble, and they are recommend to be run on separate machines.
- For instructions to install Java, refer to
Apache ZooKeeper is supported by the following platforms.
GNU/Linux is supported as a development and production platform for both server and client.
Sun Solaris is supported as a development and production platform for both server and client.
FreeBSD is supported as a development and production platform for clients only. Java NIO selector support in the FreeBSD JVM is broken.
Win32 is supported as a development platform for both server and client.
MacOSX is supported as a development platform only for both server and client.
Download ZooKeeper
Download links for the latest, stable Apache ZooKeeper distribution can be found in one of the Apache Download Mirrors: http://zookeeper.apache.org/releases.html.
Standalone Operation (Minimum Configuration)
Setting up a ZooKeeper server in standalone mode is straightforward. The server is contained in a single JAR file, so installation consists of creating a configuration. Once you've downloaded a stable ZooKeeper release, unpack it. This unpacked directory is referred as <ZK_HOME>. To start ZooKeeper, a configuration file is needed as the sample below. Create it in <ZK_HOME>/conf/zoo.cfg.
tickTime=2000 dataDir=/var/zookeeper clientPort=2181
Config element | Description |
---|---|
tickTime | the basic time unit in milliseconds used by ZooKeeper. It is used to do heartbeats and the minimum session timeout will be twice the tickTime. |
dataDir | the location to store the in-memory database snapshots and, unless specified otherwise, the transaction log of updates to the database. |
clientPort | the port to listen for client connections |
This file can be given any name. In this documentation, it is called conf/zoo.cfg. Change the value of dataDir to specify an existing (empty to start with) directory.
Setting up Zookeeper Server to accept SASL Connections
WSO2 Message Broker is configured to use SASL to connect to the Zookeeper server bundled with it. Thus when setting up an external ZooKeeper server to work with WSO2 Message Broker it is needed to configure ZooKeeper server to accept SASL connections from Message Broker. ZooKeeper installation folder is reffered to as <ZK_HOME>.
- Edit <ZK_HOME>/conf/zoo.cfg file and add the following
requireClientAuthScheme=sasl is optional: if it is set to any value, it will only allow non-authenticated clients to ping, create session, close session, or sasl-authenticate.
authProvider.1=org.apache.zookeeper.server.auth.SASLAuthenticationProvider #requireClientAuthScheme=sasl # renew server-side ticket once an hour. 1000*60*60 = 3600000 milliseconds jaasLoginRenew=3600000
2. Inside <ZK_HOME>/conf/ folder create a file named jaas.conf and add following lines to configure DIGEST-MD5 authentication. Note that value given for "user_admin" is exactly same as password value given for user name "admin" under client section of jaas.conf file in <MB_HOME>/repository/conf/security folder.
Server { org.apache.zookeeper.server.auth.DigestLoginModule required user_super="admin" user_admin="admin"; };
The passwords in the above are in plain text, so the both JAAS configuration files should not be readable by anyone other than the Zookeeper server process user.
3. Inside <ZK_HOME>/conf/ folder create a file named java.env and define the full qualified name to above jaas.conf file in there.
SERVER_JVMFLAGS="-Djava.security.auth.login.config=/user/<ZK_HOME>/conf/jaas.conf"
Be aware to change passwords and user names as you desire. You can get more information on setting SASL authentication for ZooKeeper here.
Start ZooKeeper
Start ZooKeeper as follows, after creating the configuration file.
bin/zkServer.sh start
ZooKeeper logs messages using log4j. Depending on the log4j configuration, log messages can be seen in the console (default) and/or a log file. More information is available in the Logging section of the Programmer's Guide: http://zookeeper.apache.org/doc/r3.2.2/zookeeperProgrammers.html#Logging.
Copyright © WSO2 Inc. 2005-2013