doc-exports/docs/dws/dev/dws_04_0276.html
Lu, Huayi e6fa411af0 DWS DEV 830.201 version
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: Lu, Huayi <luhuayi@huawei.com>
Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
2024-05-16 07:24:04 +00:00

88 lines
20 KiB
HTML

<a name="EN-US_TOPIC_0000001233883223"></a><a name="EN-US_TOPIC_0000001233883223"></a>
<h1 class="topictitle1">Exporting All Databases</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_a1e4f81ea1e944c77bb32f45197f9070e">You can use gs_dumpall to export full information of all databases in a cluster from <span id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_text241998867">GaussDB(DWS)</span>, including information about each database and global objects in the cluster. You can specify the information to be exported as follows:</p>
<ul id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_ul15714195354211"><li id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_li14800333980">Export full information of all databases, including information about each database and global objects (such as roles and tablespaces) in the cluster.<p id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_p9932705311"><a name="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_li14800333980"></a><a name="en-us_topic_0000001098814506_li14800333980"></a>You can use the exported information to create a same cluster containing the same databases, global objects, and data as the current one.</p>
</li><li id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_li197146539426">Export data of all databases, excluding all object definitions and global objects.</li><li id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_li27141153114215">Export all object definitions of all databases, including the definitions of tablespaces, databases, functions, schemas, tables, indexes, and stored procedures.<p id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_p539122043110"><a name="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_li27141153114215"></a><a name="en-us_topic_0000001098814506_li27141153114215"></a>You can use the exported object definitions to quickly create a same cluster as the current one, containing the same databases and tablespaces but without data.</p>
</li></ul>
<div class="section" id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_s92dde18bfe374ae28e35a3c03e5b76db"><h4 class="sectiontitle">Procedure</h4><ol id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_ol16997726145918"><li id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_li6104335165311"><span>Prepare an ECS as the gsql client host. For details, see "Preparing an ECS as the gsql Client Host" in the Data Warehouse Service (DWS) User Guide.</span></li><li id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_li879775734918"><span>Download the gsql client and use an SSH transfer tool (such as WinSCP) to upload it to the Linux server where gsql is to be installed. For details, see "Downloading the Client" in <em id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_en-us_topic_0000001145895053_i2086742622120">Data Warehouse Service User Guide</em>.</span><p><p id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_en-us_topic_0000001145895053_adf760149a35140c48cf09071207cd279">The user who uploads the client must have the full control permission on the target directory on the host to which the client is uploaded.</p>
</p></li><li id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_li144081359105012"><span>Run the following commands to decompress the client:</span><p><pre class="screen" id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_en-us_topic_0000001145895053_screen173918175523"><strong id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_en-us_topic_0000001145895053_b2025583889759">cd &lt;</strong><em id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_en-us_topic_0000001145895053_i18005909159759">Path_for_storing_the_client</em><strong id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_en-us_topic_0000001145895053_b9103889179759">&gt;</strong>
unzip <em id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_en-us_topic_0000001145895053_i10517201512535">dws_client_8.x.x_redhat_x64.zip</em></pre>
<p id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_en-us_topic_0000001145895053_p14308192714355">Where,</p>
<ul id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_en-us_topic_0000001145895053_ul18555114323517"><li id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_en-us_topic_0000001145895053_li155410439357">&lt;<em id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_en-us_topic_0000001145895053_i20191440039759">Path_for_storing_the_client</em>&gt;: Replace it with the actual path.</li><li id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_en-us_topic_0000001145895053_li9555114313356"><em id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_en-us_topic_0000001145895053_i15053567519759">dws_client_8.1.x_redhat_x86.zip</em>: This is the client tool package of <span class="parmvalue" id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_en-us_topic_0000001145895053_parmvalue1355249759759"><b>RedHat x86</b></span>. Replace it with the actual one.</li></ul>
</p></li><li id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_li106321216523"><span>Run the following command to configure the GaussDB(DWS) client:</span><p><pre class="screen" id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_en-us_topic_0000001145895053_screen39549318531">source gsql_env.sh</pre>
<p id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_en-us_topic_0000001145895053_acba60d877148432faf5ecdf94dd7b73e">If the following information is displayed, the GaussDB(DWS) client is successfully configured:</p>
<pre class="screen" id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_en-us_topic_0000001145895053_s8fd77cb5c040479baaab9ae3f2ea8fa5">All things done.</pre>
</p></li><li id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_li10855234125911"><span>Use gs_dumpall to run the following command to export information of all databases.</span><p><pre class="screen" id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_screen16976154145912"><strong id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_b03562339503">gs_dumpall <strong id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_b113561433175010">-W </strong></strong><em id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_i0582143212120">password</em><strong id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_b335713316506"><strong id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_b735783317501"> <strong id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_b143571033185010">-U </strong></strong></strong><span id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_ph11987163424617">dbadmin</span><strong id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_b9521626175017"> -f</strong> <em id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_i119828411592">/home/<span id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_ph1066094513488">dbadmin</span>/backup/MPPDB_backup.sql</em> <strong id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_b798324185912">-p</strong> 8000<em id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_i1366941111284"><span id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_text4496174519514"> -h 10.10.10.100</span></em></pre>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_table1781122816253" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Common parameters</caption><thead align="left"><tr id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_row10837281257"><th align="left" class="cellrowborder" valign="top" width="25%" id="mcps1.3.3.2.5.2.2.2.4.1.1"><p id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_p48382816258">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="43.33%" id="mcps1.3.3.2.5.2.2.2.4.1.2"><p id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_p18332812257">Description</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="31.669999999999998%" id="mcps1.3.3.2.5.2.2.2.4.1.3"><p id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_p583122816257">Example Value</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_row1483528152520"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.3.2.5.2.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_p3830287252">-U</p>
</td>
<td class="cellrowborder" valign="top" width="43.33%" headers="mcps1.3.3.2.5.2.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_p8232111218592">Username for database connection. The user must be a cluster administrator.</p>
</td>
<td class="cellrowborder" valign="top" width="31.669999999999998%" headers="mcps1.3.3.2.5.2.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_p1583152842510">-U <span id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_ph12587382459">dbadmin</span></p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_row199295855317"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.3.2.5.2.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_p89920588539">-W</p>
</td>
<td class="cellrowborder" valign="top" width="43.33%" headers="mcps1.3.3.2.5.2.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_p69431335210">User password for database connection.</p>
<ul id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_ul194074341627"><li id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_li640710341028">This parameter is not required for database administrators if the trust policy is used for authentication.</li><li id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_li0407734425">If you connect to the database without specifying this parameter and you are not a database administrator, you will be prompted to enter the password.</li></ul>
</td>
<td class="cellrowborder" valign="top" width="31.669999999999998%" headers="mcps1.3.3.2.5.2.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_p44042341359">-W <em id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_i103211152182019">Password</em></p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_row1823810139566"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.3.2.5.2.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_p11238171316560">-f</p>
</td>
<td class="cellrowborder" valign="top" width="43.33%" headers="mcps1.3.3.2.5.2.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_p323861311565">Folder to store exported files. If this parameter is not specified, the exported files are stored in the standard output.</p>
</td>
<td class="cellrowborder" valign="top" width="31.669999999999998%" headers="mcps1.3.3.2.5.2.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_p11238513175619">-f /home/<span id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_ph1134414418517">dbadmin</span>/backup/MPPDB_backup.sql</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_row9411195215519"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.3.2.5.2.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_p84119521250">-p</p>
</td>
<td class="cellrowborder" valign="top" width="43.33%" headers="mcps1.3.3.2.5.2.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_p14838631464">Name extension of the TCP port on which the server is listening or the local Unix domain socket. This parameter is configured to ensure connections.</p>
</td>
<td class="cellrowborder" valign="top" width="31.669999999999998%" headers="mcps1.3.3.2.5.2.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_p341117521853">-p 8000</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_row1440902719297"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.3.2.5.2.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_p338520273452">-h</p>
</td>
<td class="cellrowborder" valign="top" width="43.33%" headers="mcps1.3.3.2.5.2.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_p12385172734513"><em id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_i142928147991425">Cluster address</em>: If a public network address is used for connection, set this parameter to <strong id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_b208199054691425">Public Network Address</strong> or <strong id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_b31983938991425">Public Network Domain Name</strong>. If a private network address is used for connection, set this parameter to <strong id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_b8878845191425">Private Network Address</strong> or <strong id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_b149212996791425">Private Network Domain Name</strong>.</p>
</td>
<td class="cellrowborder" valign="top" width="31.669999999999998%" headers="mcps1.3.3.2.5.2.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_p133852271452">-h 10.10.10.100</p>
</td>
</tr>
</tbody>
</table>
</div>
<p id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_p158951329152915">For details about other parameters, see "gs_dumpall" in the <em id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_i15591713152315">Tool </em><em id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_i859871342315"></em><em id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_i8599101332318">Guide</em>.</p>
</p></li></ol>
</div>
<div class="section" id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_s57c0883a3628476f9664e81b377891a2"><h4 class="sectiontitle">Examples</h4><p id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_ac96fd55118a448499b13a953cbe0546c">Example 1: Use <strong id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_b3176937199">gs_dumpall</strong> to run the following command as the cluster administrator <strong id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_b115367342914"></strong><strong id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_b1553613347913"><span id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_ph13649957124617">dbadmin</span></strong> to export information of all databases in a cluster. The exported files are in text format. After the command is executed, a large amount of output information will be displayed. <strong id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_en-us_topic_0096392335_b84235270617211">total time</strong> will be displayed at the end of the information, indicating that the export is successful. In this example, only related output information is included.</p>
<pre class="screen" id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_s6587f5caabd640b5b186c236ff4d7ca1">gs_dumpall <strong id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_b65235561185827">-W </strong><em id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_i18106133718116">password</em><strong id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_b49589095185827"> <strong id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_b43648679185827">-U </strong></strong><span id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_ph3814125115467">dbadmin</span> -f /home/<span id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_ph14575121204813">dbadmin</span>/backup/MPPDB_backup.sql -p 8000<em id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_i101501192416"><span id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_text115212241"> -h 10.10.10.100</span></em>
gs_dumpall[port=''][2017-07-21 15:57:31]: dumpall operation successful
gs_dumpall[port=''][2017-07-21 15:57:31]: total time: 9627 ms</pre>
<p id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_p17323020115215">Example 2: Use <strong id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_b853413165103">gs_dumpall</strong> to run the following command as the cluster administrator <strong id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_b165921314101012"></strong><strong id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_b059201401010"><span id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_ph48115354716">dbadmin</span></strong> to export definitions of all databases in a cluster. The exported files are in text format. After the command is executed, a large amount of output information will be displayed. <strong id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_b6762738182918">total time</strong> will be displayed at the end of the information, indicating that the export is successful. In this example, only related output information is included.</p>
<pre class="screen" id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_screen1811512399548">gs_dumpall <strong id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_b136478459599">-W </strong><em id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_i16840193815117">password</em><strong id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_b17649144514592"> <strong id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_b565014515914">-U </strong></strong><span id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_ph16921014718">dbadmin</span> -f /home/<span id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_ph1459313924820">dbadmin</span>/backup/MPPDB_backup.sql -p 8000<em id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_i1823697202410"><span id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_text823620712249"> -h 10.10.10.100</span></em> -s
gs_dumpall[port=''][2018-11-14 11:28:14]: dumpall operation successful
gs_dumpall[port=''][2018-11-14 11:28:14]: total time: 4147 ms</pre>
<p id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_p229712721416">Example 3: Use gs_dumpall to run the following command export data of all databases in a cluster, encrypt the exported files, and store them in text format. After the command is executed, a large amount of output information will be displayed. <strong id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_b683223842917">total time</strong> will be displayed at the end of the information, indicating that the export is successful. In this example, only related output information is included.</p>
<pre class="screen" id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_screen1629852791413">gs_dumpall<strong id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_b545110544132"> -W </strong><em id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_i1570394019116">password</em><strong id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_b34517546132"> -U </strong><span id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_ph194526545135">dbadmin</span> -f /home/<span id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_ph1191995213473">dbadmin</span>/backup/MPPDB_backup.sql -p 8000<em id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_i1695919149248"><span id="EN-US_TOPIC_0000001233883223__en-us_topic_0000001098814506_text18959714162412"> -h 10.10.10.100</span></em> -a --with-encryption AES128 --with-key 1234567812345678
gs_dumpall[port=''][2018-11-14 11:32:26]: dumpall operation successful
gs_dumpall[port=''][2018-11-14 11:23:26]: total time: 4147 ms</pre>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0275.html">Exporting All Databases</a></div>
</div>
</div>