zookeeper和kafka安装总结

一。zookeeper

ZK实际用到的目录

clip_image002

clip_image004

clip_image006

clip_image008

Scp 。。。。

Echo 2> myid

Echo 3> myid

 

  • 1. 启动ZK服务:       sh bin/zkServer.sh start
  • 2. 查看ZK服务状态: sh bin/zkServer.sh status
  • 3. 停止ZK服务:       sh bin/zkServer.sh stop
  • 4. 重启ZK服务:       sh bin/zkServer.sh restart

 

二。KAFKA

 

clip_image002[7]

clip_image004[4]

clip_image006[5]

clip_image008[7]

clip_image010

1. broker.id=0

2. port=9092

3. num.network.threads=2

4. num.io.threads=8

5. socket.send.buffer.bytes=102400

6. socket.receive.buffer.bytes=102400

7. socket.request.max.bytes=104857600

8. log.dirs=/tmp/kafka-logs

9. num.partitions=2

10. log.retention.hours=168

11. log.segment.bytes=536870912

12. log.retention.check.interval.ms=60000

13. log.cleaner.enable=false

14. zookeeper.connect=localhost:2181

15. zookeeper.connection.timeout.ms=1000000

clip_image012

clip_image014

以下是kafka常用命令行总结:

1.查看topic的详细信息

./kafka-topics.sh -zookeeper 127.0.0.1:2181 -describe -topic testKJ1

2、为topic增加副本

./kafka-reassign-partitions.sh -zookeeper 127.0.0.1:2181 -reassignment-json-file json/partitions-to-move.json -execute

3、创建topic

./kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic testKJ1

4、为topic增加partition

./bin/kafka-topics.sh –zookeeper 127.0.0.1:2181 –alter –partitions 20 –topic testKJ1

5、kafka生产者客户端命令

./kafka-console-producer.sh --broker-list localhost:9092 --topic testKJ1

6、kafka消费者客户端命令

./kafka-console-consumer.sh -zookeeper localhost:2181 --from-beginning --topic testKJ1

7、kafka服务启动

./kafka-server-start.sh -daemon ../config/server.properties

8、下线broker

./kafka-run-class.sh kafka.admin.ShutdownBroker --zookeeper 127.0.0.1:2181 --broker #brokerId# --num.retries 3 --retry.interval.ms 60

shutdown broker

9、删除topic

./kafka-run-class.sh kafka.admin.DeleteTopicCommand --topic testKJ1 --zookeeper 127.0.0.1:2181

您可以选择一种方式赞助本站