数据湖探索 DLI-MRS Kafka输出流:示例

时间:2024-11-16 13:21:40

示例

将数据输出到Kafka中。

  • 示例一
    1
    2
    3
    4
    5
    6
    7
    CREATE SINK STREAM kafka_sink (name STRING) 
      WITH (
        type="kafka",
        kafka_bootstrap_servers =  "ip1:port1,ip2:port2",
        kafka_topic = "testsink",
        encode = "json" 
      );
    
  • 示例二
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    CREATE SINK STREAM kafka_sink ( 
      a1 string,
      a2 string,
      a3 string,
      a4 INT
    ) // 输出字段
      WITH (
        type="kafka",
        kafka_bootstrap_servers =  "192.x.x.x:9093, 192.x.x.x:9093, 192.x.x.x:9093",
        kafka_topic = "testflink", // 写入的topic
        encode = "csv", // 编码格式,支持json/csv
        kafka_certificate_name = "Flink",
        kafka_properties_delimiter = ",",
        kafka_properties = "sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username=\"xxx\" password=\"xxx\";,sasl.mechanism=PLAIN,security.protocol=SASL_SSL"
      );
    
support.huaweicloud.com/sqlref-flink-dli/dli_08_0254.html