The previous log has been set up zookeeper cluster, see: http://www.cnblogs.com/lianliang/p/6533670.html, then continue to build Kafka cluster
1, first download Kafka GZ package: Http://kafka.apache.org/downloads
Unzip to/opt/soft/kafka/directory, unzip and create folder logs for Kafka log file
Go to the Kafka/config directory, modify the configuration file, Vim server.properties, the configuration that needs to be modified is:
#每台服务器的broker. ID is not the same
Broker.id=0
#在log. retention.hours=168 the following three additions
message.max.byte=5242880
Default.replication.factor=1
replica.fetch.max.bytes=5242880
#设置zookeeper的连接端口
zookeeper.connect=master:2181,slave1:2181
#日志文件的目录, set to the logs directory you just created
log.dirs=/opt/soft/kafka/logs/
Note: The broker.id in Salve1 is 1
Save after modification is complete, exit
2. Start Kafka cluster:
Execute start command: Kafka_2.11-0.10.1.1/bin/kafka-server-start.sh-daemon kafka_2.11-0.10.1.1/config/server.properties
Then execute the command: JPS, if printing
5709 Kafka
2850 Quorumpeermain
6056 Jps
Description Kafka Startup success
3, next Test whether production and consumption of information
Create a topic:bin/kafka-topics.sh--create--zookeeper master:2181--replication-factor 1--partitions 1--topic Lian
View topic:bin/kafka-topics.sh--list--zookeeper master:2181, if you can view the topic instructions just created topic success
Open the producer client: bin/kafka-console-producer.sh--broker-list master:9092--topic Lian
Enter a row of data in the console: this is a message
To open a consumer client on the slave1 machine: bin/kafka-console-consumer.sh--bootstrap-server slave1:9092--topic Lian--from-beginning
If you can receive the string you just entered: This is a message stating that the cluster was built successfully!
Construction of Kafka cluster under Linux