Install Kafka 0.10.1 on CentOS 6.7
Master
[root@master ~]# wget http://apache.fayea.com/kafka/0.10.1.0/kafka_2.10-0.10.1.0.tgz[root@master ~]# tar -zxvf kafka_2.10-0.10.1.0.tgz[root@master ~]# mv kafka_2.10-0.10.1.0 /usr/local/
[root@master ~]# vi /usr/local/kafka_2.10-0.10.1.0/config/server.properties
Modify
zookeeper.connect=localhost:2181
Is
zookeeper.connect=master:2181,slave:2181
Add
host.name=master
Save and exit
[root@master ~]# rsync -av /usr/local/kafka_2.10-0.10.1.0 slave:/usr/local/
Slave[root@slave ~]# vi /usr/local/kafka_2.10-0.10.1.0/config/server.properties
Modify
broker.id=0host.name=master
Is
broker.id=1host.name=slave
Save and exit
Start KafkaMaster[root@master ~]# cd /usr/local/kafka_2.10-0.10.1.0/[root@master kafka_2.10-0.10.1.0]# bin/kafka-server-start.sh -daemon config/server.properties
Slave[root@slave ~]# cd /usr/local/kafka_2.10-0.10.1.0/[root@slave kafka_2.10-0.10.1.0]# bin/kafka-server-start.sh -daemon config/server.properties
- Finally, check whether the installation is successful. Use the Client Detection that comes with Kafka. Go to the Kafka installation home directory and start the producer to enter the Interactive Client mode.
MasterCreate a topic named test
[root@master kafka_2.10-0.10.1.0]# bin/kafka-topics.sh --create --zookeeper master:2181 --replication-factor 1 --partitions 1 --topic test
Start a producer on a terminal
[root@master kafka_2.10-0.10.1.0]# bin/kafka-console-producer.sh --broker-list master:9092 --topic test
SlaveStart the consumer in another terminal and enter the Interactive Client
[root@slave kafka_2.10-0.10.1.0]# bin/kafka-console-consumer.sh --zookeeper master:2181 --topic test --from-beginning
On the master (producer), input Hello World on the keyboard !; And then on the slave (consumer), the screen has the same information output. This proves that the Kafka cluster has been successfully built.