暂无图片
暂无图片
1
暂无图片
暂无图片
暂无图片

GDCA学习实践--基于onbar的备份与恢复实验

原创 张玉龙 2023-02-19
515

ON-Bar体系架构

ON-Bar 由各种组件组成,它需要与存储管理器一起使用,来备份和恢复数据。
ON-Bar组件:

  • sysutils 数据库,其中包含 ON-Bar 目录表
  • onbar 和 onbar_d 命令行实用程序
  • 系统上存储管理器的 XBSA 共享库
  • 用于存储备份的存储介质
  • ON-Bar 活动日志
  • ON-Bar 紧急引导文件

image.png

GBase 8s 的 ON-Bar 支持第三方的存储管理器,进行数据库的备份与恢复。GBase 8s 也内置了一个存储管理器 PSM(Primary Storage Manager)。
对于备份会话,ON-Bar 从数据库服务器请求存储空间和逻辑日志的内容,并将它们传递到存储管理器。存储管理器将数据存储在存储介质上。
对于恢复会话,ON-Bar 从存储管理器请求已备份的数据,然后在数据库服务器上恢复该数据。

环境准备

配置存储管理器 PSM 的共享库

ON-Bar 和存储管理器通过“备份服务应用程序编程接口 (XBSA)”通信,该接口支持将存储管理器作为数据库服务器的备份介质。
通过使用存储管理器的开放式系统接口,ON-Bar 可以与各种同样使用 XBSA 的存储管理器一起协同工作。
GBase 8s 内置了一个存储管理器 PSM,该存储管理器的接口库位置为/opt/gbase/lib/libbsapsm.so

[gbasedbt@gbase ~]$ cd /opt/gbase/lib [gbasedbt@gbase lib]$ ls -lrt total 38572 -rwxr-xr-x. 1 gbasedbt gbasedbt 74921 Mar 23 2021 libencrypt_f.so -rwxr-xr-x. 1 gbasedbt gbasedbt 239980 Mar 23 2021 libnativeAPI.so -rwxr-xr-x. 1 gbasedbt gbasedbt 326676 Mar 23 2021 libAPI.jar -rwxr-xr-x. 1 gbasedbt gbasedbt 8846 Mar 23 2021 iosm11a.so -rwxr-xr-x. 1 gbasedbt gbasedbt 403608 Mar 23 2021 liboracle.udr -rwxr-xr-x. 1 gbasedbt gbasedbt 283227 Mar 23 2021 libmisc.udr -rwxr-xr-x. 1 gbasedbt gbasedbt 174756 Mar 23 2021 libastool.so -rwxr-xr-x. 1 gbasedbt gbasedbt 24322266 Mar 23 2021 libxml.udr -rwxr-xr-x. 1 gbasedbt gbasedbt 11644279 Mar 23 2021 libdwa.udr -r-xr-xr-x. 1 gbasedbt gbasedbt 1920732 Mar 23 2021 libbsapsm.so -rwxr-xr-x. 1 gbasedbt gbasedbt 14130 Mar 23 2021 libbsanull.so -r-xr-xr-x. 1 gbasedbt gbasedbt 59340 Mar 23 2021 libtxbsa.so

保用ON-Bar时,需要做一些简单的配置,配置参数如下:

参数 说明
BAR_BSALIB_PATH 指定 XBSA 库的位置
BAR_MAX_BACKUP 最大并行进程数
LTAPEDEV 逻辑日志备份目录
[gbasedbt@gbase ~]$ onstat -c | grep BAR_BSALIB_PATH Your evaluation license will expire on 2024-02-04 00:00:00 # BAR_BSALIB_PATH - The shared library for ON-Bar and the BAR_BSALIB_PATH [gbasedbt@gbase ~]$ onmode -wf BAR_BSALIB_PATH=/opt/gbase/lib/libbsapsm.so Your evaluation license will expire on 2024-02-04 00:00:00 Value of BAR_BSALIB_PATH has been changed to /opt/gbase/lib/libbsapsm.so. [gbasedbt@gbase ~]$ onstat -c | grep BAR_BSALIB_PATH Your evaluation license will expire on 2024-02-04 00:00:00 # BAR_BSALIB_PATH - The shared library for ON-Bar and the BAR_BSALIB_PATH /opt/gbase/lib/libbsapsm.so [gbasedbt@gbase ~]$ onstat -c | grep LTAPEDEV Your evaluation license will expire on 2024-02-04 00:00:00 # LTAPEDEV - The tape device path for logical logs LTAPEDEV /home/gbasedbt/backup [gbasedbt@gbase ~]$ onmode -wf LTAPEDEV=/opt/gbase/backups Your evaluation license will expire on 2024-02-04 00:00:00 Value of LTAPEDEV has been changed to /opt/gbase/backups. [gbasedbt@gbase ~]$ onstat -c | grep LTAPEDEV Your evaluation license will expire on 2024-02-04 00:00:00 # LTAPEDEV - The tape device path for logical logs LTAPEDEV /opt/gbase/backups

说明:LTAPEDEV是 ontape 中的一个参数,在使用 onbar 时,该参数不能为/dev/null。我们可以临时为参数设置一个目录,实际备份时,逻辑日志并不保存在该目录中。

PSM配置

初始化Catalog

[gbasedbt@gbase ~]$ onpsm -C init The __PSM__ catalog is not present in the '/opt/gbase/etc/psm/' directory. The system will try to create it. __PSM__ catalog creation in the '/opt/gbase/etc/psm/' directory succeeded. This option deletes the __PSM__ catalogs. Are you sure you want to delete these items? (y/n) n [gbasedbt@gbase ~]$ ls -lrt /opt/gbase/etc/psm total 60 -rw-rw-r-- 1 gbasedbt gbasedbt 5120 Feb 16 14:39 volume.idx -rw-rw-r-- 1 gbasedbt gbasedbt 1024 Feb 16 14:39 volume.dat -rw-rw-r-- 1 gbasedbt gbasedbt 2048 Feb 16 14:39 serial.idx -rw-rw-r-- 1 gbasedbt gbasedbt 1024 Feb 16 14:39 serial.dat -rw-rw-r-- 1 gbasedbt gbasedbt 4096 Feb 16 14:39 pool.idx -rw-rw-r-- 1 gbasedbt gbasedbt 0 Feb 16 14:39 pool.dat -rw-rw-r-- 1 gbasedbt gbasedbt 4096 Feb 16 14:39 object.idx -rw-rw-r-- 1 gbasedbt gbasedbt 3072 Feb 16 14:39 object_detail.idx -rw-rw-r-- 1 gbasedbt gbasedbt 0 Feb 16 14:39 object_detail.dat -rw-rw-r-- 1 gbasedbt gbasedbt 0 Feb 16 14:39 object.dat -rw-rw-r-- 1 gbasedbt gbasedbt 5120 Feb 16 14:39 device.idx -rw-rw-r-- 1 gbasedbt gbasedbt 1024 Feb 16 14:39 device.dat -rw-rw-r-- 1 gbasedbt gbasedbt 3072 Feb 16 14:39 session.idx -rw-rw-r-- 1 gbasedbt gbasedbt 1024 Feb 16 14:39 session.dat -rw-rw-r-- 1 gbasedbt gbasedbt 2048 Feb 16 14:39 lock.idx -rw-rw-r-- 1 gbasedbt gbasedbt 1024 Feb 16 14:39 lock.dat

