Kafka+zookeeper Environment Configuration (MAC or Linux environment)

Source: Internet
Author: User
Tags zookeeper zookeeper download

I. Zookeeper Download and Installation

1) Download

Ademacbook-pro:zookeeper_soft apple$ wget http://mirrors.cnnic.cn/apache/zookeeper/zookeeper-3.4.6/ Zookeeper-3.4.6.tar.gz

2) Unzip

Tar zxvf zookeeper-3.4. 6. tar.gz

3) configuration

CD zookeeper-3.4. 6

CP-RF conf/zoo_sample.cfg conf/zoo.cfg
Vim Zoo.cfg

Zoo.cfg:

# of milliseconds of each tickticktime= -# The number of ticks that the initial # synchronization phase can takeinitlimit=Ten# The number of ticks that can pass between # Sending a request and getting an acknowledgementsynclimit=5# The DirectorywhereThe snapshot isstored.# DoNot use/tmp forStorage,/tmp here isJust # example sakes. DataDir =/users/apple/documents/soft/zookeeper_soft/ zkdata #这个目录是预先创建的# The port at which the clients would connectclientport=2181# The maximum number of client connections.# increase This ifYou need to handle more Clients#maxclientcnxns= -# # is sure to read the maintenance sections of the # Administrator guide before turning on autopurge.## http://zookeeper.apache.org/doc/current/zookeeperadmin.html#sc_maintenance# # of snapshots to retaininchDatadir#autopurge.snapretaincount=3# Purge Task intervalinchhours# Set to"0"To disable Auto purge feature#autopurge.purgeinterval=1

4) Start Zookeeper

ademacbook-pro:bin apple$ sh zkserver.sh startjmx enabled bydefaultUsing config:/users/apple/documents/soft/zookeeper_soft/zookeeper-3.4.6/bin/. /conf/zoo.cfg-N Starting Zookeeper ... Startedademacbook-pro:bin apple$ PS ax| grep zookeeper. out 10311s003 s+0:00.01grep zookeeper. outAdemacbook-pro:bin apple$ PS ax|grep Zookeeper10307s003 S0:00.63/usr/bin/java-dzookeeper.log.dir=. -dzookeeper.root.logger=info,console-cp/users/apple/documents/soft/zookeeper_soft/zookeeper-3.4.6/bin/. /build/classes:/users/apple/documents/soft/zookeeper_soft/zookeeper-3.4.6/bin/. /build/lib/*.jar:/users/apple/documents/soft/zookeeper_soft/zookeeper-3.4.6/bin/. /lib/slf4j-log4j12-1.6.1.jar:/users/apple/documents/soft/zookeeper_soft/zookeeper-3.4.6/bin/. /lib/slf4j-api-1.6.1.jar:/users/apple/documents/soft/zookeeper_soft/zookeeper-3.4.6/bin/. /lib/netty-3.7.0.final.jar:/users/apple/documents/soft/zookeeper_soft/zookeeper-3.4.6/bin/. /lib/log4j-1.2.16.jar:/users/apple/documents/soft/zookeeper_soft/zookeeper-3.4.6/bin/. /lib/jline-0.9.94.jar:/users/apple/documents/soft/zookeeper_soft/zookeeper-3.4.6/bin/. /zookeeper-3.4.6.jar:/users/apple/documents/soft/zookeeper_soft/zookeeper-3.4.6/bin/. /src/java/lib/*.jar:/users/apple/documents/soft/zookeeper_soft/zookeeper-3.4.6/bin/. /conf:-dcom.sun.management.jmxremote-dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.quorumpeermain/users/apple/documents/soft/zookeeper_soft/zookeeper-3.4.6/ bin/. /conf/zoo.cfg 

Two downloads and installs Kafka (pre-installed Scala environment, MAC Environment Reference: http://www.cnblogs.com/super-d2/p/4534208.html)

1). Download Kafka:

wget http://apache.fayea.com/kafka/0.8.2.1/kafka_2.10-0.8.2.1.tgz

2) Unzip:

TAR-ZXF kafka_2.10-0.8.2.1.tgz

3) Start Kafka

ademacbook-pro:kafka_2.10-0.8.2.1 apple$ sh bin/kafka-server-start.sh config/server.properties

Note: To be hung in the background use:

SH bin/kafka-server-start.sh config/server.properties &

4) Create a new topic

1 1 --zookeeper localhost:2181

Note: To be hung in the background use:

SH kafka-topics.sh--create--topic kafkatopic--replication-factor 1--partitions 1--zookeeper localhost:2181 &

5) Start up the Kafka producers:

Ademacbook-pro:bin apple$ sh kafka-console-producer.sh--broker-list localhost:9092 --sync--topic kafkatopic

Note: To be hung in the background use:

SH kafka-console-producer.sh--broker-list localhost:9092--sync--topic kafkatopic &

6) Open another terminal to start up the consumer:

Ademacbook-pro:bin apple$ sh kafka-console-consumer.sh--zookeeper localhost:2181 --topic kafkatopic--  from-beginning

Note: To be hung in the background use:

SH kafka-console-consumer.sh--zookeeper localhost:2181--topic kafkatopic--from-beginning &

7) Use

    1. Enter AAA at the terminal where the message is sent, which can be displayed at the end of the consumer message, as shown in:

Kafka+zookeeper Environment Configuration (MAC or Linux environment)

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.