forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Co-authored-by: Su, Xiaomeng <suxiaomeng1@huawei.com> Co-committed-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
697 lines
70 KiB
HTML
697 lines
70 KiB
HTML
<a name="dli_08_0386"></a><a name="dli_08_0386"></a>
|
|
|
|
<h1 class="topictitle1">Kafka Source Table</h1>
|
|
<div id="body8662426"><div class="section" id="dli_08_0386__en-us_topic_0000001310095781_dli_08_0237_en-us_topic_0111555123_section17358104193813"><h4 class="sectiontitle">Function</h4><p id="dli_08_0386__en-us_topic_0000001310095781_dli_08_0239_en-us_topic_0111499973_p18963184212118">Create a source stream to obtain data from Kafka as input data for jobs.</p>
|
|
<p id="dli_08_0386__en-us_topic_0000001310095781_dli_08_0239_en-us_topic_0111499973_p433435316341">Apache Kafka is a fast, scalable, and fault-tolerant distributed message publishing and subscription system. It delivers high throughput and built-in partitions and provides data replicas and fault tolerance. Apache Kafka is applicable to scenarios of handling massive messages.</p>
|
|
</div>
|
|
<div class="section" id="dli_08_0386__en-us_topic_0000001310095781_dli_08_0237_section1144171011544"><h4 class="sectiontitle">Prerequisites</h4><ul id="dli_08_0386__en-us_topic_0000001310095781_ul578517503176"><li id="dli_08_0386__en-us_topic_0000001310095781_li2785750141711">You have created a Kafka cluster.</li><li id="dli_08_0386__en-us_topic_0000001310095781_li1627119813515">An enhanced datasource connection has been created for DLI to connect to Kafka clusters, so that jobs can run on the dedicated queue of DLI and you can set the security group rules as required.
|
|
</li></ul>
|
|
</div>
|
|
<div class="section" id="dli_08_0386__en-us_topic_0000001310095781_section495615388216"><h4 class="sectiontitle">Precautions</h4><ul id="dli_08_0386__en-us_topic_0000001310095781_ul17647145194019"><li id="dli_08_0386__en-us_topic_0000001310095781_li6647155118407">When creating a Flink OpenSource SQL job, you need to set <strong id="dli_08_0386__en-us_topic_0000001310095781_b1896312284192">Flink Version</strong> to <strong id="dli_08_0386__en-us_topic_0000001310095781_b8963228171918">1.12</strong> on the <strong id="dli_08_0386__en-us_topic_0000001310095781_b4963142881915">Running Parameters</strong> tab of the job editing page, select <strong id="dli_08_0386__en-us_topic_0000001310095781_b99647285194">Save Job Log</strong>, and set the OBS bucket for saving job logs.</li><li id="dli_08_0386__en-us_topic_0000001310095781_li457192194611">For details about how to use data types when creating tables, see <a href="dli_08_0407.html#dli_08_0407">Format</a>.</li></ul>
|
|
</div>
|
|
<div class="section" id="dli_08_0386__en-us_topic_0000001310095781_dli_08_0237_en-us_topic_0111555123_section1832173783817"><h4 class="sectiontitle">Syntax</h4><div class="codecoloring" codetype="Sql" id="dli_08_0386__en-us_topic_0000001310095781_dli_08_0237_screen16634186122414"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal"> 1</span>
|
|
<span class="normal"> 2</span>
|
|
<span class="normal"> 3</span>
|
|
<span class="normal"> 4</span>
|
|
<span class="normal"> 5</span>
|
|
<span class="normal"> 6</span>
|
|
<span class="normal"> 7</span>
|
|
<span class="normal"> 8</span>
|
|
<span class="normal"> 9</span>
|
|
<span class="normal">10</span>
|
|
<span class="normal">11</span>
|
|
<span class="normal">12</span>
|
|
<span class="normal">13</span>
|
|
<span class="normal">14</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">create</span><span class="w"> </span><span class="k">table</span><span class="w"> </span><span class="n">kafkaSource</span><span class="p">(</span>
|
|
<span class="w"> </span><span class="n">attr_name</span><span class="w"> </span><span class="n">attr_type</span><span class="w"> </span>
|
|
<span class="w"> </span><span class="p">(</span><span class="s1">','</span><span class="w"> </span><span class="n">attr_name</span><span class="w"> </span><span class="n">attr_type</span><span class="p">)</span><span class="o">*</span><span class="w"> </span>
|
|
<span class="w"> </span><span class="p">(</span><span class="s1">','</span><span class="k">PRIMARY</span><span class="w"> </span><span class="k">KEY</span><span class="w"> </span><span class="p">(</span><span class="n">attr_name</span><span class="p">,</span><span class="w"> </span><span class="p">...)</span><span class="w"> </span><span class="k">NOT</span><span class="w"> </span><span class="n">ENFORCED</span><span class="p">)</span>
|
|
<span class="w"> </span><span class="p">(</span><span class="s1">','</span><span class="w"> </span><span class="n">WATERMARK</span><span class="w"> </span><span class="k">FOR</span><span class="w"> </span><span class="n">rowtime_column_name</span><span class="w"> </span><span class="k">AS</span><span class="w"> </span><span class="n">watermark</span><span class="o">-</span><span class="n">strategy_expression</span><span class="p">)</span>
|
|
<span class="p">)</span>
|
|
<span class="k">with</span><span class="w"> </span><span class="p">(</span>
|
|
<span class="w"> </span><span class="s1">'connector'</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'kafka'</span><span class="p">,</span>
|
|
<span class="w"> </span><span class="s1">'topic'</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">''</span><span class="p">,</span>
|
|
<span class="w"> </span><span class="s1">'properties.bootstrap.servers'</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">''</span><span class="p">,</span>
|
|
<span class="w"> </span><span class="s1">'properties.group.id'</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">''</span><span class="p">,</span>
|
|
<span class="w"> </span><span class="s1">'scan.startup.mode'</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">''</span><span class="p">,</span>
|
|
<span class="w"> </span><span class="s1">'format'</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">''</span>
|
|
<span class="p">);</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="section" id="dli_08_0386__en-us_topic_0000001310095781_section13754915155510"><h4 class="sectiontitle">Parameters</h4>
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dli_08_0386__en-us_topic_0000001310095781_table185541831102213" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Parameter description</caption><thead align="left"><tr id="dli_08_0386__en-us_topic_0000001310095781_row17554113122215"><th align="left" class="cellrowborder" valign="top" width="18%" id="mcps1.3.5.2.2.6.1.1"><p id="dli_08_0386__en-us_topic_0000001310095781_p19554231162219">Parameter</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="9.719999999999999%" id="mcps1.3.5.2.2.6.1.2"><p id="dli_08_0386__en-us_topic_0000001310095781_p85541931152210">Mandatory</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="9.139999999999999%" id="mcps1.3.5.2.2.6.1.3"><p id="dli_08_0386__en-us_topic_0000001310095781_p1355420315224">Default Value</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="11.559999999999999%" id="mcps1.3.5.2.2.6.1.4"><p id="dli_08_0386__en-us_topic_0000001310095781_p855443142218">Data Type</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="51.580000000000005%" id="mcps1.3.5.2.2.6.1.5"><p id="dli_08_0386__en-us_topic_0000001310095781_p1755423182218">Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="dli_08_0386__en-us_topic_0000001310095781_row12554203162212"><td class="cellrowborder" valign="top" width="18%" headers="mcps1.3.5.2.2.6.1.1 "><p id="dli_08_0386__en-us_topic_0000001310095781_p455415311227">connector</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.719999999999999%" headers="mcps1.3.5.2.2.6.1.2 "><p id="dli_08_0386__en-us_topic_0000001310095781_p105541431182216">Yes</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.139999999999999%" headers="mcps1.3.5.2.2.6.1.3 "><p id="dli_08_0386__en-us_topic_0000001310095781_p1751255011569">None</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="11.559999999999999%" headers="mcps1.3.5.2.2.6.1.4 "><p id="dli_08_0386__en-us_topic_0000001310095781_p1554143182210">String</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="51.580000000000005%" headers="mcps1.3.5.2.2.6.1.5 "><p id="dli_08_0386__en-us_topic_0000001310095781_p13554103162218">Connector to be used. Set this parameter to <strong id="dli_08_0386__en-us_topic_0000001310095781_b8680848172017">kafka</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0386__en-us_topic_0000001310095781_row7554123117224"><td class="cellrowborder" valign="top" width="18%" headers="mcps1.3.5.2.2.6.1.1 "><p id="dli_08_0386__en-us_topic_0000001310095781_p755433111222">topic</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.719999999999999%" headers="mcps1.3.5.2.2.6.1.2 "><p id="dli_08_0386__en-us_topic_0000001310095781_p12554133122219">Yes</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.139999999999999%" headers="mcps1.3.5.2.2.6.1.3 "><p id="dli_08_0386__en-us_topic_0000001310095781_p1355420312222">None</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="11.559999999999999%" headers="mcps1.3.5.2.2.6.1.4 "><p id="dli_08_0386__en-us_topic_0000001310095781_p1055483111222">String</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="51.580000000000005%" headers="mcps1.3.5.2.2.6.1.5 "><p id="dli_08_0386__en-us_topic_0000001310095781_p161095483019">Topic name of the Kafka record.</p>
|
|
<p id="dli_08_0386__en-us_topic_0000001310095781_p5178182619577">Note:</p>
|
|
<ul id="dli_08_0386__en-us_topic_0000001310095781_ul12833113410573"><li id="dli_08_0386__en-us_topic_0000001310095781_li1383323475712">Only one of <strong id="dli_08_0386__en-us_topic_0000001310095781_b12270115715228">topic</strong> and <strong id="dli_08_0386__en-us_topic_0000001310095781_b38669232310">topic-pattern</strong> can be specified.</li><li id="dli_08_0386__en-us_topic_0000001310095781_li991125516574">If there are multiple topics, separate them with semicolons (;), for example, <strong id="dli_08_0386__en-us_topic_0000001310095781_b1120495316232">topic-1;topic-2</strong>.</li></ul>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0386__en-us_topic_0000001310095781_row12554103122215"><td class="cellrowborder" valign="top" width="18%" headers="mcps1.3.5.2.2.6.1.1 "><p id="dli_08_0386__en-us_topic_0000001310095781_p17554731112214">topic-pattern</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.719999999999999%" headers="mcps1.3.5.2.2.6.1.2 "><p id="dli_08_0386__en-us_topic_0000001310095781_p355483132220">No</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.139999999999999%" headers="mcps1.3.5.2.2.6.1.3 "><p id="dli_08_0386__en-us_topic_0000001310095781_p012095655615">None</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="11.559999999999999%" headers="mcps1.3.5.2.2.6.1.4 "><p id="dli_08_0386__en-us_topic_0000001310095781_p455493116222">String</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="51.580000000000005%" headers="mcps1.3.5.2.2.6.1.5 "><p id="dli_08_0386__en-us_topic_0000001310095781_p415223719318">Regular expression for a pattern of topic names to read from.</p>
|
|
<p id="dli_08_0386__en-us_topic_0000001310095781_p1797018378534">Only one of <strong id="dli_08_0386__en-us_topic_0000001310095781_b54821482250">topic</strong> and <strong id="dli_08_0386__en-us_topic_0000001310095781_b114821148122517">topic-pattern</strong> can be specified.</p>
|
|
<p id="dli_08_0386__en-us_topic_0000001310095781_p193113117599">For example:</p>
|
|
<p id="dli_08_0386__en-us_topic_0000001310095781_p16915112317">'topic.*'</p>
|
|
<p id="dli_08_0386__en-us_topic_0000001310095781_p1915151183110">'(topic-c|topic-d)'</p>
|
|
<p id="dli_08_0386__en-us_topic_0000001310095781_p791581153114">'(topic-a|topic-b|topic-\\d*)'</p>
|
|
<p id="dli_08_0386__en-us_topic_0000001310095781_p10915171193115">'(topic-a|topic-b|topic-[0-9]*)'</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0386__en-us_topic_0000001310095781_row1855423122217"><td class="cellrowborder" valign="top" width="18%" headers="mcps1.3.5.2.2.6.1.1 "><p id="dli_08_0386__en-us_topic_0000001310095781_p6554113162211">properties.bootstrap.servers</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.719999999999999%" headers="mcps1.3.5.2.2.6.1.2 "><p id="dli_08_0386__en-us_topic_0000001310095781_p1554163122214">Yes</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.139999999999999%" headers="mcps1.3.5.2.2.6.1.3 "><p id="dli_08_0386__en-us_topic_0000001310095781_p10582657155610">None</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="11.559999999999999%" headers="mcps1.3.5.2.2.6.1.4 "><p id="dli_08_0386__en-us_topic_0000001310095781_p555473182217">String</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="51.580000000000005%" headers="mcps1.3.5.2.2.6.1.5 "><p id="dli_08_0386__en-us_topic_0000001310095781_p3554183182218">Comma separated list of Kafka brokers.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0386__en-us_topic_0000001310095781_row8554113119225"><td class="cellrowborder" valign="top" width="18%" headers="mcps1.3.5.2.2.6.1.1 "><p id="dli_08_0386__en-us_topic_0000001310095781_p955417319221">properties.group.id</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.719999999999999%" headers="mcps1.3.5.2.2.6.1.2 "><p id="dli_08_0386__en-us_topic_0000001310095781_p3554163112223">Yes</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.139999999999999%" headers="mcps1.3.5.2.2.6.1.3 "><p id="dli_08_0386__en-us_topic_0000001310095781_p10125155985617">None</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="11.559999999999999%" headers="mcps1.3.5.2.2.6.1.4 "><p id="dli_08_0386__en-us_topic_0000001310095781_p755493192210">String</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="51.580000000000005%" headers="mcps1.3.5.2.2.6.1.5 "><p id="dli_08_0386__en-us_topic_0000001310095781_p1455412319223">ID of the consumer group for the Kafka source.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0386__en-us_topic_0000001310095781_row18554113114228"><td class="cellrowborder" valign="top" width="18%" headers="mcps1.3.5.2.2.6.1.1 "><p id="dli_08_0386__en-us_topic_0000001310095781_p1755413314229">properties.*</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.719999999999999%" headers="mcps1.3.5.2.2.6.1.2 "><p id="dli_08_0386__en-us_topic_0000001310095781_p115541531182212">No</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.139999999999999%" headers="mcps1.3.5.2.2.6.1.3 "><p id="dli_08_0386__en-us_topic_0000001310095781_p35547318225">None</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="11.559999999999999%" headers="mcps1.3.5.2.2.6.1.4 "><p id="dli_08_0386__en-us_topic_0000001310095781_p10554113119225">String</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="51.580000000000005%" headers="mcps1.3.5.2.2.6.1.5 "><p id="dli_08_0386__en-us_topic_0000001310095781_p97929517327">This parameter can set and pass arbitrary Kafka configurations.</p>
|
|
<p id="dli_08_0386__en-us_topic_0000001310095781_p773119105325">Note:</p>
|
|
<ul id="dli_08_0386__en-us_topic_0000001310095781_ul0491787522"><li id="dli_08_0386__en-us_topic_0000001310095781_li199931630195813">The suffix to <strong id="dli_08_0386__en-us_topic_0000001310095781_b6340195692817">properties.</strong> must match the configuration key in <a href="https://kafka.apache.org/documentation/#configuration" target="_blank" rel="noopener noreferrer">Apache Kafka</a>.<p id="dli_08_0386__en-us_topic_0000001310095781_p948323185810">For example, you can disable automatic topic creation via <strong id="dli_08_0386__en-us_topic_0000001310095781_b15319142353015">'properties.</strong><strong id="dli_08_0386__en-us_topic_0000001310095781_b14799153201212">allow.auto.create.topics</strong><strong id="dli_08_0386__en-us_topic_0000001310095781_b23191023143015">' = 'false'</strong>.</p>
|
|
</li><li id="dli_08_0386__en-us_topic_0000001310095781_li1678319119157">Some configurations are not supported, for example, <strong id="dli_08_0386__en-us_topic_0000001310095781_b135041111113114">'key.deserializer'</strong> and <strong id="dli_08_0386__en-us_topic_0000001310095781_b1163810155314">'value.deserializer'</strong>.</li></ul>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0386__en-us_topic_0000001310095781_row4554123182211"><td class="cellrowborder" valign="top" width="18%" headers="mcps1.3.5.2.2.6.1.1 "><p id="dli_08_0386__en-us_topic_0000001310095781_p8554231182218">format</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.719999999999999%" headers="mcps1.3.5.2.2.6.1.2 "><p id="dli_08_0386__en-us_topic_0000001310095781_p855410313225">Yes</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.139999999999999%" headers="mcps1.3.5.2.2.6.1.3 "><p id="dli_08_0386__en-us_topic_0000001310095781_p155453112221">None</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="11.559999999999999%" headers="mcps1.3.5.2.2.6.1.4 "><p id="dli_08_0386__en-us_topic_0000001310095781_p65551531202220">String</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="51.580000000000005%" headers="mcps1.3.5.2.2.6.1.5 "><p id="dli_08_0386__en-us_topic_0000001310095781_p34676571032">Format used to deserialize and serialize the value part of Kafka messages. Note: Either this parameter or the <strong id="dli_08_0386__en-us_topic_0000001310095781_b7582102314323">value.format</strong> parameter is required.</p>
|
|
<p id="dli_08_0386__en-us_topic_0000001310095781_p1360104983714">Refer to <a href="dli_08_0407.html#dli_08_0407">Format</a> for more details and format parameters.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0386__en-us_topic_0000001310095781_row115558318229"><td class="cellrowborder" valign="top" width="18%" headers="mcps1.3.5.2.2.6.1.1 "><p id="dli_08_0386__en-us_topic_0000001310095781_p45551331122214">key.format</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.719999999999999%" headers="mcps1.3.5.2.2.6.1.2 "><p id="dli_08_0386__en-us_topic_0000001310095781_p1555593115225">No</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.139999999999999%" headers="mcps1.3.5.2.2.6.1.3 "><p id="dli_08_0386__en-us_topic_0000001310095781_p1685117175713">None</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="11.559999999999999%" headers="mcps1.3.5.2.2.6.1.4 "><p id="dli_08_0386__en-us_topic_0000001310095781_p1555831112210">String</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="51.580000000000005%" headers="mcps1.3.5.2.2.6.1.5 "><p id="dli_08_0386__en-us_topic_0000001310095781_p13344156135116">Format used to deserialize and serialize the key part of Kafka messages.</p>
|
|
<p id="dli_08_0386__en-us_topic_0000001310095781_p18697238193219">Note:</p>
|
|
<ul id="dli_08_0386__en-us_topic_0000001310095781_ul14125816519"><li id="dli_08_0386__en-us_topic_0000001310095781_li1812531195116">If a key format is defined, the <strong id="dli_08_0386__en-us_topic_0000001310095781_b93171558123417">key.fields</strong> parameter is required as well. Otherwise, the Kafka records will have an empty key.</li><li id="dli_08_0386__en-us_topic_0000001310095781_li134171651171711">Refer to <a href="dli_08_0407.html#dli_08_0407">Format</a> for more details and format parameters.</li></ul>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0386__en-us_topic_0000001310095781_row1055523142219"><td class="cellrowborder" valign="top" width="18%" headers="mcps1.3.5.2.2.6.1.1 "><p id="dli_08_0386__en-us_topic_0000001310095781_p65559316223">key.fields</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.719999999999999%" headers="mcps1.3.5.2.2.6.1.2 "><p id="dli_08_0386__en-us_topic_0000001310095781_p1955515318222">No</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.139999999999999%" headers="mcps1.3.5.2.2.6.1.3 "><p id="dli_08_0386__en-us_topic_0000001310095781_p1355515319223">[]</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="11.559999999999999%" headers="mcps1.3.5.2.2.6.1.4 "><p id="dli_08_0386__en-us_topic_0000001310095781_p155563192211">List<String></p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="51.580000000000005%" headers="mcps1.3.5.2.2.6.1.5 "><p id="dli_08_0386__en-us_topic_0000001310095781_p19922554193214">Defines the columns in the table as the list of keys. This parameter must be configured in pair with <strong id="dli_08_0386__en-us_topic_0000001310095781_b129184264010">key.format</strong>.</p>
|
|
<p id="dli_08_0386__en-us_topic_0000001310095781_p1675215518324">This parameter is left empty by default. Therefore, no key is defined.</p>
|
|
<p id="dli_08_0386__en-us_topic_0000001310095781_p1275275133218">The format is like <strong id="dli_08_0386__en-us_topic_0000001310095781_b1611318327411">field1;field2</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0386__en-us_topic_0000001310095781_row115557317227"><td class="cellrowborder" valign="top" width="18%" headers="mcps1.3.5.2.2.6.1.1 "><p id="dli_08_0386__en-us_topic_0000001310095781_p1555519310225">key.fields-prefix</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.719999999999999%" headers="mcps1.3.5.2.2.6.1.2 "><p id="dli_08_0386__en-us_topic_0000001310095781_p125552031152220">No</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.139999999999999%" headers="mcps1.3.5.2.2.6.1.3 "><p id="dli_08_0386__en-us_topic_0000001310095781_p1655523116225">None</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="11.559999999999999%" headers="mcps1.3.5.2.2.6.1.4 "><p id="dli_08_0386__en-us_topic_0000001310095781_p20555231112219">String</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="51.580000000000005%" headers="mcps1.3.5.2.2.6.1.5 "><p id="dli_08_0386__en-us_topic_0000001310095781_p1955593111223">Defines a custom prefix for all fields of the key format to avoid name clashes with fields of the value format.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0386__en-us_topic_0000001310095781_row1555133117226"><td class="cellrowborder" valign="top" width="18%" headers="mcps1.3.5.2.2.6.1.1 "><p id="dli_08_0386__en-us_topic_0000001310095781_p10555163112220">value.format</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.719999999999999%" headers="mcps1.3.5.2.2.6.1.2 "><p id="dli_08_0386__en-us_topic_0000001310095781_p1055593118223">Yes</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.139999999999999%" headers="mcps1.3.5.2.2.6.1.3 "><p id="dli_08_0386__en-us_topic_0000001310095781_p1892114128578">None</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="11.559999999999999%" headers="mcps1.3.5.2.2.6.1.4 "><p id="dli_08_0386__en-us_topic_0000001310095781_p7555193116229">String</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="51.580000000000005%" headers="mcps1.3.5.2.2.6.1.5 "><p id="dli_08_0386__en-us_topic_0000001310095781_p8314133141511">Format used to deserialize and serialize the value part of Kafka messages.</p>
|
|
<p id="dli_08_0386__en-us_topic_0000001310095781_p7555431122212">Note:</p>
|
|
<ul id="dli_08_0386__en-us_topic_0000001310095781_ul166571238111518"><li id="dli_08_0386__en-us_topic_0000001310095781_li667718114163">Either this parameter or the <strong id="dli_08_0386__en-us_topic_0000001310095781_b12120203424411">format</strong> parameter is required. If two parameters are configured, a conflict occurs.</li><li id="dli_08_0386__en-us_topic_0000001310095781_li7846255121711">Refer to <a href="dli_08_0407.html#dli_08_0407">Format</a> for more details and format parameters.</li></ul>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0386__en-us_topic_0000001310095781_row15555123102217"><td class="cellrowborder" valign="top" width="18%" headers="mcps1.3.5.2.2.6.1.1 "><p id="dli_08_0386__en-us_topic_0000001310095781_p145552031142215">value.fields-include</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.719999999999999%" headers="mcps1.3.5.2.2.6.1.2 "><p id="dli_08_0386__en-us_topic_0000001310095781_p1955503122213">No</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.139999999999999%" headers="mcps1.3.5.2.2.6.1.3 "><p id="dli_08_0386__en-us_topic_0000001310095781_p13555133172214">ALL</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="11.559999999999999%" headers="mcps1.3.5.2.2.6.1.4 "><p id="dli_08_0386__en-us_topic_0000001310095781_p134898438282">Enum</p>
|
|
<p id="dli_08_0386__en-us_topic_0000001310095781_p548954310282">Possible values: [ALL, EXCEPT_KEY]</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="51.580000000000005%" headers="mcps1.3.5.2.2.6.1.5 "><p id="dli_08_0386__en-us_topic_0000001310095781_p14555193120228">Whether to contain the key field when parsing the message body.</p>
|
|
<p id="dli_08_0386__en-us_topic_0000001310095781_p83061413192819">Possible values are:</p>
|
|
<ul id="dli_08_0386__en-us_topic_0000001310095781_ul133062136285"><li id="dli_08_0386__en-us_topic_0000001310095781_li63061713192810"><strong id="dli_08_0386__en-us_topic_0000001310095781_b11896639184919">ALL</strong> (default): All defined fields are included in the value of Kafka messages.</li><li id="dli_08_0386__en-us_topic_0000001310095781_li1430611132287"><strong id="dli_08_0386__en-us_topic_0000001310095781_b12592450916">EXCEPT_KEY</strong>: All the fields except those defined by <strong id="dli_08_0386__en-us_topic_0000001310095781_b512114291424">key.fields</strong> are included in the value of Kafka messages.</li></ul>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0386__en-us_topic_0000001310095781_row955523152217"><td class="cellrowborder" valign="top" width="18%" headers="mcps1.3.5.2.2.6.1.1 "><p id="dli_08_0386__en-us_topic_0000001310095781_p1555631202210">scan.startup.mode</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.719999999999999%" headers="mcps1.3.5.2.2.6.1.2 "><p id="dli_08_0386__en-us_topic_0000001310095781_p195551231142217">No</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.139999999999999%" headers="mcps1.3.5.2.2.6.1.3 "><p id="dli_08_0386__en-us_topic_0000001310095781_p20555431122219">group-offsets</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="11.559999999999999%" headers="mcps1.3.5.2.2.6.1.4 "><p id="dli_08_0386__en-us_topic_0000001310095781_p17555163112216">String</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="51.580000000000005%" headers="mcps1.3.5.2.2.6.1.5 "><p id="dli_08_0386__en-us_topic_0000001310095781_p1955515319224">Start position for Kafka to read data.</p>
|
|
<p id="dli_08_0386__en-us_topic_0000001310095781_p18140182923611">Possible values are:</p>
|
|
<ul id="dli_08_0386__en-us_topic_0000001310095781_ul1414013299363"><li id="dli_08_0386__en-us_topic_0000001310095781_li15140202914369"><strong id="dli_08_0386__en-us_topic_0000001310095781_b199876134519">earliest-offset</strong>: Data is read from the earliest Kafka offset.</li><li id="dli_08_0386__en-us_topic_0000001310095781_li2140029193615"><strong id="dli_08_0386__en-us_topic_0000001310095781_b128563391851">latest-offset</strong>: Data is read from the latest Kafka offset.</li><li id="dli_08_0386__en-us_topic_0000001310095781_li91401329193610"><strong id="dli_08_0386__en-us_topic_0000001310095781_b11669123813615">group-offsets</strong> (default): Data is read based on the consumer group.</li><li id="dli_08_0386__en-us_topic_0000001310095781_li1914032910365"><strong id="dli_08_0386__en-us_topic_0000001310095781_b76656221073">timestamp</strong>: Data is read from a user-supplied timestamp. When setting this option, you also need to specify <strong id="dli_08_0386__en-us_topic_0000001310095781_b93081154886">scan.startup.timestamp-millis</strong> in <strong id="dli_08_0386__en-us_topic_0000001310095781_b5343155515818">WITH</strong>.</li><li id="dli_08_0386__en-us_topic_0000001310095781_li1514052923611"><strong id="dli_08_0386__en-us_topic_0000001310095781_b204187138916">specific-offsets</strong>: Data is read from user-supplied specific offsets for each partition. When setting this option, you also need to specify <strong id="dli_08_0386__en-us_topic_0000001310095781_b89991841191013">scan.startup.specific-offsets</strong> in <strong id="dli_08_0386__en-us_topic_0000001310095781_b1689513421107">WITH</strong>.</li></ul>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0386__en-us_topic_0000001310095781_row455511315228"><td class="cellrowborder" valign="top" width="18%" headers="mcps1.3.5.2.2.6.1.1 "><p id="dli_08_0386__en-us_topic_0000001310095781_p455573192210">scan.startup.specific-offsets</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.719999999999999%" headers="mcps1.3.5.2.2.6.1.2 "><p id="dli_08_0386__en-us_topic_0000001310095781_p135551031102218">No</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.139999999999999%" headers="mcps1.3.5.2.2.6.1.3 "><p id="dli_08_0386__en-us_topic_0000001310095781_p32321118175714">None</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="11.559999999999999%" headers="mcps1.3.5.2.2.6.1.4 "><p id="dli_08_0386__en-us_topic_0000001310095781_p7555133192215">String</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="51.580000000000005%" headers="mcps1.3.5.2.2.6.1.5 "><p id="dli_08_0386__en-us_topic_0000001310095781_p386918723611">This parameter takes effect only when <strong id="dli_08_0386__en-us_topic_0000001310095781_b2707151314119">scan.startup.mode</strong> is set to <strong id="dli_08_0386__en-us_topic_0000001310095781_b25461916171110">specific-offsets</strong>. It specifies the offsets for each partition, for example, <strong id="dli_08_0386__en-us_topic_0000001310095781_b1554333412110">partition:0,offset:42;partition:1,offset:300</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0386__en-us_topic_0000001310095781_row7555193113226"><td class="cellrowborder" valign="top" width="18%" headers="mcps1.3.5.2.2.6.1.1 "><p id="dli_08_0386__en-us_topic_0000001310095781_p12555531162219">scan.startup.timestamp-millis</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.719999999999999%" headers="mcps1.3.5.2.2.6.1.2 "><p id="dli_08_0386__en-us_topic_0000001310095781_p175551312226">No</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.139999999999999%" headers="mcps1.3.5.2.2.6.1.3 "><p id="dli_08_0386__en-us_topic_0000001310095781_p7668191985713">None</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="11.559999999999999%" headers="mcps1.3.5.2.2.6.1.4 "><p id="dli_08_0386__en-us_topic_0000001310095781_p19555173122215">Long</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="51.580000000000005%" headers="mcps1.3.5.2.2.6.1.5 "><p id="dli_08_0386__en-us_topic_0000001310095781_p1425614893714">Startup timestamp. This parameter takes effect when <strong id="dli_08_0386__en-us_topic_0000001310095781_b15710916111314">scan.startup.mode</strong> is set to <strong id="dli_08_0386__en-us_topic_0000001310095781_b840292010131">timestamp</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0386__en-us_topic_0000001310095781_row1955512313223"><td class="cellrowborder" valign="top" width="18%" headers="mcps1.3.5.2.2.6.1.1 "><p id="dli_08_0386__en-us_topic_0000001310095781_p8555193162211">scan.topic-partition-discovery.interval</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.719999999999999%" headers="mcps1.3.5.2.2.6.1.2 "><p id="dli_08_0386__en-us_topic_0000001310095781_p17555103120224">No</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.139999999999999%" headers="mcps1.3.5.2.2.6.1.3 "><p id="dli_08_0386__en-us_topic_0000001310095781_p11997142095710">None</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="11.559999999999999%" headers="mcps1.3.5.2.2.6.1.4 "><p id="dli_08_0386__en-us_topic_0000001310095781_p055553115229">Duration</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="51.580000000000005%" headers="mcps1.3.5.2.2.6.1.5 "><p id="dli_08_0386__en-us_topic_0000001310095781_p1355543119227">Interval for a consumer to periodically discover dynamically created Kafka topics and partitions.</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="dli_08_0386__en-us_topic_0000001310095781_section83771218194120"><h4 class="sectiontitle">Metadata Column</h4><p id="dli_08_0386__en-us_topic_0000001310095781_p1631183325318">You can define metadata columns in the source table to obtain the metadata of Kafka messages. For example, if multiple topics are defined in the <strong id="dli_08_0386__en-us_topic_0000001310095781_b184194421169">WITH</strong> parameter and the metadata column is defined in the Kafka source table, the data read by Flink is labeled with the topic from which the data is read.</p>
|
|
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dli_08_0386__en-us_topic_0000001310095781_table7595115635314" frame="border" border="1" rules="all"><caption><b>Table 2 </b>Metadata column</caption><thead align="left"><tr id="dli_08_0386__en-us_topic_0000001310095781_row55955561539"><th align="left" class="cellrowborder" valign="top" width="17.41%" id="mcps1.3.6.3.2.5.1.1"><p id="dli_08_0386__en-us_topic_0000001310095781_p14595556115317">Key</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="36.27%" id="mcps1.3.6.3.2.5.1.2"><p id="dli_08_0386__en-us_topic_0000001310095781_p5595175612539">Data Type</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="16.34%" id="mcps1.3.6.3.2.5.1.3"><p id="dli_08_0386__en-us_topic_0000001310095781_p1859585655319">R/W</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="29.98%" id="mcps1.3.6.3.2.5.1.4"><p id="dli_08_0386__en-us_topic_0000001310095781_p145953563537">Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="dli_08_0386__en-us_topic_0000001310095781_row18595156115315"><td class="cellrowborder" valign="top" width="17.41%" headers="mcps1.3.6.3.2.5.1.1 "><p id="dli_08_0386__en-us_topic_0000001310095781_p9595956145318">topic</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.3.6.3.2.5.1.2 "><p id="dli_08_0386__en-us_topic_0000001310095781_p1259516563534">STRING NOT NULL</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="16.34%" headers="mcps1.3.6.3.2.5.1.3 "><p id="dli_08_0386__en-us_topic_0000001310095781_p75957563538">R</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="29.98%" headers="mcps1.3.6.3.2.5.1.4 "><p id="dli_08_0386__en-us_topic_0000001310095781_p45952566535">Topic name of the Kafka record.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0386__en-us_topic_0000001310095781_row115951156165312"><td class="cellrowborder" valign="top" width="17.41%" headers="mcps1.3.6.3.2.5.1.1 "><p id="dli_08_0386__en-us_topic_0000001310095781_p135951456165320">partition</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.3.6.3.2.5.1.2 "><p id="dli_08_0386__en-us_topic_0000001310095781_p15595135615538">INT NOT NULL</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="16.34%" headers="mcps1.3.6.3.2.5.1.3 "><p id="dli_08_0386__en-us_topic_0000001310095781_p95951956115313">R</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="29.98%" headers="mcps1.3.6.3.2.5.1.4 "><p id="dli_08_0386__en-us_topic_0000001310095781_p259517562538">Partition ID of the Kafka record.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0386__en-us_topic_0000001310095781_row1159585620531"><td class="cellrowborder" valign="top" width="17.41%" headers="mcps1.3.6.3.2.5.1.1 "><p id="dli_08_0386__en-us_topic_0000001310095781_p5595456185315">headers</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.3.6.3.2.5.1.2 "><p id="dli_08_0386__en-us_topic_0000001310095781_p2059525635313">MAP<STRING, BYTES> NOT NULL</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="16.34%" headers="mcps1.3.6.3.2.5.1.3 "><p id="dli_08_0386__en-us_topic_0000001310095781_p17595756185319">R/W</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="29.98%" headers="mcps1.3.6.3.2.5.1.4 "><p id="dli_08_0386__en-us_topic_0000001310095781_p10595256195320">Headers of Kafka messages.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0386__en-us_topic_0000001310095781_row124337451411"><td class="cellrowborder" valign="top" width="17.41%" headers="mcps1.3.6.3.2.5.1.1 "><p id="dli_08_0386__en-us_topic_0000001310095781_p194331145447">leader-epoch</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.3.6.3.2.5.1.2 "><p id="dli_08_0386__en-us_topic_0000001310095781_p6433445644">INT NULL</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="16.34%" headers="mcps1.3.6.3.2.5.1.3 "><p id="dli_08_0386__en-us_topic_0000001310095781_p104334451643">R</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="29.98%" headers="mcps1.3.6.3.2.5.1.4 "><p id="dli_08_0386__en-us_topic_0000001310095781_p114331745346">Leader epoch of the Kafka record.</p>
|
|
<p id="dli_08_0386__en-us_topic_0000001310095781_p1139516254610"><a href="#dli_08_0386__en-us_topic_0000001310095781_li47891356134710">For details, see example 1.</a></p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0386__en-us_topic_0000001310095781_row859520562533"><td class="cellrowborder" valign="top" width="17.41%" headers="mcps1.3.6.3.2.5.1.1 "><p id="dli_08_0386__en-us_topic_0000001310095781_p759518566538">offset</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.3.6.3.2.5.1.2 "><p id="dli_08_0386__en-us_topic_0000001310095781_p459515569535">BIGINT NOT NULL</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="16.34%" headers="mcps1.3.6.3.2.5.1.3 "><p id="dli_08_0386__en-us_topic_0000001310095781_p1959565625311">R</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="29.98%" headers="mcps1.3.6.3.2.5.1.4 "><p id="dli_08_0386__en-us_topic_0000001310095781_p659517566534">Offset of the Kafka record.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0386__en-us_topic_0000001310095781_row1859516567535"><td class="cellrowborder" valign="top" width="17.41%" headers="mcps1.3.6.3.2.5.1.1 "><p id="dli_08_0386__en-us_topic_0000001310095781_p15959563532">timestamp</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.3.6.3.2.5.1.2 "><p id="dli_08_0386__en-us_topic_0000001310095781_p6595125619532">TIMESTAMP(3) WITH LOCAL TIME ZONE NOT NULL</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="16.34%" headers="mcps1.3.6.3.2.5.1.3 "><p id="dli_08_0386__en-us_topic_0000001310095781_p3595256145317">R/W</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="29.98%" headers="mcps1.3.6.3.2.5.1.4 "><p id="dli_08_0386__en-us_topic_0000001310095781_p135958561531">Timestamp of the Kafka record.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0386__en-us_topic_0000001310095781_row51111649345"><td class="cellrowborder" valign="top" width="17.41%" headers="mcps1.3.6.3.2.5.1.1 "><p id="dli_08_0386__en-us_topic_0000001310095781_p211119493420">timestamp-type</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.3.6.3.2.5.1.2 "><p id="dli_08_0386__en-us_topic_0000001310095781_p1511110491244">STRING NOT NULL</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="16.34%" headers="mcps1.3.6.3.2.5.1.3 "><p id="dli_08_0386__en-us_topic_0000001310095781_p811111495410">R</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="29.98%" headers="mcps1.3.6.3.2.5.1.4 "><p id="dli_08_0386__en-us_topic_0000001310095781_p1412210418512">Timestamp type of the Kafka record. The options are as follows:</p>
|
|
<ul id="dli_08_0386__en-us_topic_0000001310095781_ul712284110514"><li id="dli_08_0386__en-us_topic_0000001310095781_li161223411955"><strong id="dli_08_0386__en-us_topic_0000001310095781_b8410430234">NoTimestampType</strong>: No timestamp is defined in the message.</li><li id="dli_08_0386__en-us_topic_0000001310095781_li2122144116514"><strong id="dli_08_0386__en-us_topic_0000001310095781_b75591282319">CreateTime</strong>: time when the message is generated.</li><li id="dli_08_0386__en-us_topic_0000001310095781_li4995445465"><strong id="dli_08_0386__en-us_topic_0000001310095781_b460013247235">LogAppendTime</strong>: time when the message is added to the Kafka broker.<p id="dli_08_0386__en-us_topic_0000001310095781_p2086514495615"><a href="#dli_08_0386__en-us_topic_0000001310095781_li47891356134710">For details, see example 1.</a></p>
|
|
</li></ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="dli_08_0386__en-us_topic_0000001310095781_dli_08_0237_section11421328152716"><h4 class="sectiontitle">Example (SASL_SSL Disabled for the Kafka Cluster)</h4><ul id="dli_08_0386__en-us_topic_0000001310095781_ul11789356184715"><li id="dli_08_0386__en-us_topic_0000001310095781_li47891356134710"><a name="dli_08_0386__en-us_topic_0000001310095781_li47891356134710"></a><a name="en-us_topic_0000001310095781_li47891356134710"></a><strong id="dli_08_0386__en-us_topic_0000001310095781_b20246548132311">Example 1</strong><strong id="dli_08_0386__en-us_topic_0000001310095781_b742735718388">: Read data from the Kafka metadata column and write it to the Print sink.</strong><ol id="dli_08_0386__en-us_topic_0000001310095781_ol14771132475"><li id="dli_08_0386__en-us_topic_0000001310095781_li6127741153217">Create an enhanced datasource connection in the VPC and subnet where Kafka locates, and bind the connection to the required Flink elastic resource pool.</li><li id="dli_08_0386__en-us_topic_0000001310095781_li1233002211514">Set Kafka security groups and add inbound rules to allow access from the Flink queue. Test the connectivity using the Kafka address. If the connection is successful, the datasource is bound to the queue. Otherwise, the binding fails.</li><li id="dli_08_0386__en-us_topic_0000001310095781_li1077111334713">Create a Flink OpenSource SQL job. Enter the following job script and submit the job.<div class="p" id="dli_08_0386__en-us_topic_0000001310095781_p39352912333"><a name="dli_08_0386__en-us_topic_0000001310095781_li1077111334713"></a><a name="en-us_topic_0000001310095781_li1077111334713"></a>When you create a job, set <strong id="dli_08_0386__en-us_topic_0000001310095781_b103739615263">Flink Version</strong> to <strong id="dli_08_0386__en-us_topic_0000001310095781_b1637416622619">1.12</strong> on the <strong id="dli_08_0386__en-us_topic_0000001310095781_b14374163268">Running Parameters</strong> tab. Select <strong id="dli_08_0386__en-us_topic_0000001310095781_b33744692617">Save Job Log</strong>, and specify the OBS bucket for saving job logs. <strong id="dli_08_0386__en-us_topic_0000001310095781_b134883912618">Change the values of the parameters in bold as needed in the following script.</strong><pre class="screen" id="dli_08_0386__en-us_topic_0000001310095781_screen73275223261">CREATE TABLE orders (
|
|
`topic` String metadata,
|
|
`partition` int metadata,
|
|
`headers` MAP<STRING, BYTES> metadata,
|
|
`leaderEpoch` INT metadata from 'leader-epoch',
|
|
`offset` bigint metadata,
|
|
`timestamp` TIMESTAMP(3) metadata,
|
|
`timestampType` string metadata from 'timestamp-type',
|
|
`message` string
|
|
) WITH (
|
|
'connector' = 'kafka',
|
|
'topic' = '<em id="dli_08_0386__en-us_topic_0000001310095781_i4543155265320"><strong id="dli_08_0386__en-us_topic_0000001310095781_b1754316528535">Kafka</strong></em><em id="dli_08_0386__en-us_topic_0000001310095781_i15341759195319"><strong id="dli_08_0386__en-us_topic_0000001310095781_b5227105913538">Topic</strong></em>',
|
|
'properties.bootstrap.servers' = '<em id="dli_08_0386__en-us_topic_0000001310095781_i9319103215313"><strong id="dli_08_0386__en-us_topic_0000001310095781_b0322115133213">KafkaAddress1:KafkaPort,KafkaAddress2:KafkaPort</strong></em>',
|
|
'properties.group.id' = '<em id="dli_08_0386__en-us_topic_0000001310095781_i14535174011311"><strong id="dli_08_0386__en-us_topic_0000001310095781_b1466610178329">GroupId</strong></em>',
|
|
'scan.startup.mode' = 'latest-offset',
|
|
"format" = "csv",
|
|
"csv.field-delimiter" = "\u0001",
|
|
"csv.quote-character" = "''"
|
|
);
|
|
|
|
CREATE TABLE printSink (
|
|
`topic` String,
|
|
`partition` int,
|
|
`headers` MAP<STRING, BYTES>,
|
|
`leaderEpoch` INT,
|
|
`offset` bigint,
|
|
`timestamp` TIMESTAMP(3),
|
|
`timestampType` string,
|
|
`message` string -- Indicates that data written by users is read from Kafka.
|
|
) WITH (
|
|
'connector' = 'print'
|
|
);
|
|
|
|
insert into printSink select * from orders;</pre>
|
|
</div>
|
|
<p id="dli_08_0386__en-us_topic_0000001310095781_p173274224263">If you need to read the value of each field instead of the entire message, use the following statements:</p>
|
|
<pre class="screen" id="dli_08_0386__en-us_topic_0000001310095781_screen5327102242618">CREATE TABLE orders (
|
|
`topic` String metadata,
|
|
`partition` int metadata,
|
|
`headers` MAP<STRING, BYTES> metadata,
|
|
`leaderEpoch` INT metadata from 'leader-epoch',
|
|
`offset` bigint metadata,
|
|
`timestamp` TIMESTAMP(3) metadata,
|
|
`timestampType` string metadata from 'timestamp-type',
|
|
order_id string,
|
|
order_channel string,
|
|
order_time string,
|
|
pay_amount double,
|
|
real_pay double,
|
|
pay_time string,
|
|
user_id string,
|
|
user_name string,
|
|
area_id string
|
|
) WITH (
|
|
'connector' = 'kafka',
|
|
'topic' = '<yourTopic>',
|
|
'properties.bootstrap.servers' = '<em id="dli_08_0386__en-us_topic_0000001310095781_i1127101053010"><strong id="dli_08_0386__en-us_topic_0000001310095781_b1134372418327">KafkaAddress1:KafkaPort,KafkaAddress2:KafkaPort</strong></em>',
|
|
'properties.group.id' = '<em id="dli_08_0386__en-us_topic_0000001310095781_i2834203093018"><strong id="dli_08_0386__en-us_topic_0000001310095781_b161961126193216">GroupId</strong></em>',
|
|
'scan.startup.mode' = 'latest-offset',
|
|
"format" = "json"
|
|
);
|
|
|
|
CREATE TABLE printSink (
|
|
`topic` String,
|
|
`partition` int,
|
|
`headers` MAP<STRING, BYTES>,
|
|
`leaderEpoch` INT,
|
|
`offset` bigint,
|
|
`timestamp` TIMESTAMP(3),
|
|
`timestampType` string,
|
|
order_id string,
|
|
order_channel string,
|
|
order_time string,
|
|
pay_amount double,
|
|
real_pay double,
|
|
pay_time string,
|
|
user_id string,
|
|
user_name string,
|
|
area_id string
|
|
) WITH (
|
|
'connector' = 'print'
|
|
);
|
|
|
|
insert into printSink select * from orders;</pre>
|
|
</li><li id="dli_08_0386__en-us_topic_0000001310095781_li1477116316472">Send the following data to the corresponding topics in Kafka:<pre class="screen" id="dli_08_0386__en-us_topic_0000001310095781_screen29631127162115">{"order_id":"202103241000000001", "order_channel":"webShop", "order_time":"2021-03-24 10:00:00", "pay_amount":"100.00", "real_pay":"100.00", "pay_time":"2021-03-24 10:02:03", "user_id":"0001", "user_name":"Alice", "area_id":"330106"}
|
|
|
|
{"order_id":"202103241606060001", "order_channel":"appShop", "order_time":"2021-03-24 16:06:06", "pay_amount":"200.00", "real_pay":"180.00", "pay_time":"2021-03-24 16:10:06", "user_id":"0001", "user_name":"Alice", "area_id":"330106"}
|
|
|
|
{"order_id":"202103251202020001", "order_channel":"miniAppShop", "order_time":"2021-03-25 12:02:02", "pay_amount":"60.00", "real_pay":"60.00", "pay_time":"2021-03-25 12:03:00", "user_id":"0002", "user_name":"Bob", "area_id":"330110"}</pre>
|
|
</li><li id="dli_08_0386__en-us_topic_0000001310095781_li1077115324719">Perform the following operations to view the output:<ol type="a" id="dli_08_0386__en-us_topic_0000001310095781_ol2309701380"><li id="dli_08_0386__en-us_topic_0000001310095781_li1830911016384">Log in to the DLI console. In the navigation pane, choose <strong id="dli_08_0386__en-us_topic_0000001310095781_b1086914323296">Job Management</strong> > <strong id="dli_08_0386__en-us_topic_0000001310095781_b118705328291">Flink Jobs</strong>.</li><li id="dli_08_0386__en-us_topic_0000001310095781_li63092033817">Click the name of the corresponding Flink job, choose <strong id="dli_08_0386__en-us_topic_0000001310095781_b648623672912">Run Log</strong>, click <strong id="dli_08_0386__en-us_topic_0000001310095781_b848683619293">OBS Bucket</strong>, and locate the folder of the log you want to view according to the date.</li><li id="dli_08_0386__en-us_topic_0000001310095781_li1630917010386">Go to the folder of the date, find the folder whose name contains <strong id="dli_08_0386__en-us_topic_0000001310095781_b0961164772916">taskmanager</strong>, download the <strong id="dli_08_0386__en-us_topic_0000001310095781_b89621647102920">taskmanager.out</strong> file, and view result logs.</li></ol>
|
|
<p id="dli_08_0386__en-us_topic_0000001310095781_p175994152383">The data result is as follows:</p>
|
|
<pre class="screen" id="dli_08_0386__en-us_topic_0000001310095781_screen3907125312210">+I(fz-source-json,0,{},0,243,2021-12-27T09:23:32.253,CreateTime,{"order_id":"202103241000000001", "order_channel":"webShop", "order_time":"2021-03-24 10:00:00", "pay_amount":"100.00", "real_pay":"100.00", "pay_time":"2021-03-24 10:02:03", "user_id":"0001", "user_name":"Alice", "area_id":"330106"})
|
|
+I(fz-source-json,0,{},0,244,2021-12-27T09:23:39.655,CreateTime,{"order_id":"202103241606060001", "order_channel":"appShop", "order_time":"2021-03-24 16:06:06", "pay_amount":"200.00", "real_pay":"180.00", "pay_time":"2021-03-24 16:10:06", "user_id":"0001", "user_name":"Alice", "area_id":"330106"})
|
|
+I(fz-source-json,0,{},0,245,2021-12-27T09:23:48.405,CreateTime,{"order_id":"202103251202020001", "order_channel":"miniAppShop", "order_time":"2021-03-25 12:02:02", "pay_amount":"60.00", "real_pay":"60.00", "pay_time":"2021-03-25 12:03:00", "user_id":"0002", "user_name":"Bob", "area_id":"330110"})</pre>
|
|
</li></ol>
|
|
<p id="dli_08_0386__en-us_topic_0000001310095781_p10841142053518"></p>
|
|
</li><li id="dli_08_0386__en-us_topic_0000001310095781_li33352014164810"><strong id="dli_08_0386__en-us_topic_0000001310095781_b93041603012">Example 2</strong><strong id="dli_08_0386__en-us_topic_0000001310095781_b616011143920">: Use the Kafka source table and Print result table to read JSON data from Kafka and output it to the log file.</strong><ol id="dli_08_0386__en-us_topic_0000001310095781_ol17226191620486"><li id="dli_08_0386__en-us_topic_0000001310095781_li10278194718557">Create an enhanced datasource connection in the VPC and subnet where Kafka locates, and bind the connection to the required Flink elastic resource pool.</li><li id="dli_08_0386__en-us_topic_0000001310095781_li182781747185517">Set Kafka security groups and add inbound rules to allow access from the Flink queue. Test the connectivity using the Kafka address. If the connection is successful, the datasource is bound to the queue. Otherwise, the binding fails.</li><li id="dli_08_0386__en-us_topic_0000001310095781_li722618161489">Create a Flink OpenSource SQL job. Enter the following job script and submit the job.<div class="p" id="dli_08_0386__en-us_topic_0000001310095781_p1790134833214"><a name="dli_08_0386__en-us_topic_0000001310095781_li722618161489"></a><a name="en-us_topic_0000001310095781_li722618161489"></a>When you create a job, set <strong id="dli_08_0386__en-us_topic_0000001310095781_b33262048113214">Flink Version</strong> to <strong id="dli_08_0386__en-us_topic_0000001310095781_b183276484322">1.12</strong> on the <strong id="dli_08_0386__en-us_topic_0000001310095781_b2032784819324">Running Parameters</strong> tab. Select <strong id="dli_08_0386__en-us_topic_0000001310095781_b143288486328">Save Job Log</strong>, and specify the OBS bucket for saving job logs. <strong id="dli_08_0386__en-us_topic_0000001310095781_b1792775123219">Change the values of the parameters in bold as needed in the following script.</strong><pre class="screen" id="dli_08_0386__en-us_topic_0000001310095781_screen116021338175619">CREATE TABLE orders (
|
|
order_id string,
|
|
order_channel string,
|
|
order_time timestamp(3),
|
|
pay_amount double,
|
|
real_pay double,
|
|
pay_time string,
|
|
user_id string,
|
|
user_name string,
|
|
area_id string
|
|
) WITH (
|
|
'connector' = 'kafka',
|
|
'topic' = '<yourTopic>',
|
|
'properties.bootstrap.servers' = '<em id="dli_08_0386__en-us_topic_0000001310095781_i10585155318568"><strong id="dli_08_0386__en-us_topic_0000001310095781_b6585753175619">KafkaAddress1:KafkaPort,KafkaAddress2:KafkaPort</strong></em>',
|
|
'properties.group.id' = '<em id="dli_08_0386__en-us_topic_0000001310095781_i865010865712"><strong id="dli_08_0386__en-us_topic_0000001310095781_b206500815574">GroupId</strong></em>',
|
|
'scan.startup.mode' = 'latest-offset',
|
|
"format" = "json"
|
|
);
|
|
|
|
CREATE TABLE printSink (
|
|
order_id string,
|
|
order_channel string,
|
|
order_time timestamp(3),
|
|
pay_amount double,
|
|
real_pay double,
|
|
pay_time string,
|
|
user_id string,
|
|
user_name string,
|
|
area_id string
|
|
) WITH (
|
|
'connector' = 'print'
|
|
);
|
|
|
|
insert into printSink select * from orders;</pre>
|
|
</div>
|
|
</li><li id="dli_08_0386__en-us_topic_0000001310095781_li3226161674814">Send the following test data to the corresponding topics in Kafka:<pre class="screen" id="dli_08_0386__en-us_topic_0000001310095781_screen16679723173112">{"order_id":"202103241000000001", "order_channel":"webShop", "order_time":"2021-03-24 10:00:00", "pay_amount":"100.00", "real_pay":"100.00", "pay_time":"2021-03-24 10:02:03", "user_id":"0001", "user_name":"Alice", "area_id":"330106"}
|
|
|
|
{"order_id":"202103241606060001", "order_channel":"appShop", "order_time":"2021-03-24 16:06:06", "pay_amount":"200.00", "real_pay":"180.00", "pay_time":"2021-03-24 16:10:06", "user_id":"0001", "user_name":"Alice", "area_id":"330106"}
|
|
|
|
{"order_id":"202103251202020001", "order_channel":"miniAppShop", "order_time":"2021-03-25 12:02:02", "pay_amount":"60.00", "real_pay":"60.00", "pay_time":"2021-03-25 12:03:00", "user_id":"0002", "user_name":"Bob", "area_id":"330110"}</pre>
|
|
</li><li id="dli_08_0386__en-us_topic_0000001310095781_li72262162488">Perform the following operations to view the output:<ol type="a" id="dli_08_0386__en-us_topic_0000001310095781_ol864115198285"><li id="dli_08_0386__en-us_topic_0000001310095781_li10901621122819">Log in to the DLI console. In the navigation pane, choose <strong id="dli_08_0386__en-us_topic_0000001310095781_b6396127203312">Job Management</strong> > <strong id="dli_08_0386__en-us_topic_0000001310095781_b183971627163319">Flink Jobs</strong>.</li><li id="dli_08_0386__en-us_topic_0000001310095781_li1912163912282">Click the name of the corresponding Flink job, choose <strong id="dli_08_0386__en-us_topic_0000001310095781_b181106294336">Run Log</strong>, click <strong id="dli_08_0386__en-us_topic_0000001310095781_b101115296332">OBS Bucket</strong>, and locate the folder of the log you want to view according to the date.</li><li id="dli_08_0386__en-us_topic_0000001310095781_li0641191914285">Go to the folder of the date, find the folder whose name contains <strong id="dli_08_0386__en-us_topic_0000001310095781_b1264531153319">taskmanager</strong>, download the <strong id="dli_08_0386__en-us_topic_0000001310095781_b1626473123314">taskmanager.out</strong> file, and view result logs.</li></ol>
|
|
<p id="dli_08_0386__en-us_topic_0000001310095781_p211811587353">The data result is as follows:</p>
|
|
<pre class="screen" id="dli_08_0386__en-us_topic_0000001310095781_screen24791121123516">+I(202103241000000001,webShop,2021-03-24T10:00,100.0,100.0,2021-03-2410:02:03,0001,Alice,330106)
|
|
+I(202103241606060001,appShop,2021-03-24T16:06:06,200.0,180.0,2021-03-2416:10:06,0001,Alice,330106)
|
|
+I(202103251202020001,miniAppShop,2021-03-25T12:02:02,60.0,60.0,2021-03-2512:03:00,0002,Bob,330110)</pre>
|
|
</li></ol>
|
|
</li></ul>
|
|
</div>
|
|
<div class="section" id="dli_08_0386__en-us_topic_0000001310095781_section1376121165311"><h4 class="sectiontitle">Example (SASL_SSL Enabled for the Kafka Cluster)</h4><ul id="dli_08_0386__en-us_topic_0000001310095781_ul165787314155"><li id="dli_08_0386__en-us_topic_0000001310095781_li157853171516"><strong id="dli_08_0386__en-us_topic_0000001310095781_b1615142615405">Example 1: Enable SASL_SSL authentication for the DMS cluster.</strong><p id="dli_08_0386__en-us_topic_0000001310095781_p48839353813">Create a Kafka cluster for DMS, enable SASL_SSL, download the SSL certificate, and upload the downloaded certificate <strong id="dli_08_0386__en-us_topic_0000001310095781_b727121674119">client.jks</strong> to an OBS bucket.</p>
|
|
<pre class="screen" id="dli_08_0386__en-us_topic_0000001310095781_screen691531701511">CREATE TABLE ordersSource (
|
|
order_id string,
|
|
order_channel string,
|
|
order_time timestamp(3),
|
|
pay_amount double,
|
|
real_pay double,
|
|
pay_time string,
|
|
user_id string,
|
|
user_name string,
|
|
area_id string
|
|
) WITH (
|
|
'connector' = 'kafka',
|
|
'topic' = 'xx',
|
|
'properties.bootstrap.servers' = 'xx:9093,xx:9093,xx:9093',
|
|
'properties.group.id' = 'GroupId',
|
|
'scan.startup.mode' = 'latest-offset',
|
|
'properties.connector.auth.open' = 'true',
|
|
'properties.ssl.truststore.location' = 'obs://xx/xx.jks', -- Location where the user uploads the certificate to
|
|
'properties.sasl.mechanism' = 'PLAIN', -- Value format: SASL_PLAINTEXT
|
|
'properties.security.protocol' = 'SASL_SSL',
|
|
'properties.sasl.jaas.config' = 'org.apache.kafka.common.security.plain.PlainLoginModule required username=\"xx\" password=\"xx\";', -- Account and password set when the Kafka cluster is created
|
|
"format" = "json"
|
|
);
|
|
|
|
CREATE TABLE ordersSink (
|
|
order_id string,
|
|
order_channel string,
|
|
order_time timestamp(3),
|
|
pay_amount double,
|
|
real_pay double,
|
|
pay_time string,
|
|
user_id string,
|
|
user_name string,
|
|
area_id string
|
|
) WITH (
|
|
'connector' = 'kafka',
|
|
'topic' = 'xx',
|
|
'properties.bootstrap.servers' = 'xx:9093,xx:9093,xx:9093',
|
|
'properties.connector.auth.open' = 'true',
|
|
'properties.ssl.truststore.location' = 'obs://xx/xx.jks',
|
|
'properties.sasl.mechanism' = 'PLAIN',
|
|
'properties.security.protocol' = 'SASL_SSL',
|
|
'properties.sasl.jaas.config' = 'org.apache.kafka.common.security.plain.PlainLoginModule required username=\"xx\" password=\"xx\";',
|
|
"format" = "json"
|
|
);
|
|
|
|
insert into ordersSink select * from ordersSource;</pre>
|
|
</li><li id="dli_08_0386__en-us_topic_0000001310095781_li107204111517"><strong id="dli_08_0386__en-us_topic_0000001310095781_b153566314430">Example 2: Enable Kafka SASL_SSL authentication for the MRS cluster.</strong><ul id="dli_08_0386__en-us_topic_0000001310095781_ul0537181312174"><li id="dli_08_0386__en-us_topic_0000001310095781_li11610111071719">Enable Kerberos authentication for the MRS cluster.</li><li id="dli_08_0386__en-us_topic_0000001310095781_li1261921017172">Click the <strong id="dli_08_0386__en-us_topic_0000001310095781_b1624616617165">Components</strong> tab and click <strong id="dli_08_0386__en-us_topic_0000001310095781_b196895461618">Kafka</strong>. In the displayed page, click the <strong id="dli_08_0386__en-us_topic_0000001310095781_b7886122919170">Service Configuration</strong> tab, locate the <strong id="dli_08_0386__en-us_topic_0000001310095781_b1117255781713">security.protocol</strong>, and set it to <strong id="dli_08_0386__en-us_topic_0000001310095781_b4822184151812">SASL_SSL</strong>.</li><li id="dli_08_0386__en-us_topic_0000001310095781_li06912478184">Log in to the FusionInsight Manager of the MRS cluster and download the user credential. Choose <strong id="dli_08_0386__en-us_topic_0000001310095781_b999511506233">System</strong> > <strong id="dli_08_0386__en-us_topic_0000001310095781_b1297675202315">Permission</strong> > <strong id="dli_08_0386__en-us_topic_0000001310095781_b1057815532312">User</strong>. Locate the row that contains the target user, choose <strong id="dli_08_0386__en-us_topic_0000001310095781_b9521732152415">More</strong> > <strong id="dli_08_0386__en-us_topic_0000001310095781_b65063351244">Download Authentication Credential</strong>.<p id="dli_08_0386__en-us_topic_0000001310095781_p333645161810">Obtain the <strong id="dli_08_0386__en-us_topic_0000001310095781_b1872285013246">truststore.jks</strong> file using the authentication credential and store the credential and <strong id="dli_08_0386__en-us_topic_0000001310095781_b18744182712255">truststore.jks</strong> file in OBS.</p>
|
|
</li><li id="dli_08_0386__en-us_topic_0000001310095781_li061981014175">If "Message stream modified (41)" is displayed, the JDK version may be incorrect. Change the JDK version in the sample code to a version earlier than 8u_242 or delete the <strong id="dli_08_0386__en-us_topic_0000001310095781_b118581656102610">renew_lifetime = 0m</strong> configuration item from the <strong id="dli_08_0386__en-us_topic_0000001310095781_b4858145692613">krb5.conf</strong> configuration file.</li><li id="dli_08_0386__en-us_topic_0000001310095781_li10619121014179">Set the port to the <strong id="dli_08_0386__en-us_topic_0000001310095781_b12616371276">sasl_ssl.port</strong> configured in the Kafka service configuration.</li><li id="dli_08_0386__en-us_topic_0000001310095781_li861916104173">In the following statements, set <strong id="dli_08_0386__en-us_topic_0000001310095781_b32437492279">security.protocol</strong> to <strong id="dli_08_0386__en-us_topic_0000001310095781_b31069517275">SASL_SSL</strong>.</li></ul>
|
|
<pre class="screen" id="dli_08_0386__en-us_topic_0000001310095781_screen14604182619228">CREATE TABLE ordersSource (
|
|
order_id string,
|
|
order_channel string,
|
|
order_time timestamp(3),
|
|
pay_amount double,
|
|
real_pay double,
|
|
pay_time string,
|
|
user_id string,
|
|
user_name string,
|
|
area_id string
|
|
) WITH (
|
|
'connector' = 'kafka',
|
|
'topic' = 'xx',
|
|
'properties.bootstrap.servers' = 'xx:21009,xx:21009',
|
|
'properties.group.id' = 'GroupId',
|
|
'scan.startup.mode' = 'latest-offset',
|
|
'properties.sasl.kerberos.service.name' = 'kafka',
|
|
'properties.connector.auth.open' = 'true',
|
|
'properties.connector.kerberos.principal' = 'xx', --Username
|
|
'properties.connector.kerberos.krb5' = 'obs://xx/krb5.conf',
|
|
'properties.connector.kerberos.keytab' = 'obs://xx/user.keytab',
|
|
'properties.security.protocol' = 'SASL_SSL',
|
|
'properties.ssl.truststore.location' = 'obs://xx/truststore.jks',
|
|
'properties.ssl.truststore.password' = 'xx', -- Password set for generating <strong id="dli_08_0386__en-us_topic_0000001310095781_b415514783818">truststore.jks</strong>
|
|
'properties.sasl.mechanism' = 'GSSAPI',
|
|
"format" = "json"
|
|
);
|
|
|
|
CREATE TABLE ordersSink (
|
|
order_id string,
|
|
order_channel string,
|
|
order_time timestamp(3),
|
|
pay_amount double,
|
|
real_pay double,
|
|
pay_time string,
|
|
user_id string,
|
|
user_name string,
|
|
area_id string
|
|
) WITH (
|
|
'connector' = 'kafka',
|
|
'topic' = 'xx',
|
|
'properties.bootstrap.servers' = 'xx:21009,xx:21009',
|
|
'properties.sasl.kerberos.service.name' = 'kafka',
|
|
'properties.connector.auth.open' = 'true',
|
|
'properties.connector.kerberos.principal' = 'xx',
|
|
'properties.connector.kerberos.krb5' = 'obs://xx/krb5.conf',
|
|
'properties.connector.kerberos.keytab' = 'obs://xx/user.keytab',
|
|
'properties.ssl.truststore.location' = 'obs://xx/truststore.jks',
|
|
'properties.ssl.truststore.password' = 'xx',
|
|
'properties.security.protocol' = 'SASL_SSL',
|
|
'properties.sasl.mechanism' = 'GSSAPI',
|
|
"format" = "json"
|
|
);
|
|
|
|
insert into ordersSink select * from ordersSource;</pre>
|
|
</li><li id="dli_08_0386__en-us_topic_0000001310095781_li3317747102218"><strong id="dli_08_0386__en-us_topic_0000001310095781_b315652615317">Example 3: Enable Kerberos SASL_PAINTEXT authentication for the MRS cluster</strong><ul id="dli_08_0386__en-us_topic_0000001310095781_ul184471113132319"><li id="dli_08_0386__en-us_topic_0000001310095781_li144471513152311">Enable Kerberos authentication for the MRS cluster.</li><li id="dli_08_0386__en-us_topic_0000001310095781_li10447161315237">Click the <strong id="dli_08_0386__en-us_topic_0000001310095781_b6590105635618">Components</strong> tab and click <strong id="dli_08_0386__en-us_topic_0000001310095781_b7590856195611">Kafka</strong>. In the displayed page, click the <strong id="dli_08_0386__en-us_topic_0000001310095781_b859185619564">Service Configuration</strong> tab, locate the <strong id="dli_08_0386__en-us_topic_0000001310095781_b185911256115614">security.protocol</strong>, and set it to <strong id="dli_08_0386__en-us_topic_0000001310095781_b15911856145610">SASL_PLAINTEXT</strong>.</li><li id="dli_08_0386__en-us_topic_0000001310095781_li544713139232">Log in to the FusionInsight Manager of the MRS cluster and download the user credential. Choose <strong id="dli_08_0386__en-us_topic_0000001310095781_b122614158577">System</strong> > <strong id="dli_08_0386__en-us_topic_0000001310095781_b11261191510574">Permission</strong> > <strong id="dli_08_0386__en-us_topic_0000001310095781_b12261315145714">User</strong>. Locate the row that contains the target user, choose <strong id="dli_08_0386__en-us_topic_0000001310095781_b15262171519579">More</strong> > <strong id="dli_08_0386__en-us_topic_0000001310095781_b112621415105712">Download Authentication Credential</strong>. Upload the credential to OBS.</li><li id="dli_08_0386__en-us_topic_0000001310095781_li744713131237">If error message "Message stream modified (41)" is displayed, the JDK version may be incorrect. Change the JDK version in the sample code to a version earlier than 8u_242 or delete the <strong id="dli_08_0386__en-us_topic_0000001310095781_b1095743618578">renew_lifetime = 0m</strong> configuration item from the <strong id="dli_08_0386__en-us_topic_0000001310095781_b1295713616570">krb5.conf</strong> configuration file.</li><li id="dli_08_0386__en-us_topic_0000001310095781_li544751382315">Set the port to the <strong id="dli_08_0386__en-us_topic_0000001310095781_b154639199256">sasl.port</strong> configured in the Kafka service configuration.</li><li id="dli_08_0386__en-us_topic_0000001310095781_li55706303232">In the following statements, set <strong id="dli_08_0386__en-us_topic_0000001310095781_b614482182912">security.protocol</strong> to <strong id="dli_08_0386__en-us_topic_0000001310095781_b8144142122913">SASL_PLAINTEXT</strong>.</li></ul>
|
|
<pre class="screen" id="dli_08_0386__en-us_topic_0000001310095781_screen17997112152617">CREATE TABLE ordersSources (
|
|
order_id string,
|
|
order_channel string,
|
|
order_time timestamp(3),
|
|
pay_amount double,
|
|
real_pay double,
|
|
pay_time string,
|
|
user_id string,
|
|
user_name string,
|
|
area_id string
|
|
) WITH (
|
|
'connector' = 'kafka',
|
|
'topic' = 'xx',
|
|
'properties.bootstrap.servers' = 'xx:21007,xx:21007',
|
|
'properties.group.id' = 'GroupId',
|
|
'scan.startup.mode' = 'latest-offset',
|
|
'properties.sasl.kerberos.service.name' = 'kafka',
|
|
'properties.connector.auth.open' = 'true',
|
|
'properties.connector.kerberos.principal' = 'xx',
|
|
'properties.connector.kerberos.krb5' = 'obs://xx/krb5.conf',
|
|
'properties.connector.kerberos.keytab' = 'obs://xx/user.keytab',
|
|
'properties.security.protocol' = 'SASL_PLAINTEXT',
|
|
'properties.sasl.mechanism' = 'GSSAPI',
|
|
"format" = "json"
|
|
);
|
|
|
|
CREATE TABLE ordersSink (
|
|
order_id string,
|
|
order_channel string,
|
|
order_time timestamp(3),
|
|
pay_amount double,
|
|
real_pay double,
|
|
pay_time string,
|
|
user_id string,
|
|
user_name string,
|
|
area_id string
|
|
) WITH (
|
|
'connector' = 'kafka',
|
|
'topic' = 'xx',
|
|
'properties.bootstrap.servers' = 'xx:21007,xx:21007',
|
|
'properties.sasl.kerberos.service.name' = 'kafka',
|
|
'properties.connector.auth.open' = 'true',
|
|
'properties.connector.kerberos.principal' = 'xx',
|
|
'properties.connector.kerberos.krb5' = 'obs://xx/krb5.conf',
|
|
'properties.connector.kerberos.keytab' = 'obs://xx/user.keytab',
|
|
'properties.security.protocol' = 'SASL_PLAINTEXT',
|
|
'properties.sasl.mechanism' = 'GSSAPI',
|
|
"format" = "json"
|
|
);
|
|
|
|
insert into ordersSink select * from ordersSource;</pre>
|
|
</li><li id="dli_08_0386__en-us_topic_0000001310095781_li9872336192610"><strong id="dli_08_0386__en-us_topic_0000001310095781_b34356665818">Example 4: Use SSL for the MRS cluster</strong><ul id="dli_08_0386__en-us_topic_0000001310095781_ul56598200271"><li id="dli_08_0386__en-us_topic_0000001310095781_li196591420192719">Do not enable Kerberos authentication for the MRS cluster.</li><li id="dli_08_0386__en-us_topic_0000001310095781_li8781164792714">Log in to the FusionInsight Manager of the MRS cluster and download the user credential. Choose <strong id="dli_08_0386__en-us_topic_0000001310095781_b266414402613">System</strong> > <strong id="dli_08_0386__en-us_topic_0000001310095781_b266418405616">Permission</strong> > <strong id="dli_08_0386__en-us_topic_0000001310095781_b1066420409617">User</strong>. Locate the row that contains the target user, choose <strong id="dli_08_0386__en-us_topic_0000001310095781_b1366412401611">More</strong> > <strong id="dli_08_0386__en-us_topic_0000001310095781_b4665144012612">Download Authentication Credential</strong>.<p id="dli_08_0386__en-us_topic_0000001310095781_p626025219286">Obtain the <strong id="dli_08_0386__en-us_topic_0000001310095781_b15842547365">truststore.jks</strong> file using the authentication credential and store the credential and <strong id="dli_08_0386__en-us_topic_0000001310095781_b178428471760">truststore.jks</strong> file in OBS.</p>
|
|
</li><li id="dli_08_0386__en-us_topic_0000001310095781_li56593204272">Set the port to the <strong id="dli_08_0386__en-us_topic_0000001310095781_b163213314713">ssl.port</strong> configured in the Kafka service configuration.</li><li id="dli_08_0386__en-us_topic_0000001310095781_li14659920202712">In the following statements, set <strong id="dli_08_0386__en-us_topic_0000001310095781_b16346417874">security.protocol</strong> to <strong id="dli_08_0386__en-us_topic_0000001310095781_b173464171177">SSL</strong>.</li><li id="dli_08_0386__en-us_topic_0000001310095781_li66597202270">Set <strong id="dli_08_0386__en-us_topic_0000001310095781_b1474518124815">ssl.mode.enable</strong> to <strong id="dli_08_0386__en-us_topic_0000001310095781_b154236319337">true</strong>.<pre class="screen" id="dli_08_0386__en-us_topic_0000001310095781_screen842494402916">CREATE TABLE ordersSource (
|
|
order_id string,
|
|
order_channel string,
|
|
order_time timestamp(3),
|
|
pay_amount double,
|
|
real_pay double,
|
|
pay_time string,
|
|
user_id string,
|
|
user_name string,
|
|
area_id string
|
|
) WITH (
|
|
'connector' = 'kafka',
|
|
'topic' = 'xx',
|
|
'properties.bootstrap.servers' = 'xx:9093,xx:9093,xx:9093',
|
|
'properties.group.id' = 'GroupId',
|
|
'scan.startup.mode' = 'latest-offset',
|
|
'properties.connector.auth.open' = 'true',
|
|
'properties.ssl.truststore.location' = 'obs://xx/truststore.jks',
|
|
'properties.ssl.truststore.password' = 'xx', -- Password set for generating <strong id="dli_08_0386__en-us_topic_0000001310095781_b1530114386913">truststore.jks</strong>
|
|
'properties.security.protocol' = 'SSL',
|
|
"format" = "json"
|
|
);
|
|
|
|
CREATE TABLE ordersSink (
|
|
order_id string,
|
|
order_channel string,
|
|
order_time timestamp(3),
|
|
pay_amount double,
|
|
real_pay double,
|
|
pay_time string,
|
|
user_id string,
|
|
user_name string,
|
|
area_id string
|
|
) WITH (
|
|
'connector' = 'print'
|
|
);
|
|
|
|
insert into ordersSink select * from ordersSource;</pre>
|
|
</li></ul>
|
|
</li></ul>
|
|
</div>
|
|
<div class="section" id="dli_08_0386__en-us_topic_0000001310095781_section6615132175310"><h4 class="sectiontitle">FAQ</h4><ul id="dli_08_0386__en-us_topic_0000001310095781_ul2134161411254"><li id="dli_08_0386__en-us_topic_0000001310095781_li12490182212593"><strong id="dli_08_0386__en-us_topic_0000001310095781_b3769151017458">Q: What should I do if the Flink job execution fails and the log contains the following error information?</strong><pre class="screen" id="dli_08_0386__en-us_topic_0000001310095781_screen1325344945818">org.apache.kafka.common.errors.TimeoutException: Timeout expired while fetching topic metadata</pre>
|
|
<p id="dli_08_0386__en-us_topic_0000001310095781_p169161432181415">A: The datasource connection is not bound, the binding fails, or the security group of the Kafka cluster is not configured to allow access from the network segment of the DLI queue. Configure the datasource connection or configure the security group of the Kafka cluster to allow access from the DLI queue.</p>
|
|
</li><li id="dli_08_0386__en-us_topic_0000001310095781_li1604152318012"><strong id="dli_08_0386__en-us_topic_0000001310095781_b911119376454">Q: What should I do if the Flink job execution fails and the log contains the following error information?</strong><pre class="screen" id="dli_08_0386__en-us_topic_0000001310095781_screen78029291301">Caused by: java.lang.RuntimeException: RealLine:45;Table 'default_catalog.default_database.printSink' declares persistable metadata columns, but the underlying DynamicTableSink doesn't implement the SupportsWritingMetadata interface. If the column should not be persisted, it can be declared with the VIRTUAL keyword.</pre>
|
|
<p id="dli_08_0386__en-us_topic_0000001310095781_p14021031803">A: The metadata type is defined in the sink table, but the Print connector does not support deletion of matadata from the sink table.</p>
|
|
</li></ul>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dli_08_0381.html">Creating Source Tables</a></div>
|
|
</div>
|
|
</div>
|
|
|