查看PSM设备情况

[gbasedbt@gbase ~]$ onpsm -D list __PSM__ Device List Type Prio Block/Size (MB) Pool Name Device Name FILE LOW --/-- DBSPOOL /opt/gbase/backups FILE LOW --/-- LOGPOOL /opt/gbase/backups

配置PSM设备

我们不使用默认的PSM设备,使用下面的方法,添加一个自己的设备,并将原来的设备删除。

[gbasedbt@gbase ~]$ mkdir -p /opt/gbase/dbspool [gbasedbt@gbase ~]$ mkdir -p /opt/gbase/logpool [gbasedbt@gbase ~]$ onpsm -D add /opt/gbase/dbspool -g DBSPOOL -p HIGHEST -t FILE [gbasedbt@gbase ~]$ onpsm -D add /opt/gbase/logpool -g LOGPOOL -p HIGHEST -t FILE [gbasedbt@gbase ~]$ onpsm -D del /opt/gbase/backups -d Delete the device from ALL pools and DELETE ALL backup objects stored in FILE devices? (y/n) y [gbasedbt@gbase ~]$ onpsm -D list __PSM__ Device List Type Prio Block/Size (MB) Pool Name Device Name FILE HIGHEST --/-- DBSPOOL /opt/gbase/dbspool FILE HIGHEST --/-- LOGPOOL /opt/gbase/logpool

备份与恢复演示

创建数据库和表

[gbasedbt@gbase ~]$ dbaccess - - Your evaluation license will expire on 2024-02-04 00:00:00 > drop database mydb; > create database mydb in datadbs1 with log; > create table t_dept(f_deptid int, f_deptname varchar(20)); > create table t_employee(f_employeeid int, f_deptid int, f_employeename varchar(20)); > info tables; Table name t_dept t_employee # t_dept新增3条数据 insert into t_dept values(1, 'dept_1'); insert into t_dept values(2, 'dept_2'); insert into t_dept values(3, 'dept_3'); > select * from t_dept; f_deptid f_deptname 1 dept_1 2 dept_2 3 dept_3 3 row(s) retrieved. > !date +'%F %T' 2023-02-16 14:47:56 # t_employee新增5条数据 insert into t_employee values(1, 1, 'employee_01'); insert into t_employee values(2, 1, 'employee_02'); insert into t_employee values(3, 2, 'employee_03'); insert into t_employee values(4, 2, 'employee_04'); insert into t_employee values(5, 3, 'employee_05'); > select * from t_employee; f_employeeid f_deptid f_employeename 1 1 employee_01 2 1 employee_02 3 2 employee_03 4 2 employee_04 5 3 employee_05 5 row(s) retrieved. > !date +'%F %T' 2023-02-16 14:48:49

系统进行L0备份

  • 查看当前的日志,文件编号为6,唯一编号为9
[gbasedbt@gbase ~]$ onstat -l Your evaluation license will expire on 2024-02-04 00:00:00 On-Line -- Up 04:05:45 -- 2632420 Kbytes Physical Logging Buffer bufused bufsize numpages numwrits pages/io P-1 0 1024 3620 25 144.80 phybegin physize phypos phyused %used 3:53 99400 9579 0 0.00 Logical Logging Buffer bufused bufsize numrecs numpages numwrits recs/pages pages/io L-3 0 512 26923 2035 56 13.2 36.3 Subsystem numrecs Log Space used OLDRSAM 26868 4000224 HA 20 880 DDL 35 12180 address number flags uniqid begin size used %used 49ad1f88 4 F------ 0 2:53 5000 0 0.00 4adea970 5 U-B---- 8 2:5053 5000 2570 51.40 4adea9d8 6 U---C-L 9 2:10053 5000 2035 40.70 4adeaa40 7 A------ 0 2:15053 5000 0 0.00 4adeaaa8 8 A------ 0 2:20053 5000 0 0.00 4adeab10 9 A------ 0 2:25053 5000 0 0.00 4adeab78 10 A------ 0 2:30053 5000 0 0.00 4adeabe0 11 A------ 0 2:35053 5000 0 0.00 4adeac48 12 A------ 0 2:40053 5000 0 0.00 4adeacb0 13 A------ 0 2:45053 5000 0 0.00 4adead18 14 A------ 0 2:50053 5000 0 0.00 4adead80 15 A------ 0 2:55053 5000 0 0.00 4adeade8 16 A------ 0 2:60053 5000 0 0.00 4adeae50 17 A------ 0 2:65053 5000 0 0.00 4adeaeb8 18 A------ 0 2:70053 5000 0 0.00 4adeaf20 19 A------ 0 2:75053 5000 0 0.00 4adeaf88 20 A------ 0 2:80053 5000 0 0.00 4983af30 21 A------ 0 2:85053 5000 0 0.00 4983af98 22 A------ 0 2:90053 5000 0 0.00 49909f30 23 A------ 0 2:95053 5000 0 0.00 20 active, 20 total
  • 查看实例的服务器编号为 232
[gbasedbt@gbase ~]$ onstat -c | grep SERVERNUM Your evaluation license will expire on 2024-02-04 00:00:00 # SERVERNUM - The unique ID for the GBase instance. Acceptable SERVERNUM 232
  • 执行L0备份
[gbasedbt@gbase ~]$ onbar -b -L 0 Your evaluation license will expire on 2024-02-04 00:00:00 [gbasedbt@gbase ~]$ onpsm -O list __PSM__ Object List Object ID Date Created Size (MB) Logical path (name.version) 1 2023-02-16 14:51:14 16.0 /gbs/rootdbs/0/gbs.1 2 2023-02-16 14:51:15 17.0 /gbs/datadbs1/0/gbs.1 3 2023-02-16 14:51:16 0.1 /gbs/plogdbs/0/gbs.1 4 2023-02-16 14:51:16 0.1 /gbs/llogdbs/0/gbs.1 5 2023-02-16 14:51:16 0.1 /gbs/datadbs5/0/gbs.1 6 2023-02-16 14:51:16 0.1 /gbs/datadbs2/0/gbs.1 7 2023-02-16 14:51:17 0.1 /gbs/sbspace1/0/gbs.1 8 2023-02-16 14:51:17 0.1 /gbs/datadbs4/0/gbs.1 9 2023-02-16 14:51:17 0.1 /gbs/datadbs3/0/gbs.1 10 2023-02-16 14:51:18 4.0 /gbs/232/9/gbs.1 11 2023-02-16 14:51:18 0.0 /gbs/critical_files/ixbar/gbs.1 12 2023-02-16 14:51:18 0.0 /gbs/critical_files/oncfg/gbs.1 13 2023-02-16 14:51:18 0.1 /gbs/critical_files/onconfig/gbs.1 14 2023-02-16 14:51:18 0.0 /gbs/critical_files/sqlhosts/gbs.1

