kafka集群安装
wanzixiang163 人气:6tar xf kafka_2.11-0.9.0.1.tgz
mv kafka_2.11-0.9.0.1 kafka
cd kafka
vi config/server.properties
broker.id=0 //当前机器在集群中的唯一标识
port=9092 //kafka对外提供服务的tcp端口
host.name=192.168.0.103 //主机IP地址
log.dirs=/home/wanzixiang/app/kafka/logs //log存放目录
zookeeper.connect=192.168.0.103:2181, 192.168.0.104:2181, 192.168.0.105:2181
vi zookeeper.propertie
dataDir=/home/wanzixiang/app/zookeeper-3.4.6https://img.qb5200.com/download-x/data
clientPort=2181
maxClientCnxns=0
启动kafka:
bin/kafka-server-start.sh -daemon config/server.properties //后台启动
测试:
kafka-console-consumer.sh --zookeeper 192.168.0.103:2181,192.168.0.104:2181,192.168.0.105:2181 --topic test --from-beginning //消费者
创建topic:
kafka-topics.sh --create --zookeeper 192.168.0.103:2181 --replication-factor 1 --partitions 1 --topic test
Created topic "test".
查看topic:
kafka-topics.sh --list --zookeeper 192.168.0.103:2181
test
开启发送者并发送消息:
kafka-console-producer.sh --broker-list 192.168.0.103:9092,192.168.0.104:9092,192.168.0.105:9092 --topic test //生产者
kafka-console-producer.sh --broker-list 192.168.0.103:9092 --topic test
开启消费者并接收消息:
kafka-console-consumer.sh --zookeeper 192.168.0.103:2181 --topic test --from-beginning
加载全部内容