doc-exports/docs/dws/umn/dws_01_0039.html
luhuayi 85562e1879 DWS UMN 831.100 version
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: luhuayi <luhuayi@huawei.com>
Co-committed-by: luhuayi <luhuayi@huawei.com>
2024-11-13 08:55:54 +00:00

145 lines
17 KiB
HTML

<a name="EN-US_TOPIC_0000001924728760"></a><a name="EN-US_TOPIC_0000001924728760"></a>
<h1 class="topictitle1">Managing Database Connections</h1>
<div id="body1491553271744"><div class="section" id="EN-US_TOPIC_0000001924728760__section17619740162122"><h4 class="sectiontitle">Scenario</h4><p id="EN-US_TOPIC_0000001924728760__p46027906162126">By default, a database supports a certain number of connections. Administrators can manage database connections to learn about the connection performance of the current database or increase the connection limit so that more users or applications can connect to the database at the same time.</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001924728760__section18787142425711"><h4 class="sectiontitle">Maximum Number of Connections</h4><p id="EN-US_TOPIC_0000001924728760__p1765194119589">The number of connections supported by a cluster depends on its node flavor.</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001924728760__table557563285720" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Number of supported connections</caption><thead align="left"><tr id="EN-US_TOPIC_0000001924728760__row4575123218579"><th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.2.3.2.5.1.1"><p id="EN-US_TOPIC_0000001924728760__p125751232155713">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="30%" id="mcps1.3.2.3.2.5.1.2"><p id="EN-US_TOPIC_0000001924728760__p6759199137">Description</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="19.98%" id="mcps1.3.2.3.2.5.1.3"><p id="EN-US_TOPIC_0000001924728760__p55759329576">Number of CN Connections</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="30.020000000000003%" id="mcps1.3.2.3.2.5.1.4"><p id="EN-US_TOPIC_0000001924728760__p25759329573">Number of DN Connections</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001924728760__row1457613328578"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.3.2.5.1.1 "><p id="EN-US_TOPIC_0000001924728760__p557623245711">max_connections</p>
</td>
<td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.2.3.2.5.1.2 "><p id="EN-US_TOPIC_0000001924728760__p1975131911312">Specifies the maximum number of concurrent connections to the database.</p>
</td>
<td class="cellrowborder" rowspan="3" valign="top" width="19.98%" headers="mcps1.3.2.3.2.5.1.3 "><p id="EN-US_TOPIC_0000001924728760__p45764328573">800</p>
<p id="EN-US_TOPIC_0000001924728760__p149331833961"></p>
<p id="EN-US_TOPIC_0000001924728760__p3126338067"></p>
</td>
<td class="cellrowborder" rowspan="3" valign="top" width="30.020000000000003%" headers="mcps1.3.2.3.2.5.1.4 "><p id="EN-US_TOPIC_0000001924728760__p9576173215711">Max (Number of vCPU cores/Number of DNs on a single node x 120 + 24, 5000)</p>
<p id="EN-US_TOPIC_0000001924728760__p993317331862"></p>
<p id="EN-US_TOPIC_0000001924728760__p171262386611"></p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001924728760__row11932143318620"><td class="cellrowborder" valign="top" headers="mcps1.3.2.3.2.5.1.1 "><p id="EN-US_TOPIC_0000001924728760__p689016910614">max_pool_size</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.3.2.3.2.5.1.2 "><p id="EN-US_TOPIC_0000001924728760__p1175141961312">Specifies the maximum number of connections between the connection pool of a CN and another CN or DN.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001924728760__row2126838365"><td class="cellrowborder" valign="top" headers="mcps1.3.2.3.2.5.1.1 "><p id="EN-US_TOPIC_0000001924728760__p1655310211462">max_prepared_transactions</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.3.2.3.2.5.1.2 "><p id="EN-US_TOPIC_0000001924728760__p27612191132">Specifies the maximum number of transactions that can stay in the <strong id="EN-US_TOPIC_0000001924728760__b15927030074618">prepared</strong> state simultaneously.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001924728760__section63237288162656"><h4 class="sectiontitle">Viewing the Maximum Number of Connections</h4><p id="EN-US_TOPIC_0000001924728760__p7668117143418">Method 1: Post cluster creation, select the cluster name on the GaussDB(DWS) console to access the <strong id="EN-US_TOPIC_0000001924728760__b17389869774618">Parameter Modification</strong> page and view the value of <strong id="EN-US_TOPIC_0000001924728760__b555226274618">max_connections</strong>.</p>
<div class="p" id="EN-US_TOPIC_0000001924728760__p12205169113411">Method 2: Use an SQL client tool to establish a database connection within the cluster and execute an SQL query to obtain the value of <strong id="EN-US_TOPIC_0000001924728760__b129271487774618">max_connections</strong>.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001924728760__screen2825194581012"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SHOW</span><span class="w"> </span><span class="n">max_connections</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</div>
<p id="EN-US_TOPIC_0000001924728760__p61212335163113">Information similar to the following is displayed, showing that the maximum number of database connections is <strong id="EN-US_TOPIC_0000001924728760__b842352706113115">200</strong> by default.</p>
<pre class="screen" id="EN-US_TOPIC_0000001924728760__screen55741306163042">max_connections
-----------------
200
(1 row)</pre>
</div>
<div class="section" id="EN-US_TOPIC_0000001924728760__section51149057162719"><h4 class="sectiontitle">Viewing the Number of Used Connections</h4><ol id="EN-US_TOPIC_0000001924728760__ol11467480163251"><li id="EN-US_TOPIC_0000001924728760__li38556866163251"><span>Use the SQL client tool to connect to the database in a cluster.</span></li><li id="EN-US_TOPIC_0000001924728760__li8717975163256"><span>View the number of connections in scenarios described in <a href="#EN-US_TOPIC_0000001924728760__table573712172169">Table 2</a>.</span><p><div class="notice" id="EN-US_TOPIC_0000001924728760__note169553114361"><span class="noticetitle"><img src="public_sys-resources/notice_3.0-en-us.png"> </span><div class="noticebody"><p id="EN-US_TOPIC_0000001924728760__en-us_topic_0000001188642224_p795616114368">Except for database and user names that are enclosed with double quotation marks (") during creation, uppercase letters are not allowed in the database and user names in the commands in the following table.</p>
</div></div>
<div class="tablenoborder"><a name="EN-US_TOPIC_0000001924728760__table573712172169"></a><a name="table573712172169"></a><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001924728760__table573712172169" frame="border" border="1" rules="all"><caption><b>Table 2 </b>Viewing the number of connections</caption><thead align="left"><tr id="EN-US_TOPIC_0000001924728760__r179959cf45364cf58c799bda03c7bb64"><th align="left" class="cellrowborder" valign="top" width="31.41%" id="mcps1.3.4.2.2.2.2.2.3.1.1"><p id="EN-US_TOPIC_0000001924728760__ae171f1cd533b4726b49baf1132425434"><strong id="EN-US_TOPIC_0000001924728760__b3780005091637">Description</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="68.58999999999999%" id="mcps1.3.4.2.2.2.2.2.3.1.2"><p id="EN-US_TOPIC_0000001924728760__a28ea6d3b74bd402e9d3dcfeeb2e0746f"><strong id="EN-US_TOPIC_0000001924728760__b997270598115138">Command</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001924728760__rf78f73de6ad54b2a8e09f2d3382d3dbd"><td class="cellrowborder" valign="top" width="31.41%" headers="mcps1.3.4.2.2.2.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001924728760__afb7e4b301e2843e7a08a5ff536ddbeed">View the maximum number of sessions connected to a specific user.</p>
</td>
<td class="cellrowborder" valign="top" width="68.58999999999999%" headers="mcps1.3.4.2.2.2.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001924728760__p13379174213154">Run the following command to view the maximum number of sessions connected to user <strong id="EN-US_TOPIC_0000001924728760__b865093478115336">dbadmin</strong>. </p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001924728760__screen2212164912153"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="n">ROLNAME</span><span class="p">,</span><span class="n">ROLCONNLIMIT</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">PG_ROLES</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="n">ROLNAME</span><span class="o">=</span><span class="s1">'dbadmin'</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001924728760__ab8dd33c527184267906ad039a6609f45">Information similar to the following is displayed. <span class="parmvalue" id="EN-US_TOPIC_0000001924728760__parmvalue1796574260115424"><b>-1</b></span> indicates that the number of sessions connected to user <strong id="EN-US_TOPIC_0000001924728760__b2043011165115517">dbadmin</strong> is not limited.</p>
<pre class="screen" id="EN-US_TOPIC_0000001924728760__screen5384699191838"> rolname | rolconnlimit
----------+--------------
dwsadmin | -1
(1 row)</pre>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001924728760__rb9364ee1488746ba915d61980913738b"><td class="cellrowborder" valign="top" width="31.41%" headers="mcps1.3.4.2.2.2.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001924728760__a84b65df54eb7428fb4beefcf68b01d51">View the number of session connections that have been used by a user.</p>
</td>
<td class="cellrowborder" valign="top" width="68.58999999999999%" headers="mcps1.3.4.2.2.2.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001924728760__p4469493185">Run the following command to view the number of session connections that have been used by <strong id="EN-US_TOPIC_0000001924728760__b125312233611565">dbadmin</strong>.</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001924728760__screen104591518171819"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="k">COUNT</span><span class="p">(</span><span class="o">*</span><span class="p">)</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">V$SESSION</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="n">USERNAME</span><span class="o">=</span><span class="s1">'dbadmin'</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001924728760__a7bbf9e48551c4e42bc4e3d96f03ef5f9">Information similar to the following is displayed. <span class="parmvalue" id="EN-US_TOPIC_0000001924728760__parmvalue6572030216394"><b>1</b></span> indicates the number of session connections used by user <strong id="EN-US_TOPIC_0000001924728760__b3268088416391">dbadmin</strong>.</p>
<pre class="screen" id="EN-US_TOPIC_0000001924728760__screen32646809135149"> count
-------
1
(1 row)</pre>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001924728760__r889ca3da3fd94fac8d7084502eb05337"><td class="cellrowborder" valign="top" width="31.41%" headers="mcps1.3.4.2.2.2.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001924728760__a299da3745d0b40e48789114e0fa70011">View the maximum number of sessions connected to a specific database.</p>
</td>
<td class="cellrowborder" valign="top" width="68.58999999999999%" headers="mcps1.3.4.2.2.2.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001924728760__p1666713314192">View the upper limit of connections used by the <strong id="EN-US_TOPIC_0000001924728760__b1887421018342">postgres</strong> database.</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001924728760__screen11272363194"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="n">DATNAME</span><span class="p">,</span><span class="n">DATCONNLIMIT</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">PG_DATABASE</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="n">DATNAME</span><span class="o">=</span><span class="s1">'postgres'</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001924728760__ac7ab9e1f26c84b959f03594e27683d08">Information similar to the following is displayed. <span class="parmvalue" id="EN-US_TOPIC_0000001924728760__parmvalue1935916187345"><b>-1</b></span> indicates that the number of sessions connected to the <strong id="EN-US_TOPIC_0000001924728760__b18895123153419">postgres</strong> database is not limited.</p>
<pre class="screen" id="EN-US_TOPIC_0000001924728760__s116628f616314f27a5a02cd806cf7e23"> datname | datconnlimit
----------+--------------
postgres | -1
(1 row)</pre>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001924728760__r1d23eb9755ed45379a778f04d1a7ceea"><td class="cellrowborder" valign="top" width="31.41%" headers="mcps1.3.4.2.2.2.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001924728760__af67879da387345dc9470f0d5872e160c">View the number of session connections that have been used by a database.</p>
</td>
<td class="cellrowborder" valign="top" width="68.58999999999999%" headers="mcps1.3.4.2.2.2.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001924728760__p18457121482013">View the number of session connections that have been used by the <strong id="EN-US_TOPIC_0000001924728760__b17382114411349">postgres</strong> database.</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001924728760__screen15485102911204"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="k">COUNT</span><span class="p">(</span><span class="o">*</span><span class="p">)</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">PG_STAT_ACTIVITY</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="n">DATNAME</span><span class="o">=</span><span class="s1">'postgres'</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001924728760__adc65e02e0fde4ae2ae7bda282f3eb6a4">Information similar to the following is displayed. <span class="parmvalue" id="EN-US_TOPIC_0000001924728760__parmvalue918624171816"><b>1</b></span> indicates the number of session connections used by the <strong id="EN-US_TOPIC_0000001924728760__b19702058356">postgres</strong> database.</p>
<pre class="screen" id="EN-US_TOPIC_0000001924728760__screen502887401659"> count
-------
1
(1 row)</pre>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001924728760__rc9f924a62f4e4ea8b06e58653f1f3a90"><td class="cellrowborder" valign="top" width="31.41%" headers="mcps1.3.4.2.2.2.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001924728760__aa5d31760ef1d4425bd3e68793c11148c">View the number of session connections that have been used by all users.</p>
</td>
<td class="cellrowborder" valign="top" width="68.58999999999999%" headers="mcps1.3.4.2.2.2.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001924728760__p596419113364">Run the following command to view the number of session connections that have been used by all users:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001924728760__screen13964171113368"><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></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="k">COUNT</span><span class="p">(</span><span class="o">*</span><span class="p">)</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">PG_STAT_ACTIVITY</span><span class="p">;</span>
<span class="w"> </span><span class="k">count</span>
<span class="c1">-------</span>
<span class="w"> </span><span class="mi">10</span>
<span class="p">(</span><span class="mi">1</span><span class="w"> </span><span class="k">row</span><span class="p">)</span>
</pre></div></td></tr></table></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</p></li></ol>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_01_0131.html">Cluster Connection</a></div>
</div>
</div>