导出全局对象
openGauss支持使用gs_dumpall工具导出所有数据库公共的全局对象,包含数据库用户和组,表空间及属性(例如:适用于数据库整体的访问权限)信息。
操作步骤
以操作系统用户omm登录数据库主节点。
使用gs_dumpall导出表空间对象信息。
gs_dumpall -U omm -f /home/omm/backup/MPPDB_tablespace.sql -p 8000 -t
Password: ```
**表 1** 常用参数说明
<a name="zh-cn_topic_0237121174_table1781122816253"></a>
<table><thead align="left"><tr id="zh-cn_topic_0237121174_row10837281257"><th class="cellrowborder" valign="top" width="25%" id="mcps1.2.4.1.1"><p id="zh-cn_topic_0237121174_p48382816258"><a name="zh-cn_topic_0237121174_p48382816258"></a><a name="zh-cn_topic_0237121174_p48382816258"></a>参数</p>
</th>
<th class="cellrowborder" valign="top" width="43.33%" id="mcps1.2.4.1.2"><p id="zh-cn_topic_0237121174_p18332812257"><a name="zh-cn_topic_0237121174_p18332812257"></a><a name="zh-cn_topic_0237121174_p18332812257"></a>参数说明</p>
</th>
<th class="cellrowborder" valign="top" width="31.669999999999998%" id="mcps1.2.4.1.3"><p id="zh-cn_topic_0237121174_p583122816257"><a name="zh-cn_topic_0237121174_p583122816257"></a><a name="zh-cn_topic_0237121174_p583122816257"></a>举例</p>
</th>
</tr>
</thead>
<tbody><tr id="zh-cn_topic_0237121174_row1483528152520"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.4.1.1 "><p id="zh-cn_topic_0237121174_p3830287252"><a name="zh-cn_topic_0237121174_p3830287252"></a><a name="zh-cn_topic_0237121174_p3830287252"></a>-U</p>
</td>
<td class="cellrowborder" valign="top" width="43.33%" headers="mcps1.2.4.1.2 "><p id="zh-cn_topic_0237121174_p8232111218592"><a name="zh-cn_topic_0237121174_p8232111218592"></a><a name="zh-cn_topic_0237121174_p8232111218592"></a>连接数据库的用户名,需要是openGauss管理员用户。</p>
</td>
<td class="cellrowborder" valign="top" width="31.669999999999998%" headers="mcps1.2.4.1.3 "><p id="zh-cn_topic_0237121174_p1583152842510"><a name="zh-cn_topic_0237121174_p1583152842510"></a><a name="zh-cn_topic_0237121174_p1583152842510"></a>-U <span id="zh-cn_topic_0237121174_text086013275487"><a name="zh-cn_topic_0237121174_text086013275487"></a><a name="zh-cn_topic_0237121174_text086013275487"></a>omm</span></p>
</td>
</tr>
<tr id="zh-cn_topic_0237121174_row199295855317"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.4.1.1 "><p id="zh-cn_topic_0237121174_p89920588539"><a name="zh-cn_topic_0237121174_p89920588539"></a><a name="zh-cn_topic_0237121174_p89920588539"></a>-W</p>
</td>
<td class="cellrowborder" valign="top" width="43.33%" headers="mcps1.2.4.1.2 "><p id="zh-cn_topic_0237121174_p69431335210"><a name="zh-cn_topic_0237121174_p69431335210"></a><a name="zh-cn_topic_0237121174_p69431335210"></a>指定用户连接的密码。</p>
<a name="zh-cn_topic_0237121174_ul194074341627"></a><a name="zh-cn_topic_0237121174_ul194074341627"></a><ul id="zh-cn_topic_0237121174_ul194074341627"><li>如果主机的认证策略是trust,则不会对数据库管理员进行密码验证,即无需输入-W选项;</li><li>如果没有-W选项,并且不是数据库管理员,会提示用户输入密码。</li></ul>
</td>
<td class="cellrowborder" valign="top" width="31.669999999999998%" headers="mcps1.2.4.1.3 "><p id="zh-cn_topic_0237121174_p1898043113581"><a name="zh-cn_topic_0237121174_p1898043113581"></a><a name="zh-cn_topic_0237121174_p1898043113581"></a>-W abcd@123</p>
</td>
</tr>
<tr id="zh-cn_topic_0237121174_row1823810139566"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.4.1.1 "><p id="zh-cn_topic_0237121174_p11238171316560"><a name="zh-cn_topic_0237121174_p11238171316560"></a><a name="zh-cn_topic_0237121174_p11238171316560"></a>-f</p>
</td>
<td class="cellrowborder" valign="top" width="43.33%" headers="mcps1.2.4.1.2 "><p id="zh-cn_topic_0237121174_p323861311565"><a name="zh-cn_topic_0237121174_p323861311565"></a><a name="zh-cn_topic_0237121174_p323861311565"></a>将导出文件发送至指定目录文件夹。如果这里省略,则使用标准输出。</p>
</td>
<td class="cellrowborder" valign="top" width="31.669999999999998%" headers="mcps1.2.4.1.3 "><p id="zh-cn_topic_0237121174_p11238513175619"><a name="zh-cn_topic_0237121174_p11238513175619"></a><a name="zh-cn_topic_0237121174_p11238513175619"></a>-f /home/<span id="zh-cn_topic_0237121174_text45761636125319"><a name="zh-cn_topic_0237121174_text45761636125319"></a><a name="zh-cn_topic_0237121174_text45761636125319"></a>omm</span>/backup/<em id="zh-cn_topic_0237121174_i022863611191"><a name="zh-cn_topic_0237121174_i022863611191"></a><a name="zh-cn_topic_0237121174_i022863611191"></a>MPPDB_tablespace</em>.sql</p>
</td>
</tr>
<tr id="zh-cn_topic_0237121174_row9411195215519"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.4.1.1 "><p id="zh-cn_topic_0237121174_p84119521250"><a name="zh-cn_topic_0237121174_p84119521250"></a><a name="zh-cn_topic_0237121174_p84119521250"></a>-p</p>
</td>
<td class="cellrowborder" valign="top" width="43.33%" headers="mcps1.2.4.1.2 "><p id="zh-cn_topic_0237121174_p14838631464"><a name="zh-cn_topic_0237121174_p14838631464"></a><a name="zh-cn_topic_0237121174_p14838631464"></a>指定服务器所侦听的TCP端口或本地Unix域套接字后缀,以确保连接。</p>
</td>
<td class="cellrowborder" valign="top" width="31.669999999999998%" headers="mcps1.2.4.1.3 "><p id="zh-cn_topic_0237121174_p341117521853"><a name="zh-cn_topic_0237121174_p341117521853"></a><a name="zh-cn_topic_0237121174_p341117521853"></a>-p <span id="zh-cn_topic_0237121174_text11526133105112"><a name="zh-cn_topic_0237121174_text11526133105112"></a><a name="zh-cn_topic_0237121174_text11526133105112"></a>8000</span></p>
</td>
</tr>
<tr id="zh-cn_topic_0237121174_row1339718574716"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.4.1.1 "><p id="zh-cn_topic_0237121174_p18625164815715"><a name="zh-cn_topic_0237121174_p18625164815715"></a><a name="zh-cn_topic_0237121174_p18625164815715"></a>-t</p>
</td>
<td class="cellrowborder" valign="top" width="43.33%" headers="mcps1.2.4.1.2 "><p id="zh-cn_topic_0237121174_p1962511481717"><a name="zh-cn_topic_0237121174_p1962511481717"></a><a name="zh-cn_topic_0237121174_p1962511481717"></a>或者--tablespaces-only,只转储表空间,不转储数据库或角色。</p>
</td>
<td class="cellrowborder" valign="top" width="31.669999999999998%" headers="mcps1.2.4.1.3 "><p id="zh-cn_topic_0237121174_p1662514481776"><a name="zh-cn_topic_0237121174_p1662514481776"></a><a name="zh-cn_topic_0237121174_p1662514481776"></a>-</p>
</td>
</tr>
其他参数说明请参见《工具参考》中“服务端工具 \> gs\_dumpall”章节。
示例
示例一:执行gs_dumpall,导出所有数据库的公共全局表空间信息和用户信息(omm用户为管理员用户),导出文件为文本格式。
gs_dumpall -U omm -f /home/omm/backup/MPPDB_globals.sql -p 8000 -g
Password:
gs_dumpall[port='8000'][2018-11-14 19:06:24]: dumpall operation successful
gs_dumpall[port='8000'][2018-11-14 19:06:24]: total time: 1150 ms
示例二: 执行gs_dumpall,导出所有数据库的公共全局表空间信息(omm用户为管理员用户),并对导出文件进行加密,导出文件为文本格式。
gs_dumpall -U omm -f /home/omm/backup/MPPDB_tablespace.sql -p 8000 -t --with-encryption AES128 --with-key 1212121212121212
Password:
gs_dumpall[port='8000'][2018-11-14 19:00:58]: dumpall operation successful
gs_dumpall[port='8000'][2018-11-14 19:00:58]: total time: 186 ms
示例三:执行gs_dumpall,导出所有数据库的公共全局用户信息(omm用户为管理员用户),导出文件为文本格式。
gs_dumpall -U omm -f /home/omm/backup/MPPDB_user.sql -p 8000 -r
Password:
gs_dumpall[port='8000'][2018-11-14 19:03:18]: dumpall operation successful
gs_dumpall[port='8000'][2018-11-14 19:03:18]: total time: 162 ms