Reference:Kafka cluster--3 broker 3 Zookeeper Create a real combat kafka_kafka introduction and installation _v1.3 http://www.docin.com/p-1291437890.html
I. Preparatory work:1. Prepare 3 machines with IP addresses of: 192.168.3.230 (233,234) 2 respectively. Download Kafka stable version, my version is: Scala 2.11-kafka_2.11-0.9.0.0.tgz http://kafka.apache.org/downloads.html 3. respectively extracted into the directory you want to install, my directory is:/home/rasa decompression command: TAR-XZF *.tgz
second, build zookeeper cluster1. Enter the extracted directory/home/rasa/kafka_2.11-0.9.0.0 2. Go to config directory and modify the Zookeeper.properties file (all machines are the same)Ticktime
= -DataDir
=/data/zookeeper/ClientPort
=2181Initlimit
=5Synclimit
=2Server.1
=192.168.3.230:2888:3888Server.2
=192.168.3.233:2888:3888server.3
=192.168.3.234:2888:38883. In the DataDir directory/data/zookeeper/write a myID file, the command is as follows: Echo 1 >myid Note: This ID is the zookeeper host flag, each host ID is different second is 2 third is 3. 4. The zookeeper of 3 machines is formed a cluster: > bin/zookeeper-server-start.sh config/zookeeper.properties & due to Zookee When the per cluster is started, each node tries to connect to the other nodes in the cluster, and the first boot must not be connected to the back, so the printed part of the exception is negligible. After selecting a leader, the cluster finally stabilized. Other nodes may also appear to have similar problems, which belong to normal.
third, build Kafka cluster1. Go to config directory and modify server.properties (machine-by-device modification)broker.id
=1(Other machines are 2/3)Port
=9092Zookeeper.connect
= 192.168.3.230:2181,192.168.3.233:2181,192.168.3.234:2181Log.dirs
=/home/rasa/kafka-logsHost.name
=192.168.3.230Advertised.host.name
=192.168.3.2302. Start Kafka for each server: > bin/kafka-server-start.sh config/server.properties &
iv. test Clusters 1. Create a topic > bin/kafka-topics.sh--create--zookeeper 192.168.3.230:2181--r Eplication-factor 3--partitions 1 --topic test-topic 2. View created T opic > bin/kafka-topics.sh--describe--zookeeper 192.168.3.230:2181--topic test-topic& nbsp topic:test-replicated-topic partitioncount:1 replicationfactor:3 configs: topic:test-replicated-topic & nbsp partition:0 leader:1 replicas:1,2,0 isr:1,2,0 3. View Topi C List > bin/kafka-topics.sh--list--zookeeper 192.168.3.230:2181 test tes t-topic View list and specific information > bin/kafka-topics.sh--zookeeper localhost--describe  ; 4. View cluster status: >bin/kafka-topics.sh--describe--zookeeper 192.168.3.233:2181--topic test-topic & nbsp >bin/kafka-topics.sh--describe--zookeeper 192.168.3.234:2181--topic test-topic Found that all can see test-topic. 5. Production messages > bin/ kafka-console-producer.sh--broker-list 192.168.3.234:9092-topic test-topic 6. Consumer News & nbsp > bin/kafka-console-consumer.sh--zookeeper 192.168.3.234:2181--from-beginning--topic test-topic
Kafka cluster Deployment steps