Setup and test of Kafka cluster environment under Ubuntu

Source: Internet
Author: User
Tags zookeeper

1, unzip

[Email protected] 1:/usr/local# tar zxvf kafka_2. One-0.8. 2.2. tgz

2, renaming

[Email protected] 1:/usr/local# mv/usr/local/kafka_2. One-0.8. 2.2 /usr/local/kafka

3, from zookeeper cluster to the specified background file (not occupy the page)

[Email protected] 1:/usr/local/kafka# bin/zookeeper-server-start.sh config/zookeeper.properties > logs/kafka131-1 . Log >&1 &

4, from Kafka cluster to the specified background file (not occupy the page)

bin/kafka-server-start.sh config/server.properties >logs/kafka131-server-1. Log >&1 &

5. View zookeeper and Kafka boot status

[Email protected] 1:/usr/local/kafka# JPS3104  quorumpeermain5048  Kafka  5064 Jps

6, add a topic

[Email protected] 1:/usr/local/kafka# bin/kafka-topics.sh--create--topic huxing--zookeeper localhost:21812  1"huxing".

7, all the topic that can be used

[Email protected] 1:/usr/local/kafka# bin/kafka-topics.sh--list--zookeeper localhost:2181huxing

8, query the information of a topic

[Email protected] 1:/usr/local/kafka# bin/kafka-topics.sh--describe--topic huxing--zookeeper localhost:2181  Topic:huxing    partitioncount:2    replicationfactor:1    configs:    Topic: huxing    0    0    0    0    topic:huxing     1    0    0    0

9. Delete a topic

Before this, you need to include a line in the Server.properties configuration file

Delete.topic.enable=True

Reboot, then execute code

[Email protected] 1:/usr/local/kafka# bin/kafka-topics.sh--delete--topic huxing--zookeeper localhost:2181   is, if is set true. [ Email protected]-1:/usr/local/kafka# bin/kafka-topics.sh--list--zookeeper localhost:2181  HelloWorld

In the JPS can be queried to have actually been deleted

10, create producer and consumer users

The following error occurred while creating the producer User:

Workaround: Add a row to the Server.properties configuration file

Advertised.host.name=192.168. 22.131

On server.properties, this parameter is used to configure the returned Host.name value, which is configured as an extranet IP address.
This parameter is not enabled by default, the default is the value of the returned Java.net.InetAddress.getCanonicalHostName, which is not equal to the hostname value but returns the IP, but on Linux this value is the value of hostname.

After configuring the reboot, enter the following command in the two shell boxes:

Producer

[Email protected] 1:/usr/local/kafka# bin/kafka-console-producer.sh--topic Hello--broker-list localhost:9092[  --£ º916 is  Not valid (kafka.utils.VerifiableProperties) aaaaa1222

Consumer

[Email protected] 1:/usr/local/kafka# bin/kafka-console-consumer.sh--topic Hello--zookeeper localhost:2181

As a result, the content entered in the Shell box of producer will be updated in sync to consumer

Tag-deleted topic can also be used

Setup and test of Kafka cluster environment under Ubuntu

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.