GBase 8a
备份恢复
文章

GBase8a 备份恢复管理(库级)-02

发表于2025-02-28 15:33:3927次浏览0个评论

执行模式

gcrcman 支持两种执行模式,即交互式模式和命令行模式:

1. 交互式模式,进入gcrcman>提示符下,进行备份恢复的相关操作,具体命令如下:

# su - gbase
$ gcrcman.py -d/home/gbase/backuptest/
gcrcman> show backup
cycle point level time
0      0      0   2017-06-10 21:20:52
1      0      0   2017-06-10 21:20:54
1      1      1   2017-06-10 21:20:56
1      2      1   2017-06-10 21:20:59
1      3      1   2017-06-10 21:21:01
1      4      1   2017-06-10 21:21:03
1      5      1   2017-06-10 21:21:05
2      0      0   2017-06-10 21:21:09
3      0      0   2017-06-10 21:21:23
4      0      0   2017-06-10 21:21:40
5      0      0   2017-06-10 21:21:43
6      0      0   2017-06-10 21:21:58
7      0      0   2017-06-10 21:22:00

2. 命令行模式,使用-e 参数,gcrcman 启动后,仅执行-e 指定的命令,执行完毕后自动退出,具体命令如下:

# su - gbase
$ cd $GCLUSTER_BASE/server/bin
$ python gcrcman.py -d /home/gbase/backuptest -e "show backup"
cycle point level time
0      0      0   2017-06-10 21:20:52
1      0      0   2017-06-10 21:20:54
1      1      1   2017-06-10 21:20:56
1      2      1   2017-06-10 21:20:59
1      3      1   2017-06-10 21:21:01
1      4      1   2017-06-10 21:21:03
1      5      1   2017-06-10 21:21:05
2      0      0   2017-06-10 21:21:09
3      0      0   2017-06-10 21:21:23
4      0      0   2017-06-10 21:21:40
5      0      0   2017-06-10 21:21:43
6      0      0   2017-06-10 21:21:58
7      0      0   2017-06-10 21:22:00

集群的备份

注意说明:

在进行备份时需要集群各项状态正常。

 由于 gcrcman 需要与 gcware 有交互,因此,需要在安装 gcware 服务的Coordinator 上执行备份操作。

 集群拓扑结构不能发生改变。拓扑结构包括 Coordinator 节点,Data 节点,distribution,distribution 的各个 segment 与 datanode 的对应关系。

 备份时,由于 gcrcman 工具运行节点获取当前时间作为备份点的备份时间,因此集群务必保持各节点时间一致,才能保证在不同节点上进行持续备份。

 实例级备份时,需要使用集群安装用户 dbauser (默认 gbase),执行 gcadminswitchmode readonly,将集群设置为只读状态,备份完毕后,执行 gcadmin

switchmode normal,将集群恢复为正常状态。否则会报告错误信息,

例如:
gcrcman>backup level 0
11.13 09:52:43 [ERROR]: (GBA-02BR-0065) The gcware not in
'READONLY' mode, please switch this mode by hand!

 备份时,程序连同数据库中所有的用户和密码同时备份,因此恢复时,也是备份时的用户和密码,因此建议客户,备份前记录好集群中默认的 root用户和 gbase 用户的密码,以免恢复时忘记。

 当集群进行了扩容或者缩容操作时,集群的结构会发生变化。因此,原先的备份记录将会失效,无法完成恢复操作。正确的做法是在集群扩容、缩容后,进行新的备份操作,这样就可以通过备份记录进行数据恢复。

 当备份时数据是使用密钥进行加密过,还需要保存好密钥,在恢复数据时,解密过程需要用到原始密钥

集群级备份集群数据

功能说明

使用交互模式或者命令方式运行 backup level [0 | 1],即可完成数据备份。进行备份操作时,必须保证集群在READONLY 模式下。

首先使用gcadmin switchmode readonly 命令将集群置为 READONLY 模式,此命令仅在一个部署 gcware 的节点上执行一次即可。

执行完毕后,启动集群备份命令,即可进行备份操作了。

语法格式

backup level < 0 | 1 >

示例

