数据库运维
记录DBA学习成长历程

第11章:基于onbar的备份与恢复实验

文章目录

1 ON-Bar体系架构

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

ON-Bar组件:

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

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

2 环境准备

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

ON-Bar 和存储管理器通过“备份服务应用程序编程接口 (XBSA)”通信,该接口支持将存储管理器作为数据库服务器的备份介质。

通过使用存储管理器的开放式系统接口,ON-Bar 可以与各种同样使用 XBSA 的存储管理器一起协同工作。

GBase 8s 内置了一个存储管理器PSM,该存储管理器的接口库位置为/opt/gbase/lib/libbsapsm.so

[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]$

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

[gbasedbt@devsvr ~]$ onstat -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
[gbasedbt@devsvr ~]$ onmode -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 ~]$ onstat -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 ~]$ onmode -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 ~]$ onstat -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中的一个参数,在使用onbar时,该参数不能为/dev/null。我们可以临时为参数设置一个目录,实际备份时,逻辑日志并不保存在该目录中。

—2.2 PSM配置

——2.2.1 初始化Catalog

[gbasedbt@devsvr ~]$ ll /opt/gbase/etc/psm
ls: cannot access /opt/gbase/etc/psm: No such file or directory
[gbasedbt@devsvr ~]$ 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@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 ~]$ 

——2.2.2 查看PSM设备情况

[gbasedbt@devsvr ~]$ 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

——2.2.3 配置PSM设备

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

[gbasedbt@devsvr ~]$ mkdir -p /opt/gbase/dbspool
[gbasedbt@devsvr ~]$ mkdir -p /opt/gbase/logpool
[gbasedbt@devsvr ~]$ onpsm -D add /opt/gbase/dbspool -g DBSPOOL -p HIGHEST -t FILE
[gbasedbt@devsvr ~]$ onpsm -D add /opt/gbase/logpool -g LOGPOOL -p HIGHEST -t FILE
[gbasedbt@devsvr ~]$ 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@devsvr ~]$ 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@devsvr ~]$ ll /opt/gbase/dbspool
total 0
[gbasedbt@devsvr ~]$ ll /opt/gbase/logpool
total 0
[gbasedbt@devsvr ~]$

3 实验说明

业务场景说明:

  • 数据空间文件被删除时的数据完全恢复
  • 表删除后基于时间点的不完全恢复

4 备份与恢复演示

—4.1 创建数据库和表(t1)

[gbasedbt@devsvr ~]$ dbaccess - -
Your evaluation license will expire on 2022-07-30 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         

>

—4.2 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
> 

—4.3 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
> 

—4.4 系统进行L0备份(t4)

查看当前的日志,文件编号为11,唯一编号为14

[gbasedbt@devsvr ~]$ onstat -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 ~]$ onstat -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 ~]$ onbar -b -L 0
Your evaluation license will expire on 2022-07-30 00:00:00
[gbasedbt@devsvr ~]$ onpsm -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)。

—4.5 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
> 


—4.6 系统进行L1备份(t6)

[gbasedbt@devsvr ~]$ onbar -b -L 1
Your evaluation license will expire on 2022-07-30 00:00:00
[gbasedbt@devsvr ~]$ onpsm -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个。

—4.7 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'
2021-07-30 16:29:43
> 

—4.8 系统进行L1备份(t8)

[gbasedbt@devsvr ~]$ onbar -b -L 1
Your evaluation license will expire on 2022-07-30 00:00:00
[gbasedbt@devsvr ~]$ onpsm -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个。通过观察,ON-Bar备份时,PSM是通过组织文件系统的目录来管理备份文件的。PSM为L0,L1,L2创建3个目录,分别为0,1,2。每个备份文件名称为<instance_name>.<seq_num>。
逻辑日志的备份,是按逻辑日志的唯一编号,创建对应的目录进行存储。

—4.9 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
> 


—4.10 系统进行L2备份(t10)

[gbasedbt@devsvr ~]$ onbar -b -L 2
Your evaluation license will expire on 2022-07-30 00:00:00
[gbasedbt@devsvr ~]$ onpsm -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

[gbasedbt@devsvr ~]$ onstat -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 ~]$ 

—4.11 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'
2021-07-30 16:34:21
> 


—4.12 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'
2021-07-30 16:35:08
> 


—4.13 切换逻辑日志(t13)

[gbasedbt@devsvr ~]$ onstat -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 ~]$ onmode -l
Your evaluation license will expire on 2022-07-30 00:00:00
[gbasedbt@devsvr ~]$ onstat -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。

—4.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'
2021-07-30 16:38:10
> 


—4.15 删除Chunk文件(t15)

[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]$ 


—4.16 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'
2021-07-30 16:40:39
> 


—4.17 备份逻辑日志(t17)

[gbasedbt@devsvr ~]$ onbar -b -l
Your evaluation license will expire on 2022-07-30 00:00:00
[gbasedbt@devsvr ~]$ onpsm -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 ~]$ onstat -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 ~]$ 


—4.18 演示完全恢复(t18)

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

在GBase 8s启动过程中,会因无法打开被删除的文件而报错。

Cannot open chunk '/opt/gbase/gbaseserver_dbs/datadbs1_1

根据报错中的信息,得到被删除的Chunk文件(datadbs1_1)。

[gbasedbt@devsvr ~]$ onmode -ky
Your evaluation license will expire on 2022-07-30 00:00:00
[gbasedbt@devsvr ~]$ oninit -vy
Your evaluation license will expire on 2022-07-30 00:00:00
Initializing dbspaces...succeeded
Opening primary chunks...oninit: Cannot open chunk '/opt/gbase/gbaseserver_dbs/datadbs1_1'. errno = 2
Starting scheduling system...succeeded
Verbose output complete: mode = 5
[gbasedbt@devsvr ~]$ onstat -
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 ~]$ onmode -ky
[gbasedbt@devsvr ~]$ 

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

[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]$ 

——4.18.3 完全恢复

[gbasedbt@devsvr ~]$ onstat -
Your evaluation license will expire on 2022-07-30 00:00:00
shared memory not initialized for GBASEDBTSERVER 'gbaseserver'
[gbasedbt@devsvr ~]$ onbar -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@gbase01 gbaseserver_dbs]$ ll
total 1536000
-rw-rw---- 1 gbasedbt gbasedbt 104857600 Jul 16 06:13 datadbs1_1
[gbasedbt@devsvr ~]$ onstat -
Your evaluation license will expire on 2022-07-30 00:00:00
Quiescent -- Up 00:00:35 -- 1135464 Kbytes

[gbasedbt@devsvr ~]$ onmode -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文件被删除,只要有备份,依然可以完全恢复,不丢失数据。

—4.19 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
> 

—4.20 删除t_employee表(20)

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

> !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             

> 

—4.21 基于时间点的不完全恢复(t21)

根据上面测试时记录的时间点,进行不完全恢复。

[gbasedbt@gbase01 gbaseserver_dbs]$ onmode -ky
[gbasedbt@devsvr ~]$ onstat -
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 ~]$ onbar -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 ~]$ onmode -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 ~]$ 


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

赞(0)
MySQL学习笔记 » 第11章:基于onbar的备份与恢复实验