测试Ubuntu Kafka配置效果可按以下步骤进行:
sudo systemctl status kafka和sudo systemctl status zookeeper确保服务正常运行。server.properties中broker.id、listeners、advertised.listeners、zookeeper.connect等关键配置是否正确。tail -f /var/log/kafka/server.log查看日志,确认无错误或异常信息。bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test。bin/kafka-topics.sh --list --zookeeper localhost:2181。bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test。bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning,确认能收到消息。ping和telnet确保Kafka端口(如9092)可达,且advertised.listeners配置正确。