步骤 1:查看集群状态:
$ gcadmin
CLUSTER STATE: ACTIVE
================================================================
|            GBASE COORDINATOR CLUSTER INFORMATION             |
================================================================
| NodeName     | IpAddress     | gcware | gcluster | DataState |
----------------------------------------------------------------
| coordinator1 | 172.168.83.11 |  OPEN  |    OPEN  |     0     |
----------------------------------------------------------------
| coordinator2 | 172.168.83.12 |  OPEN  |    OPEN  |     0     |
----------------------------------------------------------------
| coordinator3 | 172.168.83.13 |  OPEN  |    OPEN  |     0     |
----------------------------------------------------------------
================================================================
===========================================================
|            GBASE VIRTUAL CLUSTER INFORMATION            |
===========================================================
|    VcName    | DistributionId |         comment         |
-----------------------------------------------------------
|      vc1     |       1        | comment message for vc1 |
-----------------------------------------------------------
|      vc2     |       2        | comment message for vc2 |
-----------------------------------------------------------

2 virtual cluster: vc1, vc2
3 coordinator node
0 free data node

$ gcadmin showcluster vc vc1
CLUSTER STATE: ACTIVE
VIRTUAL CLUSTER MODE: NORMAL
===========================================================
|            GBASE VIRTUAL CLUSTER INFORMATION            |
===========================================================
|    VcName    | DistributionId |         comment         |
-----------------------------------------------------------
|      vc1     |       1        | comment message for vc1 |
-----------------------------------------------------------
=============================================================================
|                   VIRTUAL CLUSTER DATA NODE INFORMATION                   |
=============================================================================
| NodeName|    IpAddress  | DistributionId | gnode | syncserver | DataState |
-----------------------------------------------------------------------------
|  node1  | 172.168.83.11 |       1        |  OPEN |    OPEN    |      0    |
-----------------------------------------------------------------------------
|  node2  | 172.168.83.12 |       1        |  OPEN |    OPEN    |      0    |
-----------------------------------------------------------------------------
2 data node
$ gcadmin showcluster vc vc2
CLUSTER STATE: ACTIVE
VIRTUAL CLUSTER MODE: NORMAL
===========================================================
|            GBASE VIRTUAL CLUSTER INFORMATION            |
===========================================================
|    VcName    | DistributionId |         comment         |
-----------------------------------------------------------
|      vc2    |       2        | comment message for vc2 |
-----------------------------------------------------------
=============================================================================
|                   VIRTUAL CLUSTER DATA NODE INFORMATION                   |
=============================================================================
| NodeName|    IpAddress  | DistributionId | gnode | syncserver | DataState |
-----------------------------------------------------------------------------
|  node1  | 172.168.83.13 |       2        |  OPEN |    OPEN    |      0    |
-----------------------------------------------------------------------------
|  node2  | 172.168.83.14 |       2        |  OPEN |    OPEN    |      0    |
-----------------------------------------------------------------------------
2 data node

步骤 2:设置集群内所有 vc 的状态为 readonly:
$ gcadmin switchmode readonly vc vc1
========== switch cluster mode...
switch pre mode: [NORMAL]
switch mode to [READONLY]
switch after mode: [READONLY]

$ gcadmin switchmode readonly vc vc2
========== switch cluster mode...
switch pre mode: [NORMAL]
switch mode to [READONLY]
switch after mode: [READONLY]
$ gcadmin
CLUSTER STATE: ACTIVE
================================================================
|            GBASE COORDINATOR CLUSTER INFORMATION             |
================================================================
| NodeName     | IpAddress     | gcware | gcluster | DataState |
----------------------------------------------------------------
| coordinator1 | 172.168.83.11 |  OPEN  |    OPEN  |     0     |
----------------------------------------------------------------
| coordinator2 | 172.168.83.12 |  OPEN  |    OPEN  |     0     |
----------------------------------------------------------------
| coordinator3 | 172.168.83.13 |  OPEN  |    OPEN  |     0     |
----------------------------------------------------------------
================================================================
===========================================================
|            GBASE VIRTUAL CLUSTER INFORMATION            |
===========================================================
|    VcName    | DistributionId |         comment         |
-----------------------------------------------------------
|      vc1     |       1        | comment message for vc1 |
-----------------------------------------------------------
|      vc2     |       2        | comment message for vc2 |
-----------------------------------------------------------

