三台服务器分别是
192.168.10.150
192.168.10.151
192.168.10.152
然后在三台服务器分别安装 kafka。
下载 kafka
wget --no-check-certificate https://dlcdn.apache.org/kafka/3.1.0/kafka_2.13-3.1.0.tgz
解压
tar -xzf kafka_2.13-3.1.0.tgz
修改配置
vim kafka_2.13-3.1.0/config/server.properties
分别修改
broker.id=0
listeners=PLAINTEXT://192.168.10.150:9092
log.dirs=/data/kafka/kafka-logs
zookeeper.connect=192.168.10.150:2181,192.168.10.151:2181,192.168.10.152:2181
broker.id=1
listeners=PLAINTEXT://192.168.10.151:9092
log.dirs=/data/kafka/kafka-logs
zookeeper.connect=192.168.10.150:2181,192.168.10.151:2181,192.168.10.152:2181
broker.id=2
listeners=PLAINTEXT://192.168.10.152:9092
log.dirs=/data/kafka/kafka-logs
zookeeper.connect=192.168.10.150:2181,192.168.10.151:2181,192.168.10.152:2181
配置环境变量
vim /etc/profile
export KAFKA_HOME=/usr/local/soft/kafka/kafka_2.13-3.1.0
PATH=${KAFKA_HOME}/bin:$PATH
强制生效
source /etc/profile
启动kafka
# 无启动信息
kafka-server-start.sh -daemon /usr/local/soft/kafka/kafka_2.13-3.1.0/config/server.properties
# 有启动信息
kafka-server-start.sh /usr/local/soft/kafka/kafka_2.13-3.1.0/config/server.properties &
验证服务是否可以使用
ps -ef | grep kafka
创建 topic
kafka-topics.sh --create --topic test --bootstrap-server 192.168.10.150:9092 --partitions 1 --replication-factor 1
查看 topic 信息
kafka-topics.sh --describe --topic test --bootstrap-server 192.168.10.150:9092
会出现如下信息:
OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N
Topic: test TopicId: 7hey1seSQyajTXs4rw56_g PartitionCount: 1 ReplicationFactor: 1 Configs: segment.bytes=1073741824
Topic: test Partition: 0 Leader: 0 Replicas: 0 Isr: 0