云数据库 GAUSSDB-归档账本数据库:操作步骤

时间:2024-11-13 10:05:08

操作步骤

  1. 使用EXECUTE DIRECT对某个DN节点进行归档操作。

    1
    gaussdb=# EXECUTE DIRECT ON (datanode1) 'select pg_catalog.ledger_hist_archive(''ledgernsp'', ''usertable'');';
    
    查询结果如下:
     ledger_hist_archive
    ---------------------
     t
    (1 row)
    用户历史表将归档为一条数据:
    gaussdb=# EXECUTE DIRECT ON (datanode1) 'SELECT * FROM blockchain.ledgernsp_usertable_hist;';
     rec_num |     hash_ins     |     hash_del     |             pre_hash
    ---------+------------------+------------------+----------------------------------
           3 | e78e75b00d396899 | 8fcd74a8a6a4b484 | fd61cb772033da297d10c4e658e898d7
    (1 row)

    该结果表明datanode1节点用户历史表导出成功。

  2. 连接CN执行全局区块表导出操作。

    1
    gaussdb=# SELECT pg_catalog.ledger_gchain_archive();
    

    查询结果如下:

     ledger_gchain_archive
    -----------------------
     t
    (1 row)

    全局历史表将以用户表为单位归档为N(用户表数量)条数据:

    gaussdb=# SELECT * FROM gs_global_chain;
     blocknum |  dbname  | username |           starttime           | relid |  relnsp   |  relname  |     relhash      |            globalhash            | txcommand
    ----------+----------+----------+-------------------------------+-------+-----------+-----------+------------------+----------------------------------+-----------
            1 | testdb | libc     | 2021-05-10 19:59:38.619472+08 | 16388 | ledgernsp | usertable | 57c101076694b415 | be82f98ee68b2bc4e375f69209345406 | Archived.
    (1 row)

    该结果表明,当前coordinator节点全局区块表导出成功。

support.huaweicloud.com/fg-gaussdb-dist-v8/gaussdb-18-0024.html