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

第10章:基于ontape的备份与恢复

文章目录

备份恢复介绍

1 ontape简介

使用ontape,可以进行GBase 8s数据库的备份与恢复。

  1. ontape支持L0,L1,L2三级备份与恢复。
  2. ontape支持逻辑日志的备份与恢复。
  3. ontape本身不支持基于时间点的恢复,但可通过其它工具,将ontape备份的单个表中数据,恢复到指定的时间点(暂不讨论)。基于时间点的数据库备份与恢复,建议使用onbar实现。

2 备份命令

3 恢复命令

4 业务场景模拟规划

模拟数据库在遇到数据库空间文件被删除时和表被删除时,如何尽可能的抢救数据。

5 备份/恢复操作演示

—5.1 ontape环境参数设置

使用ontape进行数据库的备份与恢复时,需要设置ontape默认使用的存储设备。

可通过修改参数文件,或使用 onmode -wf 命令,设置GBase 8s的参数。可通过 onstat -c 命令,查看GBase 8s的参数设置。

检查 GBase 8s 备份的存储设备参数,发现未指定备份存储设备。

[gbasedbt@devsvr ~]$ onstat -c | grep TAPEDEV | grep -v '#'
Your evaluation license will expire on 2022-06-18 00:00:00
TAPEDEV         /dev/null       
LTAPEDEV        /dev/null 

创建一个目录,并设置物理备份和逻辑备份的存储设备为新创建的目录。

[gbasedbt@devsvr ~]$ mkdir backup
[gbasedbt@devsvr ~]$ onmode -wf "TAPEDEV=/home/gbasedbt/backup"
Your evaluation license will expire on 2022-06-18 00:00:00
Value of TAPEDEV has been changed to /home/gbasedbt/backup.
[gbasedbt@devsvr ~]$ onmode -wf "LTAPEDEV=/home/gbasedbt/backup"
Your evaluation license will expire on 2022-06-18 00:00:00
Value of LTAPEDEV has been changed to /home/gbasedbt/backup.

查看备份设备参数,已经指向新创建的目录。

[gbasedbt@devsvr ~]$ onstat -c | grep TAPEDEV | grep -v '#'
Your evaluation license will expire on 2022-06-18 00:00:00
TAPEDEV         /home/gbasedbt/backup 
LTAPEDEV        /home/gbasedbt/backup 

—5.2 实验步骤

——5.2.1 数据准备

数据库与表

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

