forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Co-authored-by: Hasko, Vladimir <vladimir.hasko@t-systems.com> Co-committed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com>
130 lines
38 KiB
HTML
130 lines
38 KiB
HTML
<a name="dli_09_0012"></a><a name="dli_09_0012"></a>
|
|
|
|
<h1 class="topictitle1">Reading Data from MySQL CDC and Writing Data to GaussDB(DWS)</h1>
|
|
<div id="body8662426"><div class="notice" id="dli_09_0012__en-us_topic_0000001269342112_note04712015123019"><span class="noticetitle"><img src="public_sys-resources/notice_3.0-en-us.png"> </span><div class="noticebody"><p id="dli_09_0012__en-us_topic_0000001269342112_p89081621193310">This guide provides reference for Flink 1.12 only.</p>
|
|
</div></div>
|
|
<div class="section" id="dli_09_0012__en-us_topic_0000001269342112_section10920163411416"><h4 class="sectiontitle">Description</h4><p id="dli_09_0012__en-us_topic_0000001269342112_p128093392048">Change Data Capture (CDC) can synchronize incremental changes from the source database to one or more destinations. During data synchronization, CDC processes data, for example, grouping (GROUP BY) and joining multiple tables (JOIN).</p>
|
|
<p id="dli_09_0012__en-us_topic_0000001269342112_p519175932112">This example creates a MySQL CDC source table to monitor MySQL data changes and insert the changed data into a GaussDB(DWS) database.</p>
|
|
</div>
|
|
<div class="section" id="dli_09_0012__en-us_topic_0000001269342112_section99670144912"><h4 class="sectiontitle">Prerequisites</h4><ol id="dli_09_0012__en-us_topic_0000001269342112_ol188213811126"><li id="dli_09_0012__en-us_topic_0000001269342112_li1087117102575">You have created an RDS for MySQL instance.. In this example, the RDS for MySQL database version is 8.0.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li82101214183620">You have created a GaussDB(DWS) cluster.</li></ol>
|
|
</div>
|
|
<div class="section" id="dli_09_0012__en-us_topic_0000001269342112_section12587518310"><h4 class="sectiontitle">Overall Process</h4><div class="p" id="dli_09_0012__en-us_topic_0000001269342112_p7741285314"><a href="#dli_09_0012__en-us_topic_0000001269342112_fig1691441652">Figure 1</a> shows the overall development process.<div class="fignone" id="dli_09_0012__en-us_topic_0000001269342112_fig1691441652"><a name="dli_09_0012__en-us_topic_0000001269342112_fig1691441652"></a><a name="en-us_topic_0000001269342112_fig1691441652"></a><span class="figcap"><b>Figure 1 </b>Job development process</span><br><span><img id="dli_09_0012__en-us_topic_0000001269342112_image691841454" src="en-us_image_0000001269022192.png"></span></div>
|
|
</div>
|
|
<p id="dli_09_0012__en-us_topic_0000001269342112_p16413127863"><a href="#dli_09_0012__en-us_topic_0000001269342112_section792923214216">Step 1: Create a Queue</a></p>
|
|
<p id="dli_09_0012__en-us_topic_0000001269342112_p1259352616818"><a href="#dli_09_0012__en-us_topic_0000001269342112_section1627154113018">Step 2: Create an RDS MySQL Database and Table</a></p>
|
|
<p id="dli_09_0012__en-us_topic_0000001269342112_p112432312316"><a href="#dli_09_0012__en-us_topic_0000001269342112_section1744572443816">Step 3: Create a GaussDB(DWS) Database and Table</a></p>
|
|
<p id="dli_09_0012__en-us_topic_0000001269342112_p11783144819818"><a href="#dli_09_0012__en-us_topic_0000001269342112_section074025752119">Step 4: Create an Enhanced Datasource Connection</a></p>
|
|
<p id="dli_09_0012__en-us_topic_0000001269342112_p102618381914"><a href="#dli_09_0012__en-us_topic_0000001269342112_section12448959174212">Step 5: Run a Job</a></p>
|
|
<p id="dli_09_0012__en-us_topic_0000001269342112_p491452441010"><a href="#dli_09_0012__en-us_topic_0000001269342112_section4387527162418">Step 6: Send Data and Query Results</a></p>
|
|
</div>
|
|
<div class="section" id="dli_09_0012__en-us_topic_0000001269342112_section792923214216"><a name="dli_09_0012__en-us_topic_0000001269342112_section792923214216"></a><a name="en-us_topic_0000001269342112_section792923214216"></a><h4 class="sectiontitle">Step 1: Create a Queue</h4><ol id="dli_09_0012__en-us_topic_0000001269342112_ol193907145108"><li id="dli_09_0012__en-us_topic_0000001269342112_li3390161431020">Log in to the DLI console. In the navigation pane on the left, choose <strong id="dli_09_0012__en-us_topic_0000001269342112_b1027955116115">Resources</strong> > <strong id="dli_09_0012__en-us_topic_0000001269342112_b62794516113">Queue Management</strong>.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li5390171401016">On the displayed page, click <strong id="dli_09_0012__en-us_topic_0000001269342112_b481717525113">Buy Queue</strong> in the upper right corner.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li133901314191011">On the <strong id="dli_09_0012__en-us_topic_0000001269342112_b1727543117">Buy Queue</strong> page, set queue parameters as follows:<ul id="dli_09_0012__en-us_topic_0000001269342112_ul161521581016"><li id="dli_09_0012__en-us_topic_0000001269342112_li5992112615541"><strong id="dli_09_0012__en-us_topic_0000001269342112_b21291531114314">Billing Mode</strong>: . </li><li id="dli_09_0012__en-us_topic_0000001269342112_li17566251558"><strong id="dli_09_0012__en-us_topic_0000001269342112_b220916196127">Region</strong> and <strong id="dli_09_0012__en-us_topic_0000001269342112_b7215151981217">Project</strong>: Retain the default values.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li9378124110319"><strong id="dli_09_0012__en-us_topic_0000001269342112_b8981520161215">Name</strong>: Enter a queue name.<div class="note" id="dli_09_0012__en-us_topic_0000001269342112_note1523218284569"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="dli_09_0012__en-us_topic_0000001269342112_en-us_topic_0069078607_en-us_topic_0069077926_p61185513">The queue name can contain only digits, letters, and underscores (_), but cannot contain only digits or start with an underscore (_). The name must contain 1 to 128 characters.</p>
|
|
<p id="dli_09_0012__en-us_topic_0000001269342112_p6288122915199"><strong id="dli_09_0012__en-us_topic_0000001269342112_b15970523201214">The queue name is case-insensitive. Uppercase letters will be automatically converted to lowercase letters.</strong></p>
|
|
</div></div>
|
|
</li><li id="dli_09_0012__en-us_topic_0000001269342112_li1761814682119"><strong id="dli_09_0012__en-us_topic_0000001269342112_b3666624161211">Type</strong>: Select <strong id="dli_09_0012__en-us_topic_0000001269342112_b166722417124">For general purpose</strong>. Select the <strong id="dli_09_0012__en-us_topic_0000001269342112_b1611312261121">Dedicated Resource Mode</strong>.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li360481635014"><strong id="dli_09_0012__en-us_topic_0000001269342112_b817653514313">AZ Mode</strong> and <strong id="dli_09_0012__en-us_topic_0000001269342112_b1117623584310">Specifications</strong>: Retain the default values.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li32421882515"><strong id="dli_09_0012__en-us_topic_0000001269342112_b14729927131210">Enterprise Project</strong>: Select <strong id="dli_09_0012__en-us_topic_0000001269342112_b7730827131214">default</strong>.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li6862026155115"><strong id="dli_09_0012__en-us_topic_0000001269342112_b1586162801213">Advanced Settings</strong>: Select <strong id="dli_09_0012__en-us_topic_0000001269342112_b55862285120">Custom</strong>.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li615215819015"><strong id="dli_09_0012__en-us_topic_0000001269342112_b174424296129">CIDR Block</strong>: Specify the queue network segment. For example, <strong id="dli_09_0012__en-us_topic_0000001269342112_b1643616307129">10.0.0.0/16</strong>.<div class="caution" id="dli_09_0012__en-us_topic_0000001269342112_note243428112912"><span class="cautiontitle"><img src="public_sys-resources/caution_3.0-en-us.png"> </span><div class="cautionbody"><p id="dli_09_0012__en-us_topic_0000001269342112_p114344818296">The CIDR block of a queue cannot overlap with the CIDR blocks of DMS Kafka and RDS for MySQL DB instances. Otherwise, datasource connections will fail to be created.</p>
|
|
</div></div>
|
|
</li><li id="dli_09_0012__en-us_topic_0000001269342112_li1066019193813">Set other parameters as required.</li></ul>
|
|
</li><li id="dli_09_0012__en-us_topic_0000001269342112_li83901314181011">Click <strong id="dli_09_0012__en-us_topic_0000001269342112_b932063616123">Buy</strong>. Confirm the configuration and click <strong id="dli_09_0012__en-us_topic_0000001269342112_b123201636101219">Submit</strong>.</li></ol>
|
|
</div>
|
|
<div class="section" id="dli_09_0012__en-us_topic_0000001269342112_section1627154113018"><a name="dli_09_0012__en-us_topic_0000001269342112_section1627154113018"></a><a name="en-us_topic_0000001269342112_section1627154113018"></a><h4 class="sectiontitle">Step 2: Create an RDS MySQL Database and Table</h4><ol id="dli_09_0012__en-us_topic_0000001269342112_ol622615816111"><li id="dli_09_0012__en-us_topic_0000001269342112_li16226198013">Log in to the RDS console. On the displayed page, locate the target MySQL DB instance and choose <strong id="dli_09_0012__en-us_topic_0000001269342112_b2693123881220">More</strong> > <strong id="dli_09_0012__en-us_topic_0000001269342112_b136931238161212">Log In</strong> in the <strong id="dli_09_0012__en-us_topic_0000001269342112_b146933385127">Operation</strong> column.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li1371112481236">On the displayed login dialog box, enter the username and password and click <strong id="dli_09_0012__en-us_topic_0000001269342112_b1249642181311">Log In</strong>.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li2298131648">On the <strong id="dli_09_0012__en-us_topic_0000001269342112_b1726154310131">Databases</strong> page, click <strong id="dli_09_0012__en-us_topic_0000001269342112_b11261943181315">Create Database</strong>. In the displayed dialog box, enter <strong id="dli_09_0012__en-us_topic_0000001269342112_b1626274310134">testrdsdb</strong> as the database name and retain default values of rest parameters. Then, click <strong id="dli_09_0012__en-us_topic_0000001269342112_b162628438133">OK</strong>.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li75524472088">In the <strong id="dli_09_0012__en-us_topic_0000001269342112_b6599844161315">Operation</strong> column of row where the created database locates, click <strong id="dli_09_0012__en-us_topic_0000001269342112_b1599144415132">SQL Window</strong> and enter the following statement to create a table:<pre class="screen" id="dli_09_0012__en-us_topic_0000001269342112_screen15200175112817">CREATE TABLE mysqlcdc (
|
|
`order_id` VARCHAR(64) NOT NULL,
|
|
`order_channel` VARCHAR(32) NOT NULL,
|
|
`order_time` VARCHAR(32),
|
|
`pay_amount` DOUBLE,
|
|
`real_pay` DOUBLE,
|
|
`pay_time` VARCHAR(32),
|
|
`user_id` VARCHAR(32),
|
|
`user_name` VARCHAR(32),
|
|
`area_id` VARCHAR(32)
|
|
|
|
) ENGINE = InnoDB
|
|
DEFAULT CHARACTER SET = utf8mb4;</pre>
|
|
</li></ol>
|
|
</div>
|
|
<div class="section" id="dli_09_0012__en-us_topic_0000001269342112_section1744572443816"><a name="dli_09_0012__en-us_topic_0000001269342112_section1744572443816"></a><a name="en-us_topic_0000001269342112_section1744572443816"></a><h4 class="sectiontitle">Step 3: Create a GaussDB(DWS) Database and Table</h4><p id="dli_09_0012__en-us_topic_0000001269342112_p10419201615398"></p>
|
|
<ol id="dli_09_0012__en-us_topic_0000001269342112_ol5444161915482"><li id="dli_09_0012__en-us_topic_0000001269342112_li1644413197483">Connect to the created GaussDB(DWS) cluster.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li13452124716514">Connect to the default database <strong id="dli_09_0012__en-us_topic_0000001269342112_b141024529136">gaussdb</strong> of a GaussDB(DWS) cluster.<pre class="screen" id="dli_09_0012__en-us_topic_0000001269342112_screen83931272818">gsql -d gaussdb -h <em id="dli_09_0012__en-us_topic_0000001269342112_i14894535131">Connection address of the GaussDB(DWS) cluster</em> -U dbadmin -p 8000 -W <em id="dli_09_0012__en-us_topic_0000001269342112_i198965313132">password</em> -r</pre>
|
|
<ul id="dli_09_0012__en-us_topic_0000001269342112_ul174831718681"><li id="dli_09_0012__en-us_topic_0000001269342112_li15692151710103"><strong id="dli_09_0012__en-us_topic_0000001269342112_b2095495381313">gaussdb</strong>: Default database of the GaussDB(DWS) cluster</li><li id="dli_09_0012__en-us_topic_0000001269342112_li124831018983"><strong id="dli_09_0012__en-us_topic_0000001269342112_b91694550136">Connection address of the DWS cluster</strong>: If a public network address is used for connection, set this parameter to the public network IP address or domain name. If a private network address is used for connection, set this parameter to the private network IP address or domain name. If an ELB is used for connection, set this parameter to the ELB address.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li727319471581"><strong id="dli_09_0012__en-us_topic_0000001269342112_b2796859121318">dbadmin</strong>: Default administrator username used during cluster creation</li><li id="dli_09_0012__en-us_topic_0000001269342112_li4715191411119"><strong id="dli_09_0012__en-us_topic_0000001269342112_b1764931201420">-W</strong>: Default password of the administrator</li></ul>
|
|
</li><li id="dli_09_0012__en-us_topic_0000001269342112_li1024132193916">Run the following command to create the <strong id="dli_09_0012__en-us_topic_0000001269342112_b16775722147">testdwsdb</strong> database:<pre class="screen" id="dli_09_0012__en-us_topic_0000001269342112_screen6700124819131">CREATE DATABASE testdwsdb;</pre>
|
|
</li><li id="dli_09_0012__en-us_topic_0000001269342112_li18700124812130">Run the following command to exit the <strong id="dli_09_0012__en-us_topic_0000001269342112_b1959910951415">gaussdb</strong> database and connect to <strong id="dli_09_0012__en-us_topic_0000001269342112_b4605139141415">testdwsdb</strong>:<pre class="screen" id="dli_09_0012__en-us_topic_0000001269342112_screen184211821618">\q
|
|
gsql -d testdwsdb -h <em id="dli_09_0012__en-us_topic_0000001269342112_i1748931112149">Connection address of the GaussDB(DWS) cluster</em> -U dbadmin -p 8000 -W <em id="dli_09_0012__en-us_topic_0000001269342112_i16489141121415">password</em> -r</pre>
|
|
</li><li id="dli_09_0012__en-us_topic_0000001269342112_li1996848151611">Run the following commands to create a table:<pre class="screen" id="dli_09_0012__en-us_topic_0000001269342112_screen1610120280179">create schema test;
|
|
set current_schema= test;
|
|
drop table if exists dwsresult;
|
|
CREATE TABLE dwsresult
|
|
(
|
|
car_id VARCHAR,
|
|
car_owner VARCHAR,
|
|
car_age INTEGER ,
|
|
average_speed FLOAT8,
|
|
total_miles FLOAT8
|
|
);</pre>
|
|
</li></ol>
|
|
</div>
|
|
<div class="section" id="dli_09_0012__en-us_topic_0000001269342112_section074025752119"><a name="dli_09_0012__en-us_topic_0000001269342112_section074025752119"></a><a name="en-us_topic_0000001269342112_section074025752119"></a><h4 class="sectiontitle">Step 4: Create an Enhanced Datasource Connection</h4><ul id="dli_09_0012__en-us_topic_0000001269342112_ul1231663714228"><li id="dli_09_0012__en-us_topic_0000001269342112_li193161137122213"><strong id="dli_09_0012__en-us_topic_0000001269342112_b4732162014148">Connecting DLI to RDS</strong><ol id="dli_09_0012__en-us_topic_0000001269342112_ol24611049949"><li id="dli_09_0012__en-us_topic_0000001269342112_li876915469390">Go to the RDS console, click the name of the target RDS DB instance on the <strong id="dli_09_0012__en-us_topic_0000001269342112_b198668211148">Instances</strong> page. Basic information of the instance is displayed.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li1976917464396"><a name="dli_09_0012__en-us_topic_0000001269342112_li1976917464396"></a><a name="en-us_topic_0000001269342112_li1976917464396"></a>In the <strong id="dli_09_0012__en-us_topic_0000001269342112_b1981292231420">Connection Information</strong> pane, obtain the floating IP address, database port, VPC, and subnet.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li11769194618399">Click the security group name. On the displayed page, click the <strong id="dli_09_0012__en-us_topic_0000001269342112_b071313235149">Inbound Rules</strong> tab and add a rule to allow access from DLI queues. For example, if the CIDR block of the queue is 10.0.0.0/16, set <strong id="dli_09_0012__en-us_topic_0000001269342112_b6570152421410">Priority</strong> to <strong id="dli_09_0012__en-us_topic_0000001269342112_b05701824161410">1</strong>, <strong id="dli_09_0012__en-us_topic_0000001269342112_b16570224121419">Action</strong> to <strong id="dli_09_0012__en-us_topic_0000001269342112_b1571142471414">Allow</strong>, <strong id="dli_09_0012__en-us_topic_0000001269342112_b145712024201414">Protocol</strong> to <strong id="dli_09_0012__en-us_topic_0000001269342112_b1157192431412">TCP</strong>, <strong id="dli_09_0012__en-us_topic_0000001269342112_b9571524191412">Type</strong> to <strong id="dli_09_0012__en-us_topic_0000001269342112_b9571724161412">IPv4</strong>, <strong id="dli_09_0012__en-us_topic_0000001269342112_b1757215246144">Source</strong> to <strong id="dli_09_0012__en-us_topic_0000001269342112_b10572924181415">10.0.0.0/16</strong>, and click <strong id="dli_09_0012__en-us_topic_0000001269342112_b1857222471418">OK</strong>.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li27691446183918">Log in to the DLI management console. In the navigation pane on the left, choose <strong id="dli_09_0012__en-us_topic_0000001269342112_b2058219258144">Datasource Connections</strong>. On the displayed page, click <strong id="dli_09_0012__en-us_topic_0000001269342112_b195831425171419">Create</strong> in the <strong id="dli_09_0012__en-us_topic_0000001269342112_b7583122531415">Enhanced</strong> tab.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li77695469394">In the displayed dialog box, set the following parameters: For details, see the following section:<ul id="dli_09_0012__en-us_topic_0000001269342112_ul9769174683913"><li id="dli_09_0012__en-us_topic_0000001269342112_li4769134623917"><strong id="dli_09_0012__en-us_topic_0000001269342112_b11773029131419">Connection Name</strong>: Enter a name for the enhanced datasource connection. For this example, enter <strong id="dli_09_0012__en-us_topic_0000001269342112_b1822133119142">dli_rds</strong>.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li18769114618392"><strong id="dli_09_0012__en-us_topic_0000001269342112_b12178333141">Resource Pool</strong>: Select the name of the queue created in <a href="#dli_09_0012__en-us_topic_0000001269342112_section792923214216">Step 1: Create a Queue</a>.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li1776916465398"><strong id="dli_09_0012__en-us_topic_0000001269342112_b1523513413143">VPC</strong>: Select the VPC of the RDS DB instance.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li11769134616395"><strong id="dli_09_0012__en-us_topic_0000001269342112_b15993361147">Subnet</strong>: Select the subnet of RDS DB instance.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li276944623911">Set other parameters as you need.</li></ul>
|
|
<p id="dli_09_0012__en-us_topic_0000001269342112_p11769194618394">Click <strong id="dli_09_0012__en-us_topic_0000001269342112_b3541103820146">OK</strong>. Click the name of the created datasource connection to view its status. You can perform subsequent steps only after the connection status changes to <strong id="dli_09_0012__en-us_topic_0000001269342112_b20693173971418">Active</strong>.</p>
|
|
</li><li id="dli_09_0012__en-us_topic_0000001269342112_li1376924683912">Choose <strong id="dli_09_0012__en-us_topic_0000001269342112_b1380974113149">Resources</strong> > <strong id="dli_09_0012__en-us_topic_0000001269342112_b38094414149">Queue Management</strong> from the navigation pane, locate the queue you created in <a href="#dli_09_0012__en-us_topic_0000001269342112_section792923214216">Step 1: Create a Queue</a>. In the <strong id="dli_09_0012__en-us_topic_0000001269342112_b4810144171416">Operation</strong> column, click <strong id="dli_09_0012__en-us_topic_0000001269342112_b1810164110144">More</strong> > <strong id="dli_09_0012__en-us_topic_0000001269342112_b148101041131412">Test Address Connectivity</strong>.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li976911460392">In the displayed dialog box, enter <em id="dli_09_0012__en-us_topic_0000001269342112_i480414361420">floating IP address</em><strong id="dli_09_0012__en-us_topic_0000001269342112_b1680484317149">:</strong><em id="dli_09_0012__en-us_topic_0000001269342112_i38044435146">database port</em> of the RDS DB instance you have obtained in <a href="#dli_09_0012__en-us_topic_0000001269342112_li1976917464396">2</a> in the <strong id="dli_09_0012__en-us_topic_0000001269342112_b2805174321411">Address</strong> box and click <strong id="dli_09_0012__en-us_topic_0000001269342112_b13805194310144">Test</strong> to check whether the database is reachable.</li></ol>
|
|
</li><li id="dli_09_0012__en-us_topic_0000001269342112_li474495213221"><strong id="dli_09_0012__en-us_topic_0000001269342112_b983924410141">Connecting DLI to GaussDB(DWS)</strong><ol id="dli_09_0012__en-us_topic_0000001269342112_ol17815135442310"><li id="dli_09_0012__en-us_topic_0000001269342112_li14815454112312">On the GaussDB(DWS) management console, choose <strong id="dli_09_0012__en-us_topic_0000001269342112_b391310457149">Clusters</strong>. On the displayed page, click the name of the created GaussDB(DWS) cluster to view basic information.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li19666016361"><a name="dli_09_0012__en-us_topic_0000001269342112_li19666016361"></a><a name="en-us_topic_0000001269342112_li19666016361"></a>In the Basic Information tab, locate the <strong id="dli_09_0012__en-us_topic_0000001269342112_b1843017479147">Database Attributes</strong> pane and obtain the private IP address and port number of the DB instance. In the <strong id="dli_09_0012__en-us_topic_0000001269342112_b1743154731419">Network</strong> pane, obtain VPC, and subnet information.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li4233434123610">Click the security group name. On the displayed page, click the <strong id="dli_09_0012__en-us_topic_0000001269342112_b196801048181415">Inbound Rules</strong> tab and add a rule to allow access from DLI queues. For example, if the CIDR block of the queue is 10.0.0.0/16, set <strong id="dli_09_0012__en-us_topic_0000001269342112_b98481249201413">Priority</strong> to <strong id="dli_09_0012__en-us_topic_0000001269342112_b984924951411">1</strong>, <strong id="dli_09_0012__en-us_topic_0000001269342112_b108491449181414">Action</strong> to <strong id="dli_09_0012__en-us_topic_0000001269342112_b15849154915142">Allow</strong>, <strong id="dli_09_0012__en-us_topic_0000001269342112_b128492495144">Protocol</strong> to <strong id="dli_09_0012__en-us_topic_0000001269342112_b084904991413">TCP</strong>, <strong id="dli_09_0012__en-us_topic_0000001269342112_b385084916144">Type</strong> to <strong id="dli_09_0012__en-us_topic_0000001269342112_b10850184941415">IPv4</strong>, <strong id="dli_09_0012__en-us_topic_0000001269342112_b88506498141">Source</strong> to <strong id="dli_09_0012__en-us_topic_0000001269342112_b1485064971413">10.0.0.0/16</strong>, and click <strong id="dli_09_0012__en-us_topic_0000001269342112_b1285014917147">OK</strong>.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li14803182620216">Check whether the RDS instance and GaussDB(DWS) instance are in the same VPC and subnet.<ol type="a" id="dli_09_0012__en-us_topic_0000001269342112_ol184431423137"><li id="dli_09_0012__en-us_topic_0000001269342112_li957111932">If they are, go to <a href="#dli_09_0012__en-us_topic_0000001269342112_li9816175412318">7</a>. You do not need to create an enhanced datasource connection again.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li1086652519411">If they are not, go to <a href="#dli_09_0012__en-us_topic_0000001269342112_li11976319011">5</a>. Create an enhanced datasource connection to connect RDS to the subnet where the GaussDB(DWS) instance locates.</li></ol>
|
|
</li><li id="dli_09_0012__en-us_topic_0000001269342112_li11976319011"><a name="dli_09_0012__en-us_topic_0000001269342112_li11976319011"></a><a name="en-us_topic_0000001269342112_li11976319011"></a>Log in to the DLI management console. In the navigation pane on the left, choose <strong id="dli_09_0012__en-us_topic_0000001269342112_b892322841511">Datasource Connections</strong>. On the displayed page, click <strong id="dli_09_0012__en-us_topic_0000001269342112_b1292362811517">Create</strong> in the <strong id="dli_09_0012__en-us_topic_0000001269342112_b10923142819152">Enhanced</strong> tab.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li198151354192319">In the displayed dialog box, set the following parameters: For details, see the following section:<ul id="dli_09_0012__en-us_topic_0000001269342112_ul17815125415233"><li id="dli_09_0012__en-us_topic_0000001269342112_li1181518543233"><strong id="dli_09_0012__en-us_topic_0000001269342112_b1337433315155">Connection Name</strong>: Enter a name for the enhanced datasource connection. For this example, enter <strong id="dli_09_0012__en-us_topic_0000001269342112_b3344123610159">dli_dws</strong>.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li681518542232"><strong id="dli_09_0012__en-us_topic_0000001269342112_b1313124081519">Resource Pool</strong>: Select the name of the queue created in <a href="#dli_09_0012__en-us_topic_0000001269342112_section792923214216">Step 1: Create a Queue</a>.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li58162542235"><strong id="dli_09_0012__en-us_topic_0000001269342112_b1685704041517">VPC</strong>: Select the VPC of the GaussDB(DWS) instance.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li11816105432317"><strong id="dli_09_0012__en-us_topic_0000001269342112_b15201942121510">Subnet</strong>: Select the subnet of GaussDB(DWS) instance.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li781675472310">Set other parameters as you need.</li></ul>
|
|
<p id="dli_09_0012__en-us_topic_0000001269342112_p1081617549235">Click <strong id="dli_09_0012__en-us_topic_0000001269342112_b16507124481511">OK</strong>. Click the name of the created datasource connection to view its status. You can perform subsequent steps only after the connection status changes to <strong id="dli_09_0012__en-us_topic_0000001269342112_b135411645151511">Active</strong>.</p>
|
|
</li><li id="dli_09_0012__en-us_topic_0000001269342112_li9816175412318"><a name="dli_09_0012__en-us_topic_0000001269342112_li9816175412318"></a><a name="en-us_topic_0000001269342112_li9816175412318"></a>Choose <strong id="dli_09_0012__en-us_topic_0000001269342112_b1985311469156">Resources</strong> > <strong id="dli_09_0012__en-us_topic_0000001269342112_b8853146141510">Queue Management</strong> from the navigation pane, locate the queue you created in <a href="#dli_09_0012__en-us_topic_0000001269342112_section792923214216">Step 1: Create a Queue</a>. In the <strong id="dli_09_0012__en-us_topic_0000001269342112_b785314641514">Operation</strong> column, click <strong id="dli_09_0012__en-us_topic_0000001269342112_b1085317461151">More</strong> > <strong id="dli_09_0012__en-us_topic_0000001269342112_b18853846131516">Test Address Connectivity</strong>.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li7816454162319">In the displayed dialog box, enter <em id="dli_09_0012__en-us_topic_0000001269342112_i3849174851519">floating IP address</em><strong id="dli_09_0012__en-us_topic_0000001269342112_b1284915482150">:</strong><em id="dli_09_0012__en-us_topic_0000001269342112_i285064831514">database port</em> of the GaussDB(DWS) instance you have obtained in <a href="#dli_09_0012__en-us_topic_0000001269342112_li19666016361">2</a> in the <strong id="dli_09_0012__en-us_topic_0000001269342112_b19850204861511">Address</strong> box and click <strong id="dli_09_0012__en-us_topic_0000001269342112_b1885044841514">Test</strong> to check whether the database is reachable.</li></ol>
|
|
</li></ul>
|
|
</div>
|
|
<div class="section" id="dli_09_0012__en-us_topic_0000001269342112_section12448959174212"><a name="dli_09_0012__en-us_topic_0000001269342112_section12448959174212"></a><a name="en-us_topic_0000001269342112_section12448959174212"></a><h4 class="sectiontitle">Step 5: Run a Job</h4><ol id="dli_09_0012__en-us_topic_0000001269342112_ol1313811362437"><li id="dli_09_0012__en-us_topic_0000001269342112_li219661215114">On the DLI management console, choose <strong id="dli_09_0012__en-us_topic_0000001269342112_b129691850141511">Job Management</strong> > <strong id="dli_09_0012__en-us_topic_0000001269342112_b69691850151516">Flink Jobs</strong>. On the <strong id="dli_09_0012__en-us_topic_0000001269342112_b139701550171518">Flink Jobs</strong> page, click <strong id="dli_09_0012__en-us_topic_0000001269342112_b1297075041512">Create Job</strong>.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li18197181225114">In the <strong id="dli_09_0012__en-us_topic_0000001269342112_b1217515531153"> Create Job</strong> dialog box, set <strong id="dli_09_0012__en-us_topic_0000001269342112_b121754538151">Type</strong> to <strong id="dli_09_0012__en-us_topic_0000001269342112_b10176135361513">Flink OpenSource SQL</strong> and <strong id="dli_09_0012__en-us_topic_0000001269342112_b71769538152">Name</strong> to <strong id="dli_09_0012__en-us_topic_0000001269342112_b13176953181517">FlinkCDCMySQLDWS</strong>. Click <strong id="dli_09_0012__en-us_topic_0000001269342112_b14167111142111">OK</strong>.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li119731295112">On the job editing page, set the following parameters and retain the default values of other parameters.<ul id="dli_09_0012__en-us_topic_0000001269342112_ul1970291612112"><li id="dli_09_0012__en-us_topic_0000001269342112_li6702216152118"><strong id="dli_09_0012__en-us_topic_0000001269342112_b88562317211">Queue</strong>: Select the queue created in <a href="#dli_09_0012__en-us_topic_0000001269342112_section792923214216">Step 1: Create a Queue</a>.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li1629221563615"><strong id="dli_09_0012__en-us_topic_0000001269342112_b223075102120">Flink Version</strong>: Select <strong id="dli_09_0012__en-us_topic_0000001269342112_b102302055219">1.12</strong>.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li84401118192110"><strong id="dli_09_0012__en-us_topic_0000001269342112_b1117618619211">Save Job Log</strong>: Enable this function.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li12684193718212"><strong id="dli_09_0012__en-us_topic_0000001269342112_b1740612762118">OBS Bucket</strong>: Select an OBS bucket for storing job logs and grant access permissions of the OBS bucket as prompted.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li1382275713215"><strong id="dli_09_0012__en-us_topic_0000001269342112_b2029416815219">Enable Checkpointing</strong>: Enable this function.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li1479717252318">Enter a SQL statement in the editing pane. The following is an example. Modify the parameters in bold as you need.<div class="note" id="dli_09_0012__en-us_topic_0000001269342112_note16434951143717"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="dli_09_0012__en-us_topic_0000001269342112_p193401434164514">In this example, the syntax version of Flink OpenSource SQL is 1.12. In this example, the data source is Kafka and the result data is written to Elasticsearch.</p>
|
|
</div></div>
|
|
<pre class="screen" id="dli_09_0012__en-us_topic_0000001269342112_screen453112325017">create table mysqlCdcSource(
|
|
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' = 'mysql-cdc',
|
|
'hostname' = ' <em id="dli_09_0012__en-us_topic_0000001269342112_i19464628164412"><strong id="dli_09_0012__en-us_topic_0000001269342112_b820272854419">192.168.12.148</strong></em>',--IP address of the RDS MySQL instance
|
|
'port'= ' <em id="dli_09_0012__en-us_topic_0000001269342112_i596143013442"><strong id="dli_09_0012__en-us_topic_0000001269342112_b18676630144415">3306</strong></em>',--Port number of the RDS MySQL instance
|
|
'pwd_auth_name'= '<em id="dli_09_0012__en-us_topic_0000001269342112_i0194132294515"><strong id="dli_09_0012__en-us_topic_0000001269342112_b141931226457">xxxxx</strong></em>', -- Name of the datasource authentication of the password type created on DLI. If datasource authentication is used, you do not need to set the username and password for the job.
|
|
'database-name' = ' <em id="dli_09_0012__en-us_topic_0000001269342112_i181771920154518"><strong id="dli_09_0012__en-us_topic_0000001269342112_b129151919124514">testrdsdb</strong></em>',--Database name of the RDS MySQL instance
|
|
'table-name' = ' <em id="dli_09_0012__en-us_topic_0000001269342112_i2908045134510"><strong id="dli_09_0012__en-us_topic_0000001269342112_b368664534516">mysqlcdc</strong></em>'--Name of the tartet table in the database
|
|
);
|
|
|
|
create table dwsSink(
|
|
order_channel string,
|
|
pay_amount double,
|
|
real_pay double,
|
|
primary key(order_channel) not enforced
|
|
) with (
|
|
'connector' = 'gaussdb',
|
|
'driver' = 'com.gauss200.jdbc.Driver',
|
|
'url'='jdbc:gaussdb://<strong id="dli_09_0012__en-us_topic_0000001269342112_b354295452411"><em id="dli_09_0012__en-us_topic_0000001269342112_i953616547241">192.168.168.16:8000</em>/testdwsdb</strong> ', ---192.168.168.16:8000 indicates the internal IP address and port of the GaussDB(DWS) instance. testdwsdb indicates the name of the created GaussDB(DWS) database.
|
|
'table-name' = ' <strong id="dli_09_0012__en-us_topic_0000001269342112_b11914262516">test\".\"dwsresult</strong>', ---test indicates the schema of the created GaussDB(DWS) table, and dwsresult indicates the GaussDB(DWS) table name.
|
|
'pwd_auth_name'= '<em id="dli_09_0012__en-us_topic_0000001269342112_i972316917466"><strong id="dli_09_0012__en-us_topic_0000001269342112_b772399124618">xxxxx</strong></em>', -- Name of the datasource authentication of the password type created on DLI. If datasource authentication is used, you do not need to set the username and password for the job.
|
|
'write.mode' = 'insert'
|
|
);
|
|
|
|
insert into dwsSink select order_channel, sum(pay_amount),sum(real_pay) from mysqlCdcSource group by order_channel;</pre>
|
|
</li></ul>
|
|
</li><li id="dli_09_0012__en-us_topic_0000001269342112_li219761217517">Click <strong id="dli_09_0012__en-us_topic_0000001269342112_b199521712162616">Check Semantic</strong> and ensure that the SQL statement passes the check. Click <strong id="dli_09_0012__en-us_topic_0000001269342112_b9802141311267">Save</strong>. Click <strong id="dli_09_0012__en-us_topic_0000001269342112_b35391514142613">Start</strong>, confirm the job parameters, and click <strong id="dli_09_0012__en-us_topic_0000001269342112_b353931417268">Start Now</strong> to execute the job. Wait until the job status changes to <strong id="dli_09_0012__en-us_topic_0000001269342112_b3344215142615">Running</strong>.</li></ol>
|
|
</div>
|
|
<div class="section" id="dli_09_0012__en-us_topic_0000001269342112_section4387527162418"><a name="dli_09_0012__en-us_topic_0000001269342112_section4387527162418"></a><a name="en-us_topic_0000001269342112_section4387527162418"></a><h4 class="sectiontitle">Step 6: Send Data and Query Results</h4><ol id="dli_09_0012__en-us_topic_0000001269342112_ol0558165272410"><li id="dli_09_0012__en-us_topic_0000001269342112_li1942135894212">Log in to the RDS console. On the displayed page, locate the target MySQL DB instance and choose <strong id="dli_09_0012__en-us_topic_0000001269342112_b17523151752620">More</strong> > <strong id="dli_09_0012__en-us_topic_0000001269342112_b3524111712264">Log In</strong> in the <strong id="dli_09_0012__en-us_topic_0000001269342112_b12524517132610">Operation</strong> column.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li3202121184911">On the displayed login dialog box, enter the username and password and click <strong id="dli_09_0012__en-us_topic_0000001269342112_b101183411267">Log In</strong>.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li1247361815504">In the <strong id="dli_09_0012__en-us_topic_0000001269342112_b1465733410265">Operation</strong> column of row where the created database locates, click <strong id="dli_09_0012__en-us_topic_0000001269342112_b86580348262">SQL Window</strong> and enter the following statement to create a table and insert data to the table:<pre class="screen" id="dli_09_0012__en-us_topic_0000001269342112_screen15137185717515">insert into mysqlcdc values
|
|
('202103241000000001','webShop','2021-03-24 10:00:00','100.00','100.00','2021-03-24 10:02:03','0001','Alice','330106'),
|
|
('202103241206060001','appShop','2021-03-24 12:06:06','200.00','180.00','2021-03-24 16:10:06','0002','Jason','330106'),
|
|
('202103241403000001','webShop','2021-03-24 14:03:00','300.00','100.00','2021-03-24 10:02:03','0003','Lily','330106'),
|
|
('202103241636060001','appShop','2021-03-24 16:36:06','200.00','150.00','2021-03-24 16:10:06','0001','Henry','330106');</pre>
|
|
</li><li id="dli_09_0012__en-us_topic_0000001269342112_li1113716579515">.</li><li id="dli_09_0012__en-us_topic_0000001269342112_li1047472222014">Connect to the default database <strong id="dli_09_0012__en-us_topic_0000001269342112_b5313171911277">testdwsdb</strong> of a GaussDB(DWS) cluster.<pre class="screen" id="dli_09_0012__en-us_topic_0000001269342112_screen58207310201">gsql -d testdwsdb -h <em id="dli_09_0012__en-us_topic_0000001269342112_i11459142019274">Connection address of the GaussDB(DWS) cluster</em> -U dbadmin -p 8000 -W <em id="dli_09_0012__en-us_topic_0000001269342112_i11460152022712">password</em> -r</pre>
|
|
</li><li id="dli_09_0012__en-us_topic_0000001269342112_li4931152514209">Run the following statements to query table data:<pre class="screen" id="dli_09_0012__en-us_topic_0000001269342112_screen893492516205">select * from test.dwsresult;</pre>
|
|
<div class="p" id="dli_09_0012__en-us_topic_0000001269342112_p13934102532017">The query result is as follows:<pre class="screen" id="dli_09_0012__en-us_topic_0000001269342112_screen4934325122014">order_channel pay_amount real_pay
|
|
appShop 400.0 330.0
|
|
webShop 400.0 200.0</pre>
|
|
</div>
|
|
</li></ol>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dli_09_0006.html">Flink OpenSource SQL Jobs</a></div>
|
|
</div>
|
|
</div>
|
|
|