Raspberry Pi Apache Kafka Cluster [P013]
https://www.youtube.com/watch?v=dAVwsc1Zhfo
* Parts
- Raspberry Pi 3 B Model (RASPBERRY-PI-3-B) [B088] x 3ea
- USB Power Supply
- Ethernet Hub
* Contents
- Installation & Setup
1. JDK
$ sudo apt-get install openjdk-8-jdk
2. Kafka
$ cd
$ mkdir kafka
$ wget http://apache.tt.co.kr/kafka/0.10.1.0/kafka_2.11-0.10.1.0.tgz
$ tar zxvf kafka_2.11-0.10.1.0.tgz
3. hosts
$ vi /etc/hosts
192.168.0.11 kafka-pi-01
192.168.0.12 kafka-pi-02
192.168.0.13 kafka-pi-03
4. Config Zookeeper
$ vi config/zookeeper.properties (added)
initLimit=5
syncLimit=2
server.1=kafka-pi-01:2888:3888
server.2=kafka-pi-02:2888:3888
server.3=kafka-pi-03:2888:3888
$ mkdir /tmp/zookeeper (each server)
$ echo 1 > /tmp/zookeeper/myid
$ echo 2 > /tmp/zookeeper/myid
$ echo 3 > /tmp/zookeeper/myid
5. Config Kafka
$ vi config/server.properties (each server 1,2,3)
broker.id=1
zookeeper.connect=kafka-pi-01:2181,kafka-pi-02:2181,kafka-pi-03:2181
* Demo Test Script
1. Zookeeper Cluster Start
/home/dragon/kafka/kafka/bin/zookeeper-server-start.sh -daemon /home/dragon/kafka/kafka/config/zookeeper.properties
2. Kafka Cluster Start
/home/dragon/kafka/kafka/bin/kafka-server-start.sh -daemon /home/dragon/kafka/kafka/config/server.properties
3. Create topics
/home/dragon/kafka/kafka/bin/kafka-topics.sh --create --zookeeper kafka-pi-01:2181 --replication-factor 3 --partitions 5 -topic rdtest
4. Producer
/home/dragon/kafka/kafka/bin/kafka-console-producer.sh --broker-list kafka-pi-01:9092 --topic rdtest
5. Consumer
/home/dragon/kafka/kafka/bin/kafka-console-consumer.sh --zookeeper kafka-pi-01:2181 --topic rdtest --from-beginning
6. Start KafkaOffsetMonitor
java -cp KafkaOffsetMonitor-assembly-0.2.1.jar \
com.quantifind.kafka.offsetapp.OffsetGetterWeb \
--zk kafka-pi-01:2181,kafka-pi-02:2181,kafka-pi-03:2181 \
--port 8080 \
--refresh 10.seconds \
--retain 2.days &
7. Monitor Kafka
http://192.168.0.11:8080
8. How to solve the "map failed" problem in the 32bit raspberry pi.
- edit kafka-run-class.sh
- replace the KAFKA_JVM_PERFORMANCE_OPTS as follows
# JVM performance options
if [ -z "$KAFKA_JVM_PERFORMANCE_OPTS" ]; then
#KAFKA_JVM_PERFORMANCE_OPTS="-server -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:+CMSScavengeBeforeRemark -XX:+DisableExplicitGC -Djava.awt.headless=true"
KAFKA_JVM_PERFORMANCE_OPTS="-server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:+DisableExplicitGC -Djava.awt.headless=true"
fi
- add KAFKA_HEAP_OPTS under 1G
export KAFKA_HEAP_OPTS="-Xmx256M -Xms128M"
'1) HW Platform > Raspberry_Pi' 카테고리의 다른 글
MQTT + Kafka + Amazon ElasticSearch Service [P015] (0) | 2017.10.24 |
---|---|
ARTIK MQTT + Raspberry Pi Apache Kafka Cluster Bridge [P014] (0) | 2017.09.27 |
Raspberry Pi GPIO Ruler [B180] (0) | 2017.02.22 |
Raspberry Pi 3 B Model (RASPBERRY-PI-3-B) [B088] (0) | 2016.09.01 |
Raspberry Pi 2 Model B (RASPBERRY-PI-2-B) [B016] (0) | 2016.09.01 |