赞
踩
192.168.1.32
192.168.1.17
192.168.1.18
cd /usr/apps/kafka
mkdir kafka
cd kafka
wget https://archive.apache.org/dist/kafka/2.7.0/kafka_2.12-2.7.0.tgz
tar -zxvf kafka_2.12-2.7.0.tgz
进入主文件夹
cd kafka_2.12-2.7.0
cd config
# 存储快照的目录 dataDir=/usr/apps/kafka/zk/data # 需开放端口 2181 clientPort=2181 maxClientCnxns=0 # 是否开启管理服务器 admin.enableServer=true # 管理服务器端口,admin.enableServer=true时需配置,需开放端口 12182 admin.serverPort=2182 tickTime=2000 initLimit=5 syncLimit=2 # 需开放端口 3888 server.1=192.168.1.32:2888:3888 server.2=192.168.1.17:2888:3888 server.3=192.168.1.18:2888:3888
# broker.id要唯一
broker.id=1
# # 需开放端口 9092
listeners=PLAINTEXT://:9092
advertised.listeners=PLAINTEXT://192.168.1.32:9092
# 日志目录
log.dirs=/usr/apps/kafka/kafka_2.12-2.7.0/kafka-logs
# zookeeper集群','隔开
zookeeper.connect=192.168.1.32:2181,192.168.1.17:2181,192.168.1.18:2181
broker.id=2
listeners=PLAINTEXT://:9092
advertised.listeners=PLAINTEXT://192.168.1.17:9092
log.dirs=/usr/apps/kafka/kafka_2.12-2.7.0/kafka-logs
zookeeper.connect=192.168.1.32:2181,192.168.1.17:2181,192.168.1.18:2181
broker.id=3
listeners=PLAINTEXT://:9092
advertised.listeners=PLAINTEXT://192.168.1.18:9092
log.dirs=/usr/apps/kafka/kafka_2.12-2.7.0/kafka-logs
zookeeper.connect=192.168.1.32:2181,192.168.1.17:2181,192.168.1.18:2181
cd /usr/apps/kafka/kafka_2.12-2.7.0
# -daemon 以守护线程方式启动
./bin/zookeeper-server-start.sh -daemon config/zookeeper.properties
./bin/kafka-server-start.sh -daemon config/server.properties
bin/kafka-topics.sh --create --topic quickstart-events --bootstrap-server 192.168.1.32:9092
bin/kafka-topics.sh --describe --topic quickstart-events --bootstrap-server 192.168.1.32:9092
bin/kafka-console-producer.sh --topic quickstart-events --bootstrap-server 192.168.1.32:9092
first event
second event
# ctrl-C 停止生产者客户端
bin/kafka-console-consumer.sh --topic quickstart-events --from-beginning --bootstrap-server 192.168.1.32:19092
# ctrl-C 停止消费者客户端
#查看想开的端口是否已开:
firewall-cmd --query-port=2181/tcp
#添加指定需要开放的端口:
firewall-cmd --add-port=2181/tcp --permanent
#重载入添加的端口:
firewall-cmd --reload
#查询指定端口是否开启成功:
firewall-cmd --query-port=2181/tcp
#移除指定端口:
firewall-cmd --permanent --remove-port=2181/tcp
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。