Centos7-kafka-2.12安装验证
1.下载Kafka
官网:https://kafka.apache.org/
2.安装脚本
#解压 tar zxf kafka_2.12-2.0.0.tgz -C /usr/local mv /usr/local/kafka_2.12-2.0.0/ /usr/local/kafka #启动zookeeper(启动比较慢,启动后检查2181端口)
bin/zookeeper-server-start.sh -daemon config/zookeeper.propertiesnetstat -anlpt | grep 2181
#启动kafka-server(默认端口是 9092)
/usr/local/kafka/bin/kafka-server-start.sh -daemon /usr/local/kafka/config/server.properties
netstat -anlpt | grep 9092
3.测试生产和消费消息
#创建topic test kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --p artitions 1 --topic test #获取所有topic kafka-topics.sh --list --zookeeper localhost:2181 #生产测试消息 /usr/local/kafka/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
>1234 #输入的消息1 >gggg #输入的消息2 #消费消息 /usr/local/kafka/bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning 1234 gggg
关注公众号