L0 备份了 rootdbs,plogdbs,llogdbs,datadbs,ixbar,oncfg,onconfig,sqlhosts。另外还有一个目录/gbs/232/9/gbs.1,其中的232为实例的服务器编号,9为当前逻辑日志的唯一编号(uniqid)。

t_employee新增5条数据

insert into t_employee values(11, 1, 'employee_11'); insert into t_employee values(12, 1, 'employee_12'); insert into t_employee values(13, 2, 'employee_13'); insert into t_employee values(14, 2, 'employee_14'); insert into t_employee values(15, 3, 'employee_15'); > select * from t_employee; f_employeeid f_deptid f_employeename 1 1 employee_01 2 1 employee_02 3 2 employee_03 4 2 employee_04 5 3 employee_05 11 1 employee_11 12 1 employee_12 13 2 employee_13 14 2 employee_14 15 3 employee_15 10 row(s) retrieved. > !date +'%F %T' 2023-02-16 14:54:05

系统进行L1备份

[gbasedbt@gbase ~]$ onbar -b -L 1 Your evaluation license will expire on 2024-02-04 00:00:00 [gbasedbt@gbase ~]$ onpsm -O list __PSM__ Object List Object ID Date Created Size (MB) Logical path (name.version) 1 2023-02-16 14:51:14 16.0 /gbs/rootdbs/0/gbs.1 2 2023-02-16 14:51:15 17.0 /gbs/datadbs1/0/gbs.1 3 2023-02-16 14:51:16 0.1 /gbs/plogdbs/0/gbs.1 4 2023-02-16 14:51:16 0.1 /gbs/llogdbs/0/gbs.1 5 2023-02-16 14:51:16 0.1 /gbs/datadbs5/0/gbs.1 6 2023-02-16 14:51:16 0.1 /gbs/datadbs2/0/gbs.1 7 2023-02-16 14:51:17 0.1 /gbs/sbspace1/0/gbs.1 8 2023-02-16 14:51:17 0.1 /gbs/datadbs4/0/gbs.1 9 2023-02-16 14:51:17 0.1 /gbs/datadbs3/0/gbs.1 10 2023-02-16 14:51:18 4.0 /gbs/232/9/gbs.1 11 2023-02-16 14:51:18 0.0 /gbs/critical_files/ixbar/gbs.1 12 2023-02-16 14:51:18 0.0 /gbs/critical_files/oncfg/gbs.1 13 2023-02-16 14:51:18 0.1 /gbs/critical_files/onconfig/gbs.1 14 2023-02-16 14:51:18 0.0 /gbs/critical_files/sqlhosts/gbs.1 15 2023-02-16 14:54:51 0.2 /gbs/rootdbs/1/gbs.1 16 2023-02-16 14:54:52 0.1 /gbs/datadbs1/1/gbs.1 17 2023-02-16 14:54:53 0.1 /gbs/datadbs2/1/gbs.1 18 2023-02-16 14:54:53 0.1 /gbs/datadbs5/1/gbs.1 19 2023-02-16 14:54:53 0.1 /gbs/plogdbs/1/gbs.1 20 2023-02-16 14:54:53 0.1 /gbs/llogdbs/1/gbs.1 21 2023-02-16 14:54:54 0.1 /gbs/datadbs3/1/gbs.1 22 2023-02-16 14:54:54 0.1 /gbs/sbspace1/1/gbs.1 23 2023-02-16 14:54:54 0.1 /gbs/datadbs4/1/gbs.1 24 2023-02-16 14:54:54 0.1 /gbs/232/10/gbs.1 25 2023-02-16 14:54:54 0.0 /gbs/critical_files/ixbar/gbs.2 26 2023-02-16 14:54:54 0.0 /gbs/critical_files/oncfg/gbs.2 27 2023-02-16 14:54:54 0.1 /gbs/critical_files/onconfig/gbs.2 28 2023-02-16 14:54:54 0.0 /gbs/critical_files/sqlhosts/gbs.2

进行L1备份后,备份文件数量由14个变为28个。

t_employee新增1条数据

> insert into t_employee values(16, 3, 'employee_16'); > select * from t_employee; f_employeeid f_deptid f_employeename 1 1 employee_01 2 1 employee_02 3 2 employee_03 4 2 employee_04 5 3 employee_05 11 1 employee_11 12 1 employee_12 13 2 employee_13 14 2 employee_14 15 3 employee_15 16 3 employee_16 11 row(s) retrieved. > !date +'%F %T' 2023-02-16 14:55:55

系统进行L1备份

[gbasedbt@gbase ~]$ onbar -b -L 1 Your evaluation license will expire on 2024-02-04 00:00:00 [gbasedbt@gbase ~]$ onpsm -O list __PSM__ Object List Object ID Date Created Size (MB) Logical path (name.version) 1 2023-02-16 14:51:14 16.0 /gbs/rootdbs/0/gbs.1 2 2023-02-16 14:51:15 17.0 /gbs/datadbs1/0/gbs.1 3 2023-02-16 14:51:16 0.1 /gbs/plogdbs/0/gbs.1 4 2023-02-16 14:51:16 0.1 /gbs/llogdbs/0/gbs.1 5 2023-02-16 14:51:16 0.1 /gbs/datadbs5/0/gbs.1 6 2023-02-16 14:51:16 0.1 /gbs/datadbs2/0/gbs.1 7 2023-02-16 14:51:17 0.1 /gbs/sbspace1/0/gbs.1 8 2023-02-16 14:51:17 0.1 /gbs/datadbs4/0/gbs.1 9 2023-02-16 14:51:17 0.1 /gbs/datadbs3/0/gbs.1 10 2023-02-16 14:51:18 4.0 /gbs/232/9/gbs.1 11 2023-02-16 14:51:18 0.0 /gbs/critical_files/ixbar/gbs.1 12 2023-02-16 14:51:18 0.0 /gbs/critical_files/oncfg/gbs.1 13 2023-02-16 14:51:18 0.1 /gbs/critical_files/onconfig/gbs.1 14 2023-02-16 14:51:18 0.0 /gbs/critical_files/sqlhosts/gbs.1 15 2023-02-16 14:54:51 0.2 /gbs/rootdbs/1/gbs.1 16 2023-02-16 14:54:52 0.1 /gbs/datadbs1/1/gbs.1 17 2023-02-16 14:54:53 0.1 /gbs/datadbs2/1/gbs.1 18 2023-02-16 14:54:53 0.1 /gbs/datadbs5/1/gbs.1 19 2023-02-16 14:54:53 0.1 /gbs/plogdbs/1/gbs.1 20 2023-02-16 14:54:53 0.1 /gbs/llogdbs/1/gbs.1 21 2023-02-16 14:54:54 0.1 /gbs/datadbs3/1/gbs.1 22 2023-02-16 14:54:54 0.1 /gbs/sbspace1/1/gbs.1 23 2023-02-16 14:54:54 0.1 /gbs/datadbs4/1/gbs.1 24 2023-02-16 14:54:54 0.1 /gbs/232/10/gbs.1 25 2023-02-16 14:54:54 0.0 /gbs/critical_files/ixbar/gbs.2 26 2023-02-16 14:54:54 0.0 /gbs/critical_files/oncfg/gbs.2 27 2023-02-16 14:54:54 0.1 /gbs/critical_files/onconfig/gbs.2 28 2023-02-16 14:54:54 0.0 /gbs/critical_files/sqlhosts/gbs.2 29 2023-02-16 14:56:53 0.2 /gbs/rootdbs/1/gbs.2 30 2023-02-16 14:56:55 0.1 /gbs/datadbs2/1/gbs.2 31 2023-02-16 14:56:55 0.1 /gbs/plogdbs/1/gbs.2 32 2023-02-16 14:56:55 0.1 /gbs/sbspace1/1/gbs.2 33 2023-02-16 14:56:55 0.1 /gbs/datadbs5/1/gbs.2 34 2023-02-16 14:56:55 0.1 /gbs/llogdbs/1/gbs.2 35 2023-02-16 14:56:55 0.1 /gbs/datadbs1/1/gbs.2 36 2023-02-16 14:56:56 0.1 /gbs/datadbs4/1/gbs.2 37 2023-02-16 14:56:56 0.1 /gbs/datadbs3/1/gbs.2 38 2023-02-16 14:56:58 0.1 /gbs/232/11/gbs.1 39 2023-02-16 14:56:58 0.0 /gbs/critical_files/ixbar/gbs.3 40 2023-02-16 14:56:58 0.0 /gbs/critical_files/oncfg/gbs.3 41 2023-02-16 14:56:58 0.1 /gbs/critical_files/onconfig/gbs.3 42 2023-02-16 14:56:58 0.0 /gbs/critical_files/sqlhosts/gbs.3

进行两次L1备份后,备份文件变为42个。通过观察,ON-Bar备份时,PSM是通过组织文件系统的目录来管理备份文件的。PSM为L0,L1,L2创建3个目录,分别为0,1,2。每个备份文件名称为<instance_name>.<seq_num>。
逻辑日志的备份,是按逻辑日志的唯一编号,创建对应的目录进行存储。

t_employee新增5条数据

insert into t_employee values(21, 1, 'employee_21'); insert into t_employee values(22, 1, 'employee_22'); insert into t_employee values(23, 2, 'employee_23'); insert into t_employee values(24, 2, 'employee_24'); insert into t_employee values(25, 3, 'employee_25'); > select * from t_employee; f_employeeid f_deptid f_employeename 1 1 employee_01 2 1 employee_02 3 2 employee_03 4 2 employee_04 5 3 employee_05 11 1 employee_11 12 1 employee_12 13 2 employee_13 14 2 employee_14 15 3 employee_15 16 3 employee_16 21 1 employee_21 22 1 employee_22 23 2 employee_23 24 2 employee_24 25 3 employee_25 16 row(s) retrieved. > !date +'%F %T' 2023-02-16 14:58:53

系统进行L2备份

[gbasedbt@gbase ~]$ onbar -b -L 2 Your evaluation license will expire on 2024-02-04 00:00:00 [gbasedbt@gbase ~]$ onpsm -O list __PSM__ Object List Object ID Date Created Size (MB) Logical path (name.version) 1 2023-02-16 14:51:14 16.0 /gbs/rootdbs/0/gbs.1 2 2023-02-16 14:51:15 17.0 /gbs/datadbs1/0/gbs.1 3 2023-02-16 14:51:16 0.1 /gbs/plogdbs/0/gbs.1 4 2023-02-16 14:51:16 0.1 /gbs/llogdbs/0/gbs.1 5 2023-02-16 14:51:16 0.1 /gbs/datadbs5/0/gbs.1 6 2023-02-16 14:51:16 0.1 /gbs/datadbs2/0/gbs.1 7 2023-02-16 14:51:17 0.1 /gbs/sbspace1/0/gbs.1 8 2023-02-16 14:51:17 0.1 /gbs/datadbs4/0/gbs.1 9 2023-02-16 14:51:17 0.1 /gbs/datadbs3/0/gbs.1 10 2023-02-16 14:51:18 4.0 /gbs/232/9/gbs.1 11 2023-02-16 14:51:18 0.0 /gbs/critical_files/ixbar/gbs.1 12 2023-02-16 14:51:18 0.0 /gbs/critical_files/oncfg/gbs.1 13 2023-02-16 14:51:18 0.1 /gbs/critical_files/onconfig/gbs.1 14 2023-02-16 14:51:18 0.0 /gbs/critical_files/sqlhosts/gbs.1 15 2023-02-16 14:54:51 0.2 /gbs/rootdbs/1/gbs.1 16 2023-02-16 14:54:52 0.1 /gbs/datadbs1/1/gbs.1 17 2023-02-16 14:54:53 0.1 /gbs/datadbs2/1/gbs.1 18 2023-02-16 14:54:53 0.1 /gbs/datadbs5/1/gbs.1 19 2023-02-16 14:54:53 0.1 /gbs/plogdbs/1/gbs.1 20 2023-02-16 14:54:53 0.1 /gbs/llogdbs/1/gbs.1 21 2023-02-16 14:54:54 0.1 /gbs/datadbs3/1/gbs.1 22 2023-02-16 14:54:54 0.1 /gbs/sbspace1/1/gbs.1 23 2023-02-16 14:54:54 0.1 /gbs/datadbs4/1/gbs.1 24 2023-02-16 14:54:54 0.1 /gbs/232/10/gbs.1 25 2023-02-16 14:54:54 0.0 /gbs/critical_files/ixbar/gbs.2 26 2023-02-16 14:54:54 0.0 /gbs/critical_files/oncfg/gbs.2 27 2023-02-16 14:54:54 0.1 /gbs/critical_files/onconfig/gbs.2 28 2023-02-16 14:54:54 0.0 /gbs/critical_files/sqlhosts/gbs.2 29 2023-02-16 14:56:53 0.2 /gbs/rootdbs/1/gbs.2 30 2023-02-16 14:56:55 0.1 /gbs/datadbs2/1/gbs.2 31 2023-02-16 14:56:55 0.1 /gbs/plogdbs/1/gbs.2 32 2023-02-16 14:56:55 0.1 /gbs/sbspace1/1/gbs.2 33 2023-02-16 14:56:55 0.1 /gbs/datadbs5/1/gbs.2 34 2023-02-16 14:56:55 0.1 /gbs/llogdbs/1/gbs.2 35 2023-02-16 14:56:55 0.1 /gbs/datadbs1/1/gbs.2 36 2023-02-16 14:56:56 0.1 /gbs/datadbs4/1/gbs.2 37 2023-02-16 14:56:56 0.1 /gbs/datadbs3/1/gbs.2 38 2023-02-16 14:56:58 0.1 /gbs/232/11/gbs.1 39 2023-02-16 14:56:58 0.0 /gbs/critical_files/ixbar/gbs.3 40 2023-02-16 14:56:58 0.0 /gbs/critical_files/oncfg/gbs.3 41 2023-02-16 14:56:58 0.1 /gbs/critical_files/onconfig/gbs.3 42 2023-02-16 14:56:58 0.0 /gbs/critical_files/sqlhosts/gbs.3 43 2023-02-16 14:59:29 0.1 /gbs/rootdbs/2/gbs.1 44 2023-02-16 14:59:29 0.1 /gbs/datadbs2/2/gbs.1 45 2023-02-16 14:59:30 0.1 /gbs/datadbs3/2/gbs.1 46 2023-02-16 14:59:30 0.1 /gbs/datadbs5/2/gbs.1 47 2023-02-16 14:59:30 0.1 /gbs/llogdbs/2/gbs.1 48 2023-02-16 14:59:30 0.1 /gbs/sbspace1/2/gbs.1 49 2023-02-16 14:59:30 0.1 /gbs/datadbs4/2/gbs.1 50 2023-02-16 14:59:30 0.1 /gbs/datadbs1/2/gbs.1 51 2023-02-16 14:59:31 0.1 /gbs/plogdbs/2/gbs.1 52 2023-02-16 14:59:32 0.1 /gbs/232/12/gbs.1 53 2023-02-16 14:59:32 0.0 /gbs/critical_files/ixbar/gbs.4 54 2023-02-16 14:59:32 0.0 /gbs/critical_files/oncfg/gbs.4 55 2023-02-16 14:59:32 0.1 /gbs/critical_files/onconfig/gbs.4 56 2023-02-16 14:59:32 0.0 /gbs/critical_files/sqlhosts/gbs.4

备份完成后,当前的逻辑日志唯一编号为13

[gbasedbt@gbase ~]$ onstat -l Your evaluation license will expire on 2024-02-04 00:00:00 On-Line -- Up 04:16:21 -- 2632420 Kbytes Physical Logging Buffer bufused bufsize numpages numwrits pages/io P-1 22 1024 3900 36 108.33 phybegin physize phypos phyused %used 3:53 99400 9859 22 0.02 Logical Logging Buffer bufused bufsize numrecs numpages numwrits recs/pages pages/io L-3 0 512 27677 2169 188 12.8 11.5 Subsystem numrecs Log Space used OLDRSAM 27609 4065624 HA 33 1452 DDL 35 12180 address number flags uniqid begin size used %used 49ad1f88 4 F------ 0 2:53 5000 0 0.00 4adea970 5 U-B---- 8 2:5053 5000 2570 51.40 4adea9d8 6 U-B---- 9 2:10053 5000 2071 41.42 4adeaa40 7 U-B---- 10 2:15053 5000 34 0.68 4adeaaa8 8 U-B---- 11 2:20053 5000 28 0.56 4adeab10 9 U-B---L 12 2:25053 5000 34 0.68 4adeab78 10 U---C-- 13 2:30053 5000 2 0.04 4adeabe0 11 A------ 0 2:35053 5000 0 0.00 4adeac48 12 A------ 0 2:40053 5000 0 0.00 4adeacb0 13 A------ 0 2:45053 5000 0 0.00 4adead18 14 A------ 0 2:50053 5000 0 0.00 4adead80 15 A------ 0 2:55053 5000 0 0.00 4adeade8 16 A------ 0 2:60053 5000 0 0.00 4adeae50 17 A------ 0 2:65053 5000 0 0.00 4adeaeb8 18 A------ 0 2:70053 5000 0 0.00 4adeaf20 19 A------ 0 2:75053 5000 0 0.00 4adeaf88 20 A------ 0 2:80053 5000 0 0.00 4983af30 21 A------ 0 2:85053 5000 0 0.00 4983af98 22 A------ 0 2:90053 5000 0 0.00 49909f30 23 A------ 0 2:95053 5000 0 0.00 20 active, 20 total

t_dept新增1条数据

> insert into t_dept values(4, 'dept_4'); > select * from t_dept; f_deptid f_deptname 1 dept_1 2 dept_2 3 dept_3 4 dept_4 4 row(s) retrieved. > !date +'%F %T' 2023-02-16 15:01:22

t_employee更新1条数据

> update t_employee set f_employeename = 'employee_updated' where f_employeeid = 11; > select * from t_employee; f_employeeid f_deptid f_employeename 1 1 employee_01 2 1 employee_02 3 2 employee_03 4 2 employee_04 5 3 employee_05 11 1 employee_updated 12 1 employee_12 13 2 employee_13 14 2 employee_14 15 3 employee_15 16 3 employee_16 21 1 employee_21 22 1 employee_22 23 2 employee_23 24 2 employee_24 25 3 employee_25 16 row(s) retrieved. > !date +'%F %T' 2023-02-16 15:02:08

切换逻辑日志

[gbasedbt@gbase ~]$ onstat -l Your evaluation license will expire on 2024-02-04 00:00:00 On-Line -- Up 04:19:04 -- 2632420 Kbytes Physical Logging Buffer bufused bufsize numpages numwrits pages/io P-1 14 1024 3953 38 104.03 phybegin physize phypos phyused %used 3:53 99400 9912 29 0.03 Logical Logging Buffer bufused bufsize numrecs numpages numwrits recs/pages pages/io L-1 0 512 27687 2173 192 12.7 11.3 Subsystem numrecs Log Space used OLDRSAM 27618 4066188 HA 34 1496 DDL 35 12180 address number flags uniqid begin size used %used 49ad1f88 4 F------ 0 2:53 5000 0 0.00 4adea970 5 U-B---- 8 2:5053 5000 2570 51.40 4adea9d8 6 U-B---- 9 2:10053 5000 2071 41.42 4adeaa40 7 U-B---- 10 2:15053 5000 34 0.68 4adeaaa8 8 U-B---- 11 2:20053 5000 28 0.56 4adeab10 9 U-B---- 12 2:25053 5000 34 0.68 4adeab78 10 U---C-L 13 2:30053 5000 6 0.12 4adeabe0 11 A------ 0 2:35053 5000 0 0.00 4adeac48 12 A------ 0 2:40053 5000 0 0.00 4adeacb0 13 A------ 0 2:45053 5000 0 0.00 4adead18 14 A------ 0 2:50053 5000 0 0.00 4adead80 15 A------ 0 2:55053 5000 0 0.00 4adeade8 16 A------ 0 2:60053 5000 0 0.00 4adeae50 17 A------ 0 2:65053 5000 0 0.00 4adeaeb8 18 A------ 0 2:70053 5000 0 0.00 4adeaf20 19 A------ 0 2:75053 5000 0 0.00 4adeaf88 20 A------ 0 2:80053 5000 0 0.00 4983af30 21 A------ 0 2:85053 5000 0 0.00 4983af98 22 A------ 0 2:90053 5000 0 0.00 49909f30 23 A------ 0 2:95053 5000 0 0.00 20 active, 20 total [gbasedbt@gbase ~]$ onmode -l Your evaluation license will expire on 2024-02-04 00:00:00 [gbasedbt@gbase ~]$ onstat -l Your evaluation license will expire on 2024-02-04 00:00:00 On-Line -- Up 04:19:16 -- 2632420 Kbytes Physical Logging Buffer bufused bufsize numpages numwrits pages/io P-1 14 1024 3953 38 104.03 phybegin physize phypos phyused %used 3:53 99400 9912 29 0.03 Logical Logging Buffer bufused bufsize numrecs numpages numwrits recs/pages pages/io L-2 0 512 27687 2174 193 12.7 11.3 Subsystem numrecs Log Space used OLDRSAM 27618 4066188 HA 34 1496 DDL 35 12180 address number flags uniqid begin size used %used 49ad1f88 4 F------ 0 2:53 5000 0 0.00 4adea970 5 U-B---- 8 2:5053 5000 2570 51.40 4adea9d8 6 U-B---- 9 2:10053 5000 2071 41.42 4adeaa40 7 U-B---- 10 2:15053 5000 34 0.68 4adeaaa8 8 U-B---- 11 2:20053 5000 28 0.56 4adeab10 9 U-B---- 12 2:25053 5000 34 0.68 4adeab78 10 U-----L 13 2:30053 5000 7 0.14 4adeabe0 11 U---C-- 14 2:35053 5000 0 0.00 4adeac48 12 A------ 0 2:40053 5000 0 0.00 4adeacb0 13 A------ 0 2:45053 5000 0 0.00 4adead18 14 A------ 0 2:50053 5000 0 0.00 4adead80 15 A------ 0 2:55053 5000 0 0.00 4adeade8 16 A------ 0 2:60053 5000 0 0.00 4adeae50 17 A------ 0 2:65053 5000 0 0.00 4adeaeb8 18 A------ 0 2:70053 5000 0 0.00 4adeaf20 19 A------ 0 2:75053 5000 0 0.00 4adeaf88 20 A------ 0 2:80053 5000 0 0.00 4983af30 21 A------ 0 2:85053 5000 0 0.00 4983af98 22 A------ 0 2:90053 5000 0 0.00 49909f30 23 A------ 0 2:95053 5000 0 0.00 20 active, 20 total

切换逻辑日志后,当前逻辑日志唯一编号由13变为14。

t_employee删除1条数据

> delete from t_employee where f_employeeid = 14; > select * from t_employee; f_employeeid f_deptid f_employeename 1 1 employee_01 2 1 employee_02 3 2 employee_03 4 2 employee_04 5 3 employee_05 11 1 employee_updated 12 1 employee_12 13 2 employee_13 15 3 employee_15 16 3 employee_16 21 1 employee_21 22 1 employee_22 23 2 employee_23 24 2 employee_24 25 3 employee_25 15 row(s) retrieved. > !date +'%F %T' 2023-02-16 15:04:14

删除Chunk文件

[gbasedbt@gbase ~]$ cd /opt/gbase/gbs_dbs/ [gbasedbt@gbase gbs_dbs]$ ls -lrt total 1536000 -rw-rw----. 1 gbasedbt gbasedbt 104857600 Feb 16 10:44 sbspace1 -rw-rw----. 1 gbasedbt gbasedbt 104857600 Feb 16 10:44 datadbs5_1 -rw-rw----. 1 gbasedbt gbasedbt 104857600 Feb 16 10:44 datadbs4_1 -rw-rw----. 1 gbasedbt gbasedbt 104857600 Feb 16 10:44 datadbs3_1 -rw-rw----. 1 gbasedbt gbasedbt 104857600 Feb 16 10:44 datadbs2_1 -rw-rw----. 1 gbasedbt gbasedbt 104857600 Feb 16 15:01 tmpdbs3 -rw-rw----. 1 gbasedbt gbasedbt 104857600 Feb 16 15:01 tmpdbs2 -rw-rw----. 1 gbasedbt gbasedbt 104857600 Feb 16 15:01 tmpdbs1 -rw-rw----. 1 gbasedbt gbasedbt 209715200 Feb 16 15:03 plogdbs -rw-rw----. 1 gbasedbt gbasedbt 209715200 Feb 16 15:03 rootdbs -rw-rw---- 1 gbasedbt gbasedbt 104857600 Feb 16 15:03 datadbs1_1 -rw-rw----. 1 gbasedbt gbasedbt 209715200 Feb 16 15:04 llogdbs [gbasedbt@gbase gbs_dbs]$ rm -rf datadbs1_1

t_dept新增1条数据

> insert into t_dept values(5, 'dept_5'); > select * from t_dept; f_deptid f_deptname 1 dept_1 2 dept_2 3 dept_3 4 dept_4 5 dept_5 5 row(s) retrieved. > !date +'%F %T' 2023-02-16 15:06:12

即使在保存数据的Chunk文件被删除,最近的事务仍然可以执行成功。

备份逻辑日志

[gbasedbt@gbase ~]$ onbar -b -l Your evaluation license will expire on 2024-02-04 00:00:00 [gbasedbt@gbase ~]$ onpsm -O list __PSM__ Object List Object ID Date Created Size (MB) Logical path (name.version) 1 2023-02-16 14:51:14 16.0 /gbs/rootdbs/0/gbs.1 2 2023-02-16 14:51:15 17.0 /gbs/datadbs1/0/gbs.1 3 2023-02-16 14:51:16 0.1 /gbs/plogdbs/0/gbs.1 4 2023-02-16 14:51:16 0.1 /gbs/llogdbs/0/gbs.1 5 2023-02-16 14:51:16 0.1 /gbs/datadbs5/0/gbs.1 6 2023-02-16 14:51:16 0.1 /gbs/datadbs2/0/gbs.1 7 2023-02-16 14:51:17 0.1 /gbs/sbspace1/0/gbs.1 8 2023-02-16 14:51:17 0.1 /gbs/datadbs4/0/gbs.1 9 2023-02-16 14:51:17 0.1 /gbs/datadbs3/0/gbs.1 10 2023-02-16 14:51:18 4.0 /gbs/232/9/gbs.1 11 2023-02-16 14:51:18 0.0 /gbs/critical_files/ixbar/gbs.1 12 2023-02-16 14:51:18 0.0 /gbs/critical_files/oncfg/gbs.1 13 2023-02-16 14:51:18 0.1 /gbs/critical_files/onconfig/gbs.1 14 2023-02-16 14:51:18 0.0 /gbs/critical_files/sqlhosts/gbs.1 15 2023-02-16 14:54:51 0.2 /gbs/rootdbs/1/gbs.1 16 2023-02-16 14:54:52 0.1 /gbs/datadbs1/1/gbs.1 17 2023-02-16 14:54:53 0.1 /gbs/datadbs2/1/gbs.1 18 2023-02-16 14:54:53 0.1 /gbs/datadbs5/1/gbs.1 19 2023-02-16 14:54:53 0.1 /gbs/plogdbs/1/gbs.1 20 2023-02-16 14:54:53 0.1 /gbs/llogdbs/1/gbs.1 21 2023-02-16 14:54:54 0.1 /gbs/datadbs3/1/gbs.1 22 2023-02-16 14:54:54 0.1 /gbs/sbspace1/1/gbs.1 23 2023-02-16 14:54:54 0.1 /gbs/datadbs4/1/gbs.1 24 2023-02-16 14:54:54 0.1 /gbs/232/10/gbs.1 25 2023-02-16 14:54:54 0.0 /gbs/critical_files/ixbar/gbs.2 26 2023-02-16 14:54:54 0.0 /gbs/critical_files/oncfg/gbs.2 27 2023-02-16 14:54:54 0.1 /gbs/critical_files/onconfig/gbs.2 28 2023-02-16 14:54:54 0.0 /gbs/critical_files/sqlhosts/gbs.2 29 2023-02-16 14:56:53 0.2 /gbs/rootdbs/1/gbs.2 30 2023-02-16 14:56:55 0.1 /gbs/datadbs2/1/gbs.2 31 2023-02-16 14:56:55 0.1 /gbs/plogdbs/1/gbs.2 32 2023-02-16 14:56:55 0.1 /gbs/sbspace1/1/gbs.2 33 2023-02-16 14:56:55 0.1 /gbs/datadbs5/1/gbs.2 34 2023-02-16 14:56:55 0.1 /gbs/llogdbs/1/gbs.2 35 2023-02-16 14:56:55 0.1 /gbs/datadbs1/1/gbs.2 36 2023-02-16 14:56:56 0.1 /gbs/datadbs4/1/gbs.2 37 2023-02-16 14:56:56 0.1 /gbs/datadbs3/1/gbs.2 38 2023-02-16 14:56:58 0.1 /gbs/232/11/gbs.1 39 2023-02-16 14:56:58 0.0 /gbs/critical_files/ixbar/gbs.3 40 2023-02-16 14:56:58 0.0 /gbs/critical_files/oncfg/gbs.3 41 2023-02-16 14:56:58 0.1 /gbs/critical_files/onconfig/gbs.3 42 2023-02-16 14:56:58 0.0 /gbs/critical_files/sqlhosts/gbs.3 43 2023-02-16 14:59:29 0.1 /gbs/rootdbs/2/gbs.1 44 2023-02-16 14:59:29 0.1 /gbs/datadbs2/2/gbs.1 45 2023-02-16 14:59:30 0.1 /gbs/datadbs3/2/gbs.1 46 2023-02-16 14:59:30 0.1 /gbs/datadbs5/2/gbs.1 47 2023-02-16 14:59:30 0.1 /gbs/llogdbs/2/gbs.1 48 2023-02-16 14:59:30 0.1 /gbs/sbspace1/2/gbs.1 49 2023-02-16 14:59:30 0.1 /gbs/datadbs4/2/gbs.1 50 2023-02-16 14:59:30 0.1 /gbs/datadbs1/2/gbs.1 51 2023-02-16 14:59:31 0.1 /gbs/plogdbs/2/gbs.1 52 2023-02-16 14:59:32 0.1 /gbs/232/12/gbs.1 53 2023-02-16 14:59:32 0.0 /gbs/critical_files/ixbar/gbs.4 54 2023-02-16 14:59:32 0.0 /gbs/critical_files/oncfg/gbs.4 55 2023-02-16 14:59:32 0.1 /gbs/critical_files/onconfig/gbs.4 56 2023-02-16 14:59:32 0.0 /gbs/critical_files/sqlhosts/gbs.4 57 2023-02-16 15:07:06 0.0 /gbs/232/13/gbs.1

可以通过下面的命令,查看数据的最新备份情况。

[gbasedbt@gbase ~]$ onstat -g arc Your evaluation license will expire on 2024-02-04 00:00:00 On-Line -- Up 04:23:55 -- 2632420 Kbytes num DBSpace Q Size Q Len Buffer partnum size scanner Dbspaces - Archive Status name number level date log log-position rootdbs 1 0 02/16/2023.14:51 9 0x7f3018 1 02/16/2023.14:56 11 0x4018 2 02/16/2023.14:59 12 0x9018 llogdbs 2 0 02/16/2023.14:51 9 0x7fa018 1 02/16/2023.14:56 11 0x8018 2 02/16/2023.14:59 12 0xd018 plogdbs 3 0 02/16/2023.14:51 9 0x7fa018 1 02/16/2023.14:56 11 0x8018 2 02/16/2023.14:59 12 0xd018 sbspace1 4 0 02/16/2023.14:51 9 0x7fc018 1 02/16/2023.14:56 11 0x8018 2 02/16/2023.14:59 12 0xf018 datadbs1 8 0 02/16/2023.14:51 9 0x7fa018 1 02/16/2023.14:56 11 0x8018 2 02/16/2023.14:59 12 0xd018 datadbs2 9 0 02/16/2023.14:51 9 0x7fa018 1 02/16/2023.14:56 11 0x8018 2 02/16/2023.14:59 12 0xd018 datadbs3 10 0 02/16/2023.14:51 9 0x7fa018 1 02/16/2023.14:56 11 0x8018 2 02/16/2023.14:59 12 0xd018 datadbs4 11 0 02/16/2023.14:51 9 0x7fa018 1 02/16/2023.14:56 11 0x8018 2 02/16/2023.14:59 12 0xd018 datadbs5 12 0 02/16/2023.14:51 9 0x7fa018 1 02/16/2023.14:56 11 0x8018 2 02/16/2023.14:59 12 0xd018

演示完全恢复

重启数据库,确定被删除的文件

在GBase 8s启动过程中,会因无法打开被删除的文件而报错。
Cannot open chunk ‘/opt/gbase/gbs_dbs/datadbs1_1’
根据报错中的信息,得到被删除的Chunk文件(datadbs1_1)。

[gbasedbt@gbase ~]$ onmode -ky Your evaluation license will expire on 2024-02-04 00:00:00 [gbasedbt@gbase ~]$ oninit -vy Your evaluation license will expire on 2024-02-04 00:00:00 Reading configuration file '/opt/gbase/etc/onconfig.gbs'...succeeded Creating /GBASEDBTTMP/.infxdirs...succeeded Allocating and attaching to shared memory...succeeded Creating resident pool 76314 kbytes...succeeded Creating infos file "/opt/gbase/etc/.infos.gbs"...succeeded Linking conf file "/opt/gbase/etc/.conf.gbs"...succeeded Initializing rhead structure...rhlock_t 65536 (2048K)... rlock_t (66406K)... Writing to infos file...succeeded Initialization of Encryption...succeeded Initializing ASF...succeeded Initializing Dictionary Cache and SPL Routine Cache...succeeded Bringing up ADM VP...succeeded Creating VP classes...succeeded Forking main_loop thread...succeeded Initializing DR structures...succeeded Forking 1 'soctcp' listener threads...succeeded Starting tracing...succeeded Initializing 32 flushers...succeeded Initializing SDS Server network connections...succeeded Initializing log/checkpoint information...succeeded Initializing dbspaces...succeeded Opening primary chunks...oninit: Cannot open chunk '/opt/gbase/gbs_dbs/datadbs1_1'. errno = 2 succeeded Validating chunks...succeeded Initialize Async Log Flusher...succeeded Starting B-tree Scanner...succeeded Init ReadAhead Daemon...succeeded Init DB Util Daemon...succeeded Initializing DBSPACETEMP list...succeeded Init Auto Tuning Daemon...succeeded Checking database partition index...succeeded Initializing dataskip structure...succeeded Checking for temporary tables to drop...succeeded Updating Global Row Counter...succeeded Forking onmode_mon thread...succeeded Creating periodic thread...succeeded Creating periodic thread...succeeded Starting scheduling system...succeeded Verbose output complete: mode = 5 [gbasedbt@gbase ~]$ onstat - Your evaluation license will expire on 2024-02-04 00:00:00 On-Line (CKPT INP) -- Up 00:01:05 -- 2171620 Kbytes Blocked:OVERRIDE_DOWN_SPACE

创建被删除的文件,并设置权限

[gbasedbt@gbase ~]$ cd /opt/gbase/gbs_dbs/ [gbasedbt@gbase gbs_dbs]$ touch datadbs1_1 [gbasedbt@gbase gbs_dbs]$ chmod o-r datadbs1_1 [gbasedbt@gbase gbs_dbs]$ ls -lrt total 1433600 -rw-rw----. 1 gbasedbt gbasedbt 209715200 Feb 16 15:09 plogdbs -rw-rw----. 1 gbasedbt gbasedbt 209715200 Feb 16 15:09 llogdbs -rw-rw----. 1 gbasedbt gbasedbt 209715200 Feb 16 15:09 rootdbs -rw-rw----. 1 gbasedbt gbasedbt 104857600 Feb 16 15:09 tmpdbs3 -rw-rw----. 1 gbasedbt gbasedbt 104857600 Feb 16 15:09 tmpdbs2 -rw-rw----. 1 gbasedbt gbasedbt 104857600 Feb 16 15:09 tmpdbs1 -rw-rw----. 1 gbasedbt gbasedbt 104857600 Feb 16 15:09 sbspace1 -rw-rw----. 1 gbasedbt gbasedbt 104857600 Feb 16 15:09 datadbs5_1 -rw-rw----. 1 gbasedbt gbasedbt 104857600 Feb 16 15:09 datadbs4_1 -rw-rw----. 1 gbasedbt gbasedbt 104857600 Feb 16 15:09 datadbs3_1 -rw-rw----. 1 gbasedbt gbasedbt 104857600 Feb 16 15:09 datadbs2_1 -rw-rw---- 1 gbasedbt gbasedbt 0 Feb 16 15:10 datadbs1_1

完全恢复

[gbasedbt@gbase ~]$ onmode -ky Your evaluation license will expire on 2024-02-04 00:00:00 [gbasedbt@gbase ~]$ onbar -r Your evaluation license will expire on 2024-02-04 00:00:00 Your evaluation license will expire on 2024-02-04 00:00:00 [gbasedbt@gbase ~]$ onstat - Your evaluation license will expire on 2024-02-04 00:00:00 Quiescent -- Up 00:00:32 -- 2632420 Kbytes [gbasedbt@gbase ~]$ onmode -m Your evaluation license will expire on 2024-02-04 00:00:00 [gbasedbt@gbase ~]$ echo 'select * from t_employee' |dbaccess mydb f_employeeid f_deptid f_employeename 1 1 employee_01 2 1 employee_02 3 2 employee_03 4 2 employee_04 5 3 employee_05 11 1 employee_updated 12 1 employee_12 13 2 employee_13 15 3 employee_15 16 3 employee_16 21 1 employee_21 22 1 employee_22 23 2 employee_23 24 2 employee_24 25 3 employee_25 15 row(s) retrieved. [gbasedbt@gbase ~]$ echo 'select * from t_dept' |dbaccess mydb f_deptid f_deptname 1 dept_1 2 dept_2 3 dept_3 4 dept_4 5 dept_5 5 row(s) retrieved.

即使数据库空间的Chunk文件被删除,只要有备份,依然可以完全恢复,不丢失数据。

t_employee新增5条数据

insert into t_employee values(101, 1, 'employee_101'); insert into t_employee values(102, 1, 'employee_102'); insert into t_employee values(103, 2, 'employee_103'); insert into t_employee values(104, 2, 'employee_104'); insert into t_employee values(105, 3, 'employee_105'); > select * from t_employee; f_employeeid f_deptid f_employeename 1 1 employee_01 2 1 employee_02 3 2 employee_03 4 2 employee_04 5 3 employee_05 11 1 employee_updated 12 1 employee_12 13 2 employee_13 101 1 employee_101 15 3 employee_15 16 3 employee_16 21 1 employee_21 22 1 employee_22 23 2 employee_23 24 2 employee_24 25 3 employee_25 102 1 employee_102 103 2 employee_103 104 2 employee_104 105 3 employee_105 20 row(s) retrieved. > !date +'%F %T' 2023-02-16 15:16:47

删除t_employee表

为了演示方便,在删除表之前,记录一个时间,用于后续的不完全恢复时间点。

> !date +'%F %T' 2023-02-16 15:17:29 > drop table t_employee;

基于时间点的不完全恢复

  • 根据上面测试时记录的时间点,进行不完全恢复。
[gbasedbt@gbase ~]$ onmode -ky Your evaluation license will expire on 2024-02-04 00:00:00 [gbasedbt@gbase ~]$ export GL_DATETIME="%iY-%m-%d %H:%M:%S" [gbasedbt@gbase ~]$ onbar -r -t '2023-02-16 15:17:29' Your evaluation license will expire on 2024-02-04 00:00:00 Your evaluation license will expire on 2024-02-04 00:00:00 Your evaluation license will expire on 2024-02-04 00:00:00 [gbasedbt@gbase ~]$ onmode -m Your evaluation license will expire on 2024-02-04 00:00:00
  • 查看恢复结果
[gbasedbt@gbase ~]$ echo "select * from t_employee" | dbaccess mydb f_employeeid f_deptid f_employeename 1 1 employee_01 2 1 employee_02 3 2 employee_03 4 2 employee_04 5 3 employee_05 11 1 employee_updated 12 1 employee_12 13 2 employee_13 101 1 employee_101 15 3 employee_15 16 3 employee_16 21 1 employee_21 22 1 employee_22 23 2 employee_23 24 2 employee_24 25 3 employee_25 102 1 employee_102 103 2 employee_103 104 2 employee_104 105 3 employee_105 20 row(s) retrieved. [gbasedbt@gbase ~]$ echo "select * from t_dept" | dbaccess mydb f_deptid f_deptname 1 dept_1 2 dept_2 3 dept_3 4 dept_4 5 dept_5 5 row(s) retrieved.

即使因为误操作删除了整个表,也依然可以通过不完全恢复,找回被删除的数据。

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

文章被以下合辑收录

评论