- System: 6x Ubuntu 14.04 server
- Memory: 1024 MB each host
- IP address: 192.168.5.100-140
You can easily customize the cluster parameters in the following files:
Vagrantfile
contains parameters for the system, memory, IP addresses and hostnames
Note regarding the cluster size: It is recommended to run the cluster on an odd number of hosts (3, 5, etc). Zookeeper is designed to survive failure of minority of hosts. Zookeeper running on 3 or 4 hosts can survive failure of 1 host while Zookeper running on 5 hosts can survive failure of 2 hosts.
- Install VirtualBox
- Install Vagrant
- Install Ansible
- Clone this repository
- Enter cloned repository
- Execute
vagrant provision && vagrant up
This script creates a virtual 3-node Apache ZooKeeper cluster on your local machine using Vagrant, VirtualBox and Ansible.
The Zookeeper service will run in a truly replicated mode over several machines, so you can experiment with host failures, client connections, misc cluster configurations, etc.
Also, if you want to create a virtual cluster for other services built on top of Zookeeper (e.g. Apache Kafka, HBase, Solr, Neo4j), this script might help as a starting point.
Note: This is a proof of concept and test installation only. Do ot use in production.
- IP address: 192.168.5.100 - 192.168.5.102
- Hostnames:
zookeeper-node-[x]
withx
have values 1, 2 or 3 - Zookeeper version: 3.4.11
- JVM: Oracle Java-8
Execute vagrant provision && vagrant up
With
vagrant halt
you stop the cluster and can restart the cluster with
vagrant reload
Each VM should now have the Zookeeper running on port 2181. Test that the service is running in non-error state by:
echo ruok | nc 192.168.5.100 2181
The server should respond with imok
.
If interested, checkout the list of all our-letter commands supported by the Zookeeper service
The easiest way to experiment with Zookeeper is to log into one of the machines and play with the command-line tool shipped with the Zookeeper:
vagrant ssh zookeeper-node-1
vagrant@zookeeper-node-1:~$ cd /opt/zookeeper-3.4.11/bin/
vagrant@zookeeper-node-1:/opt/zookeeper-3.4.11/bin$ ./zkCli.sh -server localhost:2181
[zk: localhost:2181(CONNECTED) 3] create /zk_test my_data
Created /zk_test
4. Exit the console and connect to Zookeeper running on zookeeper-node-1
(which runs on 192.168.5.101
)
vagrant@zookeeper-node-2:/opt/zookeeper-3.4.11/bin$ ./zkCli.sh -server 192.168.5.101:2181
[zk: 192.168.5.101:2181(CONNECTED) 0] ls /
[zookeeper, zk_test]
[zk: 192.168.5.101:2181(CONNECTED) 1] get /zk_test
my_data
Stop the cluster with
vagrant halt
Restart the cluster with
vagrant reload
Note: After restart you must also start the ZooKeeper server manual. Automatic restart is yet not configured. I'll implement this in a further version.
Steps to restart Zookepper:
- Login to node 1:
vagrant ssh zookeeper-node-1
- Start ZooKeeper:
sudo service zookeeper start
- Quit node-1:
exit
Repeat with node-2.
Creates a 1 node environment for Apache Kafka
Note: This is a proof of concept and test installation only. Do ot use in production.
- IP address: 192.168.5.110, 192.168.5.111
- Hostnames:
kafka-node-1
- Kafka version: 1.0.0
- JVM: Oracle Java-8
Execute vagrant provision && vagrant up
With
vagrant halt
you stop the cluster and can restart the cluster with
vagrant reload
- Connect to Kafka service with:
vagrant ssh kafka-node-1
- Change to Kafka
bin
directory: `cd /opt/kafka_2.11-1.0.0/bin - List existing topics:
./kafka-topics.sh --list --zookeeper 192.168.5.100:2181
- Create new topic:
./kafka-topics.sh --create --topic web2kafka --zookeeper 192.168.5.100:2181 --partitions 1 --replication-factor 1
Output:Created topic "firsttopic".
- Show created topic:
./kafka-topics.sh --list --zookeeper 192.168.5.100:2181
Output:web2kafka
List all entries in a topic:
./kafka-console-consumer.sh --zookeeper 192.168.5.100:2181 --topic web2kafka --from-beginning
Creates 2 Storm instances. One Nimbus with UI and one supervisor node.
- IP address: 192.168.5.120 -> Nimbus
- IP address: 192.168.5.130 -> Supervisor
- IP address: 192.168.5.140 -> UI
- Hostnames:
storm-nimbus-node-1
- Hostnames:
storm-supervisor-node-1
- Hostnames:
storm-ui-node-1
- Zookeeper version: 3.4.11
- JVM: Oracle Java-8
At this time of contribution, there is no autostart for the Storm services. Start the services with the following steps
- Login to Nimbus with
vagrant ssh storm-nimbus-node-1
- Get root user with
su
. Password:vagrant
- Change to director
/opt/apache-storm-1.1.1/bin
- Execute
./storm nimbus &
- Exit host
Repeat with storm-supervisor-node-1
Instead of executing ./storm nimbus &
execute ./storm supervisor &
Run UI on the Nimbus node by executing ./storm ui &
Find a Storm topology to read from Kafka (topic: web2kafka
) under client/storm
.
Build the project with mvn package
and deploy the artifact on nimbus with
./storm jar /PATHTOJAR/kafka2storm.jar de.speexx.experimental.storm.Topology
.