kafka 安装部署


一、 安装zookeeper:


Zookeeper安装

1. 安装wget http://www.apache.org/dist//zookeeper/zookeeper-3.3.6/zookeeper-3.3.6.tar.gz
2 tar zxvf zookeeper-3.3.6.tar.gz
3 cd  zookeeper-3.3.6
4 cp conf/zoo_sample.cfg conf/zoo.cfg
 
启动:
5  ./bin/zkServer.sh start

停止:
6  ./bin/zkServer.sh stop


简单操作:

 ./bin/zkCli.sh -server 127.0.0.1:2181


[zk: 127.0.0.1:2181(CONNECTED) 2] create /test  "hello"
Created /test

[zk: 127.0.0.1:2181(CONNECTED) 3] get /test
"hello"
cZxid = 0x8
ctime = Wed Dec 28 10:03:24 CST 2016
mZxid = 0x8
mtime = Wed Dec 28 10:03:24 CST 2016
pZxid = 0x8
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 7
numChildren = 0

  

二、安装kafka

2  tar zxvf kafka_2.11-0.10.1.0.tgz
3  cd kafka_2.11-0.10.1.0
4 bin/kafka-server-start.sh config/server.properties


5  Create a topic:
# bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
Created topic "test".
# bin/kafka-topics.sh --list --zookeeper localhost:2181
test


Step 4: Send some messages

Kafka comes with a command line client that will take input from a file or from standard input and send it out as messages to the Kafka cluster. By default, each line will be sent as a separate message.

Run the producer and then type a few messages into the console to send to the server.

> bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
This is a message
This is another message
Step 5: Start a consumer

Kafka also has a command line consumer that will dump out messages to standard output.

> bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
This is a message
This is another message
If you have each of the above commands running in a different terminal then you should now be able to type messages into the producer terminal and see them appear in the consumer terminal.

All of the command line tools have additional options; running the command with no arguments will display usage information documenting them in more detail.



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值