GBase 8s 学习笔记 012 —— GBase 8s 备份与恢复:基于onbar的备份与恢复实验
ON-Bar体系架构
ON-Bar 由各种组件组成,它需要与存储管理器一起使用,来备份和恢复数据。
ON-Bar组件:
- sysutils 数据库,其中包含ON-Bar目录表
- onbar 和 onbar_d 命令行实用程序
- 系统上存储管理器的 XBSA 共享库
- 用于存储备份的存储介质
- ON-Bar活动日志
- ON-Bar紧急引导文件
环境准备
配置存储管理器PSM的共享库
ON-Bar 和存储管理器通过“备份服务应用程序编程接口 (XBSA)”通信,该接口支持将存储管理器作为数据库服务器的备份介质。
通过使用存储管理器的开放式系统接口,ON-Bar 可以与各种同样使用 XBSA 的存储管理器一起协同工作。
GBase 8s 内置了一个存储管理器PSM,该存储管理器的接口库位置为/opt/gbase/lib/libbsapsm.so
[gbasedbt@localhost ~]$ cd /opt/gbase/lib [gbasedbt@localhost lib]$ pwd /opt/gbase/lib [gbasedbt@localhost lib]$ ll 总用量 38572 -rwxr-xr-x. 1 gbasedbt gbasedbt 8846 3月 23 2021 iosm11a.so -rwxr-xr-x. 1 gbasedbt gbasedbt 326676 3月 23 2021 libAPI.jar -rwxr-xr-x. 1 gbasedbt gbasedbt 174756 3月 23 2021 libastool.so -rwxr-xr-x. 1 gbasedbt gbasedbt 14130 3月 23 2021 libbsanull.so -r-xr-xr-x. 1 gbasedbt gbasedbt 1920732 3月 23 2021 libbsapsm.so -rwxr-xr-x. 1 gbasedbt gbasedbt 11644279 3月 23 2021 libdwa.udr -rwxr-xr-x. 1 gbasedbt gbasedbt 74921 3月 23 2021 libencrypt_f.so -rwxr-xr-x. 1 gbasedbt gbasedbt 283227 3月 23 2021 libmisc.udr -rwxr-xr-x. 1 gbasedbt gbasedbt 239980 3月 23 2021 libnativeAPI.so -rwxr-xr-x. 1 gbasedbt gbasedbt 403608 3月 23 2021 liboracle.udr -r-xr-xr-x. 1 gbasedbt gbasedbt 59340 3月 23 2021 libtxbsa.so -rwxr-xr-x. 1 gbasedbt gbasedbt 24322266 3月 23 2021 libxml.udr [gbasedbt@localhost lib]$
保用ON-Bar时,需要做一些简单的配置,配置参数如下:
参数 | 说明 |
---|---|
BAR_BSALIB_PATH | 指定 XBSA 库的位置 |
BAR_MAX_BACKUP | 最大并行进程数 |
LTAPEDEV | 逻辑日志备份目录 |
[gbasedbt@localhost lib]$ onstat -c | grep BAR_BSALIB_PATH
Your evaluation license will expire on 2024-02-14 00:00:00
# BAR_BSALIB_PATH - The shared library for ON-Bar and the
BAR_BSALIB_PATH
[gbasedbt@localhost lib]$ onmode -wf BAR_BSALIB_PATH=/opt/gbase/lib/libbsapsm.so
Your evaluation license will expire on 2024-02-14 00:00:00
Value of BAR_BSALIB_PATH has been changed to /opt/gbase/lib/libbsapsm.so.
[gbasedbt@localhost lib]$ onstat -c | grep BAR_BSALIB_PATH
Your evaluation license will expire on 2024-02-14 00:00:00
# BAR_BSALIB_PATH - The shared library for ON-Bar and the
BAR_BSALIB_PATH /opt/gbase/lib/libbsapsm.so
[gbasedbt@localhost lib]$
[gbasedbt@localhost lib]$ onmode -wf LTAPEDEV=/opt/gbase/backups
Your evaluation license will expire on 2024-02-14 00:00:00
Value of LTAPEDEV has been changed to /opt/gbase/backups.
[gbasedbt@localhost lib]$ onstat -c | grep LTAPEDEV
Your evaluation license will expire on 2024-02-14 00:00:00
# LTAPEDEV - The tape device path for logical logs
LTAPEDEV /opt/gbase/backups
说明:LTAPEDEV是ontape中的一个参数,在使用onbar时,该参数不能为/dev/null。我们可以临时为参数设置一个目录,实际备份时,逻辑日志并不保存在该目录中。
PSM配置
初始化Catalog
[gbasedbt@localhost ~]$ ll /opt/gbase/etc/psm
ls: 无法访问/opt/gbase/etc/psm: 没有那个文件或目录
[gbasedbt@localhost ~]$ 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@localhost ~]$ ll /opt/gbase/etc/psm
总用量 60
-rw-rw-r--. 1 gbasedbt gbasedbt 1024 2月 16 16:58 device.dat
-rw-rw-r--. 1 gbasedbt gbasedbt 5120 2月 16 16:58 device.idx
-rw-rw-r--. 1 gbasedbt gbasedbt 1024 2月 16 16:58 lock.dat
-rw-rw-r--. 1 gbasedbt gbasedbt 2048 2月 16 16:58 lock.idx
-rw-rw-r--. 1 gbasedbt gbasedbt 0 2月 16 16:58 object.dat
-rw-rw-r--. 1 gbasedbt gbasedbt 0 2月 16 16:58 object_detail.dat
-rw-rw-r--. 1 gbasedbt gbasedbt 3072 2月 16 16:58 object_detail.idx
-rw-rw-r--. 1 gbasedbt gbasedbt 4096 2月 16 16:58 object.idx
-rw-rw-r--. 1 gbasedbt gbasedbt 0 2月 16 16:58 pool.dat
-rw-rw-r--. 1 gbasedbt gbasedbt 4096 2月 16 16:58 pool.idx
-rw-rw-r--. 1 gbasedbt gbasedbt 1024 2月 16 16:58 serial.dat
-rw-rw-r--. 1 gbasedbt gbasedbt 2048 2月 16 16:58 serial.idx
-rw-rw-r--. 1 gbasedbt gbasedbt 1024 2月 16 16:58 session.dat
-rw-rw-r--. 1 gbasedbt gbasedbt 3072 2月 16 16:58 session.idx
-rw-rw-r--. 1 gbasedbt gbasedbt 1024 2月 16 16:58 volume.dat
-rw-rw-r--. 1 gbasedbt gbasedbt 5120 2月 16 16:58 volume.idx
[gbasedbt@localhost ~]$
查看PSM设备情况
[gbasedbt@localhost ~]$ 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
[gbasedbt@localhost ~]$
配置PSM设备
我们不使用默认的PSM设备,使用下面的方法,添加一个自己的设备,并将原来的设备删除。
[gbasedbt@localhost ~]$ mkdir -p /opt/gbase/dbspool
[gbasedbt@localhost ~]$ mkdir -p /opt/gbase/logpool
[gbasedbt@localhost ~]$ onpsm -D add /opt/gbase/dbspool -g DBSPOOL -p HIGHEST -t FILE
[gbasedbt@localhost ~]$ onpsm -D add /opt/gbase/logpool -g LOGPOOL -p HIGHEST -t FILE
[gbasedbt@localhost ~]$ 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@localhost ~]$ 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@localhost ~]$ ll /opt/gbase/dbspool
总用量 0
[gbasedbt@localhost ~]$ ll /opt/gbase/logpool
总用量 0
[gbasedbt@localhost ~]$
实验说明
业务场景说明:
- 数据空间文件被删除时的数据完全恢复
- 表删除后基于时间点的不完全恢复
时间 | 业务 | 说明 |
---|---|---|
t1 | 系统上线 | 创建t_dept和t_employee |
t2 | t_dept新增3条数据 | |
t3 | t_employee新增5条数据 | |
t4 | 系统进行L0备份 | |
t5 | t_employee新增5条数据 | |
t6 | 系统进行L1备份 | |
t7 | t_employee新增1条数据 | |
t8 | 系统进行L1备份 | |
t9 | t_employee新增5条数据 | |
t10 | 系统进行L2备份 | |
t11 | t_dept新增1条数据 | |
t12 | t_employee更新1条数 | |
t13 | 切换逻辑日志 | 模拟因业务变化导致日志切换 |
t14 | t_employee删除1条数据 | |
t15 | 删除Chunk文件 | 模拟灾难 |
t16 | t_dept新增1条数据 | |
t17 | 备份逻辑日志 | |
t18 | 演示完全恢复 | |
t19 | t_employee新增5条数据 | |
t20 | 删除t_employee表 | 模拟灾难 |
t21 | 基于时间点的不完全恢复 |
备份与恢复演示
创建数据库和表(t1)
[gbasedbt@localhost ~]$ dbaccess - -
Your evaluation license will expire on 2024-02-14 00:00:00
> create database mydb in datadbs1 with log;
Database created.
> create table t_dept(f_deptid int, f_deptname varchar(20));
Table created.
> create table t_employee(f_employeeid int, f_deptid int, f_employeename varchar(20));
Table created.
> info tables;
Table name
t_dept t_employee
>
t_dept新增3条数据(t2)
> insert into t_dept values(1, 'dept_1');
insert into t_dept values(2, 'dept_2');
insert into t_dept values(3, 'dept_3');
1 row(s) inserted.
>
1 row(s) inserted.
> select * from t_dept;
1 row(s) inserted.
f_deptid f_deptname
1 dept_1
2 dept_2
3 dept_3
3 row(s) retrieved.
> !date +'%F %T'
2023-02-16 17:22:48
>
t_employee新增5条数据(t3)
> 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');
1 row(s) inserted.
>
1 row(s) inserted.
>
1 row(s) inserted.
>
1 row(s) inserted.
> select * from t_employee;
1 row(s) inserted.
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 17:24:11
>
系统进行L0备份(t4)
查看当前的日志,文件编号为7,唯一编号为10
[gbasedbt@localhost ~]$ onstat -l
Your evaluation license will expire on 2024-02-14 00:00:00
On-Line -- Up 00:56:31 -- 1135464 Kbytes
Physical Logging
Buffer bufused bufsize numpages numwrits pages/io
P-2 0 1024 1330 8 166.25
phybegin physize phypos phyused %used
3:53 99400 9518 0 0.00
Logical Logging
Buffer bufused bufsize numrecs numpages numwrits recs/pages pages/io
L-2 0 512 26888 2010 31 13.4 64.8
Subsystem numrecs Log Space used
OLDRSAM 26846 3999424
HA 7 308
DDL 35 12180
address number flags uniqid begin size used %used
47140f88 4 F------ 0 2:53 5000 0 0.00
483d2970 5 F------ 0 2:5053 5000 0 0.00
483d29d8 6 U-B---- 9 2:10053 5000 2551 51.02
483d2a40 7 U---C-L 10 2:15053 5000 2010 40.20
483d2aa8 8 A------ 0 2:20053 5000 0 0.00
483d2b10 9 A------ 0 2:25053 5000 0 0.00
483d2b78 10 A------ 0 2:30053 5000 0 0.00
483d2be0 11 A------ 0 2:35053 5000 0 0.00
483d2c48 12 A------ 0 2:40053 5000 0 0.00
483d2cb0 13 A------ 0 2:45053 5000 0 0.00
483d2d18 14 A------ 0 2:50053 5000 0 0.00
483d2d80 15 A------ 0 2:55053 5000 0 0.00
483d2de8 16 A------ 0 2:60053 5000 0 0.00
483d2e50 17 A------ 0 2:65053 5000 0 0.00
483d2eb8 18 A------ 0 2:70053 5000 0 0.00
483d2f20 19 A------ 0 2:75053 5000 0 0.00
483d2f88 20 A------ 0 2:80053 5000 0 0.00
46f1ff30 21 A------ 0 2:85053 5000 0 0.00
46f1ff98 22 A------ 0 2:90053 5000 0 0.00
46feef30 23 A------ 0 2:95053 5000 0 0.00
20 active, 20 total
[gbasedbt@localhost ~]$
查看实例的服务器编号为101
[gbasedbt@localhost ~]$ onstat -c | grep SERVERNUM
Your evaluation license will expire on 2024-02-14 00:00:00
# SERVERNUM - The unique ID for the GBase instance. Acceptable
SERVERNUM 101
[gbasedbt@localhost ~]$
执行L0备份。
[gbasedbt@localhost ~]$ onbar -b -L 0 Your evaluation license will expire on 2024-02-14 00:00:00 [gbasedbt@localhost ~]$ onpsm -O list __PSM__ Object List Object ID Date Created Size (MB) Logical path (name.version) 1 2023-02-16 17:27:37 16.0 /gbaseserver/rootdbs/0/gbaseserver.1 2 2023-02-16 17:27:38 0.1 /gbaseserver/datadbs4/0/gbaseserver.1 3 2023-02-16 17:27:38 0.1 /gbaseserver/llogdbs/0/gbaseserver.1 4 2023-02-16 17:27:38 1.8 /gbaseserver/datadbs3/0/gbaseserver.1 5 2023-02-16 17:27:38 0.1 /gbaseserver/datadbs5/0/gbaseserver.1 6 2023-02-16 17:27:39 0.1 /gbaseserver/plogdbs/0/gbaseserver.1 7 2023-02-16 17:27:39 1.8 /gbaseserver/datadbs2/0/gbaseserver.1 8 2023-02-16 17:27:39 27.5 /gbaseserver/datadbs1/0/gbaseserver.1 9 2023-02-16 17:27:39 0.1 /gbaseserver/sbspace1/0/gbaseserver.1 10 2023-02-16 17:27:41 4.0 /gbaseserver/101/10/gbaseserver.1 11 2023-02-16 17:27:41 0.0 /gbaseserver/critical_files/ixbar/gbaseserver.1 12 2023-02-16 17:27:41 0.0 /gbaseserver/critical_files/oncfg/gbaseserver.1 13 2023-02-16 17:27:41 0.1 /gbaseserver/critical_files/onconfig/gbaseserver.1 14 2023-02-16 17:27:41 0.0 /gbaseserver/critical_files/sqlhosts/gbaseserver.1 [gbasedbt@localhost ~]$
L0备份了rootdbs,plogdbs,llogdbs,datadbs,ixbar,oncfg,onconfig,sqlhosts。另外还有一个目录/gbaseserver/101/10/gbaseserver.1,其中的101为实例的服务器编号,10为当前逻辑日志的唯一编号(uniqid)。
t_employee新增5条数据(t5)
> 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');
1 row(s) inserted.
>
1 row(s) inserted.
>
1 row(s) inserted.
>
1 row(s) inserted.
> select * from t_employee;
1 row(s) inserted.
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 17:30:37
>
系统进行L1备份(t6)
[gbasedbt@localhost ~]$ onbar -b -L 1 Your evaluation license will expire on 2024-02-14 00:00:00 [gbasedbt@localhost ~]$ onpsm -O list __PSM__ Object List Object ID Date Created Size (MB) Logical path (name.version) 1 2023-02-16 17:27:37 16.0 /gbaseserver/rootdbs/0/gbaseserver.1 2 2023-02-16 17:27:38 0.1 /gbaseserver/datadbs4/0/gbaseserver.1 3 2023-02-16 17:27:38 0.1 /gbaseserver/llogdbs/0/gbaseserver.1 4 2023-02-16 17:27:38 1.8 /gbaseserver/datadbs3/0/gbaseserver.1 5 2023-02-16 17:27:38 0.1 /gbaseserver/datadbs5/0/gbaseserver.1 6 2023-02-16 17:27:39 0.1 /gbaseserver/plogdbs/0/gbaseserver.1 7 2023-02-16 17:27:39 1.8 /gbaseserver/datadbs2/0/gbaseserver.1 8 2023-02-16 17:27:39 27.5 /gbaseserver/datadbs1/0/gbaseserver.1 9 2023-02-16 17:27:39 0.1 /gbaseserver/sbspace1/0/gbaseserver.1 10 2023-02-16 17:27:41 4.0 /gbaseserver/101/10/gbaseserver.1 11 2023-02-16 17:27:41 0.0 /gbaseserver/critical_files/ixbar/gbaseserver.1 12 2023-02-16 17:27:41 0.0 /gbaseserver/critical_files/oncfg/gbaseserver.1 13 2023-02-16 17:27:41 0.1 /gbaseserver/critical_files/onconfig/gbaseserver.1 14 2023-02-16 17:27:41 0.0 /gbaseserver/critical_files/sqlhosts/gbaseserver.1 15 2023-02-16 17:32:57 0.2 /gbaseserver/rootdbs/1/gbaseserver.1 16 2023-02-16 17:32:57 0.1 /gbaseserver/datadbs1/1/gbaseserver.1 17 2023-02-16 17:32:58 0.1 /gbaseserver/llogdbs/1/gbaseserver.1 18 2023-02-16 17:32:58 0.1 /gbaseserver/datadbs5/1/gbaseserver.1 19 2023-02-16 17:32:58 0.1 /gbaseserver/datadbs3/1/gbaseserver.1 20 2023-02-16 17:32:58 0.1 /gbaseserver/datadbs2/1/gbaseserver.1 21 2023-02-16 17:32:58 0.1 /gbaseserver/datadbs4/1/gbaseserver.1 22 2023-02-16 17:32:58 0.1 /gbaseserver/plogdbs/1/gbaseserver.1 23 2023-02-16 17:32:58 0.1 /gbaseserver/sbspace1/1/gbaseserver.1 24 2023-02-16 17:32:59 0.1 /gbaseserver/101/11/gbaseserver.1 25 2023-02-16 17:33:00 0.0 /gbaseserver/critical_files/ixbar/gbaseserver.2 26 2023-02-16 17:33:00 0.0 /gbaseserver/critical_files/oncfg/gbaseserver.2 27 2023-02-16 17:33:00 0.1 /gbaseserver/critical_files/onconfig/gbaseserver.2 28 2023-02-16 17:33:00 0.0 /gbaseserver/critical_files/sqlhosts/gbaseserver.2 [gbasedbt@localhost ~]$
进行L1备份后,备份文件数量由14个变为28个。
t_employee新增1条数据(t7)
> insert into t_employee values(16, 3, 'employee_16');
1 row(s) inserted.
> 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 17:34:33
>
系统进行L1备份(t8)
[gbasedbt@localhost ~]$ onbar -b -L 1 Your evaluation license will expire on 2024-02-14 00:00:00 [gbasedbt@localhost ~]$ onpsm -O list __PSM__ Object List Object ID Date Created Size (MB) Logical path (name.version) 1 2023-02-16 17:27:37 16.0 /gbaseserver/rootdbs/0/gbaseserver.1 2 2023-02-16 17:27:38 0.1 /gbaseserver/datadbs4/0/gbaseserver.1 3 2023-02-16 17:27:38 0.1 /gbaseserver/llogdbs/0/gbaseserver.1 4 2023-02-16 17:27:38 1.8 /gbaseserver/datadbs3/0/gbaseserver.1 5 2023-02-16 17:27:38 0.1 /gbaseserver/datadbs5/0/gbaseserver.1 6 2023-02-16 17:27:39 0.1 /gbaseserver/plogdbs/0/gbaseserver.1 7 2023-02-16 17:27:39 1.8 /gbaseserver/datadbs2/0/gbaseserver.1 8 2023-02-16 17:27:39 27.5 /gbaseserver/datadbs1/0/gbaseserver.1 9 2023-02-16 17:27:39 0.1 /gbaseserver/sbspace1/0/gbaseserver.1 10 2023-02-16 17:27:41 4.0 /gbaseserver/101/10/gbaseserver.1 11 2023-02-16 17:27:41 0.0 /gbaseserver/critical_files/ixbar/gbaseserver.1 12 2023-02-16 17:27:41 0.0 /gbaseserver/critical_files/oncfg/gbaseserver.1 13 2023-02-16 17:27:41 0.1 /gbaseserver/critical_files/onconfig/gbaseserver.1 14 2023-02-16 17:27:41 0.0 /gbaseserver/critical_files/sqlhosts/gbaseserver.1 15 2023-02-16 17:32:57 0.2 /gbaseserver/rootdbs/1/gbaseserver.1 16 2023-02-16 17:32:57 0.1 /gbaseserver/datadbs1/1/gbaseserver.1 17 2023-02-16 17:32:58 0.1 /gbaseserver/llogdbs/1/gbaseserver.1 18 2023-02-16 17:32:58 0.1 /gbaseserver/datadbs5/1/gbaseserver.1 19 2023-02-16 17:32:58 0.1 /gbaseserver/datadbs3/1/gbaseserver.1 20 2023-02-16 17:32:58 0.1 /gbaseserver/datadbs2/1/gbaseserver.1 21 2023-02-16 17:32:58 0.1 /gbaseserver/datadbs4/1/gbaseserver.1 22 2023-02-16 17:32:58 0.1 /gbaseserver/plogdbs/1/gbaseserver.1 23 2023-02-16 17:32:58 0.1 /gbaseserver/sbspace1/1/gbaseserver.1 24 2023-02-16 17:32:59 0.1 /gbaseserver/101/11/gbaseserver.1 25 2023-02-16 17:33:00 0.0 /gbaseserver/critical_files/ixbar/gbaseserver.2 26 2023-02-16 17:33:00 0.0 /gbaseserver/critical_files/oncfg/gbaseserver.2 27 2023-02-16 17:33:00 0.1 /gbaseserver/critical_files/onconfig/gbaseserver.2 28 2023-02-16 17:33:00 0.0 /gbaseserver/critical_files/sqlhosts/gbaseserver.2 29 2023-02-16 17:35:26 0.2 /gbaseserver/rootdbs/1/gbaseserver.2 30 2023-02-16 17:35:27 0.1 /gbaseserver/datadbs4/1/gbaseserver.2 31 2023-02-16 17:35:28 0.1 /gbaseserver/datadbs5/1/gbaseserver.2 32 2023-02-16 17:35:28 0.1 /gbaseserver/plogdbs/1/gbaseserver.2 33 2023-02-16 17:35:28 0.1 /gbaseserver/datadbs2/1/gbaseserver.2 34 2023-02-16 17:35:28 0.1 /gbaseserver/datadbs3/1/gbaseserver.2 35 2023-02-16 17:35:28 0.1 /gbaseserver/llogdbs/1/gbaseserver.2 36 2023-02-16 17:35:28 0.1 /gbaseserver/sbspace1/1/gbaseserver.2 37 2023-02-16 17:35:28 0.1 /gbaseserver/datadbs1/1/gbaseserver.2 38 2023-02-16 17:35:29 0.1 /gbaseserver/101/12/gbaseserver.1 39 2023-02-16 17:35:29 0.0 /gbaseserver/critical_files/ixbar/gbaseserver.3 40 2023-02-16 17:35:29 0.0 /gbaseserver/critical_files/oncfg/gbaseserver.3 41 2023-02-16 17:35:29 0.1 /gbaseserver/critical_files/onconfig/gbaseserver.3 42 2023-02-16 17:35:29 0.0 /gbaseserver/critical_files/sqlhosts/gbaseserver.3 [gbasedbt@localhost ~]$
进行两次L1备份后,备份文件变为42个。通过观察,ON-Bar备份时,PSM是通过组织文件系统的目录来管理备份文件的。PSM为L0,L1,L2创建3个目录,分别为0,1,2。每个备份文件名称为<instance_name>.<seq_num>。
逻辑日志的备份,是按逻辑日志的唯一编号,创建对应的目录进行存储。
t_employee新增5条数据(t9)
> 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');
1 row(s) inserted.
>
1 row(s) inserted.
>
1 row(s) inserted.
>
1 row(s) inserted.
> select * from t_employee;
1 row(s) inserted.
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 17:37:41
>
系统进行L2备份(t10)
[gbasedbt@localhost ~]$ onbar -b -L 2 Your evaluation license will expire on 2024-02-14 00:00:00 [gbasedbt@localhost ~]$ onpsm -O list __PSM__ Object List Object ID Date Created Size (MB) Logical path (name.version) 1 2023-02-16 17:27:37 16.0 /gbaseserver/rootdbs/0/gbaseserver.1 2 2023-02-16 17:27:38 0.1 /gbaseserver/datadbs4/0/gbaseserver.1 3 2023-02-16 17:27:38 0.1 /gbaseserver/llogdbs/0/gbaseserver.1 4 2023-02-16 17:27:38 1.8 /gbaseserver/datadbs3/0/gbaseserver.1 5 2023-02-16 17:27:38 0.1 /gbaseserver/datadbs5/0/gbaseserver.1 6 2023-02-16 17:27:39 0.1 /gbaseserver/plogdbs/0/gbaseserver.1 7 2023-02-16 17:27:39 1.8 /gbaseserver/datadbs2/0/gbaseserver.1 8 2023-02-16 17:27:39 27.5 /gbaseserver/datadbs1/0/gbaseserver.1 9 2023-02-16 17:27:39 0.1 /gbaseserver/sbspace1/0/gbaseserver.1 10 2023-02-16 17:27:41 4.0 /gbaseserver/101/10/gbaseserver.1 11 2023-02-16 17:27:41 0.0 /gbaseserver/critical_files/ixbar/gbaseserver.1 12 2023-02-16 17:27:41 0.0 /gbaseserver/critical_files/oncfg/gbaseserver.1 13 2023-02-16 17:27:41 0.1 /gbaseserver/critical_files/onconfig/gbaseserver.1 14 2023-02-16 17:27:41 0.0 /gbaseserver/critical_files/sqlhosts/gbaseserver.1 15 2023-02-16 17:32:57 0.2 /gbaseserver/rootdbs/1/gbaseserver.1 16 2023-02-16 17:32:57 0.1 /gbaseserver/datadbs1/1/gbaseserver.1 17 2023-02-16 17:32:58 0.1 /gbaseserver/llogdbs/1/gbaseserver.1 18 2023-02-16 17:32:58 0.1 /gbaseserver/datadbs5/1/gbaseserver.1 19 2023-02-16 17:32:58 0.1 /gbaseserver/datadbs3/1/gbaseserver.1 20 2023-02-16 17:32:58 0.1 /gbaseserver/datadbs2/1/gbaseserver.1 21 2023-02-16 17:32:58 0.1 /gbaseserver/datadbs4/1/gbaseserver.1 22 2023-02-16 17:32:58 0.1 /gbaseserver/plogdbs/1/gbaseserver.1 23 2023-02-16 17:32:58 0.1 /gbaseserver/sbspace1/1/gbaseserver.1 24 2023-02-16 17:32:59 0.1 /gbaseserver/101/11/gbaseserver.1 25 2023-02-16 17:33:00 0.0 /gbaseserver/critical_files/ixbar/gbaseserver.2 26 2023-02-16 17:33:00 0.0 /gbaseserver/critical_files/oncfg/gbaseserver.2 27 2023-02-16 17:33:00 0.1 /gbaseserver/critical_files/onconfig/gbaseserver.2 28 2023-02-16 17:33:00 0.0 /gbaseserver/critical_files/sqlhosts/gbaseserver.2 29 2023-02-16 17:35:26 0.2 /gbaseserver/rootdbs/1/gbaseserver.2 30 2023-02-16 17:35:27 0.1 /gbaseserver/datadbs4/1/gbaseserver.2 31 2023-02-16 17:35:28 0.1 /gbaseserver/datadbs5/1/gbaseserver.2 32 2023-02-16 17:35:28 0.1 /gbaseserver/plogdbs/1/gbaseserver.2 33 2023-02-16 17:35:28 0.1 /gbaseserver/datadbs2/1/gbaseserver.2 34 2023-02-16 17:35:28 0.1 /gbaseserver/datadbs3/1/gbaseserver.2 35 2023-02-16 17:35:28 0.1 /gbaseserver/llogdbs/1/gbaseserver.2 36 2023-02-16 17:35:28 0.1 /gbaseserver/sbspace1/1/gbaseserver.2 37 2023-02-16 17:35:28 0.1 /gbaseserver/datadbs1/1/gbaseserver.2 38 2023-02-16 17:35:29 0.1 /gbaseserver/101/12/gbaseserver.1 39 2023-02-16 17:35:29 0.0 /gbaseserver/critical_files/ixbar/gbaseserver.3 40 2023-02-16 17:35:29 0.0 /gbaseserver/critical_files/oncfg/gbaseserver.3 41 2023-02-16 17:35:29 0.1 /gbaseserver/critical_files/onconfig/gbaseserver.3 42 2023-02-16 17:35:29 0.0 /gbaseserver/critical_files/sqlhosts/gbaseserver.3 43 2023-02-16 17:38:46 0.1 /gbaseserver/rootdbs/2/gbaseserver.1 44 2023-02-16 17:38:47 0.1 /gbaseserver/datadbs4/2/gbaseserver.1 45 2023-02-16 17:38:47 0.1 /gbaseserver/datadbs2/2/gbaseserver.1 46 2023-02-16 17:38:47 0.1 /gbaseserver/datadbs5/2/gbaseserver.1 47 2023-02-16 17:38:48 0.1 /gbaseserver/datadbs3/2/gbaseserver.1 48 2023-02-16 17:38:49 0.1 /gbaseserver/llogdbs/2/gbaseserver.1 49 2023-02-16 17:38:49 0.1 /gbaseserver/plogdbs/2/gbaseserver.1 50 2023-02-16 17:38:49 0.1 /gbaseserver/sbspace1/2/gbaseserver.1 51 2023-02-16 17:38:49 0.1 /gbaseserver/datadbs1/2/gbaseserver.1 52 2023-02-16 17:38:50 0.1 /gbaseserver/101/13/gbaseserver.1 53 2023-02-16 17:38:50 0.0 /gbaseserver/critical_files/ixbar/gbaseserver.4 54 2023-02-16 17:38:50 0.0 /gbaseserver/critical_files/oncfg/gbaseserver.4 55 2023-02-16 17:38:50 0.1 /gbaseserver/critical_files/onconfig/gbaseserver.4 56 2023-02-16 17:38:50 0.0 /gbaseserver/critical_files/sqlhosts/gbaseserver.4 [gbasedbt@localhost ~]$
备份完成后,当前的逻辑日志唯一编号为11
[gbasedbt@localhost ~]$ onstat -l
Your evaluation license will expire on 2024-02-14 00:00:00
On-Line -- Up 01:11:01 -- 1135464 Kbytes
Physical Logging
Buffer bufused bufsize numpages numwrits pages/io
P-2 22 1024 1657 21 78.90
phybegin physize phypos phyused %used
3:53 99400 9845 22 0.02
Logical Logging
Buffer bufused bufsize numrecs numpages numwrits recs/pages pages/io
L-1 0 512 27657 2151 165 12.9 13.0
Subsystem numrecs Log Space used
OLDRSAM 27597 4065244
HA 25 1100
DDL 35 12180
address number flags uniqid begin size used %used
47140f88 4 F------ 0 2:53 5000 0 0.00
483d2970 5 F------ 0 2:5053 5000 0 0.00
483d29d8 6 U-B---- 9 2:10053 5000 2551 51.02
483d2a40 7 U-B---- 10 2:15053 5000 2045 40.90
483d2aa8 8 U-B---- 11 2:20053 5000 35 0.70
483d2b10 9 U-B---- 12 2:25053 5000 31 0.62
483d2b78 10 U-B---L 13 2:30053 5000 38 0.76
483d2be0 11 U---C-- 14 2:35053 5000 2 0.04
483d2c48 12 A------ 0 2:40053 5000 0 0.00
483d2cb0 13 A------ 0 2:45053 5000 0 0.00
483d2d18 14 A------ 0 2:50053 5000 0 0.00
483d2d80 15 A------ 0 2:55053 5000 0 0.00
483d2de8 16 A------ 0 2:60053 5000 0 0.00
483d2e50 17 A------ 0 2:65053 5000 0 0.00
483d2eb8 18 A------ 0 2:70053 5000 0 0.00
483d2f20 19 A------ 0 2:75053 5000 0 0.00
483d2f88 20 A------ 0 2:80053 5000 0 0.00
46f1ff30 21 A------ 0 2:85053 5000 0 0.00
46f1ff98 22 A------ 0 2:90053 5000 0 0.00
46feef30 23 A------ 0 2:95053 5000 0 0.00
20 active, 20 total
[gbasedbt@localhost ~]$
t_dept新增1条数据(t11)
> insert into t_dept values(4, 'dept_4');
1 row(s) inserted.
> 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 17:41:29
>
t_employee更新1条数据(t12)
> update t_employee set f_employeename = 'employee_updated' where f_employeeid =11;
1 row(s) updated.
> 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 17:43:00
>
切换逻辑日志(t13)
[gbasedbt@localhost ~]$ onstat -l
Your evaluation license will expire on 2024-02-14 00:00:00
On-Line -- Up 01:15:06 -- 1135464 Kbytes
Physical Logging
Buffer bufused bufsize numpages numwrits pages/io
P-2 0 1024 1738 25 69.52
phybegin physize phypos phyused %used
3:53 99400 9926 14 0.01
Logical Logging
Buffer bufused bufsize numrecs numpages numwrits recs/pages pages/io
L-1 0 512 27670 2157 171 12.8 12.6
Subsystem numrecs Log Space used
OLDRSAM 27608 4065892
HA 27 1188
DDL 35 12180
address number flags uniqid begin size used %used
47140f88 4 F------ 0 2:53 5000 0 0.00
483d2970 5 F------ 0 2:5053 5000 0 0.00
483d29d8 6 U-B---- 9 2:10053 5000 2551 51.02
483d2a40 7 U-B---- 10 2:15053 5000 2045 40.90
483d2aa8 8 U-B---- 11 2:20053 5000 35 0.70
483d2b10 9 U-B---- 12 2:25053 5000 31 0.62
483d2b78 10 U-B---- 13 2:30053 5000 38 0.76
483d2be0 11 U---C-L 14 2:35053 5000 8 0.16
483d2c48 12 A------ 0 2:40053 5000 0 0.00
483d2cb0 13 A------ 0 2:45053 5000 0 0.00
483d2d18 14 A------ 0 2:50053 5000 0 0.00
483d2d80 15 A------ 0 2:55053 5000 0 0.00
483d2de8 16 A------ 0 2:60053 5000 0 0.00
483d2e50 17 A------ 0 2:65053 5000 0 0.00
483d2eb8 18 A------ 0 2:70053 5000 0 0.00
483d2f20 19 A------ 0 2:75053 5000 0 0.00
483d2f88 20 A------ 0 2:80053 5000 0 0.00
46f1ff30 21 A------ 0 2:85053 5000 0 0.00
46f1ff98 22 A------ 0 2:90053 5000 0 0.00
46feef30 23 A------ 0 2:95053 5000 0 0.00
20 active, 20 total
[gbasedbt@localhost ~]$ onmode -l
Your evaluation license will expire on 2024-02-14 00:00:00
[gbasedbt@localhost ~]$ onstat -l
Your evaluation license will expire on 2024-02-14 00:00:00
On-Line -- Up 01:15:24 -- 1135464 Kbytes
Physical Logging
Buffer bufused bufsize numpages numwrits pages/io
P-2 7 1024 1738 25 69.52
phybegin physize phypos phyused %used
3:53 99400 9926 21 0.02
Logical Logging
Buffer bufused bufsize numrecs numpages numwrits recs/pages pages/io
L-2 0 512 27670 2158 172 12.8 12.5
Subsystem numrecs Log Space used
OLDRSAM 27608 4065892
HA 27 1188
DDL 35 12180
address number flags uniqid begin size used %used
47140f88 4 F------ 0 2:53 5000 0 0.00
483d2970 5 F------ 0 2:5053 5000 0 0.00
483d29d8 6 U-B---- 9 2:10053 5000 2551 51.02
483d2a40 7 U-B---- 10 2:15053 5000 2045 40.90
483d2aa8 8 U-B---- 11 2:20053 5000 35 0.70
483d2b10 9 U-B---- 12 2:25053 5000 31 0.62
483d2b78 10 U-B---- 13 2:30053 5000 38 0.76
483d2be0 11 U-----L 14 2:35053 5000 9 0.18
483d2c48 12 U---C-- 15 2:40053 5000 0 0.00
483d2cb0 13 A------ 0 2:45053 5000 0 0.00
483d2d18 14 A------ 0 2:50053 5000 0 0.00
483d2d80 15 A------ 0 2:55053 5000 0 0.00
483d2de8 16 A------ 0 2:60053 5000 0 0.00
483d2e50 17 A------ 0 2:65053 5000 0 0.00
483d2eb8 18 A------ 0 2:70053 5000 0 0.00
483d2f20 19 A------ 0 2:75053 5000 0 0.00
483d2f88 20 A------ 0 2:80053 5000 0 0.00
46f1ff30 21 A------ 0 2:85053 5000 0 0.00
46f1ff98 22 A------ 0 2:90053 5000 0 0.00
46feef30 23 A------ 0 2:95053 5000 0 0.00
20 active, 20 total
[gbasedbt@localhost ~]$
切换逻辑日志后,当前逻辑日志唯一编号变为14。
t_employee删除1条数据(t14)
> delete from t_employee where f_employeeid = 14;
1 row(s) deleted.
> 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 17:47:19
>
删除Chunk文件(t15)
[gbasedbt@localhost ~]$ cd /opt/gbase/gbaseserver_dbs/
[gbasedbt@localhost gbaseserver_dbs]$ pwd
/opt/gbase/gbaseserver_dbs
[gbasedbt@localhost gbaseserver_dbs]$ ll
总用量 1536000
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 17:47 datadbs1_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 16:29 datadbs2_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 16:29 datadbs3_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 16:29 datadbs4_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 16:29 datadbs5_1
-rw-rw----. 1 gbasedbt gbasedbt 209715200 2月 16 17:47 llogdbs
-rw-rw----. 1 gbasedbt gbasedbt 209715200 2月 16 17:47 plogdbs
-rw-rw----. 1 gbasedbt gbasedbt 209715200 2月 16 17:47 rootdbs
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 16:29 sbspace1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 17:41 tmpdbs1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 17:41 tmpdbs2
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 17:41 tmpdbs3
[gbasedbt@localhost gbaseserver_dbs]$ rm -rf datadbs1_1
[gbasedbt@localhost gbaseserver_dbs]$ ll
总用量 1433600
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 16:29 datadbs2_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 16:29 datadbs3_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 16:29 datadbs4_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 16:29 datadbs5_1
-rw-rw----. 1 gbasedbt gbasedbt 209715200 2月 16 17:47 llogdbs
-rw-rw----. 1 gbasedbt gbasedbt 209715200 2月 16 17:47 plogdbs
-rw-rw----. 1 gbasedbt gbasedbt 209715200 2月 16 17:47 rootdbs
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 16:29 sbspace1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 17:41 tmpdbs1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 17:41 tmpdbs2
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 17:41 tmpdbs3
[gbasedbt@localhost gbaseserver_dbs]$
t_dept新增1条数据(t16)
> insert into t_dept values(5, 'dept_5');
1 row(s) inserted.
> 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 17:49:40
>
即使在保存数据的Chunk文件被删除,最近的事务仍然可以执行成功。
备份逻辑日志(t17)
[gbasedbt@localhost gbaseserver_dbs]$ onbar -b -l Your evaluation license will expire on 2024-02-14 00:00:00 [gbasedbt@localhost gbaseserver_dbs]$ onpsm -O list __PSM__ Object List Object ID Date Created Size (MB) Logical path (name.version) 1 2023-02-16 17:27:37 16.0 /gbaseserver/rootdbs/0/gbaseserver.1 2 2023-02-16 17:27:38 0.1 /gbaseserver/datadbs4/0/gbaseserver.1 3 2023-02-16 17:27:38 0.1 /gbaseserver/llogdbs/0/gbaseserver.1 4 2023-02-16 17:27:38 1.8 /gbaseserver/datadbs3/0/gbaseserver.1 5 2023-02-16 17:27:38 0.1 /gbaseserver/datadbs5/0/gbaseserver.1 6 2023-02-16 17:27:39 0.1 /gbaseserver/plogdbs/0/gbaseserver.1 7 2023-02-16 17:27:39 1.8 /gbaseserver/datadbs2/0/gbaseserver.1 8 2023-02-16 17:27:39 27.5 /gbaseserver/datadbs1/0/gbaseserver.1 9 2023-02-16 17:27:39 0.1 /gbaseserver/sbspace1/0/gbaseserver.1 10 2023-02-16 17:27:41 4.0 /gbaseserver/101/10/gbaseserver.1 11 2023-02-16 17:27:41 0.0 /gbaseserver/critical_files/ixbar/gbaseserver.1 12 2023-02-16 17:27:41 0.0 /gbaseserver/critical_files/oncfg/gbaseserver.1 13 2023-02-16 17:27:41 0.1 /gbaseserver/critical_files/onconfig/gbaseserver.1 14 2023-02-16 17:27:41 0.0 /gbaseserver/critical_files/sqlhosts/gbaseserver.1 15 2023-02-16 17:32:57 0.2 /gbaseserver/rootdbs/1/gbaseserver.1 16 2023-02-16 17:32:57 0.1 /gbaseserver/datadbs1/1/gbaseserver.1 17 2023-02-16 17:32:58 0.1 /gbaseserver/llogdbs/1/gbaseserver.1 18 2023-02-16 17:32:58 0.1 /gbaseserver/datadbs5/1/gbaseserver.1 19 2023-02-16 17:32:58 0.1 /gbaseserver/datadbs3/1/gbaseserver.1 20 2023-02-16 17:32:58 0.1 /gbaseserver/datadbs2/1/gbaseserver.1 21 2023-02-16 17:32:58 0.1 /gbaseserver/datadbs4/1/gbaseserver.1 22 2023-02-16 17:32:58 0.1 /gbaseserver/plogdbs/1/gbaseserver.1 23 2023-02-16 17:32:58 0.1 /gbaseserver/sbspace1/1/gbaseserver.1 24 2023-02-16 17:32:59 0.1 /gbaseserver/101/11/gbaseserver.1 25 2023-02-16 17:33:00 0.0 /gbaseserver/critical_files/ixbar/gbaseserver.2 26 2023-02-16 17:33:00 0.0 /gbaseserver/critical_files/oncfg/gbaseserver.2 27 2023-02-16 17:33:00 0.1 /gbaseserver/critical_files/onconfig/gbaseserver.2 28 2023-02-16 17:33:00 0.0 /gbaseserver/critical_files/sqlhosts/gbaseserver.2 29 2023-02-16 17:35:26 0.2 /gbaseserver/rootdbs/1/gbaseserver.2 30 2023-02-16 17:35:27 0.1 /gbaseserver/datadbs4/1/gbaseserver.2 31 2023-02-16 17:35:28 0.1 /gbaseserver/datadbs5/1/gbaseserver.2 32 2023-02-16 17:35:28 0.1 /gbaseserver/plogdbs/1/gbaseserver.2 33 2023-02-16 17:35:28 0.1 /gbaseserver/datadbs2/1/gbaseserver.2 34 2023-02-16 17:35:28 0.1 /gbaseserver/datadbs3/1/gbaseserver.2 35 2023-02-16 17:35:28 0.1 /gbaseserver/llogdbs/1/gbaseserver.2 36 2023-02-16 17:35:28 0.1 /gbaseserver/sbspace1/1/gbaseserver.2 37 2023-02-16 17:35:28 0.1 /gbaseserver/datadbs1/1/gbaseserver.2 38 2023-02-16 17:35:29 0.1 /gbaseserver/101/12/gbaseserver.1 39 2023-02-16 17:35:29 0.0 /gbaseserver/critical_files/ixbar/gbaseserver.3 40 2023-02-16 17:35:29 0.0 /gbaseserver/critical_files/oncfg/gbaseserver.3 41 2023-02-16 17:35:29 0.1 /gbaseserver/critical_files/onconfig/gbaseserver.3 42 2023-02-16 17:35:29 0.0 /gbaseserver/critical_files/sqlhosts/gbaseserver.3 43 2023-02-16 17:38:46 0.1 /gbaseserver/rootdbs/2/gbaseserver.1 44 2023-02-16 17:38:47 0.1 /gbaseserver/datadbs4/2/gbaseserver.1 45 2023-02-16 17:38:47 0.1 /gbaseserver/datadbs2/2/gbaseserver.1 46 2023-02-16 17:38:47 0.1 /gbaseserver/datadbs5/2/gbaseserver.1 47 2023-02-16 17:38:48 0.1 /gbaseserver/datadbs3/2/gbaseserver.1 48 2023-02-16 17:38:49 0.1 /gbaseserver/llogdbs/2/gbaseserver.1 49 2023-02-16 17:38:49 0.1 /gbaseserver/plogdbs/2/gbaseserver.1 50 2023-02-16 17:38:49 0.1 /gbaseserver/sbspace1/2/gbaseserver.1 51 2023-02-16 17:38:49 0.1 /gbaseserver/datadbs1/2/gbaseserver.1 52 2023-02-16 17:38:50 0.1 /gbaseserver/101/13/gbaseserver.1 53 2023-02-16 17:38:50 0.0 /gbaseserver/critical_files/ixbar/gbaseserver.4 54 2023-02-16 17:38:50 0.0 /gbaseserver/critical_files/oncfg/gbaseserver.4 55 2023-02-16 17:38:50 0.1 /gbaseserver/critical_files/onconfig/gbaseserver.4 56 2023-02-16 17:38:50 0.0 /gbaseserver/critical_files/sqlhosts/gbaseserver.4 57 2023-02-16 17:50:44 0.0 /gbaseserver/101/14/gbaseserver.1 [gbasedbt@localhost gbaseserver_dbs]$
可以通过下面的命令,查看数据的最新备份情况。
[gbasedbt@localhost gbaseserver_dbs]$ onstat -g arc
Your evaluation license will expire on 2024-02-14 00:00:00
On-Line -- Up 01:23:21 -- 1135464 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.17:27 10 0x7da018
1 02/16/2023.17:35 12 0x6018
2 02/16/2023.17:38 13 0x9018
llogdbs 2 0 02/16/2023.17:27 10 0x7e1018
1 02/16/2023.17:35 12 0xd018
2 02/16/2023.17:38 13 0x12018
plogdbs 3 0 02/16/2023.17:27 10 0x7e1018
1 02/16/2023.17:35 12 0xd018
2 02/16/2023.17:38 13 0x12018
sbspace1 4 0 02/16/2023.17:27 10 0x7e3018
1 02/16/2023.17:35 12 0xd018
2 02/16/2023.17:38 13 0x14018
datadbs1 8 0 02/16/2023.17:27 10 0x7e1018
1 02/16/2023.17:35 12 0xd018
2 02/16/2023.17:38 13 0x12018
datadbs2 9 0 02/16/2023.17:27 10 0x7e1018
1 02/16/2023.17:35 12 0xd018
2 02/16/2023.17:38 13 0x10018
datadbs3 10 0 02/16/2023.17:27 10 0x7e1018
1 02/16/2023.17:35 12 0xd018
2 02/16/2023.17:38 13 0x12018
datadbs4 11 0 02/16/2023.17:27 10 0x7e1018
1 02/16/2023.17:35 12 0xa018
2 02/16/2023.17:38 13 0xd018
datadbs5 12 0 02/16/2023.17:27 10 0x7e1018
1 02/16/2023.17:35 12 0xa018
2 02/16/2023.17:38 13 0xd018
[gbasedbt@localhost gbaseserver_dbs]$
演示完全恢复(t18)
重启数据库,确定被删除的文件
在GBase 8s启动过程中,会因无法打开被删除的文件而报错。
Cannot open chunk '/opt/gbase/gbaseserver_dbs/datadbs1_1
根据报错中的信息,得到被删除的Chunk文件(datadbs1_1)。
[gbasedbt@localhost gbaseserver_dbs]$ onmode -ky
Your evaluation license will expire on 2024-02-14 00:00:00
[gbasedbt@localhost gbaseserver_dbs]$ oninit -vy
Your evaluation license will expire on 2024-02-14 00:00:00
Reading configuration file '/opt/gbase/etc/onconfig.gbaseserver'...succeeded
Creating /GBASEDBTTMP/.infxdirs...succeeded
Allocating and attaching to shared memory...succeeded
Creating resident pool 36470 kbytes...succeeded
Creating infos file "/opt/gbase/etc/.infos.gbaseserver"...succeeded
Linking conf file "/opt/gbase/etc/.conf.gbaseserver"...succeeded
Initializing rhead structure...rhlock_t 65536 (2048K)... rlock_t (26562K)... 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/gbaseserver_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@localhost gbaseserver_dbs]$
[gbasedbt@localhost ~]$ onstat -
Your evaluation license will expire on 2024-02-14 00:00:00
On-Line (CKPT INP) -- Up 00:04:59 -- 674664 Kbytes
Blocked:OVERRIDE_DOWN_SPACE
创建被删除的文件,并设置权限。
[gbasedbt@localhost gbaseserver_dbs]$ pwd
/opt/gbase/gbaseserver_dbs
[gbasedbt@localhost gbaseserver_dbs]$ ll
总用量 1433600
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 17:54 datadbs2_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 17:54 datadbs3_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 17:54 datadbs4_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 17:54 datadbs5_1
-rw-rw----. 1 gbasedbt gbasedbt 209715200 2月 16 17:54 llogdbs
-rw-rw----. 1 gbasedbt gbasedbt 209715200 2月 16 17:54 plogdbs
-rw-rw----. 1 gbasedbt gbasedbt 209715200 2月 16 17:54 rootdbs
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 17:54 sbspace1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 17:54 tmpdbs1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 17:54 tmpdbs2
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 17:54 tmpdbs3
[gbasedbt@localhost gbaseserver_dbs]$ touch datadbs1_1
[gbasedbt@localhost gbaseserver_dbs]$ ll
总用量 1433600
-rw-rw-r--. 1 gbasedbt gbasedbt 0 2月 16 17:55 datadbs1_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 17:54 datadbs2_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 17:54 datadbs3_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 17:54 datadbs4_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 17:54 datadbs5_1
-rw-rw----. 1 gbasedbt gbasedbt 209715200 2月 16 17:54 llogdbs
-rw-rw----. 1 gbasedbt gbasedbt 209715200 2月 16 17:54 plogdbs
-rw-rw----. 1 gbasedbt gbasedbt 209715200 2月 16 17:54 rootdbs
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 17:54 sbspace1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 17:54 tmpdbs1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 17:54 tmpdbs2
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 17:54 tmpdbs3
[gbasedbt@localhost gbaseserver_dbs]$ chmod o-r datadbs1_1
[gbasedbt@localhost gbaseserver_dbs]$ ll
总用量 1433600
-rw-rw----. 1 gbasedbt gbasedbt 0 2月 16 17:55 datadbs1_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 17:54 datadbs2_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 17:54 datadbs3_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 17:54 datadbs4_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 17:54 datadbs5_1
-rw-rw----. 1 gbasedbt gbasedbt 209715200 2月 16 17:54 llogdbs
-rw-rw----. 1 gbasedbt gbasedbt 209715200 2月 16 17:54 plogdbs
-rw-rw----. 1 gbasedbt gbasedbt 209715200 2月 16 17:54 rootdbs
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 17:54 sbspace1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 17:54 tmpdbs1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 17:54 tmpdbs2
-rw-rw----. 1 gbasedbt gbasedbt 104857600 2月 16 17:54 tmpdbs3
[gbasedbt@localhost gbaseserver_dbs]$
完全恢复
[gbasedbt@localhost ~]$ onstat -
Your evaluation license will expire on 2024-02-14 00:00:00
shared memory not initialized for GBASEDBTSERVER 'gbaseserver'
[gbasedbt@localhost ~]$ onbar -r
Your evaluation license will expire on 2024-02-14 00:00:00
Your evaluation license will expire on 2024-02-14 00:00:00
[gbasedbt@localhost ~]$ onstat -
Your evaluation license will expire on 2024-02-14 00:00:00
Quiescent -- Up 00:01:23 -- 1135464 Kbytes
[gbasedbt@localhost ~]$ onmode -m
Your evaluation license will expire on 2024-02-14 00:00:00
[gbasedbt@localhost ~]$ dbaccess - -
Your evaluation license will expire on 2024-02-14 00:00:00
> database mydb;
Database selected.
> 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.
> 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.
>
即使数据库空间的Chunk文件被删除,只要有备份,依然可以完全恢复,不丢失数据。
t_employee新增5条数据(19)
> 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');
1 row(s) inserted.
>
1 row(s) inserted.
>
1 row(s) inserted.
>
1 row(s) inserted.
> select * from t_employee;
1 row(s) inserted.
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 18:04:44
>
删除t_employee表(20)
为了演示方便,在删除表之前,记录一个时间,用于后续的不完全恢复时间点。
> !date +'%F %T'
2023-02-16 18:05:54
> drop table t_employee;
Table dropped.
> select * from t_employee;
206: The specified table (t_employee) is not in the database.
111: ISAM error: no record found.
Error in line 1
Near character position 24
> info tables;
Table name
t_dept
>
基于时间点的不完全恢复(t21)
根据上面测试时记录的时间点,进行不完全恢复。
[gbasedbt@localhost ~]$ onmode -ky Your evaluation license will expire on 2024-02-14 00:00:00 [gbasedbt@localhost ~]$ clear [gbasedbt@localhost ~]$ onmode -ky Your evaluation license will expire on 2024-02-14 00:00:00 shared memory not initialized for GBASEDBTSERVER 'gbaseserver' [gbasedbt@localhost ~]$ export GL_DATETIME="%iY-%m-%d %H:%M:%S" [gbasedbt@localhost ~]$ echo $GL_DATETIME %iY-%m-%d %H:%M:%S [gbasedbt@localhost ~]$ onbar -r -t '2023-02-16 18:04:44' Your evaluation license will expire on 2024-02-14 00:00:00 Your evaluation license will expire on 2024-02-14 00:00:00 Your evaluation license will expire on 2024-02-14 00:00:00 [gbasedbt@localhost ~]$ onmode -m Your evaluation license will expire on 2024-02-14 00:00:00 [gbasedbt@localhost ~]$
查看恢复结果。
[gbasedbt@localhost ~]$ echo "select * from t_employee" | dbaccess mydb
Your evaluation license will expire on 2024-02-14 00:00:00
Database selected.
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.
Database closed.
[gbasedbt@localhost ~]$ echo "select * from t_dept" | dbaccess mydb
Your evaluation license will expire on 2024-02-14 00:00:00
Database selected.
f_deptid f_deptname
1 dept_1
2 dept_2
3 dept_3
4 dept_4
5 dept_5
5 row(s) retrieved.
Database closed.
[gbasedbt@localhost ~]$
即使因为误操作删除了整个表,也依然可以通过不完全恢复,找回被删除的数据。
附录
数据库与表(t1)
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));
数据(t2)
insert into t_dept values(1, 'dept_1');
insert into t_dept values(2, 'dept_2');
insert into t_dept values(3, 'dept_3');
数据(t3)
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');
数据(t5)
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');
数据(t7)
insert into t_employee values(16, 3, 'employee_16');
数据(t9)
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');
数据(t11)
insert into t_dept values(4, 'dept_4');
数据(t12)
update t_employee set f_employeename = 'employee_updated' where f_employeeid = 11;
数据(t14)
delete from t_employee where f_employeeid = 14;
数据(t15)
drop table t_employee;
数据(t16)
insert into t_dept values(5, 'dept_5');
数据(t19)
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');
数据(t20)
drop table t_employee;