基于gbackuprestore的备份与恢复实验
- gbackuprestore体系架构
- 环境准备
- 实验说明
- 备份与恢复演示
- 创建数据库和表(t1)
- t_dept新增3条数据(t2)
- t_employee新增5条数据(t3)
- 系统进行L0备份(t4)
- t_employee新增5条数据(t5)
- 系统进行L1备份(t6)
- t_employee新增1条数据(t7)
- 系统进行L1备份(t8)
- t_employee新增5条数据(t9)
- 系统进行L2备份(t10)
- t_dept新增1条数据(t11)
- t_employee更新1条数据(t12)
- 切换逻辑日志(t13)
- t_employee删除1条数据(t14)
- 删除Chunk文件(t15)
- t_dept新增1条数据(t16)
- 备份逻辑日志(t17)
- 演示完全恢复(t18)
- t_employee新增5条数据(19)
- 删除t_employee表(20)
- 基于时间点的不完全恢复(t21)
- 附录
gbackuprestore体系架构
gbackuprestore 由各种组件组成,它需要与存储管理器一起使用,来备份和恢复数据。
gbackuprestore组件:
- sysutils 数据库,其中包含gbackuprestore目录表
- gbackuprestore 和 gbackuprestore_d 命令行实用程序
- 系统上存储管理器的 XBSA 共享库
- 用于存储备份的存储介质
- gbackuprestore活动日志
- gbackuprestore紧急引导文件
GBase 8s 的gbackuprestore支持第三方的存储管理器,进行数据库的备份与恢复。GBase 8s也内置了一个存储管理器PSM(Primary Storage Manager)。
对于备份会话,gbackuprestore 从数据库服务器请求存储空间和逻辑日志的内容,并将它们传递到存储管理器。存储管理器将数据存储在存储介质上。
对于恢复会话,gbackuprestore 从存储管理器请求已备份的数据,然后在数据库服务器上恢复该数据。
环境准备
配置存储管理器PSM的共享库
gbackuprestore 和存储管理器通过“备份服务应用程序编程接口 (XBSA)”通信,该接口支持将存储管理器作为数据库服务器的备份介质。
通过使用存储管理器的开放式系统接口,gbackuprestore 可以与各种同样使用 XBSA 的存储管理器一起协同工作。
GBase 8s 内置了一个存储管理器PSM,该存储管理器的接口库位置为/opt/gbase/lib/libbsapsm.so
语法
cd /opt/gbase/lib
pwd
ll
操作演示
[gbasedbt@devsvr ~]$ cd /opt/gbase/lib
[gbasedbt@devsvr lib]$ pwd
/opt/gbase/lib
[gbasedbt@devsvr lib]$ ll
total 38572
-rwxr-xr-x. 1 gbasedbt gbasedbt 8846 Mar 23 18:02 iosm11a.so
-rwxr-xr-x. 1 gbasedbt gbasedbt 326676 Mar 23 17:46 libAPI.jar
-rwxr-xr-x. 1 gbasedbt gbasedbt 174756 Mar 23 18:02 libastool.so
-rwxr-xr-x. 1 gbasedbt gbasedbt 14130 Mar 23 18:14 libbsanull.so
-r-xr-xr-x. 1 gbasedbt gbasedbt 1920732 Mar 23 18:14 libbsapsm.so
-rwxr-xr-x. 1 gbasedbt gbasedbt 11644279 Mar 23 18:13 libdwa.udr
-rwxr-xr-x. 1 gbasedbt gbasedbt 74921 Mar 23 17:46 libencrypt_f.so
-rwxr-xr-x. 1 gbasedbt gbasedbt 283227 Mar 23 18:02 libmisc.udr
-rwxr-xr-x. 1 gbasedbt gbasedbt 239980 Mar 23 17:46 libnativeAPI.so
-rwxr-xr-x. 1 gbasedbt gbasedbt 403608 Mar 23 18:02 liboracle.udr
-r-xr-xr-x. 1 gbasedbt gbasedbt 59340 Mar 23 18:20 libtxbsa.so
-rwxr-xr-x. 1 gbasedbt gbasedbt 24322266 Mar 23 18:04 libxml.udr
[gbasedbt@devsvr lib]$
保用gbackuprestore时,需要做一些简单的配置,配置参数如下:
参数 | 说明 |
---|---|
BAR_BSALIB_PATH | 指定 XBSA 库的位置 |
BAR_MAX_BACKUP | 最大并行进程数 |
LTAPEDEV | 逻辑日志备份目录 |
语法
gstat -c | grep BAR_BSALIB_PATH
gadmin -wf BAR_BSALIB_PATH=/opt/gbase/lib/libbsapsm.so
gstat -c | grep LTAPEDEV
gadmin -wf LTAPEDEV=/opt/gbase/backups
操作演示
[gbasedbt@devsvr ~]$ gstat -c | grep BAR_BSALIB_PATH
Your evaluation license will expire on 2022-07-30 00:00:00
# BAR_BSALIB_PATH - The shared library for gbackuprestore and the
BAR_BSALIB_PATH
[gbasedbt@devsvr ~]$ gadmin -wf BAR_BSALIB_PATH=/opt/gbase/lib/libbsapsm.so
Your evaluation license will expire on 2022-07-30 00:00:00
Value of BAR_BSALIB_PATH has been changed to /opt/gbase/lib/libbsapsm.so.
[gbasedbt@devsvr ~]$ gstat -c | grep BAR_BSALIB_PATH
Your evaluation license will expire on 2022-07-30 00:00:00
# BAR_BSALIB_PATH - The shared library for ON-Bar and the
BAR_BSALIB_PATH /opt/gbase/lib/libbsapsm.so
[gbasedbt@devsvr ~]$
[gbasedbt@devsvr ~]$ gadmin -wf LTAPEDEV=/opt/gbase/backups
Your evaluation license will expire on 2022-07-30 00:00:00
Value of LTAPEDEV has been changed to /opt/gbase/logpool.
[gbasedbt@devsvr ~]$ gstat -c | grep LTAPEDEV
Your evaluation license will expire on 2022-07-30 00:00:00
# LTAPEDEV - The tape device path for logical logs
LTAPEDEV /opt/gbase/backups
[gbasedbt@devsvr ~]$
说明:LTAPEDEV是ontape中的一个参数,在使用gbackuprestore时,该参数不能为/dev/null。我们可以临时为参数设置一个目录,实际备份时,逻辑日志并不保存在该目录中。
PSM配置
初始化Catalog
语法
ll /opt/gbase/etc/psm
gpsm -C init
操作演示
[gbasedbt@devsvr ~]$ ll /opt/gbase/etc/psm
ls: cannot access /opt/gbase/etc/psm: No such file or directory
[gbasedbt@devsvr ~]$ gpsm -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@devsvr ~]$ ll /opt/gbase/etc/psm
total 60
-rw-rw-r--. 1 gbasedbt gbasedbt 1024 Jul 30 10:14 device.dat
-rw-rw-r--. 1 gbasedbt gbasedbt 5120 Jul 30 10:14 device.idx
-rw-rw-r--. 1 gbasedbt gbasedbt 1024 Jul 30 10:14 lock.dat
-rw-rw-r--. 1 gbasedbt gbasedbt 2048 Jul 30 10:14 lock.idx
-rw-rw-r--. 1 gbasedbt gbasedbt 0 Jul 30 10:14 object.dat
-rw-rw-r--. 1 gbasedbt gbasedbt 0 Jul 30 10:14 object_detail.dat
-rw-rw-r--. 1 gbasedbt gbasedbt 3072 Jul 30 10:14 object_detail.idx
-rw-rw-r--. 1 gbasedbt gbasedbt 4096 Jul 30 10:14 object.idx
-rw-rw-r--. 1 gbasedbt gbasedbt 0 Jul 30 10:14 pool.dat
-rw-rw-r--. 1 gbasedbt gbasedbt 4096 Jul 30 10:14 pool.idx
-rw-rw-r--. 1 gbasedbt gbasedbt 1024 Jul 30 10:14 serial.dat
-rw-rw-r--. 1 gbasedbt gbasedbt 2048 Jul 30 10:14 serial.idx
-rw-rw-r--. 1 gbasedbt gbasedbt 1024 Jul 30 10:14 session.dat
-rw-rw-r--. 1 gbasedbt gbasedbt 3072 Jul 30 10:14 session.idx
-rw-rw-r--. 1 gbasedbt gbasedbt 1024 Jul 30 10:14 volume.dat
-rw-rw-r--. 1 gbasedbt gbasedbt 5120 Jul 30 10:14 volume.idx
[gbasedbt@devsvr ~]$
查看PSM设备情况
语法
gpsm -D list
操作演示
[gbasedbt@devsvr ~]$ gpsm -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@devsvr ~]$
配置PSM设备
我们不使用默认的PSM设备,使用下面的方法,添加一个自己的设备,并将原来的设备删除。
语法
mkdir -p /opt/gbase/dbspool
mkdir -p /opt/gbase/logpool
gpsm -D add /opt/gbase/dbspool -g DBSPOOL -p HIGHEST -t FILE
gpsm -D add /opt/gbase/logpool -g LOGPOOL -p HIGHEST -t FILE
gpsm -D del /opt/gbase/backups -d
gpsm -D list
ll /opt/gbase/dbspool
ll /opt/gbase/logpool
操作演示
[gbasedbt@devsvr ~]$ mkdir -p /opt/gbase/dbspool
[gbasedbt@devsvr ~]$ mkdir -p /opt/gbase/logpool
[gbasedbt@devsvr ~]$ gpsm -D add /opt/gbase/dbspool -g DBSPOOL -p HIGHEST -t FILE
[gbasedbt@devsvr ~]$ gpsm -D add /opt/gbase/logpool -g LOGPOOL -p HIGHEST -t FILE
[gbasedbt@devsvr ~]$ gpsm -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@devsvr ~]$ gpsm -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@devsvr ~]$ ll /opt/gbase/dbspool
total 0
[gbasedbt@devsvr ~]$ ll /opt/gbase/logpool
total 0
[gbasedbt@devsvr ~]$
实验说明
业务场景说明:
- 数据空间文件被删除时的数据完全恢复
- 表删除后基于时间点的不完全恢复
时间 | 业务 | 说明 |
---|---|---|
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)
语法
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));
操作演示
[gbasedbt@devsvr ~]$ dbaccess - -
Your evaluation license will expire on 2022-07-30 00:00:00
create database mydb in datadbs1 with log;
create table t_dept(f_deptid int, f_deptname varchar(20));
Database created.
>
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');
查询结果
> select * from t_dept;
f_deptid f_deptname
1 dept_1
2 dept_2
3 dept_3
3 row(s) retrieved.
> !date +'%F %T'
2021-07-30 16:23:56
>
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');
查询结果
> 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'
2021-07-30 16:25:04
>
系统进行L0备份(t4)
查看当前的日志,文件编号为11,唯一编号为14
语法
gstat -l
gstat -c | grep SERVERNUM
gbackuprestore -b -L 0
操作演示
[gbasedbt@devsvr ~]$ gstat -l
Your evaluation license will expire on 2022-07-30 00:00:00
On-Line -- Up 01:49:56 -- 597864 Kbytes
Physical Logging
Buffer bufused bufsize numpages numwrits pages/io
P-1 0 1024 1437 35 41.06
phybegin physize phypos phyused %used
3:53 49700 1658 0 0.00
Logical Logging
Buffer bufused bufsize numrecs numpages numwrits recs/pages pages/io
L-1 0 512 81371 6212 279 13.1 22.3
Subsystem numrecs Log Space used
OLDRSAM 81228 12075268
HA 38 1672
DDL 105 36540
address number flags uniqid begin size used %used
4713df88 4 U-B---- 7 2:53 5000 4023 80.46
48309970 5 U-B---- 8 2:5053 5000 29 0.58
483099d8 6 U-B---- 9 2:10053 5000 34 0.68
48309a40 7 U-B---- 10 2:15053 5000 27 0.54
48309aa8 8 U-B---- 11 2:20053 5000 41 0.82
48309b10 9 U-B---- 12 2:25053 5000 30 0.60
48309b78 10 U-B---- 13 2:30053 5000 36 0.72
48309be0 11 U---C-L 14 2:35053 5000 2005 40.10
48309c48 12 A------ 0 2:40053 5000 0 0.00
48309cb0 13 A------ 0 2:45053 5000 0 0.00
10 active, 10 total
[gbasedbt@devsvr ~]$
查看实例的服务器编号为165
[gbasedbt@devsvr ~]$ gstat -c | grep SERVERNUM
Your evaluation license will expire on 2022-07-30 00:00:00
# SERVERNUM - The unique ID for the GBase instance. Acceptable
SERVERNUM 165
[gbasedbt@devsvr ~]$
执行L0备份。
[gbasedbt@devsvr ~]$ gbackuprestore -b -L 0
Your evaluation license will expire on 2022-07-30 00:00:00
[gbasedbt@devsvr ~]$ gpsm -O list
__PSM__ Object List
Object ID Date Created Size (MB) Logical path (name.version)
1 2021-07-30 16:26:30 15.9 /gbaseserver/rootdbs/0/gbaseserver.1
2 2021-07-30 16:26:31 18.1 /gbaseserver/datadbs1/0/gbaseserver.1
3 2021-07-30 16:26:32 0.1 /gbaseserver/plogdbs/0/gbaseserver.1
4 2021-07-30 16:26:32 0.1 /gbaseserver/datadbs5/0/gbaseserver.1
5 2021-07-30 16:26:32 0.1 /gbaseserver/datadbs3/0/gbaseserver.1
6 2021-07-30 16:26:32 0.1 /gbaseserver/datadbs2/0/gbaseserver.1
7 2021-07-30 16:26:32 0.1 /gbaseserver/sbspace1/0/gbaseserver.1
8 2021-07-30 16:26:33 0.1 /gbaseserver/llogdbs/0/gbaseserver.1
9 2021-07-30 16:26:33 0.1 /gbaseserver/datadbs4/0/gbaseserver.1
10 2021-07-30 16:26:33 4.0 /gbaseserver/165/14/gbaseserver.1
11 2021-07-30 16:26:34 0.0 /gbaseserver/critical_files/ixbar/gbaseserver.1
12 2021-07-30 16:26:34 0.0 /gbaseserver/critical_files/oncfg/gbaseserver.1
13 2021-07-30 16:26:34 0.1 /gbaseserver/critical_files/onconfig/gbaseserver.1
14 2021-07-30 16:26:34 0.0 /gbaseserver/critical_files/sqlhosts/gbaseserver.1
[gbasedbt@devsvr ~]$
L0备份了rootdbs,plogdbs,llogdbs,datadbs,ixbar,oncfg,onconfig,sqlhosts。另外还有一个目录/gbaseserver/165/10/gbaseserver.1,其中的165为实例的服务器编号,14为当前逻辑日志的唯一编号(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');
查询结果
> 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'
2021-07-30 16:28:01
>
系统进行L1备份(t6)
语法
gbackuprestore -b -L 1
操作演示
[gbasedbt@devsvr ~]$ gbackuprestore -b -L 1
Your evaluation license will expire on 2022-07-30 00:00:00
[gbasedbt@devsvr ~]$ gpsm -O list
__PSM__ Object List
Object ID Date Created Size (MB) Logical path (name.version)
1 2021-07-30 16:26:30 15.9 /gbaseserver/rootdbs/0/gbaseserver.1
2 2021-07-30 16:26:31 18.1 /gbaseserver/datadbs1/0/gbaseserver.1
3 2021-07-30 16:26:32 0.1 /gbaseserver/plogdbs/0/gbaseserver.1
4 2021-07-30 16:26:32 0.1 /gbaseserver/datadbs5/0/gbaseserver.1
5 2021-07-30 16:26:32 0.1 /gbaseserver/datadbs3/0/gbaseserver.1
6 2021-07-30 16:26:32 0.1 /gbaseserver/datadbs2/0/gbaseserver.1
7 2021-07-30 16:26:32 0.1 /gbaseserver/sbspace1/0/gbaseserver.1
8 2021-07-30 16:26:33 0.1 /gbaseserver/llogdbs/0/gbaseserver.1
9 2021-07-30 16:26:33 0.1 /gbaseserver/datadbs4/0/gbaseserver.1
10 2021-07-30 16:26:33 4.0 /gbaseserver/165/14/gbaseserver.1
11 2021-07-30 16:26:34 0.0 /gbaseserver/critical_files/ixbar/gbaseserver.1
12 2021-07-30 16:26:34 0.0 /gbaseserver/critical_files/oncfg/gbaseserver.1
13 2021-07-30 16:26:34 0.1 /gbaseserver/critical_files/onconfig/gbaseserver.1
14 2021-07-30 16:26:34 0.0 /gbaseserver/critical_files/sqlhosts/gbaseserver.1
15 2021-07-30 16:28:44 0.1 /gbaseserver/rootdbs/1/gbaseserver.1
16 2021-07-30 16:28:45 0.1 /gbaseserver/datadbs1/1/gbaseserver.1
17 2021-07-30 16:28:45 0.1 /gbaseserver/datadbs3/1/gbaseserver.1
18 2021-07-30 16:28:45 0.1 /gbaseserver/datadbs4/1/gbaseserver.1
19 2021-07-30 16:28:46 0.1 /gbaseserver/sbspace1/1/gbaseserver.1
20 2021-07-30 16:28:46 0.1 /gbaseserver/llogdbs/1/gbaseserver.1
21 2021-07-30 16:28:46 0.1 /gbaseserver/datadbs2/1/gbaseserver.1
22 2021-07-30 16:28:46 0.1 /gbaseserver/datadbs5/1/gbaseserver.1
23 2021-07-30 16:28:46 0.1 /gbaseserver/plogdbs/1/gbaseserver.1
24 2021-07-30 16:28:48 0.1 /gbaseserver/165/15/gbaseserver.1
25 2021-07-30 16:28:48 0.0 /gbaseserver/critical_files/ixbar/gbaseserver.2
26 2021-07-30 16:28:48 0.0 /gbaseserver/critical_files/oncfg/gbaseserver.2
27 2021-07-30 16:28:48 0.1 /gbaseserver/critical_files/onconfig/gbaseserver.2
28 2021-07-30 16:28:48 0.0 /gbaseserver/critical_files/sqlhosts/gbaseserver.2
[gbasedbt@devsvr ~]$
进行L1备份后,备份文件数量由14个变为28个。
t_employee新增1条数据(t7)
语法
insert into t_employee values(16, 3, 'employee_16');
查看数据
> 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'
2021-07-30 16:29:43
>
系统进行L1备份(t8)
语法
gbackuprestore -b -L 1
操作演示
[gbasedbt@devsvr ~]$ gbackuprestore -b -L 1
Your evaluation license will expire on 2022-07-30 00:00:00
[gbasedbt@devsvr ~]$ gpsm -O list
__PSM__ Object List
Object ID Date Created Size (MB) Logical path (name.version)
1 2021-07-30 16:26:30 15.9 /gbaseserver/rootdbs/0/gbaseserver.1
2 2021-07-30 16:26:31 18.1 /gbaseserver/datadbs1/0/gbaseserver.1
3 2021-07-30 16:26:32 0.1 /gbaseserver/plogdbs/0/gbaseserver.1
4 2021-07-30 16:26:32 0.1 /gbaseserver/datadbs5/0/gbaseserver.1
5 2021-07-30 16:26:32 0.1 /gbaseserver/datadbs3/0/gbaseserver.1
6 2021-07-30 16:26:32 0.1 /gbaseserver/datadbs2/0/gbaseserver.1
7 2021-07-30 16:26:32 0.1 /gbaseserver/sbspace1/0/gbaseserver.1
8 2021-07-30 16:26:33 0.1 /gbaseserver/llogdbs/0/gbaseserver.1
9 2021-07-30 16:26:33 0.1 /gbaseserver/datadbs4/0/gbaseserver.1
10 2021-07-30 16:26:33 4.0 /gbaseserver/165/14/gbaseserver.1
11 2021-07-30 16:26:34 0.0 /gbaseserver/critical_files/ixbar/gbaseserver.1
12 2021-07-30 16:26:34 0.0 /gbaseserver/critical_files/oncfg/gbaseserver.1
13 2021-07-30 16:26:34 0.1 /gbaseserver/critical_files/onconfig/gbaseserver.1
14 2021-07-30 16:26:34 0.0 /gbaseserver/critical_files/sqlhosts/gbaseserver.1
15 2021-07-30 16:28:44 0.1 /gbaseserver/rootdbs/1/gbaseserver.1
16 2021-07-30 16:28:45 0.1 /gbaseserver/datadbs1/1/gbaseserver.1
17 2021-07-30 16:28:45 0.1 /gbaseserver/datadbs3/1/gbaseserver.1
18 2021-07-30 16:28:45 0.1 /gbaseserver/datadbs4/1/gbaseserver.1
19 2021-07-30 16:28:46 0.1 /gbaseserver/sbspace1/1/gbaseserver.1
20 2021-07-30 16:28:46 0.1 /gbaseserver/llogdbs/1/gbaseserver.1
21 2021-07-30 16:28:46 0.1 /gbaseserver/datadbs2/1/gbaseserver.1
22 2021-07-30 16:28:46 0.1 /gbaseserver/datadbs5/1/gbaseserver.1
23 2021-07-30 16:28:46 0.1 /gbaseserver/plogdbs/1/gbaseserver.1
24 2021-07-30 16:28:48 0.1 /gbaseserver/165/15/gbaseserver.1
25 2021-07-30 16:28:48 0.0 /gbaseserver/critical_files/ixbar/gbaseserver.2
26 2021-07-30 16:28:48 0.0 /gbaseserver/critical_files/oncfg/gbaseserver.2
27 2021-07-30 16:28:48 0.1 /gbaseserver/critical_files/onconfig/gbaseserver.2
28 2021-07-30 16:28:48 0.0 /gbaseserver/critical_files/sqlhosts/gbaseserver.2
29 2021-07-30 16:30:17 0.1 /gbaseserver/rootdbs/1/gbaseserver.2
30 2021-07-30 16:30:18 0.1 /gbaseserver/sbspace1/1/gbaseserver.2
31 2021-07-30 16:30:19 0.1 /gbaseserver/datadbs2/1/gbaseserver.2
32 2021-07-30 16:30:19 0.1 /gbaseserver/datadbs4/1/gbaseserver.2
33 2021-07-30 16:30:19 0.1 /gbaseserver/plogdbs/1/gbaseserver.2
34 2021-07-30 16:30:19 0.1 /gbaseserver/datadbs3/1/gbaseserver.2
35 2021-07-30 16:30:19 0.1 /gbaseserver/datadbs5/1/gbaseserver.2
36 2021-07-30 16:30:19 0.1 /gbaseserver/datadbs1/1/gbaseserver.2
37 2021-07-30 16:30:20 0.1 /gbaseserver/llogdbs/1/gbaseserver.2
38 2021-07-30 16:30:21 0.1 /gbaseserver/165/16/gbaseserver.1
39 2021-07-30 16:30:21 0.0 /gbaseserver/critical_files/ixbar/gbaseserver.3
40 2021-07-30 16:30:21 0.0 /gbaseserver/critical_files/oncfg/gbaseserver.3
41 2021-07-30 16:30:21 0.1 /gbaseserver/critical_files/onconfig/gbaseserver.3
42 2021-07-30 16:30:21 0.0 /gbaseserver/critical_files/sqlhosts/gbaseserver.3
[gbasedbt@devsvr ~]$
进行两次L1备份后,备份文件变为42个。通过观察,gbackuprestore备份时,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');
操作演示
> 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'
2021-07-30 16:31:30
>
系统进行L2备份(t10)
语法
gbackuprestore -b -L 2
操作演示
[gbasedbt@devsvr ~]$ gbackuprestore -b -L 2
Your evaluation license will expire on 2022-07-30 00:00:00
[gbasedbt@devsvr ~]$ gpsm -O list
__PSM__ Object List
Object ID Date Created Size (MB) Logical path (name.version)
1 2021-07-30 16:26:30 15.9 /gbaseserver/rootdbs/0/gbaseserver.1
2 2021-07-30 16:26:31 18.1 /gbaseserver/datadbs1/0/gbaseserver.1
3 2021-07-30 16:26:32 0.1 /gbaseserver/plogdbs/0/gbaseserver.1
4 2021-07-30 16:26:32 0.1 /gbaseserver/datadbs5/0/gbaseserver.1
5 2021-07-30 16:26:32 0.1 /gbaseserver/datadbs3/0/gbaseserver.1
6 2021-07-30 16:26:32 0.1 /gbaseserver/datadbs2/0/gbaseserver.1
7 2021-07-30 16:26:32 0.1 /gbaseserver/sbspace1/0/gbaseserver.1
8 2021-07-30 16:26:33 0.1 /gbaseserver/llogdbs/0/gbaseserver.1
9 2021-07-30 16:26:33 0.1 /gbaseserver/datadbs4/0/gbaseserver.1
10 2021-07-30 16:26:33 4.0 /gbaseserver/165/14/gbaseserver.1
11 2021-07-30 16:26:34 0.0 /gbaseserver/critical_files/ixbar/gbaseserver.1
12 2021-07-30 16:26:34 0.0 /gbaseserver/critical_files/oncfg/gbaseserver.1
13 2021-07-30 16:26:34 0.1 /gbaseserver/critical_files/onconfig/gbaseserver.1
14 2021-07-30 16:26:34 0.0 /gbaseserver/critical_files/sqlhosts/gbaseserver.1
15 2021-07-30 16:28:44 0.1 /gbaseserver/rootdbs/1/gbaseserver.1
16 2021-07-30 16:28:45 0.1 /gbaseserver/datadbs1/1/gbaseserver.1
17 2021-07-30 16:28:45 0.1 /gbaseserver/datadbs3/1/gbaseserver.1
18 2021-07-30 16:28:45 0.1 /gbaseserver/datadbs4/1/gbaseserver.1
19 2021-07-30 16:28:46 0.1 /gbaseserver/sbspace1/1/gbaseserver.1
20 2021-07-30 16:28:46 0.1 /gbaseserver/llogdbs/1/gbaseserver.1
21 2021-07-30 16:28:46 0.1 /gbaseserver/datadbs2/1/gbaseserver.1
22 2021-07-30 16:28:46 0.1 /gbaseserver/datadbs5/1/gbaseserver.1
23 2021-07-30 16:28:46 0.1 /gbaseserver/plogdbs/1/gbaseserver.1
24 2021-07-30 16:28:48 0.1 /gbaseserver/165/15/gbaseserver.1
25 2021-07-30 16:28:48 0.0 /gbaseserver/critical_files/ixbar/gbaseserver.2
26 2021-07-30 16:28:48 0.0 /gbaseserver/critical_files/oncfg/gbaseserver.2
27 2021-07-30 16:28:48 0.1 /gbaseserver/critical_files/onconfig/gbaseserver.2
28 2021-07-30 16:28:48 0.0 /gbaseserver/critical_files/sqlhosts/gbaseserver.2
29 2021-07-30 16:30:17 0.1 /gbaseserver/rootdbs/1/gbaseserver.2
30 2021-07-30 16:30:18 0.1 /gbaseserver/sbspace1/1/gbaseserver.2
31 2021-07-30 16:30:19 0.1 /gbaseserver/datadbs2/1/gbaseserver.2
32 2021-07-30 16:30:19 0.1 /gbaseserver/datadbs4/1/gbaseserver.2
33 2021-07-30 16:30:19 0.1 /gbaseserver/plogdbs/1/gbaseserver.2
34 2021-07-30 16:30:19 0.1 /gbaseserver/datadbs3/1/gbaseserver.2
35 2021-07-30 16:30:19 0.1 /gbaseserver/datadbs5/1/gbaseserver.2
36 2021-07-30 16:30:19 0.1 /gbaseserver/datadbs1/1/gbaseserver.2
37 2021-07-30 16:30:20 0.1 /gbaseserver/llogdbs/1/gbaseserver.2
38 2021-07-30 16:30:21 0.1 /gbaseserver/165/16/gbaseserver.1
39 2021-07-30 16:30:21 0.0 /gbaseserver/critical_files/ixbar/gbaseserver.3
40 2021-07-30 16:30:21 0.0 /gbaseserver/critical_files/oncfg/gbaseserver.3
41 2021-07-30 16:30:21 0.1 /gbaseserver/critical_files/onconfig/gbaseserver.3
42 2021-07-30 16:30:21 0.0 /gbaseserver/critical_files/sqlhosts/gbaseserver.3
43 2021-07-30 16:32:07 0.2 /gbaseserver/rootdbs/2/gbaseserver.1
44 2021-07-30 16:32:08 0.1 /gbaseserver/datadbs1/2/gbaseserver.1
45 2021-07-30 16:32:09 0.1 /gbaseserver/datadbs2/2/gbaseserver.1
46 2021-07-30 16:32:09 0.1 /gbaseserver/datadbs4/2/gbaseserver.1
47 2021-07-30 16:32:09 0.1 /gbaseserver/datadbs5/2/gbaseserver.1
48 2021-07-30 16:32:09 0.1 /gbaseserver/sbspace1/2/gbaseserver.1
49 2021-07-30 16:32:09 0.1 /gbaseserver/datadbs3/2/gbaseserver.1
50 2021-07-30 16:32:09 0.1 /gbaseserver/llogdbs/2/gbaseserver.1
51 2021-07-30 16:32:10 0.1 /gbaseserver/plogdbs/2/gbaseserver.1
52 2021-07-30 16:32:10 0.1 /gbaseserver/165/17/gbaseserver.1
53 2021-07-30 16:32:10 0.0 /gbaseserver/critical_files/ixbar/gbaseserver.4
54 2021-07-30 16:32:10 0.0 /gbaseserver/critical_files/oncfg/gbaseserver.4
55 2021-07-30 16:32:10 0.1 /gbaseserver/critical_files/onconfig/gbaseserver.4
56 2021-07-30 16:32:10 0.0 /gbaseserver/critical_files/sqlhosts/gbaseserver.4
[gbasedbt@devsvr ~]$
备份完成后,查看当前的逻辑日志唯一编号为18。
语法
gstat -l
操作演示
[gbasedbt@devsvr ~]$ gstat -l
Your evaluation license will expire on 2022-07-30 00:00:00
On-Line -- Up 01:57:31 -- 597864 Kbytes
Physical Logging
Buffer bufused bufsize numpages numwrits pages/io
P-1 22 1024 1678 42 39.95
phybegin physize phypos phyused %used
3:53 49700 1899 22 0.04
Logical Logging
Buffer bufused bufsize numrecs numpages numwrits recs/pages pages/io
L-1 0 512 82057 6331 396 13.0 16.0
Subsystem numrecs Log Space used
OLDRSAM 81903 12130408
HA 49 2156
DDL 105 36540
address number flags uniqid begin size used %used
4713df88 4 U-B---L 17 2:53 5000 33 0.66
48309970 5 U---C-- 18 2:5053 5000 2 0.04
483099d8 6 U-B---- 9 2:10053 5000 34 0.68
48309a40 7 U-B---- 10 2:15053 5000 27 0.54
48309aa8 8 U-B---- 11 2:20053 5000 41 0.82
48309b10 9 U-B---- 12 2:25053 5000 30 0.60
48309b78 10 U-B---- 13 2:30053 5000 36 0.72
48309be0 11 U-B---- 14 2:35053 5000 2029 40.58
48309c48 12 U-B---- 15 2:40053 5000 34 0.68
48309cb0 13 U-B---- 16 2:45053 5000 26 0.52
10 active, 10 total
[gbasedbt@devsvr ~]$
t_dept新增1条数据(t11)
语法
insert into t_dept values(4, 'dept_4');
操作演示
> 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'
2021-07-30 16:34:21
>
t_employee更新1条数据(t12)
语法
update t_employee set f_employeename = 'employee_updated' where f_employeeid = 11;
操作演示
> 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'
2021-07-30 16:35:08
>
切换逻辑日志(t13)
语法
gstat -l
gadmin -l
操作演示
[gbasedbt@devsvr ~]$ gstat -l
Your evaluation license will expire on 2022-07-30 00:00:00
On-Line -- Up 02:00:25 -- 597864 Kbytes
Physical Logging
Buffer bufused bufsize numpages numwrits pages/io
P-1 15 1024 1731 44 39.34
phybegin physize phypos phyused %used
3:53 49700 1952 30 0.06
Logical Logging
Buffer bufused bufsize numrecs numpages numwrits recs/pages pages/io
L-2 0 512 82067 6335 400 13.0 15.8
Subsystem numrecs Log Space used
OLDRSAM 81912 12130972
HA 50 2200
DDL 105 36540
address number flags uniqid begin size used %used
4713df88 4 U-B---- 17 2:53 5000 33 0.66
48309970 5 U---C-L 18 2:5053 5000 6 0.12
483099d8 6 U-B---- 9 2:10053 5000 34 0.68
48309a40 7 U-B---- 10 2:15053 5000 27 0.54
48309aa8 8 U-B---- 11 2:20053 5000 41 0.82
48309b10 9 U-B---- 12 2:25053 5000 30 0.60
48309b78 10 U-B---- 13 2:30053 5000 36 0.72
48309be0 11 U-B---- 14 2:35053 5000 2029 40.58
48309c48 12 U-B---- 15 2:40053 5000 34 0.68
48309cb0 13 U-B---- 16 2:45053 5000 26 0.52
10 active, 10 total
[gbasedbt@devsvr ~]$ gadmin -l
Your evaluation license will expire on 2022-07-30 00:00:00
[gbasedbt@devsvr ~]$ gstat -l
Your evaluation license will expire on 2022-07-30 00:00:00
On-Line -- Up 02:00:33 -- 597864 Kbytes
Physical Logging
Buffer bufused bufsize numpages numwrits pages/io
P-1 15 1024 1731 44 39.34
phybegin physize phypos phyused %used
3:53 49700 1952 30 0.06
Logical Logging
Buffer bufused bufsize numrecs numpages numwrits recs/pages pages/io
L-3 0 512 82067 6335 400 13.0 15.8
Subsystem numrecs Log Space used
OLDRSAM 81912 12130972
HA 50 2200
DDL 105 36540
address number flags uniqid begin size used %used
4713df88 4 U-B---- 17 2:53 5000 33 0.66
48309970 5 U-----L 18 2:5053 5000 7 0.14
483099d8 6 U---C-- 19 2:10053 5000 0 0.00
48309a40 7 U-B---- 10 2:15053 5000 27 0.54
48309aa8 8 U-B---- 11 2:20053 5000 41 0.82
48309b10 9 U-B---- 12 2:25053 5000 30 0.60
48309b78 10 U-B---- 13 2:30053 5000 36 0.72
48309be0 11 U-B---- 14 2:35053 5000 2029 40.58
48309c48 12 U-B---- 15 2:40053 5000 34 0.68
48309cb0 13 U-B---- 16 2:45053 5000 26 0.52
10 active, 10 total
[gbasedbt@devsvr ~]$
切换逻辑日志后,当前逻辑日志唯一编号由18变为19。
t_employee删除1条数据(t14)
语法
delete from t_employee where f_employeeid = 14;
操作演示
> 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'
2021-07-30 16:38:10
>
删除Chunk文件(t15)
语法
cd /opt/gbase/gbaseserver_dbs/
rm -rf datadbs1_1
操作演示
[gbasedbt@devsvr ~]$ cd /opt/gbase/gbaseserver_dbs/
[gbasedbt@devsvr gbaseserver_dbs]$ pwd
/opt/gbase/gbaseserver_dbs
[gbasedbt@devsvr gbaseserver_dbs]$ ll
total 1331200
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:38 datadbs1_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 14:35 datadbs2_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 14:35 datadbs3_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 14:35 datadbs4_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 14:35 datadbs5_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:38 llogdbs
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:38 plogdbs
-rw-rw----. 1 gbasedbt gbasedbt 209715200 Jul 30 16:38 rootdbs
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 14:35 sbspace1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:34 tmpdbs1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:34 tmpdbs2
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:34 tmpdbs3
[gbasedbt@devsvr gbaseserver_dbs]$ rm -rf datadbs1_1
[gbasedbt@devsvr gbaseserver_dbs]$ ll
total 1228800
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 14:35 datadbs2_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 14:35 datadbs3_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 14:35 datadbs4_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 14:35 datadbs5_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:38 llogdbs
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:38 plogdbs
-rw-rw----. 1 gbasedbt gbasedbt 209715200 Jul 30 16:38 rootdbs
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 14:35 sbspace1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:34 tmpdbs1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:34 tmpdbs2
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:34 tmpdbs3
[gbasedbt@devsvr gbaseserver_dbs]$
t_dept新增1条数据(t16)
语法
insert into t_dept values(5, 'dept_5');
操作演示
> 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'
2021-07-30 16:40:39
>
即使在保存数据的Chunk文件被删除,最近的事务仍然可以执行成功。
备份逻辑日志(t17)
语法
gbackuprestore -b -l
gstat -g arc
操作演示
[gbasedbt@devsvr ~]$ gbackuprestore -b -l
Your evaluation license will expire on 2022-07-30 00:00:00
[gbasedbt@devsvr ~]$ gpsm -O list
__PSM__ Object List
Object ID Date Created Size (MB) Logical path (name.version)
1 2021-07-30 16:26:30 15.9 /gbaseserver/rootdbs/0/gbaseserver.1
2 2021-07-30 16:26:31 18.1 /gbaseserver/datadbs1/0/gbaseserver.1
3 2021-07-30 16:26:32 0.1 /gbaseserver/plogdbs/0/gbaseserver.1
4 2021-07-30 16:26:32 0.1 /gbaseserver/datadbs5/0/gbaseserver.1
5 2021-07-30 16:26:32 0.1 /gbaseserver/datadbs3/0/gbaseserver.1
6 2021-07-30 16:26:32 0.1 /gbaseserver/datadbs2/0/gbaseserver.1
7 2021-07-30 16:26:32 0.1 /gbaseserver/sbspace1/0/gbaseserver.1
8 2021-07-30 16:26:33 0.1 /gbaseserver/llogdbs/0/gbaseserver.1
9 2021-07-30 16:26:33 0.1 /gbaseserver/datadbs4/0/gbaseserver.1
10 2021-07-30 16:26:33 4.0 /gbaseserver/165/14/gbaseserver.1
11 2021-07-30 16:26:34 0.0 /gbaseserver/critical_files/ixbar/gbaseserver.1
12 2021-07-30 16:26:34 0.0 /gbaseserver/critical_files/oncfg/gbaseserver.1
13 2021-07-30 16:26:34 0.1 /gbaseserver/critical_files/onconfig/gbaseserver.1
14 2021-07-30 16:26:34 0.0 /gbaseserver/critical_files/sqlhosts/gbaseserver.1
15 2021-07-30 16:28:44 0.1 /gbaseserver/rootdbs/1/gbaseserver.1
16 2021-07-30 16:28:45 0.1 /gbaseserver/datadbs1/1/gbaseserver.1
17 2021-07-30 16:28:45 0.1 /gbaseserver/datadbs3/1/gbaseserver.1
18 2021-07-30 16:28:45 0.1 /gbaseserver/datadbs4/1/gbaseserver.1
19 2021-07-30 16:28:46 0.1 /gbaseserver/sbspace1/1/gbaseserver.1
20 2021-07-30 16:28:46 0.1 /gbaseserver/llogdbs/1/gbaseserver.1
21 2021-07-30 16:28:46 0.1 /gbaseserver/datadbs2/1/gbaseserver.1
22 2021-07-30 16:28:46 0.1 /gbaseserver/datadbs5/1/gbaseserver.1
23 2021-07-30 16:28:46 0.1 /gbaseserver/plogdbs/1/gbaseserver.1
24 2021-07-30 16:28:48 0.1 /gbaseserver/165/15/gbaseserver.1
25 2021-07-30 16:28:48 0.0 /gbaseserver/critical_files/ixbar/gbaseserver.2
26 2021-07-30 16:28:48 0.0 /gbaseserver/critical_files/oncfg/gbaseserver.2
27 2021-07-30 16:28:48 0.1 /gbaseserver/critical_files/onconfig/gbaseserver.2
28 2021-07-30 16:28:48 0.0 /gbaseserver/critical_files/sqlhosts/gbaseserver.2
29 2021-07-30 16:30:17 0.1 /gbaseserver/rootdbs/1/gbaseserver.2
30 2021-07-30 16:30:18 0.1 /gbaseserver/sbspace1/1/gbaseserver.2
31 2021-07-30 16:30:19 0.1 /gbaseserver/datadbs2/1/gbaseserver.2
32 2021-07-30 16:30:19 0.1 /gbaseserver/datadbs4/1/gbaseserver.2
33 2021-07-30 16:30:19 0.1 /gbaseserver/plogdbs/1/gbaseserver.2
34 2021-07-30 16:30:19 0.1 /gbaseserver/datadbs3/1/gbaseserver.2
35 2021-07-30 16:30:19 0.1 /gbaseserver/datadbs5/1/gbaseserver.2
36 2021-07-30 16:30:19 0.1 /gbaseserver/datadbs1/1/gbaseserver.2
37 2021-07-30 16:30:20 0.1 /gbaseserver/llogdbs/1/gbaseserver.2
38 2021-07-30 16:30:21 0.1 /gbaseserver/165/16/gbaseserver.1
39 2021-07-30 16:30:21 0.0 /gbaseserver/critical_files/ixbar/gbaseserver.3
40 2021-07-30 16:30:21 0.0 /gbaseserver/critical_files/oncfg/gbaseserver.3
41 2021-07-30 16:30:21 0.1 /gbaseserver/critical_files/onconfig/gbaseserver.3
42 2021-07-30 16:30:21 0.0 /gbaseserver/critical_files/sqlhosts/gbaseserver.3
43 2021-07-30 16:32:07 0.2 /gbaseserver/rootdbs/2/gbaseserver.1
44 2021-07-30 16:32:08 0.1 /gbaseserver/datadbs1/2/gbaseserver.1
45 2021-07-30 16:32:09 0.1 /gbaseserver/datadbs2/2/gbaseserver.1
46 2021-07-30 16:32:09 0.1 /gbaseserver/datadbs4/2/gbaseserver.1
47 2021-07-30 16:32:09 0.1 /gbaseserver/datadbs5/2/gbaseserver.1
48 2021-07-30 16:32:09 0.1 /gbaseserver/sbspace1/2/gbaseserver.1
49 2021-07-30 16:32:09 0.1 /gbaseserver/datadbs3/2/gbaseserver.1
50 2021-07-30 16:32:09 0.1 /gbaseserver/llogdbs/2/gbaseserver.1
51 2021-07-30 16:32:10 0.1 /gbaseserver/plogdbs/2/gbaseserver.1
52 2021-07-30 16:32:10 0.1 /gbaseserver/165/17/gbaseserver.1
53 2021-07-30 16:32:10 0.0 /gbaseserver/critical_files/ixbar/gbaseserver.4
54 2021-07-30 16:32:10 0.0 /gbaseserver/critical_files/oncfg/gbaseserver.4
55 2021-07-30 16:32:10 0.1 /gbaseserver/critical_files/onconfig/gbaseserver.4
56 2021-07-30 16:32:10 0.0 /gbaseserver/critical_files/sqlhosts/gbaseserver.4
57 2021-07-30 16:43:15 0.0 /gbaseserver/165/18/gbaseserver.1
[gbasedbt@devsvr ~]$
可以通过下面的命令,查看数据的最新备份情况。
[gbasedbt@devsvr ~]$ gstat -g arc
Your evaluation license will expire on 2022-07-30 00:00:00
On-Line (CKPT INP) -- Up 00:01:24 -- 597864 Kbytes
Blocked:OVERRIDE_DOWN_SPACE
num DBSpace Q Size Q Len Buffer partnum size scanner
Dbspaces - Archive Status
name number level date log log-position
rootdbs 1 0 07/30/2021.16:26 14 0x7d5018
1 07/30/2021.16:30 16 0x3018
2 07/30/2021.16:32 17 0x8018
llogdbs 2 0 07/30/2021.16:26 14 0x7d9018
1 07/30/2021.16:30 16 0x7018
2 07/30/2021.16:32 17 0xc018
plogdbs 3 0 07/30/2021.16:26 14 0x7d9018
1 07/30/2021.16:30 16 0x7018
2 07/30/2021.16:32 17 0xc018
sbspace1 4 0 07/30/2021.16:26 14 0x7db018
1 07/30/2021.16:30 16 0x7018
2 07/30/2021.16:32 17 0xe018
datadbs1 8 0 07/30/2021.16:26 14 0x7d9018
1 07/30/2021.16:30 16 0x7018
2 07/30/2021.16:32 17 0xc018
datadbs2 9 0 07/30/2021.16:26 14 0x7d9018
1 07/30/2021.16:30 16 0x7018
2 07/30/2021.16:32 17 0xc018
datadbs3 10 0 07/30/2021.16:26 14 0x7d9018
1 07/30/2021.16:30 16 0x7018
2 07/30/2021.16:32 17 0xc018
datadbs4 11 0 07/30/2021.16:26 14 0x7d9018
1 07/30/2021.16:30 16 0x7018
2 07/30/2021.16:32 17 0xc018
datadbs5 12 0 07/30/2021.16:26 14 0x7d9018
1 07/30/2021.16:30 16 0x7018
2 07/30/2021.16:32 17 0xc018
[gbasedbt@devsvr ~]$
演示完全恢复(t18)
重启数据库,确定被删除的文件
在GBase 8s启动过程中,会因无法打开被删除的文件而报错。
Cannot open chunk '/opt/gbase/gbaseserver_dbs/datadbs1_1
根据报错中的信息,得到被删除的Chunk文件(datadbs1_1)。
[gbasedbt@devsvr ~]$ gserver stop
Your evaluation license will expire on 2022-07-30 00:00:00
[gbasedbt@devsvr ~]$ gserver start
Your evaluation license will expire on 2022-07-30 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@devsvr ~]$ gstat -
Your evaluation license will expire on 2022-07-30 00:00:00
On-Line (CKPT INP) -- Up 00:07:37 -- 597864 Kbytes
Blocked:OVERRIDE_DOWN_SPACE
[gbasedbt@devsvr ~]$
创建被删除的文件,并设置权限。
语法
touch datadbs1_1
chmod o-r datadbs1_1
操作演示
[gbasedbt@devsvr gbaseserver_dbs]$ pwd
/opt/gbase/gbaseserver_dbs
[gbasedbt@devsvr gbaseserver_dbs]$ ll
total 1228800
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:46 datadbs2_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:46 datadbs3_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:46 datadbs4_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:46 datadbs5_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:46 llogdbs
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:46 plogdbs
-rw-rw----. 1 gbasedbt gbasedbt 209715200 Jul 30 16:46 rootdbs
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:46 sbspace1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:46 tmpdbs1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:46 tmpdbs2
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:46 tmpdbs3
[gbasedbt@devsvr gbaseserver_dbs]$ touch datadbs1_1
[gbasedbt@devsvr gbaseserver_dbs]$ ll
total 1228800
-rw-rw-r--. 1 gbasedbt gbasedbt 0 Jul 30 16:52 datadbs1_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:46 datadbs2_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:46 datadbs3_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:46 datadbs4_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:46 datadbs5_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:46 llogdbs
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:46 plogdbs
-rw-rw----. 1 gbasedbt gbasedbt 209715200 Jul 30 16:46 rootdbs
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:46 sbspace1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:46 tmpdbs1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:46 tmpdbs2
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:46 tmpdbs3
[gbasedbt@devsvr gbaseserver_dbs]$ chmod o-r datadbs1_1
[gbasedbt@devsvr gbaseserver_dbs]$ ll
total 1228800
-rw-rw----. 1 gbasedbt gbasedbt 0 Jul 30 16:52 datadbs1_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:46 datadbs2_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:46 datadbs3_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:46 datadbs4_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:46 datadbs5_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:46 llogdbs
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:46 plogdbs
-rw-rw----. 1 gbasedbt gbasedbt 209715200 Jul 30 16:46 rootdbs
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:46 sbspace1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:46 tmpdbs1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:46 tmpdbs2
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 30 16:46 tmpdbs3
[gbasedbt@devsvr gbaseserver_dbs]$
完全恢复
语法
gstat -
gbackuprestore -r
gadmin -m
[gbasedbt@devsvr ~]$ gstat -
Your evaluation license will expire on 2022-07-30 00:00:00
shared memory not initialized for GBASEDBTSERVER 'gbaseserver'
[gbasedbt@devsvr ~]$ gbackuprestore -r
Your evaluation license will expire on 2022-07-30 00:00:00
Your evaluation license will expire on 2022-07-30 00:00:00
[gbasedbt@devsvr ~]$ gstat -
Your evaluation license will expire on 2022-07-30 00:00:00
Quiescent -- Up 00:00:35 -- 1135464 Kbytes
[gbasedbt@devsvr ~]$ gadmin -m
Your evaluation license will expire on 2022-07-30 00:00:00
[gbasedbt@devsvr ~]$ dbaccess - -
Your evaluation license will expire on 2022-07-30 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');
操作演示
> 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'
2021-07-30 17:05:54
>
删除t_employee表(20)
语法
!date +'%F %T'
drop table t_employee;
操作演示
为了演示方便,在删除表之前,记录一个时间,用于后续的不完全恢复时间点。
> !date +'%F %T'
2021-07-30 17:06:45
> 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)
语法
gstat -
export GL_DATETIME="%iY-%m-%d %H:%M:%S"
gbackuprestore -r -t '2021-07-30 17:06:45'
echo "select * from t_employee" | dbaccess mydb
操作演示
根据上面测试时记录的时间点,进行不完全恢复。
[gbasedbt@devsvr ~]$ gstat -
Your evaluation license will expire on 2022-07-30 00:00:00
shared memory not initialized for GBASEDBTSERVER 'gbaseserver'
[gbasedbt@devsvr ~]$ export GL_DATETIME="%iY-%m-%d %H:%M:%S"
[gbasedbt@devsvr ~]$ echo $GL_DATETIME
%iY-%m-%d %H:%M:%S
[gbasedbt@devsvr ~]$ gbackuprestore -r -t '2021-07-30 17:06:45'
Your evaluation license will expire on 2022-07-30 00:00:00
Your evaluation license will expire on 2022-07-30 00:00:00
Your evaluation license will expire on 2022-07-30 00:00:00
[gbasedbt@devsvr ~]$ gadmin -m
Your evaluation license will expire on 2022-07-30 00:00:00
查看恢复结果。
[gbasedbt@devsvr ~]$ echo "select * from t_employee" | dbaccess mydb
Your evaluation license will expire on 2022-07-30 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@devsvr ~]$ echo "select * from t_dept" | dbaccess mydb
Your evaluation license will expire on 2022-07-30 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@devsvr ~]$
即使因为误操作删除了整个表,也依然可以通过不完全恢复,找回被删除的数据。
附录
数据库与表(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;