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>
110 lines
9.8 KiB
HTML
110 lines
9.8 KiB
HTML
<a name="dli_02_0311"></a><a name="dli_02_0311"></a>
|
|
|
|
<h1 class="topictitle1">Creating and Using a Datasource Connection</h1>
|
|
<div id="body1602473883611"><div class="section" id="dli_02_0311__section851316282599"><h4 class="sectiontitle">Scenario</h4><p id="dli_02_0311__p1822151903">This section describes how to create an enhanced datasource connection using an API.</p>
|
|
</div>
|
|
<div class="section" id="dli_02_0311__section155144213214"><h4 class="sectiontitle">Notes and Constraints</h4><ul id="dli_02_0311__ul759612191669"><li id="dli_02_0311__li45963199610">It takes 6 to 10 minutes to start a job using a new queue for the first time.</li><li id="dli_02_0311__li12597141912618">Before creating an enhanced datasource connection, you need to obtain the ID of the VPC and the network ID of the subnet where the service is located. </li></ul>
|
|
</div>
|
|
<div class="section" id="dli_02_0311__section13856162971"><h4 class="sectiontitle">Involved APIs</h4><ul id="dli_02_0311__ul1862251633812"><li id="dli_02_0311__li13929164064312"><a href="dli_02_0326.html">Creating an Elastic Resource Pool</a>: Create an elastic resource pool.</li><li id="dli_02_0311__li492974014318"><a href="dli_02_0194.html">Creating a Queue</a>: Create queues within the elastic resource pool.</li><li id="dli_02_0311__li46223161388"><a href="dli_02_0187.html">Creating an Enhanced Datasource Connection</a>: Create an enhanced datasource connection.</li><li id="dli_02_0311__li1137901761318"><a href="dli_02_0191.html">Binding a Queue</a>: Bind a queue.</li><li id="dli_02_0311__li1484215716133"><a href="dli_02_0189.html">Querying an Enhanced Datasource Connection</a>: Check whether an enhanced datasource connection is successfully created.</li></ul>
|
|
</div>
|
|
<div class="section" id="dli_02_0311__section2742155213719"><h4 class="sectiontitle">Procedure</h4><ol id="dli_02_0311__ol454620011213"><li id="dli_02_0311__li33424532067">Create an elastic resource pool named <strong id="dli_02_0311__b18160192011167">elastic_pool_dli</strong>.<ul id="dli_02_0311__ul12410110912"><li id="dli_02_0311__li11419115919">API<p id="dli_02_0311__p164191891"><a name="dli_02_0311__li11419115919"></a><a name="li11419115919"></a>URI format: POST /v3/{project_id}/elastic-resource-pools</p>
|
|
<ul id="dli_02_0311__ul1241011696"><li id="dli_02_0311__li859113919">Obtain the value of <em id="dli_02_0311__i3950202491617">{project_id}</em> by referring to <a href="dli_02_0183.html">Obtaining a Project ID</a>.</li><li id="dli_02_0311__li15516118917">For details about the request parameters, see <a href="dli_02_0326.html">Creating an Elastic Resource Pool</a>.</li></ul>
|
|
</li><li id="dli_02_0311__li12516114916">Example request<ul id="dli_02_0311__ul751915920"><li id="dli_02_0311__li566016160313">Description: Create an elastic resource pool named <strong id="dli_02_0311__b142515319161">elastic_pool_dli</strong> in the project whose ID is <strong id="dli_02_0311__b1725219312164">48cc2c48765f481480c7db940d6409d1</strong>.</li><li id="dli_02_0311__li35614911">Example URL: POST https://{endpoint}/v3/48cc2c48765f481480c7db940d6409d1/elastic-resource-pools</li><li id="dli_02_0311__li45411199">Body:<pre class="screen" id="dli_02_0311__screen12372049928">{
|
|
"elastic_resource_pool_name" : "elastic_pool_dli",
|
|
"description" : "test",
|
|
"cidr_in_vpc" : "172.16.0.0/14",
|
|
"charging_mode" : "1",
|
|
"max_cu" : 64,
|
|
"min_cu" : 64
|
|
}</pre>
|
|
</li></ul>
|
|
</li><li id="dli_02_0311__li151915918">Example response<pre class="screen" id="dli_02_0311__screen75911798">{
|
|
"is_success": true,
|
|
"message": ""
|
|
}</pre>
|
|
</li></ul>
|
|
</li><li id="dli_02_0311__li1353820471116">Create a queue named <strong id="dli_02_0311__b18181103817161">queue1</strong> in the elastic resource pool.<ul id="dli_02_0311__ul25387411111"><li id="dli_02_0311__li3538940114">API<p id="dli_02_0311__p353814419114"><a name="dli_02_0311__li3538940114"></a><a name="li3538940114"></a>URI format: POST /v1.0/{project_id}/queues</p>
|
|
<ul id="dli_02_0311__ul1853810411114"><li id="dli_02_0311__li55381045113">Obtain the value of <em id="dli_02_0311__i794024241617">{project_id}</em> by referring to <a href="dli_02_0183.html">Obtaining a Project ID</a>.</li><li id="dli_02_0311__li35388431118">For details about the request parameters, see <a href="dli_02_0194.html">Creating a Queue</a>.</li></ul>
|
|
</li><li id="dli_02_0311__li7538164171114">Example request<ul id="dli_02_0311__ul125381147119"><li id="dli_02_0311__li1853864171117">Description: Create an elastic resource pool named <strong id="dli_02_0311__b1950064831614">queue1</strong> in the project whose ID is <strong id="dli_02_0311__b17500154811610">48cc2c48765f481480c7db940d6409d1</strong>.</li><li id="dli_02_0311__li1053817421112">Example URL: POST https://{<em id="dli_02_0311__i1452818500163">endpoint</em>}/v1.0/48cc2c48765f481480c7db940d6409d1/queues</li><li id="dli_02_0311__li15383461112">Body:<pre class="screen" id="dli_02_0311__screen105384441117">{
|
|
"queue_name": "queue1",
|
|
"queue_type": "sql",
|
|
"description": "test",
|
|
"cu_count": 16,
|
|
"enterprise_project_id": "elastic_pool_dli"
|
|
}</pre>
|
|
</li></ul>
|
|
</li><li id="dli_02_0311__li753818411110">Example response<pre class="screen" id="dli_02_0311__screen253811441117">{
|
|
"is_success": true,
|
|
"message": ""
|
|
}</pre>
|
|
</li></ul>
|
|
</li><li id="dli_02_0311__li117291344122510">Create an enhanced datasource connection.<ul id="dli_02_0311__ul2729144122513"><li id="dli_02_0311__li57278446258">API<p id="dli_02_0311__p7727134452510"><a name="dli_02_0311__li57278446258"></a><a name="li57278446258"></a>URI format: POST /v2.0/{<em id="dli_02_0311__i17726132518319">project_id</em>}/datasource/enhanced-connections</p>
|
|
<ul id="dli_02_0311__ul14727644162512"><li id="dli_02_0311__li9727134442515">Obtain the value of {<em id="dli_02_0311__i6335127333">project_id</em>} from <a href="dli_02_0183.html">Obtaining a Project ID</a>.</li><li id="dli_02_0311__li1372710448250">For details about the request parameters, see <a href="dli_02_0187.html">Creating an Enhanced Datasource Connection</a>.</li></ul>
|
|
</li><li id="dli_02_0311__li5728744172513">Example request<ul id="dli_02_0311__ul772864412254"><li id="dli_02_0311__li17728194415253">Description: Create an enhanced datasource connection named <strong id="dli_02_0311__b731511474310">test1</strong> in project <strong id="dli_02_0311__b14941155112316">48cc2c48765f481480c7db940d6409d1</strong>.</li><li id="dli_02_0311__li137287448256">Example URL: POST https://{<em id="dli_02_0311__i154195719312">endpoint</em>}/v2.0/48cc2c48765f481480c7db940d6409d1/datasource/enhanced-connections</li><li id="dli_02_0311__li14728144414252">Body:<pre class="screen" id="dli_02_0311__screen672864492517">{
|
|
"name": "test1",
|
|
"dest_vpc_id": "22094d8f-c310-4621-913d-4c4d655d8495",
|
|
"dest_network_id": "78f2562a-36e4-4b39-95b9-f5aab22e1281",
|
|
"elastic_resource_pools": "elastic_pool_dli",
|
|
"hosts": [
|
|
{
|
|
"ip":"192.168.0.1",
|
|
"name":"ecs-97f8-0001"
|
|
},
|
|
{
|
|
"ip":"192.168.0.2",
|
|
"name":"ecs-97f8-0002"
|
|
}
|
|
]
|
|
}</pre>
|
|
</li></ul>
|
|
</li><li id="dli_02_0311__li19729134452514">Example response<pre class="screen" id="dli_02_0311__screen15729114442511">{
|
|
"is_success": true,
|
|
"message": "",
|
|
"connection_id": "2a620c33-5609-40c9-affd-2b6453071b0f"
|
|
}</pre>
|
|
</li></ul>
|
|
</li><li id="dli_02_0311__li566476163912">(Optional) If no queue is bound when you create an enhanced datasource connection, you can use the <a href="dli_02_0191.html">Binding a Queue</a> API to bind a queue.</li><li id="dli_02_0311__li125211016104016">Verify that the enhanced datasource connection is created successfully.<ul id="dli_02_0311__ul26571210114414"><li id="dli_02_0311__li146576102444">API<p id="dli_02_0311__p10657111019442"><a name="dli_02_0311__li146576102444"></a><a name="li146576102444"></a>URI format: GET /v2.0/{<em id="dli_02_0311__i4198836341">project_id</em>}/datasource/enhanced-connections/{<em id="dli_02_0311__i18339124015410">connection_id</em>}</p>
|
|
<ul id="dli_02_0311__ul56581107449"><li id="dli_02_0311__li17658191013442">Obtain the value of {<em id="dli_02_0311__i1254211412417">project_id</em>} from <a href="dli_02_0183.html">Obtaining a Project ID</a>.</li><li id="dli_02_0311__li3658201018442">For details about the query parameters, see <a href="dli_02_0028.html">Creating a Database (Deprecated)</a>.</li></ul>
|
|
</li><li id="dli_02_0311__li10658410164410">Example request<ul id="dli_02_0311__ul14658161015442"><li id="dli_02_0311__li865851014449">Description: Query an enhanced datasource connection whose ID is <strong id="dli_02_0311__b16136145912418">2a620c33-5609-40c9-affd-2b6453071b0f</strong> in project <strong id="dli_02_0311__b156471831520">48cc2c48765f481480c7db940d6409d1</strong>.</li><li id="dli_02_0311__li6658171074411">Example URL: GET https://{<em id="dli_02_0311__i342351111511">endpoint</em>}/v2.0/48cc2c48765f481480c7db940d6409d1/datasource/enhanced-connections/2a620c33-5609-40c9-affd-2b6453071b0f</li><li id="dli_02_0311__li165811084419">Body:<pre class="screen" id="dli_02_0311__screen3658131064420">{}</pre>
|
|
</li></ul>
|
|
</li><li id="dli_02_0311__li2065912101446">Example response<pre class="screen" id="dli_02_0311__screen765961024418">{
|
|
"is_success": true,
|
|
"message": "",
|
|
"name": "test1",
|
|
"id": "2a620c33-5609-40c9-affd-2b6453071b0f",
|
|
"elastic_resource_pools": [
|
|
{
|
|
"status": "ACTIVE",
|
|
"name": "elastic_pool_dli",
|
|
"peer_id": "2a620c33-5609-40c9-affd-2b6453071b0f",
|
|
"err_msg": "",
|
|
"update_time": 1566889577861
|
|
}
|
|
],
|
|
"dest_vpc_id": "22094d8f-c310-4621-913d-4c4d655d8495",
|
|
"dest_network_id": "78f2562a-36e4-4b39-95b9-f5aab22e1281",
|
|
"isPrivis": true,
|
|
"create_time": 1566888011125,
|
|
"status": "ACTIVE",
|
|
"hosts": [
|
|
{
|
|
"ip":"192.168.0.1",
|
|
"name":"ecs-97f8-0001"
|
|
},
|
|
{
|
|
"ip":"192.168.0.2",
|
|
"name":"ecs-97f8-0002"
|
|
}
|
|
]
|
|
}</pre>
|
|
</li></ul>
|
|
</li></ol>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dli_02_0306.html">Getting Started</a></div>
|
|
</div>
|
|
</div>
|
|
|