cd /opt/pkg/
wget https://downloads.apache.org/kafka/3.5.1/kafka_2.13-3.5.1.tgz
tar zxf kafka_2.13-3.5.1.tgz
mv kafka_2.13-3.5.1 ../app/
cd /opt/app
cd kafka_2.13-3.5.1/
cd config/
cp server.properties server.properties.bak
vim server.properties
---
listeners=PLAINTEXT://kafka_1:9092
og.dirs=./kafka-logs
zookeeper.connect=kafka_1:2181
---
cd ../
./bin/kafka-server-start.sh -daemon config/server.properties
OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should c
WARNING: Due to limitations in metric names, topics with a period ('.') or underscore ('') could collide. To avo
Created topic topic_01. root@loaclhost kafka_2.13-3.5.1# ./bin/kafka-console-consumer.sh --bootstrap-server kafka_1:9092 --topic topic
OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should c
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
cd /opt/app/cluster/apache-zookeeper-3.8.2/
./bin/zkServer.sh start zoo.cfg
cd /opt/app/cluster/kafka_2.13-3.5.1
./bin/kafka-server-start.sh -daemon config/server.properties
报错:
Using config: /opt/app/cluster/apache-zookeeper-3.8.2/bin/.../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Error contacting service. It is probably not running.
原因是防火墙没关:
shell复制代码
systemctl status firewalld
#● firewalld.service - firewalld - dynamic firewall daemon
# Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
# Active: active (running) since Sun 2023-08-27 19:48:04 CST; 2h 32min ago
# Docs: man:firewalld(1)
# Main PID: 649 (firewalld)
# CGroup: /system.slice/firewalld.service
# └─649 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
#
systemctl disable firewalld
[root@kafka_1 kafka_2.13-3.5.1]# ./bin/kafka-topics.sh --bootstrap-server kafka_1:9092,kafka_2:9092,kafka_3:9092 --create --topic topic01 --partitions 3 --replication-factor 3
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
Created topic topic01.
[root@kafka_1 kafka_2.13-3.5.1]# ./bin/kafka-topics.sh --bootstrap-server kafka_1:9092,kafka_2:9092,kafka_3:9092 --create --topic topic02 --partitions 3 --replication-factor 3
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
Created topic topic02.
[root@kafka_1 kafka_2.13-3.5.1]# ./bin/kafka-topics.sh --bootstrap-server kafka_1:9092,kafka_2:9092,kafka_3:9092 --list
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
topic01
topic02
[root@kafka_1 kafka_2.13-3.5.1]# ./bin/kafka-topics.sh --bootstrap-server kafka_1:9092,kafka_2:9092,kafka_3:9092 --describe --topic topic02
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: topic02 TopicId: _s44mBQqTLaSmVWcZA2GTw PartitionCount: 3 ReplicationFactor: 3 Configs:
Topic: topic02 Partition: 0 Leader: 2 Replicas: 2,0,1 Isr: 2,1
Topic: topic02 Partition: 1 Leader: 1 Replicas: 1,2,0 Isr: 1,2
Topic: topic02 Partition: 2 Leader: 0 Replicas: 0,1,2 Isr: 0,1,2
[root@kafka_1 kafka_2.13-3.5.1]# ./bin/kafka-topics.sh --bootstrap-server kafka_1:9092,kafka_2:9092,kafka_3:9092 --alter --topic topic02 --partitions 4
[root@kafka_1 kafka_2.13-3.5.1]# ./bin/kafka-topics.sh --bootstrap-server kafka_1:9092,kafka_2:9092,kafka_3:9092 --describe --topic topic02
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: topic02 TopicId: _s44mBQqTLaSmVWcZA2GTw PartitionCount: 4 ReplicationFactor: 3 Configs:
Topic: topic02 Partition: 0 Leader: 2 Replicas: 2,0,1 Isr: 2,1
Topic: topic02 Partition: 1 Leader: 1 Replicas: 1,2,0 Isr: 1,2
Topic: topic02 Partition: 2 Leader: 0 Replicas: 0,1,2 Isr: 0,1,2
Topic: topic02 Partition: 3 Leader: 2 Replicas: 2,1,0 Isr: 2,1
[root@kafka_1 kafka_2.13-3.5.1]# ./bin/kafka-topics.sh --bootstrap-server kafka_1:9092,kafka_2:9092,kafka_3:9092 --list
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
topic01
topic02
[root@kafka_1 kafka_2.13-3.5.1]# ./bin/kafka-topics.sh --bootstrap-server kafka_1:9092,kafka_2:9092,kafka_3:9092 --delete --topic topic02
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
[root@kafka_1 kafka_2.13-3.5.1]# ./bin/kafka-topics.sh --bootstrap-server kafka_1:9092,kafka_2:9092,kafka_3:9092 --list
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
topic01
---
# 生产者
[root@kafka_1 kafka_2.13-3.5.1]# ./bin/kafka-console-producer.sh --broker-list kafka_1:9092,kafka_2:9092,kafka_3:9092 --topic topic01
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
>123
>123
>key=123
>
# 消费者
[root@kafka_1 kafka_2.13-3.5.1]# ./bin/kafka-console-consumer.sh --bootstrap-server kafka_1:9092,kafka_2:9092,kafka_3:9092 --topic topic01 --group g1 --property print.key=true --property print.value=true --property key.separator=,
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
null,123
null,123
null,key=123