1.确保kafka服务端已经配置SASL/PLANTEXT ACL
2.确保kafka客户端与kafka服务端网络通
3.在kafka客户端在路径为…/kafka/config/下创建client.properties文件 修改producer.properties、consumer.properties
security.protocol=SASL_PLAINTEXT
sasl.mechanism=PLAIN
sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="fxaidsjcpydsjmdsssjjxfw" password="prodFxaidsjcpYdsjmdsssjjxfwkafka_2023";
4.远程连接kafka服务端并创建topic(ip为kafka服务端ip,以下执行程序为kafka安装目录)
./bin/kafka-topics.sh --create --topic test1102 --bootstrap-server ip1:port1,ip2:port2,ip3:port3 --partitions 3 --replication-factor 1 --command-config ./config/client.properties
5.远程连接kafka服务端并开启生产者
./bin/kafka-console-producer.sh --bootstrap-server ip1:port1,ip2:port2,ip3:port3 --topic test1102 --producer.config ./config/producer.properties
6.远程连接kafka服务端并开启消费者
./bin/kafka-console-consumer.sh --bootstrap-server ip1:port1,ip2:port2,ip3:port3 --topic test1102 --consumer.config ./config/consumer.properties
7.效果
创建topic
开启生产
开启消费