1、实时写入Kafka可以参考阿里云官网链接,本次是记录解决使用Kafka另外两类接入点,默认为网络VPC
阿里云官网实操链接
2、SASL_SSL 配置记录
由于Flink默认没有提供公网访问的能力
1)想要打通首先需要通过这个方式打通网络
https://help.aliyun.com/zh/flink/support/faq-about-network-connectivity?spm=a2c4g.11174283.0.i2
2)在Kafka中新增用户
3)with中的配置
connector' = 'kafka'
,'properties.bootstrap.servers' = 'ip:port'
,'topic' = 'topic'
,'format' = 'json'
,'properties.enable.idempotence' = 'false'
,'properties.security.protocol' = 'SASL_SSL'
,'properties.ssl.truststore.location' = '/flink/usrlib/mix.4096.client.truststore.jks'
,'properties.ssl.endpoint.identification.algorithm' = ''
,'properties.sasl.mechanism' = 'SCRAM-SHA-256'
,'properties.sasl.jaas.config' = 'org.apache.flink.kafka.shaded.org.apache.kafka.common.security.scram.ScramLoginModule required username="username" password="password";'
官网文档链接
看完官网文档会发现,我写的配置会少几行
如果是使用了Flink提供的JKS,默认没有密码
4)上传资源包
5)在代码中引入依赖,不然依然会报错找不到jks
3、SASL_PLAINTEXT 配置记录
1)去Kafka中新增用户
2) 代码中增加配置
,'properties.security.protocol' = 'SASL_PLAINTEXT'
,'properties.sasl.mechanism' = 'PLAIN'
,'properties.sasl.jaas.config' = 'org.apache.flink.kafka.shaded.org.apache.kafka.common.security.plain.PlainLoginModule required username="username" password="password";'