Apache Zookeeper Setup & Testing Instructions for Windows (2012-R2 x64)
Single Node Setup Instructions
1. Ensure you have the syndeia-cloud-3.4_cassandra_zookeeper_kafka_setup.zip (or latest service pack) downloaded to your home directory (or home directory's Downloads folder) from the download/license instructions sent out by our team.
Note: the .ZIP will pre-create a separate folder for its contents when extracted so there is no need to pre-create a separate folder for it.
2. Ensure you satisfy Zookeeper's pre-requisites, ie: have (Open|Oracle)JDK/JRE, memory, HD space, etc. (see https://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_systemReq for more details).
3. If using a firewall, ensure the following port is accessible (consult your local network admin if required): TCP port 2181 (this is the port to listen to for client connections).
Note: If required by your IT department, perform any other standard configuration, server hardening (ie: enabling & configuring local firewall, etc.)
4. Extract YAJSW (Yet Another Java Service Wrapper) from https://sourceforge.net/projects/yajsw/files/latest/download .
The download file is just a .ZIP file, so to install it, just extract it to somewhere like C:\YAJSW or C:\Users\Administrator\Downloads, it should automatically create a subfolder like "yajsw-stable-<version>"; where <version> = 12.14 for ex.
To avoid any issues on Windows, it is recommended you do NOT extract it to a path that contains any spaces in any of the directory names.
Download, Install, Configure & Run Apache Zookeeper
1. Launch a Cygwin Terminal, it should start in your home dir.
2. Download Zookeeper 3.4.8, ie: wget https://archive.apache.org/dist/zookeeper/zookeeper-3.4.8/zookeeper-3.4.8.tar.gz
3. Use tar to extract the .tar.gz file to /opt/ and create a logs folder in it, ie: ZK_build_ver=3.4.8; tar -xvzf zookeeper-${ZK_build_ver}.tar.gz -C /opt/ ; mkdir /opt/ ; where zookeeper-${ZK_build_ver}/logsZK_build_ver = the version you downloaded, ex: 3.4.8.
4. Create/update a symlink to the current version, ie: winln -fs /opt/zookeeper-${ZK_build_ver} /opt/zookeeper-current
5. Make /etc/zookeeper/conf/ & /var/lib/zookeeper, create the configuration file /etc/zookeeper/conf/zoo.cfg & paste the configuration below, ie: mkdir -p /etc/zookeeper/conf/ /var/lib/zookeeper /var/run/zookeeper && cp /opt/zookeeper-${ZK_build_ver}/conf/zoo_sample.cfg /etc/zookeeper/conf/zoo.cfg and edit /etc/zookeeper/conf/zoo.cfg, pasting in the below to replace it:
# http://hadoop.apache.org/zookeeper/docs/current/zookeeperAdmin.html # The number of milliseconds of each tick tickTime=2000 # The number of ticks that the initial # synchronization phase can take initLimit=10 # The number of ticks that can pass between # sending a request and getting an acknowledgement syncLimit=5 # the directory where the snapshot is stored. dataDir=/var/lib/zookeeper # Place the dataLogDir to a separate physical disc for better performance # dataLogDir=/disk2/zookeeper # the port at which the clients will connect clientPortAddress=127.0.0.1 clientPort=2181 # specify all zookeeper servers # The fist port is used by followers to connect to the leader # The second one is used for leader election #server.1=zookeeperServer1.mydomain.tld:2888:3888 #server.2=zookeeperServer2.mydomain.tld:2888:3888 #server.3=zookeeperServer3.mydomain.tld:2888:3888 # To avoid seeks ZooKeeper allocates space in the transaction log file in # blocks of preAllocSize kilobytes. The default block size is 64M. One reason # for changing the size of the blocks is to reduce the block size if snapshots # are taken more often. (Also, see snapCount). #preAllocSize=65536 # Clients can submit requests faster than ZooKeeper can process them, # especially if there are a lot of clients. To prevent ZooKeeper from running # out of memory due to queued requests, ZooKeeper will throttle clients so that # there is no more than globalOutstandingLimit outstanding requests in the # system. The default limit is 1,000.ZooKeeper logs transactions to a # transaction log. After snapCount transactions are written to a log file a # snapshot is started and a new transaction log file is started. The default # snapCount is 10,000. #snapCount=1000 # If this option is defined, requests will be will logged to a trace file named # traceFile.year.month.day. #traceFile= # Leader accepts client connections. Default value is "yes". The leader machine # coordinates updates. For higher update throughput at thes slight expense of # read throughput the leader can be configured to not accept clients and focus # on coordination. #leaderServes=yes
Note: In particular, please pay attention to the value of dataDir=/var/lib/zookeeper.
Note: For a quick start, the above settings will get you up and running, however for any multi-node deployment scenarios you will need to specify server.n, where n = server # and create a /var/lib/zookeeper/myid file on each server specifying each server's id (see steps 4-5 of https://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_zkMulitServerSetup for more details)
6. To install & start the Zookeeper service open CMD.EXE in Administrator mode, cd into the bat dir where YAJSW was downloaded to, run: call setenv.bat; wrapper.bat -i To start the service, run %UserProfile%\Downloads\syndeia-cloud-3.4_cassandra_zookeeper_kafka_setup\conf\YAJSW\wrapper.zookeeper.conf; sc config zookeeper start=auto; sc start zookeeper (or start it through the NT Service Manager Applet, ie: services.msc)
7. If the service successfully starts you should get the command prompt again. If you are using the YAJSW wrapped service file you can verify that it started by verifying "Running" shows up in the output of sc queryex zookeeper:
C:\> sc queryex zookeeper
SERVICE_NAME: zookeeper
TYPE : 10 WIN32_OWN_PROCESS
STATE : 4 RUNNING
(STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
C:\>
8. To examine the log file, examine c:\cygwin64\opt\zookeeper-current\logs\wrapped_zookeeper.log. You should see output similar to the following (abridged) text:
[...] 2019-04-05 14:04:23,046 - INFO [main:QuorumPeerConfig@103] - Reading configuration from: /etc/zookeeper/conf/zoo.cfg 2019-04-05 14:04:23,051 - INFO [main:DatadirCleanupManager@78] - autopurge.snapRetainCount set to 3 2019-04-05 14:04:23,051 - INFO [main:DatadirCleanupManager@79] - autopurge.purgeInterval set to 0 2019-04-05 14:04:23,051 - INFO [main:DatadirCleanupManager@101] - Purge task is not scheduled. 2019-04-05 14:04:23,052 - WARN [main:QuorumPeerMain@113] - Either no config or no quorum defined in config, running in standalone mode 2019-04-05 14:04:23,066 - INFO [main:QuorumPeerConfig@103] - Reading configuration from: /etc/zookeeper/conf/zoo.cfg 2019-04-05 14:04:23,067 - INFO [main:ZooKeeperServerMain@95] - Starting server 2019-04-05 14:04:23,095 - INFO [main:Environment@100] - Server environment:zookeeper.version=3.4.8-1--1, built on Fri, 26 Feb 2016 14:51:43 +0100 2019-04-05 14:04:23,095 - INFO [main:Environment@100] - Server environment:host.name=zookeeperServer1.mydomain.tld 2019-04-05 14:04:23,095 - INFO [main:Environment@100] - Server environment:java.version=1.8.0_131 2019-04-05 14:04:23,095 - INFO [main:Environment@100] - Server environment:java.vendor=Oracle Corporation 2019-04-05 14:04:23,095 - INFO [main:Environment@100] - Server environment:java.home=/usr/lib/jvm/java-8-oracle/jre 2019-04-05 14:04:23,096 - INFO [main:Environment@100] - Server environment:java.class.path=/etc/zookeeper/conf:/usr/share/java/jline.jar:/usr/share/java/log4j-1.2.jar:/usr/share/java/xer cesImpl.jar:/usr/share/java/xmlParserAPIs.jar:/usr/share/java/netty.jar:/usr/share/java/slf4j-api.jar:/usr/share/java/slf4j-log4j12.jar:/usr/share/java/zookeeper.jar 2019-04-05 14:04:23,096 - INFO [main:Environment@100] - Server environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib 2019-04-05 14:04:23,096 - INFO [main:Environment@100] - Server environment:java.io.tmpdir=/tmp 2019-04-05 14:04:23,096 - INFO [main:Environment@100] - Server environment:java.compiler=<NA> 2019-04-05 14:04:23,097 - INFO [main:Environment@100] - Server environment:os.name=Linux 2019-04-05 14:04:23,098 - INFO [main:Environment@100] - Server environment:os.arch=amd64 2019-04-05 14:04:23,098 - INFO [main:Environment@100] - Server environment:os.version=4.18.16-x86_64-linode118 2019-04-05 14:04:23,098 - INFO [main:Environment@100] - Server environment:user.name=zookeeper 2019-04-05 14:04:23,098 - INFO [main:Environment@100] - Server environment:user.home=/var/lib/zookeeper 2019-04-05 14:04:23,098 - INFO [main:Environment@100] - Server environment:user.dir=/ 2019-04-05 14:04:23,107 - INFO [main:ZooKeeperServer@787] - tickTime set to 2000 2019-04-05 14:04:23,110 - INFO [main:ZooKeeperServer@796] - minSessionTimeout set to -1 2019-04-05 14:04:23,110 - INFO [main:ZooKeeperServer@805] - maxSessionTimeout set to -1 2019-04-05 14:04:23,124 - INFO [main:NIOServerCnxnFactory@89] - binding to port 0.0.0.0/0.0.0.0:2181
9. Validate correct operation and create/update an archive image to use as a new base image if the node needs to be rebuilt or if you wish to create a cluster.
Before making the image you may wish to first stop and optionally disable the service temporarily to prevent auto-start on boot, ie: sc "\\localhost" disable zookeeper
Multi-Node (Cluster) Setup Instructions (Adding nodes to an existing single-node)
11. Deploy another instance of your Zookeeper base image.
12. Make any appropriate changes for the MAC address (ex: in the VM settings, if used).
13. Setup forward & reverse DNS records on your DNS server (consult your IT admin/sysadmin if required) and set the hostname and primary DNS suffix on the machine itself (sudo hostnamectl set-hostname <new_Zookeeper_node_FQDN> where FQDN = Fully Qualified Domain Name, ex: zookeeper2.mycompany.com )
14. RDP to the IP (or the FQDN of the new node if DNS has already propagated).
15. Follow "Clustered (Multi-server) Setup" https://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_zkMulitServerSetup
16. Repeat steps 11 ~ 15 for each additional cluster node.
Validating Zookeeper Operation for 1-node (or multiple nodes)
17. To validate Zookeeper operation, we connect to each node using the included client script. To do this, connect via CQLSH on the server (or node 1 if testing a cluster) and perform the following steps:
17.1. Open a new Cygwin terminal window
17.2. In the new terminal window, run /opt/zookeeper-current/bin/zkCli.sh -server <zookeeperServerN.mydomain.tld>:2181, where N = the server # and zookeeperServerN.mydomain.tld = your server FQDN. For Zookeeper running on localhost, you should see output similar to the below:
Connecting to localhost:2181 Welcome to ZooKeeper! JLine support is enabled [...] WATCHER:: WatchedEvent state:SyncConnected type:None path:null [zk: localhost:2181(CONNECTED) 0]
17.3. Hit ^C to exit