Skip to content

Instantly share code, notes, and snippets.

@bjethwan
Created March 8, 2018 04:12
Show Gist options
  • Save bjethwan/e2d774ddda3fb1eb23241d6ff1e007c6 to your computer and use it in GitHub Desktop.
Save bjethwan/e2d774ddda3fb1eb23241d6ff1e007c6 to your computer and use it in GitHub Desktop.
Script to convert a single broker kafka instance to multi instance on single node for my demo at TMB...changing the boker.id, broker.port, and broker.log.dirs
#!/bin/bash
rm -rf mykafka
mkdir mykafka
cd mykafka
mkdir kafka-config
mkdir kafka-log0
mkdir kafka-log1
mkdir kafka-log2
cp /opt/kafka_2.12-1.0.0/config/server.properties kafka-config/server0.properties
cp /opt/kafka_2.12-1.0.0/config/server.properties kafka-config/server1.properties
cp /opt/kafka_2.12-1.0.0/config/server.properties kafka-config/server2.properties
sed -i 's|broker.id=0|broker.id=0|' kafka-config/server0.properties
sed -i 's|broker.id=0|broker.id=1|' kafka-config/server1.properties
sed -i 's|broker.id=0|broker.id=2|' kafka-config/server2.properties
sed -i 's|#listeners=PLAINTEXT://:9092|listeners=PLAINTEXT://:9092|' kafka-config/server0.properties
sed -i 's|#listeners=PLAINTEXT://:9092|listeners=PLAINTEXT://:9093|' kafka-config/server1.properties
sed -i 's|#listeners=PLAINTEXT://:9092|listeners=PLAINTEXT://:9094|' kafka-config/server2.properties
sed -i 's|log.dirs=/tmp/kafka-logs|log.dirs=/home/ec2-user/mykafka/kafka-log0|' kafka-config/server0.properties
sed -i 's|log.dirs=/tmp/kafka-logs|log.dirs=/home/ec2-user/mykafka/kafka-log1|' kafka-config/server1.properties
sed -i 's|log.dirs=/tmp/kafka-logs|log.dirs=/home/ec2-user/mykafka/kafka-log2|' kafka-config/server2.properties
cp /opt/kafka_2.12-1.0.0/config/zookeeper.properties kafka-config/zookeeper.properties
zookeeper-server-start.sh -daemon kafka-config/zookeeper.properties
kafka-server-start.sh -daemon kafka-config/server0.properties
kafka-server-start.sh -daemon kafka-config/server1.properties
kafka-server-start.sh -daemon kafka-config/server2.properties
@bjethwan
Copy link
Author

bjethwan commented Mar 8, 2018

AWS -> Red Hat Enterprise Linux 7.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment