南大通用GBase 8s数据库onbar基础使用教程

原文链接:https://www.gbase.cn/community/post/4364
更多精彩内容尽在南大通用GBase技术社区,南大通用致力于成为用户最信赖的数据库产品供应商。

数据备份与恢复是确保数据安全和业务连续性的关键环节,onbar作为GBase 8s数据库的可伸缩备份产品,提供了一套完整的数据保护解决方案。与ontape不同,onbar需要配合存储管理器使用,并涉及一系列的配置步骤。本文将详细介绍onbar的配置、备份、恢复以及监控过程,帮助数据库管理员构建数据备份与恢复计划。

在使用onbar之前,用户需要执行以下配置操作:

  1. 配置存储管理器
  2. 为onbar设置适当的ONCONFIG参数
  3. 确定逻辑日志备份策略

1、配置存储管理器与onbar

onbar和存储管理器是通过XBSA(X/Open Backup Services)接口连接起来的,所以onbar可以使用各种符合XBSA的存储管理器来工作。同时Gbase 8s也内置了一个存储管理器PSM(Primary Storage Manager),该存储管理器的接口库位置为$GBASEDBTDIR/lib/libbsapsm.so。

[root@gbase ~]# ll $GBASEDBTDIR/lib/libbsapsm.so
-r-xr-xr-x 1 gbasedbt gbasedbt 1920732 Mar 23  2021 /home/hdr/lib/libbsapsm.so

onbar配置文件修改

使用onbar时,需要做一些简单的配置,配置参数如下:

参数

说明

BAR_BSALIB_PATH指定 XBSA 库的位置
BAR_MAX_BACKUP最大并行进程数
LTAPEDEV逻辑日志备份目录

可以通过修改文件 $GBASEDBTDIR/etc/$ONCONFIG 或在在线模式下通过命令 onstat -c | grep BAR_BSALIB_PATH 以及onmode -wf BAR_BSALIB_PATH=$GBASEDBTDIR/lib/libbsapsm.so 对三个参数进行查看和修改。

一般情况下,可以将三个参数设置如下:

参数

设定

BAR_BSALIB_PATH$GBASEDBTDIR/lib/libbsapsm.so
BAR_MAX_BACKUP0
LTAPEDEV$GBASEDBTDIR/backups

其中,BAR_MAX_BACKUP可以根据实际性能进行调整,LTAPEDEV是ontape中的一个参数,在使用onbar时,该参数不能为/dev/null。我们可以临时为参数设置一个目录,实际备份时,逻辑日志并不保存在该目录中。

[root@gbase ~]# onmode -wf BAR_BSALIB_PATH=$GBASEDBTDIR/lib/libbsapsm.so
Your evaluation license will expire on 2024-10-18 00:00:00
Current value for BAR_BSALIB_PATH (/home/hdr/lib/libbsapsm.so) was saved in config file.
[root@gbase ~]# onmode -wf BAR_MAX_BACKUP=0
Your evaluation license will expire on 2024-10-18 00:00:00
Current value for BAR_MAX_BACKUP (0) was saved in config file.
[root@gbase ~]# onmode -wf LTAPEDEV=$GBASEDBTDIR/backups
Your evaluation license will expire on 2024-10-18 00:00:00
Current value for LTAPEDEV (/home/hdr/backups) was saved in config file.

[root@gbase ~]# onstat -c | grep BAR_BSALIB_PATH
Your evaluation license will expire on 2024-10-18 00:00:00
# BAR_BSALIB_PATH     - The shared library for ON-Bar and the
BAR_BSALIB_PATH /home/hdr/lib/libbsapsm.so
[root@gbase ~]# onstat -c | grep BAR_MAX_BACKUP
Your evaluation license will expire on 2024-10-18 00:00:00
# BAR_MAX_BACKUP      - The number of backup threads used in a
BAR_MAX_BACKUP  0
[root@gbase ~]# onstat -c | grep LTAPEDEV
Your evaluation license will expire on 2024-10-18 00:00:00
# LTAPEDEV     - The tape device path for logical logs
LTAPEDEV        /home/hdr/backups

启用及配置PSM设备

使用onpsm -C init初始化catalog
[root@gbase /]# ll $GBASEDBTDIR/etc/psm
ls: cannot access /home/hdr/etc/psm: No such file or directory
[root@gbase /]# onpsm -C init
 The __PSM__ catalog is not present in the '/home/hdr/etc/psm/' directory.
The system will try to create it.
 __PSM__ catalog creation in the '/home/hdr/etc/psm/' directory succeeded.
This option deletes the __PSM__ catalogs.
Are you sure you want to delete these items? (y/n) n
[root@gbase /]# ll $GBASEDBTDIR/etc/psm
total 60
-rw-rw-r-- 1 gbasedbt root 1024 Aug 18 15:50 device.dat
-rw-rw-r-- 1 gbasedbt root 5120 Aug 18 15:50 device.idx
-rw-rw-r-- 1 gbasedbt root 1024 Aug 18 15:50 lock.dat
-rw-rw-r-- 1 gbasedbt root 2048 Aug 18 15:50 lock.idx
-rw-rw-r-- 1 gbasedbt root    0 Aug 18 15:50 object.dat
-rw-rw-r-- 1 gbasedbt root    0 Aug 18 15:50 object_detail.dat
-rw-rw-r-- 1 gbasedbt root 3072 Aug 18 15:50 object_detail.idx
-rw-rw-r-- 1 gbasedbt root 4096 Aug 18 15:50 object.idx
-rw-rw-r-- 1 gbasedbt root    0 Aug 18 15:50 pool.dat
-rw-rw-r-- 1 gbasedbt root 4096 Aug 18 15:50 pool.idx
-rw-rw-r-- 1 gbasedbt root 1024 Aug 18 15:50 serial.dat
-rw-rw-r-- 1 gbasedbt root 2048 Aug 18 15:50 serial.idx
-rw-rw-r-- 1 gbasedbt root 1024 Aug 18 15:50 session.dat
-rw-rw-r-- 1 gbasedbt root 3072 Aug 18 15:50 session.idx
-rw-rw-r-- 1 gbasedbt root 1024 Aug 18 15:50 volume.dat
-rw-rw-r-- 1 gbasedbt root 5120 Aug 18 15:50 volume.idx

查看备份目录信息并自定义为其他目录

[root@gbase hdr]# onpsm -D list

__PSM__ Device List

Type    Prio     Block/Size (MB)  Pool Name     Device Name
FILE    LOW          --/--        DBSPOOL       /home/hdr/backups

FILE    LOW          --/--        LOGPOOL       /home/hdr/backups


[root@gbase hdr]# onpsm -D add $GBASEDBTDIR/dbspool -g DBSPOOL -p HIGHEST -t FILE
[root@gbase hdr]# onpsm -D add $GBASEDBTDIR/logpool -g LOGPOOL -p HIGHEST -t FILE
[root@gbase hdr]# onpsm -D del $GBASEDBTDIR/backups -d
Delete the device from ALL pools and DELETE ALL backup objects stored in
FILE devices? (y/n) y
[root@gbase hdr]# onpsm -D list

__PSM__ Device List

Type    Prio     Block/Size (MB)  Pool Name     Device Name
FILE    HIGHEST      --/--        DBSPOOL       /home/hdr/dbspool

FILE    HIGHEST      --/--        LOGPOOL       /home/hdr/logpool

2、onbar备份命令详解

BACKUP & VERIFICATION(备份与验证)

-b [-p] [-L <level>] [-w | -f <filename> | <spaces>] [-O] [-cf yes | no | only]
       -b -F
       -b -l [-c | -C | -s] [-O]
       -v [-w] [-p] [-t <time>] [-f <filename> | <spaces>]

-b:启动备份过程。

-c:备份当前逻辑日志。

-C:启动连续逻辑日志备份。

-cf:备份关键文件。

-f:指定包含存储空间列表的文件路径和文件名。

-F:执行模拟备份(不实际写入备份数据)。

-l:仅备份完整的逻辑日志(不包括存储空间)。

-L:设置备份级别,0、1或2,默认为0。

-O:覆盖内部错误检查,强制执行策略。

-p:仅备份存储空间(不包括日志)。

-s:抢救日志(可能是指从故障中恢复日志)。

-t:指定一致性验证的时间点。

-v:验证指定备份的一致性。

-w:执行全系统备份。

<spaces>:指定要备份的存储空间名称,用空格分隔。

RESTORE(恢复)

       -r [-e] [-O | {rename-chunk-syntax}] [-w] [-p] [-cf yes|no|only]
           [-t "<time>" | -n <log>] [-f <filename> | <spaces>]
       -r -l [-C | -X | -t "<time>" | -n <log>]
       -RESTART
       rename-chunk-syntax:
       {-rename -f <filename> | -p <old_path> -o <old_offset> -n <new_path> -o <new_offset>...}

-r:启动恢复过程。

-C:启动/重启连续日志恢复(日志耗尽时使服务器处于快速恢复模式)。

-cf:恢复关键文件(在冷恢复时)。

-e:执行外部恢复。

-f:指定包含要恢复的存储空间列表的文件路径和文件名。

-l:仅恢复逻辑日志(不包括存储空间)。

-n:恢复到指定的逻辑日志。

-O:覆盖内部错误检查,强制恢复被错误检查阻止的操作。

-p:仅恢复物理空间(不恢复或抢救日志)。

-t:恢复到指定的时间点,用引号包围。

-w:恢复全系统备份。

-X:停止连续逻辑日志恢复,并使服务器处于静默模式。

-RESTART:重启中断的恢复过程。

-rename:在冷恢复过程中重命名指定的块。可以重复使用块信息选项。

<spaces>:指定要恢复的存储空间名称,用空格分隔。

RECENT ACTIVITY(最近活动)

       -m [<lines>] [-r [<seconds>]]

-m:显示onbar活动日志文件的末尾指定行数,默认为20行。

-r:每隔指定秒数重复执行命令,默认为5秒。

LOGICAL-LOG DISPLAY(逻辑日志显示)

     -P {-n <log unique identifier> | -n <starting log unique identifier> - <ending log unique identifier> .

-P:显示逻辑日志信息。

-n:指定要显示的逻辑日志的唯一标识符,或者指定开始和结束的逻辑日志唯一标识符范围。

3、onbar基础使用实操

使用onbar -b -L 0对数据库进行0级备份,可以使用tail -f $GBASEDBTDIR/tmp/bar_act.log实时查看备份日志。

[root@gbase hdr]# onbar -b -L 0
Your evaluation license will expire on 2024-10-18 00:00:00

查看备份目录dbspool和logpool

[root@gbase gbase002]# cd $GBASEDBTDIR/dbspool
[root@gbase dbspool]# ll
total 0
drwxr-x--- 8 gbasedbt gbasedbt 105 Aug 18 14:58 gbase002
[root@gbase dbspool]# ll gbase002/
total 0
drwxr-x--- 6 gbasedbt gbasedbt 64 Aug 18 14:58 critical_files
drwxr-x--- 3 gbasedbt gbasedbt 15 Aug 18 14:58 datadbs1
drwxr-x--- 3 gbasedbt gbasedbt 15 Aug 18 14:58 llogdbs
drwxr-x--- 3 gbasedbt gbasedbt 15 Aug 18 14:58 plogdbs
drwxr-x--- 3 gbasedbt gbasedbt 15 Aug 18 14:58 rootdbs
drwxr-x--- 3 gbasedbt gbasedbt 15 Aug 18 14:58 sbspace1
[root@gbase dbspool]# cd $GBASEDBTDIR/logpool
[root@gbase logpool]# ll
total 0
drwxr-x--- 3 gbasedbt gbasedbt 17 Aug 18 14:58 gbase002

也可以通过onpsm -O list查看

[root@gbase logpool]# onpsm -O list

__PSM__ Object List

Object ID            Date Created         Size (MB) Logical path (name.version)
1                    2024-08-18 14:58:14       20.0 /gbase002/rootdbs/0/gbase002.1
2                    2024-08-18 14:58:15        0.1 /gbase002/sbspace1/0/gbase002.1
3                    2024-08-18 14:58:16        0.1 /gbase002/llogdbs/0/gbase002.1
4                    2024-08-18 14:58:16        8.5 /gbase002/datadbs1/0/gbase002.1
5                    2024-08-18 14:58:17        0.1 /gbase002/plogdbs/0/gbase002.1
6                    2024-08-18 14:58:17      128.5 /gbase002/199/7/gbase002.1
7                    2024-08-18 14:58:18        0.0 /gbase002/critical_files/ixbar/gbase002.1
8                    2024-08-18 14:58:18        0.0 /gbase002/critical_files/oncfg/gbase002.1
9                     2024-08-18 14:58:18        0.1 /gbase002/critical_files/onconfig/gbase002.1
10                   2024-08-18 14:58:18        0.0 /gbase002/critical_files/sqlhosts/gbase002.1

此时假设数据库遭到破坏,这里模拟删除dbspace文件

[root@gbase logpool]# cd $GBASEDBTDIR/gbase001_dbs
[root@gbase gbase001_dbs]# ll
total 24944548
-rw-rw---- 1 gbasedbt gbasedbt   104857600 Aug 18 14:27 datadbs1_1
-rw-rw---- 1 gbasedbt gbasedbt 10485760000 Aug 18 15:12 llogdbs
-rw-rw---- 1 gbasedbt gbasedbt 10485760000 Aug 18 15:12 plogdbs
-rw-rw---- 1 gbasedbt gbasedbt   209715200 Aug 18 15:12 rootdbs
-rw-rw---- 1 gbasedbt gbasedbt  2128609280 Aug 18 14:26 sbspace1
-rw-rw---- 1 gbasedbt gbasedbt  2128609280 Aug 18 15:00 tmpdbs1
[root@gbase gbase001_dbs]# rm -rf *
[root@gbase gbase001_dbs]# ll
total 0

在这种情况下,由于我们删除了系统文件,所以需要手工创建删除的文件并配置权限。

[root@gbase gbase001_dbs]# touch datadbs1_1 llogdbs plogdbs rootdbs sbspace1 tmpdbs1
[root@gbase gbase001_dbs]# ll
total 0
-rw-r--r-- 1 root root 0 Aug 18 15:23 datadbs1_1
-rw-r--r-- 1 root root 0 Aug 18 15:23 llogdbs
-rw-r--r-- 1 root root 0 Aug 18 15:23 plogdbs
-rw-r--r-- 1 root root 0 Aug 18 15:23 rootdbs
-rw-r--r-- 1 root root 0 Aug 18 15:23 sbspace1
-rw-r--r-- 1 root root 0 Aug 18 15:23 tmpdbs1
[root@gbase gbase001_dbs]# chown gbasedbt:gbasedbt *
[root@gbase gbase001_dbs]# ll
total 0
-rw-r--r-- 1 gbasedbt gbasedbt 0 Aug 18 15:23 datadbs1_1
-rw-r--r-- 1 gbasedbt gbasedbt 0 Aug 18 15:23 llogdbs
-rw-r--r-- 1 gbasedbt gbasedbt 0 Aug 18 15:23 plogdbs
-rw-r--r-- 1 gbasedbt gbasedbt 0 Aug 18 15:23 rootdbs
-rw-r--r-- 1 gbasedbt gbasedbt 0 Aug 18 15:23 sbspace1
-rw-r--r-- 1 gbasedbt gbasedbt 0 Aug 18 15:23 tmpdbs1
[root@gbase gbase001_dbs]# chmod 660 *
[root@gbase gbase001_dbs]# ll
total 0
-rw-rw---- 1 gbasedbt gbasedbt 0 Aug 18 15:23 datadbs1_1
-rw-rw---- 1 gbasedbt gbasedbt 0 Aug 18 15:23 llogdbs
-rw-rw---- 1 gbasedbt gbasedbt 0 Aug 18 15:23 plogdbs
-rw-rw---- 1 gbasedbt gbasedbt 0 Aug 18 15:23 rootdbs
-rw-rw---- 1 gbasedbt gbasedbt 0 Aug 18 15:23 sbspace1
-rw-rw---- 1 gbasedbt gbasedbt 0 Aug 18 15:23 tmpdbs1

执行恢复指令:

[root@gbase gbase001_dbs]# onbar -r
Your evaluation license will expire on 2024-10-18 00:00:00
Your evaluation license will expire on 2024-10-18 00:00:00

此时可以看到dbspace文件大小已恢复:

[root@gbase gbase001_dbs]# ll
total 24944552
-rw-rw---- 1 gbasedbt gbasedbt   104857600 Aug 18 15:38 datadbs1_1
-rw-rw---- 1 gbasedbt gbasedbt 10485760000 Aug 18 15:38 llogdbs
-rw-rw---- 1 gbasedbt gbasedbt 10485760000 Aug 18 15:38 plogdbs
-rw-rw---- 1 gbasedbt gbasedbt   209715200 Aug 18 15:38 rootdbs
-rw-rw---- 1 gbasedbt gbasedbt  2128609280 Aug 18 15:38 sbspace1
-rw-rw---- 1 gbasedbt gbasedbt  2128609280 Aug 18 15:38 tmpdbs1

恢复完成后,数据库将进入Quiescent模式,通过onmode -m切换至online模式

[root@gbase201 /]# onstat -
Your evaluation license will expire on 2024-10-18 00:00:00
Quiescent -- Up 00:24:14 -- 57688756 Kbytes

[root@gbase201 /]# onmode -m
Your evaluation license will expire on 2024-10-18 00:00:00
[root@gbase201 /]# onstat -
Your evaluation license will expire on 2024-10-18 00:00:00
On-Line -- Up 00:24:23 -- 57688756 Kbytes

至此数据库已恢复完成。

以上,通过本文的详细介绍,我们希望帮助数据库管理员更好地理解和运用onbar,从而为企业的数据安全和业务连续性提供坚实的保障。感谢您的阅读。

原文链接:https://www.gbase.cn/community/post/4364
更多精彩内容尽在南大通用GBase技术社区,南大通用致力于成为用户最信赖的数据库产品供应商。

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值