关于Kafka(三) 安装单机Kafka

1) 本机安装Linux,JDK,ZooKeeper,启动ZooKeeper

2) 安装Kafka 

> 解压缩

# tar -zxvf kafka_2.11-1.1.0.tgz

# mv kafka_2.11-1.1.0 kafka

> 启动kafka进程

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

> 查看是否正常启动

# jps

> 测试

> 新建主题test

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

> 显示主题信息

# ./kafka-topics.sh --zookeeper localhost:2181 --describe --topic test

> 生产者发布数据

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

输入:

Test Message Hello

Test Message Kitty

> 消费者读取数据

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

显示数据:

Test Message Hello

Test Message Kitty

猜你喜欢

转载自blog.csdn.net/weixin_42129080/article/details/80863868