kafka_2.13-3.7.0 单机版安装

[root@localhost ~]# adduser kafka
[root@localhost ~]# password kafka
-bash: password: command not found
[root@localhost ~]# ls /home
jenkins  kafka  nacos
[root@localhost ~]# passwd kafka
Changing password for user kafka.
New password: 
BAD PASSWORD: The password is shorter than 8 characters
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@localhost ~]# 
[kafka@localhost ~]$ wget https://dlcdn.apache.org/kafka/3.7.0/kafka_2.13-3.7.0.tgz
--2024-04-28 17:17:00--  https://dlcdn.apache.org/kafka/3.7.0/kafka_2.13-3.7.0.tgz
Resolving dlcdn.apache.org (dlcdn.apache.org)... 151.101.2.132, 2a04:4e42::644
Connecting to dlcdn.apache.org (dlcdn.apache.org)|151.101.2.132|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 119028138 (114M) [application/x-gzip]
Saving to: ‘kafka_2.13-3.7.0.tgz’

100%[===============================================================================================================================>] 119,028,138 3.37MB/s   in 22s    

2024-04-28 17:17:22 (5.20 MB/s) - ‘kafka_2.13-3.7.0.tgz’ saved [119028138/119028138]

[kafka@localhost ~]$ 

[kafka@localhost kafka_2.13-3.7.0]$ KAFKA_CLUSTER_ID="$(bin/kafka-storage.sh random-uuid)"
[kafka@localhost kafka_2.13-3.7.0]$ bin/kafka-storage.sh format -t $KAFKA_CLUSTER_ID -c config/kraft/server.properties
metaPropertiesEnsemble=MetaPropertiesEnsemble(metadataLogDir=Optional.empty, dirs={/tmp/kraft-combined-logs: EMPTY})
Formatting /tmp/kraft-combined-logs with metadata.version 3.7-IV4.
[kafka@localhost kafka_2.13-3.7.0]$ 
# 启动kafka
[kafka@localhost kafka_2.13-3.7.0]$ bin/kafka-server-start.sh config/kraft/server.properties


#防火墙配置    
iptables -A INPUT -p tcp --dport 9092 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
iptables -I INPUT -p tcp --dport 25 -j ACCEPT

#spring-kafka 版本需要严格与spring-context 的一致
#不然会报KafkaTemplate 无法绑定,在 Maven Repository 中通过查找spring-kafka 依赖的spring-context版本来确定 spring-kafka的版本。


#create a topic 
$ bin/kafka-topics.sh --create --topic quickstart-events --bootstrap-server localhost:9092

#尝试在Windows上创建 测试生产者
D:\someusefultools\kafka\bin\windows>kafka-console-producer.bat --broker-list 192.168.1.90:9092 --topic hello_word_topic
>This is my second event!
>Windows is work!
>

$ bin/kafka-console-consumer.sh --topic quickstart-events --from-beginning --bootstrap-server localhost:9092

key-serializer=org.apache.kafka.common.serialization.StringSerializer
value-deserializer=org.apache.kafka.common.serialization.StringDeserializer

 

posted @ 2024-05-14 16:47  Alex-Zeng  阅读(68)  评论(0编辑  收藏  举报