Deploy Kafka distributed cluster, install and test under Linux

Source: Internet
Author: User
Tags zookeeper

Note: Before deploying Kafka, deploy the environment Java, Zookeeper

Prepare three centos_6.5_x64 servers, respectively:
IP: 192.168.0.249 dbTest249 Kafka IP: 192.168.0.250 Other250 Kafka IP: 192.168.0.251 webTest251 Kafka

First, install the Kafka

# tar zxvf kafka_2.9.1-0.8.2.2.tgz-c/usr/local/# cd/usr/local/kafka_2.9.1-0.8.2.2/

Second, we install 3 brokers, respectively, on 3 machines: dbtest249,other250,webtest251:
1. Edit dbTest249:

# Vim Config/server.properties
1 broker.id=0    2 port=9092    3 host.name=dbTest249    4 advertised.host.name=dbTest249    5 num.partitions=2    6 zookeeper.connect=dbtest249:2181,other250:2181,webtest251:2181 

2. Edit Other250

# Vim Config/server.properties
1 broker.id=1    2 port=9092    3 host.name=Other250    4 advertised.host.name=Other250    5 num.partitions=2    6 zookeeper.connect=dbtest249:2181,other250:2181,webtest251:2181 

3. Edit webTest251

# Vim Config/server.properties
1 broker.id=2    2 port=9092    3 host.name=webTest251    4 advertised.host.name=webTest251    5 num.partitions=2    6 zookeeper.connect=dbtest249:2181,other250:2181,webtest251:2181 

Third, start the Kafka service, respectively on 3 machines: dbtest249,other250,webtest251:

# nohup/usr/local/kafka_2.9.1-0.8.2.2/bin/kafka-server-start.sh/usr/local/kafka_2.9.1-0.8.2.2/config/ Server.properties >/var/log/kafka.log 2>&1 &# Ps-ef |  grep kafka# NETSTAT-TUNPL |grep java 

Iv. Testing

1, on the dbTest249, a new topic (Replication-factor=num of brokers)

#/usr/local/kafka_2.9.1-0.8.2.2/bin/kafka-topics.sh--create--topic Test--replication-factor 3--partitions 2-- Zookeeper dbtest249:2181

2, we in Other250, open a terminal, send messages to Kafka (Other250 analog producer)

#/usr/local/kafka_2.9.1-0.8.2.2/bin/kafka-console-producer.sh--broker-list dbtest249:9092--sync--topic test

Send message at Send terminal: Hello Kafka

3, we are on the webTest251, open a terminal, display the consumption of messages (webTest251 analog consumer)

#/usr/local/kafka_2.9.1-0.8.2.2/bin/kafka-console-consumer.sh--zookeeper dbtest249:2181--topic test-- From-beginning

At the end of consumer message display: Hello Kafka

Deploy Kafka distributed cluster, install and test under Linux

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.