Skip to content

Instantly share code, notes, and snippets.

@kazusato
Last active August 6, 2018 18:22
Show Gist options
  • Save kazusato/371f339ca9c29ecb9096f707102638c6 to your computer and use it in GitHub Desktop.
Save kazusato/371f339ca9c29ecb9096f707102638c6 to your computer and use it in GitHub Desktop.

Run Zookeeper and Kafka on CentOS

Zookeeper

A file "zookeeper.out" will be created in the current directory.

$ wget http://ftp.jaist.ac.jp/pub/apache/zookeeper/zookeeper-3.4.13/zookeeper-3.4.13.tar.gz
$ tar xvfz zookeeper-3.4.13.tar.gz
$ sudo useradd zookeeper
$ sudo mv zookeeper-3.4.13 /opt
$ sudo chown -R zookeeper:zookeeper /opt/zookeeper-3.4.13
$ sudo mkdir /var/lib/zookeeper
$ sudo chown zookeeper:zookeeper /var/lib/zookeeper
$ cd /tmp
$ sudo -u zookeeper /opt/zookeeper-3.4.13/bin/zkServer.sh start

Kafka

The command written in the book [Reference#1] does not contain the prop file name and Kafka did not start with the command for this version.

The quickstart seemed to indicate that the prop file name in the argument and it worked well when I tried it (as follows).

$ wget http://ftp.jaist.ac.jp/pub/apache/kafka/2.0.0/kafka_2.12-2.0.0.tgz
$ tar xvfz kafka_2.12-2.0.0.tgz
$ sudo useradd kafka
$ sudo mv kafka_2.12-2.0.0 /opt
$ sudo chown -R kafka:kafka /opt/kafka_2.12-2.0.0
$ mkdir /tmp/kafka-logs
$ sudo chown kafka:kafka /tmp/kafka-logs
$ sudo -u kafka /opt/kafka_2.12-2.0.0/bin/kafka-server-start.sh -daemon /opt/kafka_2.12-2.0.0/config/server.properties

Create a topic, produce messages, and consume messages

The book shows the command to consume messages with a "--zookeeper" option but the command returned an error that where was no such option. The following command worked well for this version of Kafka.

$ /opt/kafka_2.12-2.0.0/bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
$ /opt/kafka_2.12-2.0.0/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
> Test message 1
> Test message 2
> Ctrl-D
$ /opt/kafka_2.12-2.0.0/bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning

References

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