Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This configuration will start and provision six CentOS6 VMs:
* Three hosts forming a three node Apache Zookeeper Quorum (Replicated ZooKeeper)
* Three Apache Kafka nodes with one broker each

Each host is a Centos 6.9 64-bit VM provisioned with JDK 8 and Kafka 1.1.0.
Each host is a Centos 7 64-bit VM provisioned with JDK 8 and Kafka 2.1.0.

Here we will be using the verion of Zookeeper that comes pre-packaged with Kafka. This will be Zookeeper version 3.4.10 for the version of Kafka we use.

Expand All @@ -27,14 +27,14 @@ Kafka is installed on all hosts and can be easily accessed through the environme

Here is the mapping of VMs to their private IPs:

| VM Name | Host Name | IP Address |
| ---------- | --------- | ---------- |
| zookeeper1 | vkc-zk1 | 10.30.3.2 |
| zookeeper2 | vkc-zk2 | 10.30.3.3 |
| zookeeper3 | vkc-zk3 | 10.30.3.4 |
| broker1 | vkc-br1 | 10.30.3.30 |
| broker2 | vkc-br2 | 10.30.3.20 |
| broker3 | vkc-br3 | 10.30.3.10 |
| VM Name | Host Name | IP Address |
| ---------- | --------- | ---------- |
| zookeeper1 | vkc-zk1 | 192.168.56.2 |
| zookeeper2 | vkc-zk2 | 192.168.56.3 |
| zookeeper3 | vkc-zk3 | 192.168.56.4 |
| broker1 | vkc-br1 | 192.168.56.30 |
| broker2 | vkc-br2 | 192.168.56.20 |
| broker3 | vkc-br3 | 192.168.56.10 |

Hosts file entries:

Expand Down Expand Up @@ -104,7 +104,7 @@ Here are some commands you can run on any of the nodes to see some of the intern

#### Open a ZK shell

```$KAFKA_HOME/bin/zookeeper-shell.sh 10.30.3.2:2181```
```$KAFKA_HOME/bin/zookeeper-shell.sh 192.168.56:2181```

(you can use the IP of any of the ZK servers)

Expand Down Expand Up @@ -137,18 +137,18 @@ sudo yum install nc -y
To get the version of ZK type:

```bash
echo status | nc 10.30.3.2 2181
echo status | nc 192.168.56.2 2181
```

You can replace 10.30.3.2 with any ZK IP 10.30.3.<2,3,4> and execute the above command from any node within the cluster.
You can replace 192.168.56.2 with any ZK IP 192.168.56.<2,3,4> and execute the above command from any node within the cluster.

*Q: Which Zookeeper server is the leader?*

Here is a simple script that asks each server for its mode:

```bash
for i in 2 3 4; do
echo "10.30.3.$i is a "$(echo status | nc 10.30.3.$i 2181 | grep ^Mode | awk '{print $2}')
echo "192.168.56.$i is a "$(echo status | nc 192.168.56.$i 2181 | grep ^Mode | awk '{print $2}')
done
```

Expand Down
8 changes: 4 additions & 4 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

Vagrant.configure("2") do |config|

config.vm.box = "centos/6"
config.vm.box = "centos/7"
config.ssh.forward_agent = true # So that boxes don't have to setup key-less ssh
config.ssh.insert_key = false # To generate a new ssh key and don't use the default Vagrant one

vars = {
"KAFKA_VERSION" => "1.1.0",
"KAFKA_VERSION" => "2.1.1",
"KAFKA_NAME" => "kafka_2.11-$KAFKA_VERSION",
"KAFKA_TARGET" => "/vagrant/tars/",
"KAFKA_HOME" => "$HOME/$KAFKA_NAME"
Expand All @@ -26,7 +26,7 @@ Vagrant.configure("2") do |config|
(1..3).each do |i|
config.vm.define "zookeeper#{i}" do |s|
s.vm.hostname = "zookeeper#{i}"
s.vm.network "private_network", ip: "10.30.3.#{i+1}"
s.vm.network "private_network", ip: "192.168.56.#{i+1}"
#s.vm.network "private_network", ip: "10.30.3.#{i+1}", netmask: "255.255.255.0", virtualbox__intnet: "my-network", drop_nat_interface_default_route: true
s.vm.provision "shell", run: "always", path: "scripts/zookeeper.sh", args:"#{i}", privileged: false, env: vars
end
Expand All @@ -36,7 +36,7 @@ Vagrant.configure("2") do |config|
(1..3).each do |i|
config.vm.define "broker#{i}" do |s|
s.vm.hostname = "broker#{i}"
s.vm.network "private_network", ip: "10.30.3.#{4-i}0"
s.vm.network "private_network", ip: "192.168.56.#{4-i}0"
#s.vm.network "private_network", ip: "10.30.3.#{4-i}0", netmask: "255.255.255.0", virtualbox__intnet: "my-network", drop_nat_interface_default_route: true
s.vm.provision "shell", run: "always", path: "scripts/broker.sh", args:"#{i}", privileged: false, env: vars
end
Expand Down
12 changes: 6 additions & 6 deletions scripts/hosts-file-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

echo "hosts file setup..."

sudo echo "10.30.3.2 vkc-zk1" | sudo tee -a /etc/hosts
sudo echo "10.30.3.3 vkc-zk2" | sudo tee -a /etc/hosts
sudo echo "10.30.3.4 vkc-zk3" | sudo tee -a /etc/hosts
sudo echo "192.168.56.2 vkc-zk1" | sudo tee -a /etc/hosts
sudo echo "192.168.56.3 vkc-zk2" | sudo tee -a /etc/hosts
sudo echo "192.168.56.4 vkc-zk3" | sudo tee -a /etc/hosts

sudo echo "10.30.3.30 vkc-br1" | sudo tee -a /etc/hosts
sudo echo "10.30.3.20 vkc-br2" | sudo tee -a /etc/hosts
sudo echo "10.30.3.10 vkc-br3" | sudo tee -a /etc/hosts
sudo echo "192.168.56.30 vkc-br1" | sudo tee -a /etc/hosts
sudo echo "192.168.56.20 vkc-br2" | sudo tee -a /etc/hosts
sudo echo "192.168.56.10 vkc-br3" | sudo tee -a /etc/hosts
12 changes: 12 additions & 0 deletions scripts/init.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
#!/bin/bash

setenforce 0
sed -i 's/SELINUX=\(enforcing\|permissive\)/SELINUX=disabled/g' /etc/selinux/config

echo "Disabling IPv6"
echo "net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
net.ipv6.conf.eth0.disable_ipv6 = 1" >> /etc/sysctl.conf

sysctl -p

echo "downloading kafka...$KAFKA_VERSION"

su -c "yum -y install wget net-tools curl telnet"
#download kafka binaries if not present
if [ ! -f $KAFKA_TARGET/$KAFKA_NAME.tgz ]; then
mkdir -p $KAFKA_TARGET
Expand Down