Zookeeper+kafka Configuration

Source: Internet
Author: User
Tags time in milliseconds

ZooKeeper
installation
#将ZooKeeper解压到/usr/local.
TAR–ZXVF zookeeper-3.4.6.tar.gz–c/usr/local
Cd/usr/local
#重命名
sudo mv zookeeper-3.4.6 zookeeper
CD zookeeper/conf
sudo cp zoo_sample.cfg zoo.cfg
Configuration
1. Append the following to the ZOO.CFG:
#server. N=IP:PORTA:PORTB
#n是服务器标识号 (1~255)
#ip是服务器ip地址
#portA是与leader进行信息交换的端口
#portB是在leader宕机后, the ports used for leader elections
server.1=200.31.157.116:20881:30881
server.2=200.31.157.116:20882:30882
server.3=200.31.157.117:20881:30881
Note:
Configuration file Information parsing:
Ticktime: The basic unit of time in milliseconds, and other times such as heartbeat/timeout are integer multiples of the unit time.
A multiple of initlimit:ticktime, indicating that the time required for followers to synchronize with leader after the leader election, leader data is very large or followers relatively long, the value should be more appropriate.
A multiple of synclimit:ticktime that represents the maximum wait time for follower and observer to interact with leader, which is the time-out when a normal request forward or ping message interacts with the leader after synchronization is complete.
ClientPort: Listen for the service port of the client connection, if you have multiple zookeeper servers installed on one server, you need to set a different port number.
DataDir: Memory Database snapshot address, transaction log address (unless otherwise specified by Datalogdir).


2. Create a new file myID under $datadir and write to the server identification number
#/tmp/zookeeper to DataDir
cd/tmp/zookeeper/
sudo vim myID
#在myid中添加服务器标识号


Start Stop
#进入 $ZOOKEEPER _home, run zkserver.sh
#启动
sudo bin/zkserver.sh start &
#停止
sudo bin/zkserver.sh stop
#查看状态
sudo bin/zkserver.sh status


Kafka
installation

TAR–ZXVF kafka_2.10-0.8.2.1.tgz–c/usr/local/
Cd/usr/local
#重命名
sudo mv kafka_2.10-0.8.2.1 Kafka

CD kafka/conf


Configuration
In the configuration file server.properties modify the following:
#broker. ID is the identity of the broker and is unique
Broker.id=0
#端口号默认为9092
port=9092
#host. Name bit Kafka the IP of the machine
host.name=200.31.157.116
#设置zookeeper, multiple zookeeper servers can be connected
zookeeper.connect=200.31.157.116:2182,200.31.157.116:2183,200.31.157.117:2182


Start Stop
#进入 $KAFKA _home
#启动
sudo bin/kafka-server-start.sh config/server.properties &
#停止

bin/kafka-server-stop.sh


Production/Consumer news
#创建topic
bin/kafka-topics.sh--create--zookeeper 200.31.157.116:2182--replication-factor 1--partitions 1--topic test
#生产消息
bin/kafka-console-producer.sh--broker-list localhost:9092--topic test
#消费消息
Bin/kafka-console-consumer.sh–zookeeper 200.31.157.116:2182,200.31.157.116:2183,200.31.157.117:2182--topic Test- -from-beginning

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Zookeeper+kafka Configuration

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.