forked from docs/doc-exports
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com> Co-authored-by: Lu, Huayi <luhuayi@huawei.com> Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
149 lines
17 KiB
HTML
149 lines
17 KiB
HTML
<a name="EN-US_TOPIC_0000001134560490"></a><a name="EN-US_TOPIC_0000001134560490"></a>
|
|
|
|
<h1 class="topictitle1">Managing Database Connections</h1>
|
|
<div id="body1491553271744"><div class="section" id="EN-US_TOPIC_0000001134560490__section17619740162122"><h4 class="sectiontitle">Scenario</h4><p id="EN-US_TOPIC_0000001134560490__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_0000001134560490__section18787142425711"><h4 class="sectiontitle">Maximum Number of Connections</h4><p id="EN-US_TOPIC_0000001134560490__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_0000001134560490__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_0000001134560490__row4575123218579"><th align="left" class="cellrowborder" valign="top" width="19.8%" id="mcps1.3.2.3.2.5.1.1"><p id="EN-US_TOPIC_0000001134560490__p125751232155713">Parameter</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="30.2%" id="mcps1.3.2.3.2.5.1.2"><p id="EN-US_TOPIC_0000001134560490__p2243132355812">Node Flavor</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="25%" id="mcps1.3.2.3.2.5.1.3"><p id="EN-US_TOPIC_0000001134560490__p55759329576">Number of CN Connections</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="25%" id="mcps1.3.2.3.2.5.1.4"><p id="EN-US_TOPIC_0000001134560490__p25759329573">Number of DN Connections</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="EN-US_TOPIC_0000001134560490__row1457613328578"><td class="cellrowborder" rowspan="3" valign="top" width="19.8%" headers="mcps1.3.2.3.2.5.1.1 "><p id="EN-US_TOPIC_0000001134560490__p557623245711">max_connections</p>
|
|
<p id="EN-US_TOPIC_0000001134560490__p65765328573"></p>
|
|
<p id="EN-US_TOPIC_0000001134560490__p2057643275712"></p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="30.2%" headers="mcps1.3.2.3.2.5.1.2 "><p id="EN-US_TOPIC_0000001134560490__p6576103235714">vCPUs < 16</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.2.3.2.5.1.3 "><p id="EN-US_TOPIC_0000001134560490__p45764328573">512</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.2.3.2.5.1.4 "><p id="EN-US_TOPIC_0000001134560490__p9576173215711">Number of CN connections x 2</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001134560490__row1057616328572"><td class="cellrowborder" valign="top" headers="mcps1.3.2.3.2.5.1.1 "><p id="EN-US_TOPIC_0000001134560490__p957613210571">vCPUs > 16 && <= 32</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" headers="mcps1.3.2.3.2.5.1.2 "><p id="EN-US_TOPIC_0000001134560490__p1657663245712">1024</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" headers="mcps1.3.2.3.2.5.1.3 "><p id="EN-US_TOPIC_0000001134560490__p16576132115715">Number of CN connections x 2</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001134560490__row1057693213577"><td class="cellrowborder" valign="top" headers="mcps1.3.2.3.2.5.1.1 "><p id="EN-US_TOPIC_0000001134560490__p1657643216578">other</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" headers="mcps1.3.2.3.2.5.1.2 "><p id="EN-US_TOPIC_0000001134560490__p1157613327577">2048</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" headers="mcps1.3.2.3.2.5.1.3 "><p id="EN-US_TOPIC_0000001134560490__p6576183295718">Number of CN connections x 2</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div class="note" id="EN-US_TOPIC_0000001134560490__note20517134217317"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001134560490__p14517142834">The policies of <strong id="EN-US_TOPIC_0000001134560490__b09971815175213">comm_max_stream</strong>, <strong id="EN-US_TOPIC_0000001134560490__b476741785213">poolsize</strong>, and <strong id="EN-US_TOPIC_0000001134560490__b1167613202527">max_prepared_transactions</strong> are the same as those of <strong id="EN-US_TOPIC_0000001134560490__b14413182495215">max_connections</strong>.</p>
|
|
</div></div>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001134560490__section63237288162656"><h4 class="sectiontitle">Viewing the Maximum Number of Connections</h4><ol id="EN-US_TOPIC_0000001134560490__ol7904741162927"><li id="EN-US_TOPIC_0000001134560490__li19203152162927"><span>Use the SQL client tool to connect to the database in a cluster.</span></li><li id="EN-US_TOPIC_0000001134560490__li32991024162943"><span>Run the following command:</span><p><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001134560490__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><span class="w"></span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
<p id="EN-US_TOPIC_0000001134560490__p61212335163113">Information similar to the following is displayed, showing that the maximum number of database connections is <strong id="EN-US_TOPIC_0000001134560490__b842352706113115">200</strong> by default.</p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001134560490__screen55741306163042">max_connections
|
|
-----------------
|
|
200
|
|
(1 row)</pre>
|
|
</p></li></ol>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001134560490__section51149057162719"><h4 class="sectiontitle">Viewing the Number of Used Connections</h4><ol id="EN-US_TOPIC_0000001134560490__ol11467480163251"><li id="EN-US_TOPIC_0000001134560490__li38556866163251"><span>Use the SQL client tool to connect to the database in a cluster.</span></li><li id="EN-US_TOPIC_0000001134560490__li8717975163256"><span>View the number of connections in scenarios described in <a href="#EN-US_TOPIC_0000001134560490__tecae727d5c1d47f897891d48c13a5589">Table 2</a>.</span><p>
|
|
<div class="tablenoborder"><a name="EN-US_TOPIC_0000001134560490__tecae727d5c1d47f897891d48c13a5589"></a><a name="tecae727d5c1d47f897891d48c13a5589"></a><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001134560490__tecae727d5c1d47f897891d48c13a5589" 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_0000001134560490__r179959cf45364cf58c799bda03c7bb64"><th align="left" class="cellrowborder" valign="top" width="31.41%" id="mcps1.3.4.2.2.2.1.2.3.1.1"><p id="EN-US_TOPIC_0000001134560490__ae171f1cd533b4726b49baf1132425434"><strong id="EN-US_TOPIC_0000001134560490__b3780005091637">Description</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="68.58999999999999%" id="mcps1.3.4.2.2.2.1.2.3.1.2"><p id="EN-US_TOPIC_0000001134560490__a28ea6d3b74bd402e9d3dcfeeb2e0746f"><strong id="EN-US_TOPIC_0000001134560490__b997270598115138">Command</strong></p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="EN-US_TOPIC_0000001134560490__rf78f73de6ad54b2a8e09f2d3382d3dbd"><td class="cellrowborder" valign="top" width="31.41%" headers="mcps1.3.4.2.2.2.1.2.3.1.1 "><p id="EN-US_TOPIC_0000001134560490__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.1.2.3.1.2 "><p id="EN-US_TOPIC_0000001134560490__p13379174213154">Run the following command to view the maximum number of sessions connected to user <strong id="EN-US_TOPIC_0000001134560490__b865093478115336">dbadmin</strong>. </p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001134560490__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><span class="w"></span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
<p id="EN-US_TOPIC_0000001134560490__ab8dd33c527184267906ad039a6609f45">Information similar to the following is displayed. <span class="parmvalue" id="EN-US_TOPIC_0000001134560490__parmvalue1796574260115424"><b>-1</b></span> indicates that the number of sessions connected to user <strong id="EN-US_TOPIC_0000001134560490__b2043011165115517">dbadmin</strong> is not limited.</p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001134560490__screen5384699191838"> rolname | rolconnlimit
|
|
----------+--------------
|
|
dwsadmin | -1
|
|
(1 row)</pre>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001134560490__rb9364ee1488746ba915d61980913738b"><td class="cellrowborder" valign="top" width="31.41%" headers="mcps1.3.4.2.2.2.1.2.3.1.1 "><p id="EN-US_TOPIC_0000001134560490__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.1.2.3.1.2 "><p id="EN-US_TOPIC_0000001134560490__p4469493185">Run the following command to view the number of session connections that have been used by <strong id="EN-US_TOPIC_0000001134560490__b125312233611565">dbadmin</strong>.</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001134560490__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><span class="w"></span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
<p id="EN-US_TOPIC_0000001134560490__a7bbf9e48551c4e42bc4e3d96f03ef5f9">Information similar to the following is displayed. <span class="parmvalue" id="EN-US_TOPIC_0000001134560490__parmvalue6572030216394"><b>1</b></span> indicates the number of session connections used by user <strong id="EN-US_TOPIC_0000001134560490__b3268088416391">dbadmin</strong>.</p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001134560490__screen32646809135149"> count
|
|
-------
|
|
1
|
|
(1 row)</pre>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001134560490__r889ca3da3fd94fac8d7084502eb05337"><td class="cellrowborder" valign="top" width="31.41%" headers="mcps1.3.4.2.2.2.1.2.3.1.1 "><p id="EN-US_TOPIC_0000001134560490__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.1.2.3.1.2 "><p id="EN-US_TOPIC_0000001134560490__p1666713314192">Run the following command to view the upper limit of connections used by <strong id="EN-US_TOPIC_0000001134560490__b09612418306"><span id="EN-US_TOPIC_0000001134560490__text16873162714512">gaussdb</span></strong>.</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001134560490__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">'gaussdb'</span><span class="p">;</span><span class="w"></span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
<p id="EN-US_TOPIC_0000001134560490__ac7ab9e1f26c84b959f03594e27683d08">Information similar to the following is displayed. <span class="parmvalue" id="EN-US_TOPIC_0000001134560490__parmvalue1562701316182"><b>-1</b></span> indicates that the number of sessions connected to database <strong id="EN-US_TOPIC_0000001134560490__b3869547193016"><span id="EN-US_TOPIC_0000001134560490__text18169218521">gaussdb</span></strong> is not limited.</p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001134560490__s116628f616314f27a5a02cd806cf7e23"> datname | datconnlimit
|
|
----------+--------------
|
|
<span id="EN-US_TOPIC_0000001134560490__text13535123529">gaussdb</span> | -1
|
|
(1 row)</pre>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001134560490__r1d23eb9755ed45379a778f04d1a7ceea"><td class="cellrowborder" valign="top" width="31.41%" headers="mcps1.3.4.2.2.2.1.2.3.1.1 "><p id="EN-US_TOPIC_0000001134560490__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.1.2.3.1.2 "><p id="EN-US_TOPIC_0000001134560490__p18457121482013">Run the following command to view the number of session connections that have been used by <strong id="EN-US_TOPIC_0000001134560490__b1765419223119"><span id="EN-US_TOPIC_0000001134560490__text1197391815220">gaussdb</span></strong>.</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001134560490__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">'gaussdb'</span><span class="p">;</span><span class="w"></span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
<p id="EN-US_TOPIC_0000001134560490__adc65e02e0fde4ae2ae7bda282f3eb6a4">Information similar to the following is displayed. <span class="parmvalue" id="EN-US_TOPIC_0000001134560490__parmvalue918624171816"><b>1</b></span> indicates the number of session connections used by database <strong id="EN-US_TOPIC_0000001134560490__b791016943112"><span id="EN-US_TOPIC_0000001134560490__text204241384529">gaussdb</span></strong>.</p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001134560490__screen502887401659"> count
|
|
-------
|
|
1
|
|
(1 row)</pre>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001134560490__rc9f924a62f4e4ea8b06e58653f1f3a90"><td class="cellrowborder" valign="top" width="31.41%" headers="mcps1.3.4.2.2.2.1.2.3.1.1 "><p id="EN-US_TOPIC_0000001134560490__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.1.2.3.1.2 "><p id="EN-US_TOPIC_0000001134560490__a1df256201d644b6cbaa4a5984fd7b554">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_0000001134560490__screen1661414490230"><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="p">;</span><span class="w"></span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
<p id="EN-US_TOPIC_0000001134560490__p775916468235">Information similar to the following is displayed.</p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001134560490__sf5d5e911ba2f485bba92984f0375526a"> count
|
|
-------
|
|
10
|
|
(1 row)</pre>
|
|
</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>
|
|
|