消息中间件--04. Kafka常用的命令
启动zookeeper
1 | $ bin/zkServer.sh start conf/zoo.cfg & |
启动Kafka
我们启动两个实例:1
2
3$ bin/kafka-server-start.sh -daemon config/server.properties
$ bin/kafka-server-start.sh -daemon config/server-1.properties
启动后,使用jps
进程查看对应的kafka进程:
创建主题
现在我们来创建一个名字为testTopic
和testTopic1
的Topic,这个topic有两个partition,并且备份因子也设置为2:1
2$ bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 2 --partitions 2 --topic testTopic
$ bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 2 --partitions 2 --topic testTopic1
查看Kafka的实例
1 | $ bin/zkCli.sh |