数据(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');

查看数据

> select * from t_dept;


   f_deptid f_deptname           

          1 dept_1              
          2 dept_2              
          3 dept_3              

3 row(s) retrieved.

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

> 

在L0备份前,t_dept表有3条记录,t_employee表有5条记录。在将数据库物理恢复到L0时,可恢复t_dept中的3条记录和t_employee中的5条记录。

——5.2.3 L0备份

[gbasedbt@devsvr backup]$ ontape -s -L 0
Your evaluation license will expire on 2022-06-18 00:00:00
100 percent done.
File created: /home/gbasedbt/backup/devsvr_120_L0

Please label this tape as number 1 in the arc tape sequence. 
This tape contains the following logical logs:

 33

Program over.
[gbasedbt@devsvr backup]$ ll
total 43584
-rw-rw----. 1 gbasedbt gbasedbt 44630016 Jul 24 10:08 devsvr_120_L0
[gbasedbt@devsvr backup]$ 

执行L0备份后,目录中生成一个名称为devsvr_120_L0的备份文件。

备份文件的命名规则:

<hostname>_<serverid>_<L0 | L1 | L2>

——5.2.4 L1备份前的数据准备

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.

> 

——5.2.5 L1备份

[gbasedbt@devsvr backup]$ ontape -s -L 1
Your evaluation license will expire on 2022-06-18 00:00:00
100 percent done.
File created: /home/gbasedbt/backup/devsvr_120_L1

Please label this tape as number 1 in the arc tape sequence. 
This tape contains the following logical logs:

 33

Program over.
[gbasedbt@devsvr backup]$ ll
total 50176
-rw-rw----. 1 gbasedbt gbasedbt 44630016 Jul 24 10:08 devsvr_120_L0
-rw-rw----. 1 gbasedbt gbasedbt  6750208 Jul 24 10:14 devsvr_120_L1
[gbasedbt@devsvr backup]$ 

——5.2.6 L1备份前的数据准备(第二次)

insert into t_employee values(16, 3, 'employee_16');
> select * from t_employee;


f_employeeid    f_deptid f_employeename       

           1           1 employee_01         
           2           1 employee_02         
           3           2 employee_03         
           4           2 employee_04         
           5           3 employee_05         
          11           1 employee_11         
          12           1 employee_12         
          13           2 employee_13         
          14           2 employee_14         
          15           3 employee_15         
          16           3 employee_16         

11 row(s) retrieved.

> 

在第二次L1备份前,t_employee表有11条记录。
可通过L1的物理恢复,得到t_employee表的11条记录。

——5.2.7 L1备份

[gbasedbt@devsvr backup]$ ontape -s -L 1
Your evaluation license will expire on 2022-06-18 00:00:00
100 percent done.
File created: /home/gbasedbt/backup/devsvr_120_L1

Please label this tape as number 1 in the arc tape sequence. 
This tape contains the following logical logs:

 33

Program over.
[gbasedbt@devsvr backup]$ ll
total 56768
-rw-rw----. 1 gbasedbt gbasedbt  6750208 Jul 24 10:14 devsvr_120_20210724_101445_L1
-rw-rw----. 1 gbasedbt gbasedbt 44630016 Jul 24 10:08 devsvr_120_L0
-rw-rw----. 1 gbasedbt gbasedbt  6750208 Jul 24 10:17 devsvr_120_L1
[gbasedbt@devsvr backup]$ 

GBase 8s最后一次的备份文件名为 <hostname>_<serviceid>_<L0 | L1 | L2>。当连续使用同一级别进行备份时,前一次的备份会被自动更名为<hostname>_<serviceid>-<timestamp>_<L0 | L1 | L2>。

——5.2.8 L2备份前的数据准备

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.

> 

在L2备份前,t_employee表有16条记录。
可通过L2的物理恢复,得到t_employee表的16条记录。

——5.2.9 L2备份

[gbasedbt@devsvr backup]$ ontape -s -L 2
Your evaluation license will expire on 2022-06-18 00:00:00
100 percent done.
File created: /home/gbasedbt/backup/devsvr_120_L2

Please label this tape as number 1 in the arc tape sequence. 
This tape contains the following logical logs:

 33

Program over.
[gbasedbt@devsvr backup]$ ll
total 63360
-rw-rw----. 1 gbasedbt gbasedbt  6750208 Jul 24 10:14 devsvr_120_20210724_101445_L1
-rw-rw----. 1 gbasedbt gbasedbt 44630016 Jul 24 10:08 devsvr_120_L0
-rw-rw----. 1 gbasedbt gbasedbt  6750208 Jul 24 10:17 devsvr_120_L1
-rw-rw----. 1 gbasedbt gbasedbt  6750208 Jul 24 10:20 devsvr_120_L2
[gbasedbt@devsvr backup]$ 

——5.2.10 切换逻辑日志前的数据准备

insert into t_dept values(4, 'dept_4');
> select * from t_dept;


   f_deptid f_deptname           

          1 dept_1              
          2 dept_2              
          3 dept_3              
          4 dept_4              

4 row(s) retrieved.

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

> 

——5.2.11 切换逻辑日志

切换前,当前的逻辑日志文件是10,唯一编号为33。

[gbasedbt@devsvr ~]$ onstat -l
Your evaluation license will expire on 2022-06-18 00:00:00
On-Line -- Up 15 days 01:56:16 -- 1135464 Kbytes

Physical Logging
Buffer bufused  bufsize  numpages   numwrits   pages/io
  P-2  0        1024     6312       454        13.90
      phybegin         physize    phypos     phyused    %used   
      3:53             99400      36167      14         0.01    

Logical Logging
Buffer bufused  bufsize  numrecs    numpages   numwrits   recs/pages pages/io
  L-1  0        512      99535      23065      21000      4.3        1.1     
    Subsystem    numrecs    Log Space used
    OLDRSAM      99037      9833936       
    HA           452        19888         
    DDL          46         16008         

address          number   flags    uniqid   begin                size     used    %used
4713df88         4        U-B----  27       2:53                 5000        3     0.06
48445970         5        U-B----  28       2:5053               5000        5     0.10
484459d8         6        U-B----  29       2:10053              5000     5000   100.00
48445a40         7        U-B----  30       2:15053              5000     5000   100.00
48445aa8         8        U-B----  31       2:20053              5000     5000   100.00
48445b10         9        U-B----  32       2:25053              5000     5000   100.00
48445b78         10       U---C-L  33       2:30053              5000     3060    61.20
48445be0         11       F------  0        2:35053              5000        0     0.00
48445c48         12       F------  0        2:40053              5000        0     0.00
48445cb0         13       F------  0        2:45053              5000        0     0.00
48445d18         14       F------  0        2:50053              5000        0     0.00
48445d80         15       F------  0        2:55053              5000        0     0.00
48445de8         16       F------  0        2:60053              5000        0     0.00
48445e50         17       F------  0        2:65053              5000        0     0.00
48445eb8         18       F------  0        2:70053              5000        0     0.00
48445f20         19       F------  0        2:75053              5000        0     0.00
48445f88         20       F------  0        2:80053              5000        0     0.00
46f1cf30         21       U-B----  24       2:85053              5000       30     0.60
46f1cf98         22       U-B----  25       2:90053              5000       13     0.26
46febf30         23       U-B----  26       2:95053              5000        3     0.06
 20 active, 20 total

[gbasedbt@devsvr ~]$ 

执行逻辑日志切换命令

[gbasedbt@devsvr ~]$ onmode -l
Your evaluation license will expire on 2022-06-18 00:00:00

切换后,当前逻辑日志文件为11,唯一编号为34。

[gbasedbt@devsvr ~]$ onstat -l
Your evaluation license will expire on 2022-06-18 00:00:00
On-Line -- Up 15 days 01:57:06 -- 1135464 Kbytes

Physical Logging
Buffer bufused  bufsize  numpages   numwrits   pages/io
  P-2  0        1024     6312       454        13.90
      phybegin         physize    phypos     phyused    %used   
      3:53             99400      36167      14         0.01    

Logical Logging
Buffer bufused  bufsize  numrecs    numpages   numwrits   recs/pages pages/io
  L-2  0        512      99535      23065      21000      4.3        1.1     
    Subsystem    numrecs    Log Space used
    OLDRSAM      99037      9833936       
    HA           452        19888         
    DDL          46         16008         

address          number   flags    uniqid   begin                size     used    %used
4713df88         4        U-B----  27       2:53                 5000        3     0.06
48445970         5        U-B----  28       2:5053               5000        5     0.10
484459d8         6        U-B----  29       2:10053              5000     5000   100.00
48445a40         7        U-B----  30       2:15053              5000     5000   100.00
48445aa8         8        U-B----  31       2:20053              5000     5000   100.00
48445b10         9        U-B----  32       2:25053              5000     5000   100.00
48445b78         10       U-----L  33       2:30053              5000     3061    61.22
48445be0         11       U---C--  34       2:35053              5000        0     0.00
48445c48         12       F------  0        2:40053              5000        0     0.00
48445cb0         13       F------  0        2:45053              5000        0     0.00
48445d18         14       F------  0        2:50053              5000        0     0.00
48445d80         15       F------  0        2:55053              5000        0     0.00
48445de8         16       F------  0        2:60053              5000        0     0.00
48445e50         17       F------  0        2:65053              5000        0     0.00
48445eb8         18       F------  0        2:70053              5000        0     0.00
48445f20         19       F------  0        2:75053              5000        0     0.00
48445f88         20       F------  0        2:80053              5000        0     0.00
46f1cf30         21       U-B----  24       2:85053              5000       30     0.60
46f1cf98         22       U-B----  25       2:90053              5000       13     0.26
46febf30         23       U-B----  26       2:95053              5000        3     0.06
 20 active, 20 total

[gbasedbt@devsvr ~]$ 

——5.2.12 灾难前的最后一次数据变更

在灾难发生前,删除一个记录,用于后续恢复时的验证用例。

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

> select * from t_dept;


   f_deptid f_deptname           

          1 dept_1              
          2 dept_2              
          3 dept_3              
          4 dept_4              

4 row(s) retrieved.

> 


在灾难发生前,t_employee表有15条记录,t_dept表有4条记录。
可通过完全恢复,得到t_employee表的15条记录,t_dept表的4条记录。

——5.2.13 模拟灾难发生

[gbasedbt@devsvr ~]$ cd /opt/gbase/gbaseserver_dbs/
[gbasedbt@devsvr gbaseserver_dbs]$ ll
total 1536000
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 24 10:32 datadbs1_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul  9 08:29 datadbs2_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul  9 08:29 datadbs3_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul  9 08:29 datadbs4_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul  9 08:29 datadbs5_1
-rw-rw----. 1 gbasedbt gbasedbt 209715200 Jul 24 10:32 llogdbs
-rw-rw----. 1 gbasedbt gbasedbt 209715200 Jul 24 10:32 plogdbs
-rw-rw----. 1 gbasedbt gbasedbt 209715200 Jul 24 10:32 rootdbs
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul  9 08:29 sbspace1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 24 10:22 tmpdbs1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 24 10:22 tmpdbs2
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 24 10:19 tmpdbs3
[gbasedbt@gbase01 gbaseserver_dbs]$ onstat -d
address number flags fchunk nchunks pgsize flags owner name
 12 active, 2047 maximum
Chunks
4933d028 8 0x40001 8 1 16384 N BA gbasedbt datadbs1
address chunk/dbs offset size free bpages flags pathname
49349028 8 8 0 6400 5109 PO-BED /opt/gbase/gbaseserver_dbs/datadbs1_1
[gbasedbt@devsvr gbaseserver_dbs]$ rm -rf datadbs1_1
[gbasedbt@devsvr gbaseserver_dbs]$ ll
total 1433600
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul  9 08:29 datadbs2_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul  9 08:29 datadbs3_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul  9 08:29 datadbs4_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul  9 08:29 datadbs5_1
-rw-rw----. 1 gbasedbt gbasedbt 209715200 Jul 24 10:32 llogdbs
-rw-rw----. 1 gbasedbt gbasedbt 209715200 Jul 24 10:32 plogdbs
-rw-rw----. 1 gbasedbt gbasedbt 209715200 Jul 24 10:32 rootdbs
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul  9 08:29 sbspace1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 24 10:22 tmpdbs1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 24 10:22 tmpdbs2
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 24 10:19 tmpdbs3

删除数据空间文件成功。

——5.2.14 灾难后的第一次数据变更

在数据库空间文件被删除后,对t_dept表的INSERT操作可以成功。

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

> 

灾难发生后,对t_dept表的操作成功,t_dept表共有5条记录。

——5.2.15 重启数据库,出现错误信息

数据库报错,信息:Cannot open chunk ‘/opt/gbase/gbaseserver_dbs/datadbs1_1’.

因为这个文件被删除,所以GBase 8s找不到这个文件了。

[gbasedbt@devsvr ~]$ onmode -ky
Your evaluation license will expire on 2022-06-18 00:00:00
[gbasedbt@devsvr ~]$ oninit -vy
Opening primary chunks...oninit: Cannot open chunk '/opt/gbase/gbaseserver_dbs/datadbs1_1'. errno = 2
succeeded
Starting scheduling system...succeeded
Verbose output complete: mode = 5
[gbasedbt@gbase01 ~]$ dbaccess - -
Your evaluation license will expire on 2024-07-03 00:00:00
> database mydb;
 311: Cannot open system catalog (systables).
 155: ISAM error: Primary and Mirror chunks are bad
Error in line 1
Near character position 12

——5.2.16 备份逻辑日志

执行逻辑日志的备份后,目录中出现两个备份的逻辑日志(devsvr_120_Log0000000033和devsvr_120_Log0000000034)。

[gbasedbt@devsvr backup]$ ontape -a
Your evaluation license will expire on 2022-06-18 00:00:00

Performing automatic backup of logical logs.

File created: /home/gbasedbt/backup/devsvr_120_Log0000000033
Do you want to back up the current logical log? (y/n) y
File created: /home/gbasedbt/backup/devsvr_120_Log0000000034

Program over.
[gbasedbt@devsvr backup]$ ll
total 69664
-rw-rw----. 1 gbasedbt gbasedbt  6750208 Jul 24 10:14 devsvr_120_20210724_101445_L1
-rw-rw----. 1 gbasedbt gbasedbt 44630016 Jul 24 10:08 devsvr_120_L0
-rw-rw----. 1 gbasedbt gbasedbt  6750208 Jul 24 10:17 devsvr_120_L1
-rw-rw----. 1 gbasedbt gbasedbt  6750208 Jul 24 10:20 devsvr_120_L2
-rw-rw----. 1 gbasedbt gbasedbt  6356992 Jul 24 10:48 devsvr_120_Log0000000033
-rw-rw----. 1 gbasedbt gbasedbt    98304 Jul 24 10:48 devsvr_120_Log0000000034
[gbasedbt@devsvr backup]$ 

进行逻辑日志备份时,会产生逻辑日志切换。当前的逻辑日志文件变为12,唯一编号为35。

[gbasedbt@devsvr backup]$ onstat -l
Your evaluation license will expire on 2022-06-18 00:00:00
On-Line (CKPT INP) -- Up 00:07:06 -- 597864 Kbytes
Blocked:OVERRIDE_DOWN_SPACE

Physical Logging
Buffer bufused  bufsize  numpages   numwrits   pages/io
  P-1  0        1024     42         1          42.00
      phybegin         physize    phypos     phyused    %used   
      3:53             99400      36253      42         0.04    

Logical Logging
Buffer bufused  bufsize  numrecs    numpages   numwrits   recs/pages pages/io
  L-3  0        512      6          2          2          3.0        1.0     
    Subsystem    numrecs    Log Space used
    OLDRSAM      6          340           

address          number   flags    uniqid   begin                size     used    %used
4713df88         4        U-B----  27       2:53                 5000        3     0.06
4844a970         5        U-B----  28       2:5053               5000        5     0.10
4844a9d8         6        U-B----  29       2:10053              5000     5000   100.00
4844aa40         7        U-B----  30       2:15053              5000     5000   100.00
4844aaa8         8        U-B----  31       2:20053              5000     5000   100.00
4844ab10         9        U-B----  32       2:25053              5000     5000   100.00
4844ab78         10       U-B----  33       2:30053              5000     3061    61.22
4844abe0         11       U-B---L  34       2:35053              5000       14     0.28
4844ac48         12       U---C--  35       2:40053              5000        0     0.00
4844acb0         13       F------  0        2:45053              5000        0     0.00
4844ad18         14       F------  0        2:50053              5000        0     0.00
4844ad80         15       F------  0        2:55053              5000        0     0.00
4844ade8         16       F------  0        2:60053              5000        0     0.00
4844ae50         17       F------  0        2:65053              5000        0     0.00
4844aeb8         18       F------  0        2:70053              5000        0     0.00
4844af20         19       F------  0        2:75053              5000        0     0.00
4844af88         20       F------  0        2:80053              5000        0     0.00
46f1cf30         21       U-B----  24       2:85053              5000       30     0.60
46f1cf98         22       U-B----  25       2:90053              5000       13     0.26
46febf30         23       U-B----  26       2:95053              5000        3     0.06
 20 active, 20 total

[gbasedbt@devsvr backup]$ 

——5.2.17 恢复数据库

为丢失的数据库空间文件,创建一个同名的空文件,并设置好相应的权限。

[gbasedbt@devsvr gbaseserver_dbs]$ pwd
/opt/gbase/gbaseserver_dbs
[gbasedbt@devsvr gbaseserver_dbs]$ ll
total 1433600
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 24 10:44 datadbs2_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 24 10:44 datadbs3_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 24 10:44 datadbs4_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 24 10:44 datadbs5_1
-rw-rw----. 1 gbasedbt gbasedbt 209715200 Jul 24 10:48 llogdbs
-rw-rw----. 1 gbasedbt gbasedbt 209715200 Jul 24 10:44 plogdbs
-rw-rw----. 1 gbasedbt gbasedbt 209715200 Jul 24 10:44 rootdbs
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 24 10:44 sbspace1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 24 10:44 tmpdbs1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 24 10:44 tmpdbs2
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 24 10:44 tmpdbs3
[gbasedbt@devsvr gbaseserver_dbs]$ touch datadbs1_1
[gbasedbt@devsvr gbaseserver_dbs]$ ll
total 1433600
-rw-rw-r--. 1 gbasedbt gbasedbt         0 Jul 24 10:55 datadbs1_1
[gbasedbt@devsvr gbaseserver_dbs]$ chmod o-r datadbs1_1
[gbasedbt@devsvr gbaseserver_dbs]$ ll
total 1433600
-rw-rw----. 1 gbasedbt gbasedbt         0 Jul 24 10:55 datadbs1_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 24 10:44 datadbs2_1
-rw-rw----. 1 gbasedbt gbasedbt 104857600 Jul 24 10:44 datadbs3_1

关闭GBase 8s数据库实例,并进行完全恢复。

[gbasedbt@devsvr gbaseserver_dbs]$ onmode -ky
Your evaluation license will expire on 2022-06-18 00:00:00
[gbasedbt@devsvr gbaseserver_dbs]$ ontape -r
Your evaluation license will expire on 2022-06-18 00:00:00
Restore will use level 0 archive file /home/gbasedbt/backup/devsvr_120_L0. Press Return to continue ...


Archive Tape Information

Tape type:      Archive Backup Tape 
Online version: GBase Database Server Version 12.10.FC4G1TL 
Archive date:   Sat Jul 24 10:08:47 2021 
User id:        gbasedbt 
Terminal id:    /dev/pts/0 
Archive level:  0 
Tape device:    /home/gbasedbt/backup/ 
Tape blocksize (in k): 32 
Tape size (in k): system defined for directory 
Tape number in series: 1 
Continue restore? (y/n)y
Spaces to restore:1 [rootdbs                                                                                                                         ] 
2 [llogdbs                                                                                                                         ] 
3 [plogdbs                                                                                                                         ] 
4 [datadbs1                                                                                                                        ] 
5 [datadbs2                                                                                                                        ] 
6 [datadbs3                                                                                                                        ] 
7 [datadbs4                                                                                                                        ] 
8 [datadbs5                                                                                                                        ] 
9 [sbspace1                                                                                                                        ] 

Archive Information

GBase Database Server Copyright 2001, 2021  General Data Corporation
Initialization Time       06/18/2021 17:36:36
System Page Size          2048
Version                   32
Index Page Logging        OFF
Archive CheckPoint Time   07/24/2021 10:08:47

Dbspaces
number   flags    fchunk   nchunks  flags    owner                            name
1        40001    1        1        N  BA    gbasedbt                         rootdbs                                                                                                                         
2        40001    2        1        N  BA    gbasedbt                         llogdbs                                                                                                                         
3        40001    3        1        N  BA    gbasedbt                         plogdbs                                                                                                                         
4        48001    4        1        N SBA    gbasedbt                         sbspace1                                                                                                                        
5        42001    5        1        N TBA    gbasedbt                         tmpdbs1                                                                                                                         
6        42001    6        1        N TBA    gbasedbt                         tmpdbs2                                                                                                                         
7        42001    7        1        N TBA    gbasedbt                         tmpdbs3                                                                                                                         
8        40001    8        1        N  BA    gbasedbt                         datadbs1                                                                                                                        
9        40001    9        1        N  BA    gbasedbt                         datadbs2                                                                                                                        
10       40001    10       1        N  BA    gbasedbt                         datadbs3                                                                                                                        
11       40001    11       1        N  BA    gbasedbt                         datadbs4                                                                                                                        
12       40001    12       1        N  BA    gbasedbt                         datadbs5                                                                                                                        


Chunks
chk/dbs offset   size     free     bpages   flags pathname
1   1   0        102400   89290             PO-B- /opt/gbase/gbaseserver_dbs/rootdbs
2   2   0        102400   2347              PO-B- /opt/gbase/gbaseserver_dbs/llogdbs
3   3   0        102400   2947              PO-B- /opt/gbase/gbaseserver_dbs/plogdbs
4   4   0        51200    2581              POSB- /opt/gbase/gbaseserver_dbs/sbspace1
5   5   0        51200    50712             PO-B- /opt/gbase/gbaseserver_dbs/tmpdbs1
6   6   0        51200    50776             PO-B- /opt/gbase/gbaseserver_dbs/tmpdbs2
7   7   0        51200    50776             PO-B- /opt/gbase/gbaseserver_dbs/tmpdbs3
8   8   0        51200    41768             PO-BE /opt/gbase/gbaseserver_dbs/datadbs1_1
9   9   0        51200    50376             PO-BE /opt/gbase/gbaseserver_dbs/datadbs2_1
10  10  0        51200    50376             PO-BE /opt/gbase/gbaseserver_dbs/datadbs3_1
11  11  0        51200    50776             PO-BE /opt/gbase/gbaseserver_dbs/datadbs4_1
12  12  0        51200    50776             PO-BE /opt/gbase/gbaseserver_dbs/datadbs5_1

Continue restore? (y/n)y    --##### 输入y #####--
Do you want to back up the logs? (y/n)y    --##### 输入y #####--
File created: /home/gbasedbt/backup/devsvr_120_Log0000000024
File created: /home/gbasedbt/backup/devsvr_120_Log0000000025
File created: /home/gbasedbt/backup/devsvr_120_Log0000000026
File created: /home/gbasedbt/backup/devsvr_120_Log0000000027
File created: /home/gbasedbt/backup/devsvr_120_Log0000000028
File created: /home/gbasedbt/backup/devsvr_120_Log0000000029
File created: /home/gbasedbt/backup/devsvr_120_Log0000000030
File created: /home/gbasedbt/backup/devsvr_120_Log0000000031
File created: /home/gbasedbt/backup/devsvr_120_Log0000000032
File created: /home/gbasedbt/backup/devsvr_120_Log0000000033
File created: /home/gbasedbt/backup/devsvr_120_Log0000000034
Log salvage is complete, continuing restore of archive.
Your evaluation license will expire on 2022-06-18 00:00:00
Restore a level 1 archive (y/n) y    --##### 输入y #####--
Ready for level 1 tape 
Restore will use level 1 archive file /home/gbasedbt/backup/devsvr_120_L1. Press Return to continue ...


Archive Tape Information

Tape type:      Archive Backup Tape 
Online version: GBase Database Server Version 12.10.FC4G1TL 
Archive date:   Sat Jul 24 10:17:11 2021 
User id:        gbasedbt 
Terminal id:    /dev/pts/0 
Archive level:  1 
Tape device:    /home/gbasedbt/backup/ 
Tape blocksize (in k): 32 
Tape size (in k): system defined for directory 
Tape number in series: 1 
Restore a level 2 archive (y/n) y    --##### 输入y #####--
Ready for level 2 tape 
Restore will use level 2 archive file /home/gbasedbt/backup/devsvr_120_L2. Press Return to continue ...


Archive Tape Information

Tape type:      Archive Backup Tape 
Online version: GBase Database Server Version 12.10.FC4G1TL 
Archive date:   Sat Jul 24 10:20:04 2021 
User id:        gbasedbt 
Terminal id:    /dev/pts/0 
Archive level:  2 
Tape device:    /home/gbasedbt/backup/ 
Tape blocksize (in k): 32 
Tape size (in k): system defined for directory 
Tape number in series: 1 
Do you want to restore log tapes? (y/n)y    --##### 输入y #####--

Roll forward should start with log number 33
Restore will use log backup file /home/gbasedbt/backup/devsvr_120_Log0000000033. Press Return to continue ...

Rollforward log file /home/gbasedbt/backup/devsvr_120_Log0000000033 ...
Rollforward log file /home/gbasedbt/backup/devsvr_120_Log0000000034 ...

Program over.
[gbasedbt@devsvr gbaseserver_dbs]$ 

——5.2.18 查看表数据。

完全恢复后,在数据空间文件删除前的数据验证通过。即使在数据空间文件被删除后的操作成功的事务数据,也可以被完全恢复。

[gbasedbt@devsvr ~]$ onstat -
Your evaluation license will expire on 2022-06-18 00:00:00
Quiescent -- Up 00:03:54 -- 1135464 Kbytes

[gbasedbt@devsvr ~]$ onmode -m
Your evaluation license will expire on 2022-06-18 00:00:00
[gbasedbt@devsvr ~]$ dbaccess - -
Your evaluation license will expire on 2022-06-18 00:00:00
> database mydb;

Database selected.

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

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

> 

检查结果:数据表完全恢复到数据库空间被删除前的状态,且在数据库空间文件被删除后新增的记录,也被正确恢复。

——5.2.19 删除表之前的数据准备

> select * from t_employee order by f_employeeid;


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         
         101           1 employee_101        
         102           1 employee_102        
         103           2 employee_103        
         104           2 employee_104        
         105           3 employee_105        

20 row(s) retrieved.

> 

此处构造的5条测试数据,由于没有基于时间点的恢复,可能在数据表被删除时,无法正确恢复。

——5.2.20 删除t_employee数据表

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

——5.2.21 L0级物理恢复

[gbasedbt@devsvr ~]$ onmode -ky
Your evaluation license will expire on 2022-06-18 00:00:00
[gbasedbt@devsvr ~]$ ontape -p
Your evaluation license will expire on 2022-06-18 00:00:00
Restore will use level 0 archive file /home/gbasedbt/backup/devsvr_120_L0. Press Return to continue ...


Archive Tape Information

Tape type:      Archive Backup Tape 
Online version: GBase Database Server Version 12.10.FC4G1TL 
Archive date:   Sat Jul 24 10:08:47 2021 
User id:        gbasedbt 
Terminal id:    /dev/pts/0 
Archive level:  0 
Tape device:    /home/gbasedbt/backup/ 
Tape blocksize (in k): 32 
Tape size (in k): system defined for directory 
Tape number in series: 1 

Spaces to restore:1 [rootdbs                                                                                                                         ] 
2 [llogdbs                                                                                                                         ] 
3 [plogdbs                                                                                                                         ] 
4 [datadbs1                                                                                                                        ] 
5 [datadbs2                                                                                                                        ] 
6 [datadbs3                                                                                                                        ] 
7 [datadbs4                                                                                                                        ] 
8 [datadbs5                                                                                                                        ] 
9 [sbspace1                                                                                                                        ] 

Archive Information

GBase Database Server Copyright 2001, 2021  General Data Corporation
Initialization Time       06/18/2021 17:36:36
System Page Size          2048
Version                   32
Index Page Logging        OFF
Archive CheckPoint Time   07/24/2021 10:08:47

Dbspaces
number   flags    fchunk   nchunks  flags    owner                            name
1        40001    1        1        N  BA    gbasedbt                         rootdbs                                                                                                                         
2        40001    2        1        N  BA    gbasedbt                         llogdbs                                                                                                                         
3        40001    3        1        N  BA    gbasedbt                         plogdbs                                                                                                                         
4        48001    4        1        N SBA    gbasedbt                         sbspace1                                                                                                                        
5        42001    5        1        N TBA    gbasedbt                         tmpdbs1                                                                                                                         
6        42001    6        1        N TBA    gbasedbt                         tmpdbs2                                                                                                                         
7        42001    7        1        N TBA    gbasedbt                         tmpdbs3                                                                                                                         
8        40001    8        1        N  BA    gbasedbt                         datadbs1                                                                                                                        
9        40001    9        1        N  BA    gbasedbt                         datadbs2                                                                                                                        
10       40001    10       1        N  BA    gbasedbt                         datadbs3                                                                                                                        
11       40001    11       1        N  BA    gbasedbt                         datadbs4                                                                                                                        
12       40001    12       1        N  BA    gbasedbt                         datadbs5                                                                                                                        


Chunks
chk/dbs offset   size     free     bpages   flags pathname
1   1   0        102400   89290             PO-B- /opt/gbase/gbaseserver_dbs/rootdbs
2   2   0        102400   2347              PO-B- /opt/gbase/gbaseserver_dbs/llogdbs
3   3   0        102400   2947              PO-B- /opt/gbase/gbaseserver_dbs/plogdbs
4   4   0        51200    2581              POSB- /opt/gbase/gbaseserver_dbs/sbspace1
5   5   0        51200    50712             PO-B- /opt/gbase/gbaseserver_dbs/tmpdbs1
6   6   0        51200    50776             PO-B- /opt/gbase/gbaseserver_dbs/tmpdbs2
7   7   0        51200    50776             PO-B- /opt/gbase/gbaseserver_dbs/tmpdbs3
8   8   0        51200    41768             PO-BE /opt/gbase/gbaseserver_dbs/datadbs1_1
9   9   0        51200    50376             PO-BE /opt/gbase/gbaseserver_dbs/datadbs2_1
10  10  0        51200    50376             PO-BE /opt/gbase/gbaseserver_dbs/datadbs3_1
11  11  0        51200    50776             PO-BE /opt/gbase/gbaseserver_dbs/datadbs4_1
12  12  0        51200    50776             PO-BE /opt/gbase/gbaseserver_dbs/datadbs5_1

Continue restore? (y/n)y                       --##### 输入y #####--
Do you want to back up the logs? (y/n)y        --##### 输入y #####--
File created: /home/gbasedbt/backup/devsvr_120_Log0000000035
Log salvage is complete, continuing restore of archive.
Your evaluation license will expire on 2022-06-18 00:00:00
Restore a level 1 archive (y/n) n              --##### 输入n,不进行L1恢复 #####--

Program over.
[gbasedbt@devsvr ~]$ 

查看L0级物理恢复后,被删除表的恢复情况

[gbasedbt@devsvr ~]$ onstat -
Your evaluation license will expire on 2022-06-18 00:00:00
Fast Recovery -- Up 00:01:22 -- 597864 Kbytes

[gbasedbt@devsvr ~]$ onmode -m
Your evaluation license will expire on 2022-06-18 00:00:00
[gbasedbt@devsvr ~]$ onstat -
Your evaluation license will expire on 2022-06-18 00:00:00
On-Line -- Up 00:01:38 -- 597864 Kbytes

[gbasedbt@devsvr ~]$ echo "select * from t_employee" | dbaccess mydb
Your evaluation license will expire on 2022-06-18 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         

5 row(s) retrieved.



Database closed.

[gbasedbt@devsvr ~]$ 

——5.2.22  L1级物理恢复

[gbasedbt@devsvr ~]$ onmode -ky
Your evaluation license will expire on 2022-06-18 00:00:00
[gbasedbt@devsvr ~]$ ontape -p
Your evaluation license will expire on 2022-06-18 00:00:00
Restore will use level 0 archive file /home/gbasedbt/backup/devsvr_120_L0. Press Return to continue ...


Archive Tape Information

Tape type:      Archive Backup Tape 
Online version: GBase Database Server Version 12.10.FC4G1TL 
Archive date:   Sat Jul 24 10:08:47 2021 
User id:        gbasedbt 
Terminal id:    /dev/pts/0 
Archive level:  0 
Tape device:    /home/gbasedbt/backup/ 
Tape blocksize (in k): 32 
Tape size (in k): system defined for directory 
Tape number in series: 1 

Spaces to restore:1 [rootdbs                                                                                                                         ] 
2 [llogdbs                                                                                                                         ] 
3 [plogdbs                                                                                                                         ] 
4 [datadbs1                                                                                                                        ] 
5 [datadbs2                                                                                                                        ] 
6 [datadbs3                                                                                                                        ] 
7 [datadbs4                                                                                                                        ] 
8 [datadbs5                                                                                                                        ] 
9 [sbspace1                                                                                                                        ] 

Archive Information

GBase Database Server Copyright 2001, 2021  General Data Corporation
Initialization Time       06/18/2021 17:36:36
System Page Size          2048
Version                   32
Index Page Logging        OFF
Archive CheckPoint Time   07/24/2021 10:08:47

Dbspaces
number   flags    fchunk   nchunks  flags    owner                            name
1        40001    1        1        N  BA    gbasedbt                         rootdbs                                                                                                                         
2        40001    2        1        N  BA    gbasedbt                         llogdbs                                                                                                                         
3        40001    3        1        N  BA    gbasedbt                         plogdbs                                                                                                                         
4        48001    4        1        N SBA    gbasedbt                         sbspace1                                                                                                                        
5        42001    5        1        N TBA    gbasedbt                         tmpdbs1                                                                                                                         
6        42001    6        1        N TBA    gbasedbt                         tmpdbs2                                                                                                                         
7        42001    7        1        N TBA    gbasedbt                         tmpdbs3                                                                                                                         
8        40001    8        1        N  BA    gbasedbt                         datadbs1                                                                                                                        
9        40001    9        1        N  BA    gbasedbt                         datadbs2                                                                                                                        
10       40001    10       1        N  BA    gbasedbt                         datadbs3                                                                                                                        
11       40001    11       1        N  BA    gbasedbt                         datadbs4                                                                                                                        
12       40001    12       1        N  BA    gbasedbt                         datadbs5                                                                                                                        


Chunks
chk/dbs offset   size     free     bpages   flags pathname
1   1   0        102400   89290             PO-B- /opt/gbase/gbaseserver_dbs/rootdbs
2   2   0        102400   2347              PO-B- /opt/gbase/gbaseserver_dbs/llogdbs
3   3   0        102400   2947              PO-B- /opt/gbase/gbaseserver_dbs/plogdbs
4   4   0        51200    2581              POSB- /opt/gbase/gbaseserver_dbs/sbspace1
5   5   0        51200    50712             PO-B- /opt/gbase/gbaseserver_dbs/tmpdbs1
6   6   0        51200    50776             PO-B- /opt/gbase/gbaseserver_dbs/tmpdbs2
7   7   0        51200    50776             PO-B- /opt/gbase/gbaseserver_dbs/tmpdbs3
8   8   0        51200    41768             PO-BE /opt/gbase/gbaseserver_dbs/datadbs1_1
9   9   0        51200    50376             PO-BE /opt/gbase/gbaseserver_dbs/datadbs2_1
10  10  0        51200    50376             PO-BE /opt/gbase/gbaseserver_dbs/datadbs3_1
11  11  0        51200    50776             PO-BE /opt/gbase/gbaseserver_dbs/datadbs4_1
12  12  0        51200    50776             PO-BE /opt/gbase/gbaseserver_dbs/datadbs5_1

Continue restore? (y/n)y                    --##### 输入y #####--
Do you want to back up the logs? (y/n)y     --##### 输入y #####--
No log files to salvage. Logs 33 - 33 already exists in directory /home/gbasedbt/backup/
Log salvage is complete, continuing restore of archive.
Your evaluation license will expire on 2022-06-18 00:00:00
Restore a level 1 archive (y/n) y           --##### 输入y #####--
Ready for level 1 tape 
Restore will use level 1 archive file /home/gbasedbt/backup/devsvr_120_L1. Press Return to continue ...


Archive Tape Information

Tape type:      Archive Backup Tape 
Online version: GBase Database Server Version 12.10.FC4G1TL 
Archive date:   Sat Jul 24 10:17:11 2021 
User id:        gbasedbt 
Terminal id:    /dev/pts/0 
Archive level:  1 
Tape device:    /home/gbasedbt/backup/ 
Tape blocksize (in k): 32 
Tape size (in k): system defined for directory 
Tape number in series: 1 
Restore a level 2 archive (y/n) n            --##### 输入n,不进行L2的恢复 #####--

Program over.
[gbasedbt@devsvr ~]$ 

查看L1级物理恢复后,被删除表的恢复情况

[gbasedbt@devsvr ~]$ onstat -
Your evaluation license will expire on 2022-06-18 00:00:00
Fast Recovery -- Up 00:01:17 -- 597864 Kbytes

[gbasedbt@devsvr ~]$ onmode -m
Your evaluation license will expire on 2022-06-18 00:00:00
[gbasedbt@devsvr ~]$ onstat -
Your evaluation license will expire on 2022-06-18 00:00:00
On-Line -- Up 00:01:30 -- 597864 Kbytes

[gbasedbt@devsvr ~]$ echo "select * from t_employee" | dbaccess mydb
Your evaluation license will expire on 2022-06-18 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_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.



Database closed.

[gbasedbt@devsvr ~]$ 

——5.2.23 L2级物理恢复

[gbasedbt@devsvr ~]$ onmode -ky
Your evaluation license will expire on 2022-06-18 00:00:00
[gbasedbt@devsvr ~]$ ontape -p
Your evaluation license will expire on 2022-06-18 00:00:00
Restore will use level 0 archive file /home/gbasedbt/backup/devsvr_120_L0. Press Return to continue ...


Archive Tape Information

Tape type:      Archive Backup Tape 
Online version: GBase Database Server Version 12.10.FC4G1TL 
Archive date:   Sat Jul 24 10:08:47 2021 
User id:        gbasedbt 
Terminal id:    /dev/pts/0 
Archive level:  0 
Tape device:    /home/gbasedbt/backup/ 
Tape blocksize (in k): 32 
Tape size (in k): system defined for directory 
Tape number in series: 1 

Spaces to restore:1 [rootdbs                                                                                                                         ] 
2 [llogdbs                                                                                                                         ] 
3 [plogdbs                                                                                                                         ] 
4 [datadbs1                                                                                                                        ] 
5 [datadbs2                                                                                                                        ] 
6 [datadbs3                                                                                                                        ] 
7 [datadbs4                                                                                                                        ] 
8 [datadbs5                                                                                                                        ] 
9 [sbspace1                                                                                                                        ] 

Archive Information

GBase Database Server Copyright 2001, 2021  General Data Corporation
Initialization Time       06/18/2021 17:36:36
System Page Size          2048
Version                   32
Index Page Logging        OFF
Archive CheckPoint Time   07/24/2021 10:08:47

Dbspaces
number   flags    fchunk   nchunks  flags    owner                            name
1        40001    1        1        N  BA    gbasedbt                         rootdbs                                                                                                                         
2        40001    2        1        N  BA    gbasedbt                         llogdbs                                                                                                                         
3        40001    3        1        N  BA    gbasedbt                         plogdbs                                                                                                                         
4        48001    4        1        N SBA    gbasedbt                         sbspace1                                                                                                                        
5        42001    5        1        N TBA    gbasedbt                         tmpdbs1                                                                                                                         
6        42001    6        1        N TBA    gbasedbt                         tmpdbs2                                                                                                                         
7        42001    7        1        N TBA    gbasedbt                         tmpdbs3                                                                                                                         
8        40001    8        1        N  BA    gbasedbt                         datadbs1                                                                                                                        
9        40001    9        1        N  BA    gbasedbt                         datadbs2                                                                                                                        
10       40001    10       1        N  BA    gbasedbt                         datadbs3                                                                                                                        
11       40001    11       1        N  BA    gbasedbt                         datadbs4                                                                                                                        
12       40001    12       1        N  BA    gbasedbt                         datadbs5                                                                                                                        


Chunks
chk/dbs offset   size     free     bpages   flags pathname
1   1   0        102400   89290             PO-B- /opt/gbase/gbaseserver_dbs/rootdbs
2   2   0        102400   2347              PO-B- /opt/gbase/gbaseserver_dbs/llogdbs
3   3   0        102400   2947              PO-B- /opt/gbase/gbaseserver_dbs/plogdbs
4   4   0        51200    2581              POSB- /opt/gbase/gbaseserver_dbs/sbspace1
5   5   0        51200    50712             PO-B- /opt/gbase/gbaseserver_dbs/tmpdbs1
6   6   0        51200    50776             PO-B- /opt/gbase/gbaseserver_dbs/tmpdbs2
7   7   0        51200    50776             PO-B- /opt/gbase/gbaseserver_dbs/tmpdbs3
8   8   0        51200    41768             PO-BE /opt/gbase/gbaseserver_dbs/datadbs1_1
9   9   0        51200    50376             PO-BE /opt/gbase/gbaseserver_dbs/datadbs2_1
10  10  0        51200    50376             PO-BE /opt/gbase/gbaseserver_dbs/datadbs3_1
11  11  0        51200    50776             PO-BE /opt/gbase/gbaseserver_dbs/datadbs4_1
12  12  0        51200    50776             PO-BE /opt/gbase/gbaseserver_dbs/datadbs5_1

Continue restore? (y/n)y                       --##### 输入y #####--
Do you want to back up the logs? (y/n)y        --##### 输入y #####--
No log files to salvage. Logs 33 - 33 already exists in directory /home/gbasedbt/backup/
Log salvage is complete, continuing restore of archive.
Your evaluation license will expire on 2022-06-18 00:00:00
Restore a level 1 archive (y/n) y              --##### 输入y #####--
Ready for level 1 tape 
Restore will use level 1 archive file /home/gbasedbt/backup/devsvr_120_L1. Press Return to continue ...


Archive Tape Information

Tape type:      Archive Backup Tape 
Online version: GBase Database Server Version 12.10.FC4G1TL 
Archive date:   Sat Jul 24 10:17:11 2021 
User id:        gbasedbt 
Terminal id:    /dev/pts/0 
Archive level:  1 
Tape device:    /home/gbasedbt/backup/ 
Tape blocksize (in k): 32 
Tape size (in k): system defined for directory 
Tape number in series: 1 
Restore a level 2 archive (y/n) y             --##### 输入y #####--
Ready for level 2 tape 
Restore will use level 2 archive file /home/gbasedbt/backup/devsvr_120_L2. Press Return to continue ...


Archive Tape Information

Tape type:      Archive Backup Tape 
Online version: GBase Database Server Version 12.10.FC4G1TL 
Archive date:   Sat Jul 24 10:20:04 2021 
User id:        gbasedbt 
Terminal id:    /dev/pts/0 
Archive level:  2 
Tape device:    /home/gbasedbt/backup/ 
Tape blocksize (in k): 32 
Tape size (in k): system defined for directory 
Tape number in series: 1 

Program over.
[gbasedbt@devsvr ~]$ 

查看L2级物理恢复后,被删除表的恢复情况

[gbasedbt@devsvr ~]$ onstat -
Your evaluation license will expire on 2022-06-18 00:00:00
Fast Recovery -- Up 00:01:02 -- 597864 Kbytes

[gbasedbt@devsvr ~]$ onmode -m
Your evaluation license will expire on 2022-06-18 00:00:00
[gbasedbt@devsvr ~]$ onstat -
Your evaluation license will expire on 2022-06-18 00:00:00
On-Line -- Up 00:01:14 -- 597864 Kbytes

[gbasedbt@devsvr ~]$ echo "select * from t_employee" | dbaccess mydb
Your evaluation license will expire on 2022-06-18 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_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.



Database closed.

[gbasedbt@devsvr ~]$ 

——5.2.24 L2级物理恢复+部分逻辑恢复

查看备份设备中的逻辑日志情况,根据实际情况,尝试移除最近的几个逻辑日志。本次演示,移除了最后2个逻辑日志。

[gbasedbt@devsvr ~]$ cd backup/
[gbasedbt@devsvr backup]$ ll
total 116928
-rw-rw----. 1 gbasedbt gbasedbt  6750208 Jul 24 10:14 devsvr_120_20210724_101445_L1
-rw-rw----. 1 gbasedbt gbasedbt  6356992 Jul 24 10:48 devsvr_120_20210724_104845_Log0000000033
-rw-rw----. 1 gbasedbt gbasedbt    98304 Jul 24 10:48 devsvr_120_20210724_104857_Log0000000034
-rw-rw----. 1 gbasedbt gbasedbt 44630016 Jul 24 10:08 devsvr_120_L0
-rw-rw----. 1 gbasedbt gbasedbt  6750208 Jul 24 10:17 devsvr_120_L1
-rw-rw----. 1 gbasedbt gbasedbt  6750208 Jul 24 10:20 devsvr_120_L2
-rw-rw----. 1 gbasedbt gbasedbt   131072 Jul 24 10:57 devsvr_120_Log0000000024
-rw-rw----. 1 gbasedbt gbasedbt    98304 Jul 24 10:57 devsvr_120_Log0000000025
-rw-rw----. 1 gbasedbt gbasedbt    98304 Jul 24 10:57 devsvr_120_Log0000000026
-rw-rw----. 1 gbasedbt gbasedbt    98304 Jul 24 10:57 devsvr_120_Log0000000027
-rw-rw----. 1 gbasedbt gbasedbt    98304 Jul 24 10:57 devsvr_120_Log0000000028
-rw-rw----. 1 gbasedbt gbasedbt 10321920 Jul 24 10:57 devsvr_120_Log0000000029
-rw-rw----. 1 gbasedbt gbasedbt 10321920 Jul 24 10:57 devsvr_120_Log0000000030
-rw-rw----. 1 gbasedbt gbasedbt 10321920 Jul 24 10:57 devsvr_120_Log0000000031
-rw-rw----. 1 gbasedbt gbasedbt 10321920 Jul 24 10:57 devsvr_120_Log0000000032
-rw-rw----. 1 gbasedbt gbasedbt  6356992 Jul 24 10:57 devsvr_120_Log0000000033
-rw-rw----. 1 gbasedbt gbasedbt    98304 Jul 24 10:57 devsvr_120_Log0000000034
-rw-rw----. 1 gbasedbt gbasedbt   131072 Jul 24 11:56 devsvr_120_Log0000000035
[gbasedbt@devsvr backup]$ mkdir tmp
[gbasedbt@devsvr backup]$ mv devsvr_120_Log0000000034 devsvr_120_Log0000000035 tmp        -- ##### 移除两个逻辑日志文件 #####--
[gbasedbt@devsvr backup]$ ll
total 116704
-rw-rw----. 1 gbasedbt gbasedbt  6750208 Jul 24 10:14 devsvr_120_20210724_101445_L1
-rw-rw----. 1 gbasedbt gbasedbt  6356992 Jul 24 10:48 devsvr_120_20210724_104845_Log0000000033
-rw-rw----. 1 gbasedbt gbasedbt    98304 Jul 24 10:48 devsvr_120_20210724_104857_Log0000000034
-rw-rw----. 1 gbasedbt gbasedbt 44630016 Jul 24 10:08 devsvr_120_L0
-rw-rw----. 1 gbasedbt gbasedbt  6750208 Jul 24 10:17 devsvr_120_L1
-rw-rw----. 1 gbasedbt gbasedbt  6750208 Jul 24 10:20 devsvr_120_L2
-rw-rw----. 1 gbasedbt gbasedbt   131072 Jul 24 10:57 devsvr_120_Log0000000024
-rw-rw----. 1 gbasedbt gbasedbt    98304 Jul 24 10:57 devsvr_120_Log0000000025
-rw-rw----. 1 gbasedbt gbasedbt    98304 Jul 24 10:57 devsvr_120_Log0000000026
-rw-rw----. 1 gbasedbt gbasedbt    98304 Jul 24 10:57 devsvr_120_Log0000000027
-rw-rw----. 1 gbasedbt gbasedbt    98304 Jul 24 10:57 devsvr_120_Log0000000028
-rw-rw----. 1 gbasedbt gbasedbt 10321920 Jul 24 10:57 devsvr_120_Log0000000029
-rw-rw----. 1 gbasedbt gbasedbt 10321920 Jul 24 10:57 devsvr_120_Log0000000030
-rw-rw----. 1 gbasedbt gbasedbt 10321920 Jul 24 10:57 devsvr_120_Log0000000031
-rw-rw----. 1 gbasedbt gbasedbt 10321920 Jul 24 10:57 devsvr_120_Log0000000032
-rw-rw----. 1 gbasedbt gbasedbt  6356992 Jul 24 10:57 devsvr_120_Log0000000033
drwxrwxr-x. 2 gbasedbt gbasedbt       70 Jul 24 12:08 tmp
[gbasedbt@devsvr backup]$ 

进行完全恢复。

说明:虽然操作的是完全恢复,但因我们移除了部分最新的逻辑日志,实际上执行的结果是不完全恢复。

[gbasedbt@devsvr backup]$ onmode -ky
Your evaluation license will expire on 2022-06-18 00:00:00
[gbasedbt@devsvr backup]$ ontape -r
Your evaluation license will expire on 2022-06-18 00:00:00
Restore will use level 0 archive file /home/gbasedbt/backup/devsvr_120_L0. Press Return to continue ...


Archive Tape Information

Tape type:      Archive Backup Tape 
Online version: GBase Database Server Version 12.10.FC4G1TL 
Archive date:   Sat Jul 24 10:08:47 2021 
User id:        gbasedbt 
Terminal id:    /dev/pts/0 
Archive level:  0 
Tape device:    /home/gbasedbt/backup/ 
Tape blocksize (in k): 32 
Tape size (in k): system defined for directory 
Tape number in series: 1 

Spaces to restore:1 [rootdbs                                                                                                                         ] 
2 [llogdbs                                                                                                                         ] 
3 [plogdbs                                                                                                                         ] 
4 [datadbs1                                                                                                                        ] 
5 [datadbs2                                                                                                                        ] 
6 [datadbs3                                                                                                                        ] 
7 [datadbs4                                                                                                                        ] 
8 [datadbs5                                                                                                                        ] 
9 [sbspace1                                                                                                                        ] 

Archive Information

GBase Database Server Copyright 2001, 2021  General Data Corporation
Initialization Time       06/18/2021 17:36:36
System Page Size          2048
Version                   32
Index Page Logging        OFF
Archive CheckPoint Time   07/24/2021 10:08:47

Dbspaces
number   flags    fchunk   nchunks  flags    owner                            name
1        40001    1        1        N  BA    gbasedbt                         rootdbs                                                                                                                         
2        40001    2        1        N  BA    gbasedbt                         llogdbs                                                                                                                         
3        40001    3        1        N  BA    gbasedbt                         plogdbs                                                                                                                         
4        48001    4        1        N SBA    gbasedbt                         sbspace1                                                                                                                        
5        42001    5        1        N TBA    gbasedbt                         tmpdbs1                                                                                                                         
6        42001    6        1        N TBA    gbasedbt                         tmpdbs2                                                                                                                         
7        42001    7        1        N TBA    gbasedbt                         tmpdbs3                                                                                                                         
8        40001    8        1        N  BA    gbasedbt                         datadbs1                                                                                                                        
9        40001    9        1        N  BA    gbasedbt                         datadbs2                                                                                                                        
10       40001    10       1        N  BA    gbasedbt                         datadbs3                                                                                                                        
11       40001    11       1        N  BA    gbasedbt                         datadbs4                                                                                                                        
12       40001    12       1        N  BA    gbasedbt                         datadbs5                                                                                                                        


Chunks
chk/dbs offset   size     free     bpages   flags pathname
1   1   0        102400   89290             PO-B- /opt/gbase/gbaseserver_dbs/rootdbs
2   2   0        102400   2347              PO-B- /opt/gbase/gbaseserver_dbs/llogdbs
3   3   0        102400   2947              PO-B- /opt/gbase/gbaseserver_dbs/plogdbs
4   4   0        51200    2581              POSB- /opt/gbase/gbaseserver_dbs/sbspace1
5   5   0        51200    50712             PO-B- /opt/gbase/gbaseserver_dbs/tmpdbs1
6   6   0        51200    50776             PO-B- /opt/gbase/gbaseserver_dbs/tmpdbs2
7   7   0        51200    50776             PO-B- /opt/gbase/gbaseserver_dbs/tmpdbs3
8   8   0        51200    41768             PO-BE /opt/gbase/gbaseserver_dbs/datadbs1_1
9   9   0        51200    50376             PO-BE /opt/gbase/gbaseserver_dbs/datadbs2_1
10  10  0        51200    50376             PO-BE /opt/gbase/gbaseserver_dbs/datadbs3_1
11  11  0        51200    50776             PO-BE /opt/gbase/gbaseserver_dbs/datadbs4_1
12  12  0        51200    50776             PO-BE /opt/gbase/gbaseserver_dbs/datadbs5_1

Continue restore? (y/n)y                        --##### 输入y #####--
Do you want to back up the logs? (y/n)n         --##### 输入n,避免将移除的日志再次抢救到备份目录中 #####--
Your evaluation license will expire on 2022-06-18 00:00:00
Restore a level 1 archive (y/n) y                --##### 输入y #####--
Ready for level 1 tape 
Restore will use level 1 archive file /home/gbasedbt/backup/devsvr_120_L1. Press Return to continue ...


Archive Tape Information

Tape type:      Archive Backup Tape 
Online version: GBase Database Server Version 12.10.FC4G1TL 
Archive date:   Sat Jul 24 10:17:11 2021 
User id:        gbasedbt 
Terminal id:    /dev/pts/0 
Archive level:  1 
Tape device:    /home/gbasedbt/backup/ 
Tape blocksize (in k): 32 
Tape size (in k): system defined for directory 
Tape number in series: 1 
Restore a level 2 archive (y/n) y                --##### 输入y #####--
Ready for level 2 tape 
Restore will use level 2 archive file /home/gbasedbt/backup/devsvr_120_L2. Press Return to continue ...


Archive Tape Information

Tape type:      Archive Backup Tape 
Online version: GBase Database Server Version 12.10.FC4G1TL 
Archive date:   Sat Jul 24 10:20:04 2021 
User id:        gbasedbt 
Terminal id:    /dev/pts/0 
Archive level:  2 
Tape device:    /home/gbasedbt/backup/ 
Tape blocksize (in k): 32 
Tape size (in k): system defined for directory 
Tape number in series: 1 
Do you want to restore log tapes? (y/n)y        --##### 输入y,实现逻辑日志的恢复 #####--

Roll forward should start with log number 33
Restore will use log backup file /home/gbasedbt/backup/devsvr_120_Log0000000033. Press Return to continue ...

Rollforward log file /home/gbasedbt/backup/devsvr_120_Log0000000033 ...

Program over.
[gbasedbt@devsvr backup]$ 

查看L2级物理恢复+部分逻辑恢复后,被删除表的恢复情况

[gbasedbt@devsvr backup]$ onstat -
Your evaluation license will expire on 2022-06-18 00:00:00
Quiescent -- Up 00:02:36 -- 1135464 Kbytes

[gbasedbt@devsvr backup]$ onmode -m
Your evaluation license will expire on 2022-06-18 00:00:00
[gbasedbt@devsvr backup]$ onstat -
Your evaluation license will expire on 2022-06-18 00:00:00
On-Line -- Up 00:02:44 -- 1135464 Kbytes

[gbasedbt@devsvr backup]$ echo "select * from t_employee" | dbaccess mydb
Your evaluation license will expire on 2022-06-18 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_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.



Database closed.

[gbasedbt@devsvr backup]$ 

虽然此处恢复的数据仍然是11行,但L2备份后,被更新的记录被恢复成功。

赞(0)
MySQL学习笔记 » 第10章:基于ontape的备份与恢复