2 virtual cluster: vc1, vc2
3 coordinator node
0 free data node
$ gcadmin showcluster vc vc1
CLUSTER STATE: ACTIVE
VIRTUAL CLUSTER MODE: READONLY
===========================================================
|            GBASE VIRTUAL CLUSTER INFORMATION            |
===========================================================
|    VcName    | DistributionId |         comment         |
-----------------------------------------------------------
|      vc1     |       1        | comment message for vc1 |
-----------------------------------------------------------
=============================================================================
|                   VIRTUAL CLUSTER DATA NODE INFORMATION                   |
=============================================================================
| NodeName|    IpAddress  | DistributionId | gnode | syncserver | DataState |
-----------------------------------------------------------------------------
|  node1  | 172.168.83.11 |       1        |  OPEN |    OPEN    |      0    |
-----------------------------------------------------------------------------
|  node2  | 172.168.83.12 |       1        |  OPEN |    OPEN    |      0    |
-----------------------------------------------------------------------------
2 data node
$ gcadmin showcluster vc vc2
CLUSTER STATE: ACTIVE
VIRTUAL CLUSTER MODE: READONLY
===========================================================
|            GBASE VIRTUAL CLUSTER INFORMATION            |
===========================================================
|    VcName    | DistributionId |         comment         |
-----------------------------------------------------------
|      vc2    |       2        | comment message for vc2 |
-----------------------------------------------------------
=============================================================================
|                   VIRTUAL CLUSTER DATA NODE INFORMATION                   |
=============================================================================
| NodeName|    IpAddress  | DistributionId | gnode | syncserver | DataState |
-----------------------------------------------------------------------------
|  node1  | 172.168.83.13 |       2        |  OPEN |    OPEN    |      0    |
-----------------------------------------------------------------------------
|  node2  | 172.168.83.14 |       2        |  OPEN |    OPEN    |      0    |
-----------------------------------------------------------------------------
2 data node

使用交互模式进行全备:
$ python $GCLUSTER_BASE/server/bin/gcrcman.py -d /home/gbase/backup -P
gbasedba –p ******
gcrcman>backup level 0
08.07 17:24:34 BackUp start
--------------------------------------------
08.07 17:24:34 node (172.168.83.11) backup begin
08.07 17:24:34 node (172.168.83.12) backup begin
08.07 17:24:35 node (172.168.83.13) backup begin
08.07 17:24:35 node (172.168.83.14) backup begin
08.07 17:25:16 node (172.168.83.11) backup success
08.07 17:25:16 node (172.168.83.12) backup success
08.07 17:25:16 node (172.168.83.13) backup success
08.07 17:25:16 node (172.168.83.14) backup success
--------------------------------------------
08.07 17:25:17 BackUp end

使用交互模式进行增备:
gcrcman>backup level 1
08.07 19:28:53 check cluster topology begin
08.07 19:28:53 node (172.168.83.11) check topology begin
08.07 19:28:56 node (172.168.83.11) check topology success
08.07 19:28:56 check cluster topology end
08.07 19:28:56 BackUp start
--------------------------------------------
08.07 19:28:56 node (172.168.83.11) backup begin
08.07 19:28:56 node (172.168.83.12) backup begin
08.07 19:28:56 node (172.168.83.13) backup begin
08.07 19:28:57 node (172.168.83.14) backup begin
08.07 19:29:31 node (172.168.83.11) backup success
08.07 19:29:31 node (172.168.83.12) backup success
08.07 19:29:31 node (172.168.83.13) backup success
08.07 19:29:31 node (172.168.83.14) backup success
--------------------------------------------
08.07 19:29:31 BackUp end

备份完成后设置集群状态为 normal:
$ gcadmin switchmode normal vc vc1
========== switch cluster mode...
switch pre mode: [READONLY]
switch mode to [NORMAL]
switch after mode: [NORMAL]
$ gcadmin switchmode normal vc vc2
========== switch cluster mode...
switch pre mode: [READONLY]
switch mode to [NORMAL]
switch after mode: [NORMAL]
评论已关闭