本次所说的数据恢复有异于数据的导入导出
gbase8s数据库提供了两种工具进行完成系统物理备份、逻辑日志备份和系统恢复:ontape和onbar
备份会涉及到物理日志和逻辑日志的备份,关于这两个文件的参数如下:
gbase8s的系统备份有三个不同的级别:
当使用simple binary-large-object简答大对象数据空间时,需要考虑日志
智能大对象的备份分为两部分:元数据和智能大对象子系统
为了保证数据的安全,当进行数据恢复时,需要用到一些配置信息,需要和备份时的参数信息一致
场景
场景的恢复使用
- --备份物理日志
- ontap -s -L 0
- --备份逻辑日志,会提示是否保留当前日志
- ontape -a
冷恢复全部文件
- #在datadbs5创建test1数据库,创建test1表,插入id=3的数据
- > create database test1 in datadbs5 with log;
- Database closed.
- Database created.
- > create table test1(id int);
- Table created.
- > insert into test1 values(1);
- 1 row(s) inserted.
- >
- [gbasedbt@VM-8-4-centos ~]$ ontape -s
- Your evaluation license will expire on 2024-11-02 00:00:00
- Please enter the level of archive to be performed (0, 1, or 2) 0
- 100 percent done.
- File created: /home/gbasedbt/gbase/backup/phy/VM-8-4-centos_1_L0
- Please label this tape as number 1 in the arc tape sequence.
- This tape contains the following logical logs:
- 59
- Program over.
- [gbasedbt@VM-8-4-centos ~]$ ontape -a
- Your evaluation license will expire on 2024-11-02 00:00:00
- Performing automatic backup of logical logs.
- Do you want to back up the current logical log? (y/n) y
- File created: /home/gbasedbt/gbase/backup/log/VM-8-4-centos_1_Log0000000059
- Program over.
- [gbasedbt@VM-8-4-centos chunks]$ rm -rf datachk5
- [gbasedbt@VM-8-4-centos chunks]$ touch datachk5
- [gbasedbt@VM-8-4-centos chunks]$ ontape -r
- Your evaluation license will expire on 2024-11-02 00:00:00
- Restore will use level 0 archive file /home/gbasedbt/gbase/backup/phy/VM-8-4-centos_1_L0. Press Return to continue ...
- #是否继续还原
- Continue restore? (y/n)y
- #是否备份当前的遗留在线日志
- Do you want to back up the logs? (y/n)n
- Your evaluation license will expire on 2024-11-02 00:00:00
- #是否进行一级备份文件还原,没有一级备份,不需要
- Restore a level 1 archive (y/n) Restore a level 1 archive (y/n)
- #是否还原逻辑日志
- Do you want to restore log tapes? (y/n)y
- #还原之后将会处于静态模式,使用onmode -m进行还原
-
热恢复指定文件
- [gbasedbt@VM-8-4-centos chunks]$ dbaccess test1 -
- Your evaluation license will expire on 2024-11-02 00:00:00
- Database selected.
- > select * from test1;
- id
- 1
- 1 row(s) retrieved.
- > drop table test1;
- Table dropped.
- [gbasedbt@VM-8-4-centos chunks]$ ontape -r -D datadbs5
- Your evaluation license will expire on 2024-11-02 00:00:00
- DBspace 'datadbs5' is online; restoring 'datadbs5' will bring all chunks
- comprising the DBspace OFFLINE and will terminate all active
- transactions and queries accessing the DBspace.
- #是否将数据库置为离线状态进行还原
- OK to continue?y
- Restore will use level 0 archive file /home/gbasedbt/gbase/backup/phy/VM-8-4-centos_1_L0. Press Return to continue ...
- Archive Tape Information
- Tape type: Archive Backup Tape
- Online version: GBase Database Server Version 12.10.FC4G1TL
- Archive date: Sun Dec 24 16:23:39 2023
- User id: gbasedbt
- Terminal id: /dev/pts/1
- Archive level: 0
- Tape device: /home/gbasedbt/gbase/backup/phy/
- 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 [datadbs5 ]
- #是否需要还原一级备份
- Restore a level 1 archive (y/n) Restore a level 1 archive (y/n) n、
- #是否需要还原逻辑日志
- Do you want to restore log tapes? (y/n)y
- Roll forward should start with log number 59
- Restore will use log backup file /home/gbasedbt/gbase/backup/log/VM-8-4-centos_1_Log0000000059. Press Return to continue ...
- Rollforward log file /home/gbasedbt/gbase/backup/log/VM-8-4-centos_1_Log0000000059 ...
- Rollforward log file /home/gbasedbt/gbase/backup/log/VM-8-4-centos_1_Log0000000060 ...
- Rollforward log file /home/gbasedbt/gbase/backup/log/VM-8-4-centos_1_Log0000000061 ...
- Recommendation: continue the warm restore until log 62 is replayed.
- The last log that has been restored is: 61. If you want to stop the
- restore at this log, choose commit, otherwise, choose suspend.
- If you have not performed a backup that includes the log 62,
- perform a backup using the ontape -a command. Continue the suspended
- log restore using the ontape -l command.
- #选择y是还原当前日志信息中的操作,n是不还原当前日志中的操作
- Do you want to suspend (y), commit (n) or abort (CTRL/C) logical restore?
- n
- [gbasedbt@VM-8-4-centos chunks]$ dbaccess test1 -
- Your evaluation license will expire on 2024-11-02 00:00:00
-
- Database selected.
-
- > select * from test1;
-
-
- id
-
- 1
-
- 1 row(s) retrieved.
-
- >
- --查看信息
- [gbasedbt@iZ2ze5s78e4tanwe5q2znxZ ~]$ onstat -g dis
- Your evaluation license will expire on 2025-05-26 00:00:00
- On-Line -- Up 00:02:32 -- 258344 Kbytes
- There are 2 servers found
- Server : node1
- Server Number : 1
- Server Type : IDS
- Server Status : Up
- Server Version: GBase Database Server Version 12.10.FC4G1TL
- Shared Memory : 0x44000000
- GBASEDBTDIR : /home/gbasedbt/gbase
- ONCONFIG : /home/gbasedbt/gbase/etc/onconfig.node1
- SQLHOSTS : /home/gbasedbt/gbase/etc/sqlhosts.node1
- Host : iZ2ze5s78e4tanwe5q2znxZ
- --如上可知onconfig文件位置在/home/gbasedbt/gbase/etc/onconfig.node1
- --更改步骤不进行描述,更改结果如下
- [gbasedbt@iZ2ze5s78e4tanwe5q2znxZ ~]$ cat gbase/etc/onconfig.node1 |grep -iE '^TAPEDEV|^LTAPEDEV'
- TAPEDEV /home/gbasedbt/BACKUP/BACK
- LTAPEDEV /home/gbasedbt/BACKUP/LOGICAL
- --按照参数值创建文件
- mkdir /home/gbasedbt/BACKUP/BACK
- mkdir /home/gbasedbt/BACKUP/LOGICAL
- chmod 777 /home/gbasedbt/BACKUP
- --重启数据库使参数值生效,生效结果如下
- [gbasedbt@iZ2ze5s78e4tanwe5q2znxZ ~]$ onstat -g cfg|grep EDEV
- Your evaluation license will expire on 2025-05-26 00:00:00
- TAPEDEV /home/gbasedbt/BACKUP/BACK
- LTAPEDEV /home/gbasedbt/BACKUP/LOGICAL
- --系统备份
- [gbasedbt@iZ2ze5s78e4tanwe5q2znxZ ~]$ ontape -s -L 0
- Your evaluation license will expire on 2025-05-26 00:00:00
- 100 percent done.
- File created: /home/gbasedbt/BACKUP/BACK/iZ2ze5s78e4tanwe5q2znxZ_1_L0
-
- Please label this tape as number 1 in the arc tape sequence.
- This tape contains the following logical logs:
-
- 26
-
- Program over.
- --逻辑备份
- [gbasedbt@iZ2ze5s78e4tanwe5q2znxZ ~]$ ontape -a
- Your evaluation license will expire on 2025-05-26 00:00:00
-
- Performing automatic backup of logical logs.
-
- Do you want to back up the current logical log? (y/n) y
- File created: /home/gbasedbt/BACKUP/LOGICAL/iZ2ze5s78e4tanwe5q2znxZ_1_Log0000000026
-
- Program over.
- --查看当前的数据空间
- [gbasedbt@iZ2ze5s78e4tanwe5q2znxZ ~]$ onstat -d
- Your evaluation license will expire on 2025-05-26 00:00:00
- On-Line -- Up 00:00:52 -- 250152 Kbytes
-
- Dbspaces
- address number flags fchunk nchunks pgsize flags owner name
- 452a5028 1 0x70001 1 2 2048 N BA gbasedbt rootdbs
- 453bd308 2 0x60001 2 1 2048 N BA gbasedbt llogdbs
- 453bd538 3 0x1070001 3 1 2048 N PBA gbasedbt plogdbs
- 453bd768 4 0x60001 4 2 16384 N BA gbasedbt datadbs1
- 453bd998 5 0x42001 5 1 16384 N TBA gbasedbt tempdbs1
- 453bdbc8 6 0x60011 6 1 32768 N BBA gbasedbt bindbs
- 453bddf8 7 0x68001 7 1 2048 N SBA gbasedbt sbdbs
- 52c7c028 8 0x60001 8 1 16384 N BA gbasedbt datadbs2
- 8 active, 2047 maximum
-
- Note: For BLOB chunks, the number of free pages shown is out of date.
- Run 'onstat -d update' for current stats.
-
- Chunks
- address chunk/dbs offset size free bpages flags pathname
- 452a5258 1 1 0 100000 80759 PO-B-- /home/gbasedbt/gbase/node1_dbs/rootdbs
- 52c7c258 2 2 0 1024000 123947 PO-B-- /home/gbasedbt/gbase/node1_dbs/llogdbs
- 52c7d028 3 3 0 1024000 0 PO-BE- /home/gbasedbt/gbase/node1_dbs/plogdbs
- 52c7e028 4 4 0 128000 125489 PO-B-- /home/gbasedbt/gbase/node1_dbs/datadbs1
- 52c7f028 5 5 0 128000 127947 PO-B-- /home/gbasedbt/gbase/node1_dbs/tempdbs1
- 52c80028 6 6 0 1024000 ~64000 64000 POBB-- /home/gbasedbt/gbase/node1_dbs/bindbs
- 52c81028 7 7 0 1024000 955003 955004 POSB-- /home/gbasedbt/gbase/node1_dbs/sbdbs
- Metadata 68943 51302 68943
- 52c82028 8 8 0 18750 17551 PO-B-- /home/gbasedbt/gbase/node1_dbs/datadbs2
- 52c83028 9 1 0 50000 36971 PO-B-- /home/gbasedbt/gbase/node1_dbs/rootchk2
- 52c84028 10 4 0 250000 249997 PO-B-- /home/gbasedbt/gbase/node1_dbs/datadbs1_2
- 10 active, 32766 maximum
-
- NOTE: The values in the "size" and "free" columns for DBspace chunks are
- displayed in terms of "pgsize" of the DBspace to which they belong.
-
-
- Expanded chunk capacity mode: always
- [gbasedbt@iZ2ze5s78e4tanwe5q2znxZ ~]$ dbaccess test -
- Your evaluation license will expire on 2025-05-26 00:00:00
-
- Database selected.
-
- > create database test3 in datadbs2 with log;
- Database closed.
- Database created.
- Elapsed time: 0.535 sec
- > create table test(id int);
- Table created.
- Elapsed time: 0.002 sec
- > insert into test values(1),(3),(10),(11),(11),(11),(11),(11),(11);
- 9 row(s) inserted.
- > select * from test;
- id
- 1
- 3
- 10
- 11
- 11
- 11
- 11
- 11
- 11
- 9 row(s) retrieved.
- Elapsed time: 0.032 sec
-
- [gbasedbt@iZ2ze5s78e4tanwe5q2znxZ node1_dbs]$ ls -l
- total 16888028
- -rw-rw---- 1 gbasedbt gbasedbt 2097152000 Jun 20 21:06 bindbs
- -rw-rw---- 1 gbasedbt gbasedbt 2097152000 Jun 20 21:06 datadbs1
- -rw-rw---- 1 gbasedbt gbasedbt 4096000000 Jun 20 21:06 datadbs1_2
- -rw-rw---- 1 gbasedbt gbasedbt 307200000 Jun 20 21:06 datadbs2
- -rw-rw---- 1 gbasedbt gbasedbt 2097152000 Jun 20 21:06 llogdbs
- -rw-rw-r-- 1 gbasedbt gbasedbt 0 Jun 17 13:42 plog2
- -rw-rw---- 1 gbasedbt gbasedbt 2097152000 Jun 20 21:06 plogdbs
- -rw-rw---- 1 gbasedbt gbasedbt 102400000 Jun 20 21:06 rootchk2
- -rw-rw---- 1 gbasedbt gbasedbt 204800000 Jun 20 21:06 rootdbs
- -rw-rw---- 1 gbasedbt gbasedbt 2097152000 Jun 20 21:06 sbdbs
- -rw-rw---- 1 gbasedbt gbasedbt 2097152000 Jun 20 21:06 tempdbs1
-
-
- [gbasedbt@iZ2ze5s78e4tanwe5q2znxZ node1_dbs]$ mkdir test
- [gbasedbt@iZ2ze5s78e4tanwe5q2znxZ node1_dbs]$ cp root* datadbs2 test/
-
-
- [gbasedbt@iZ2ze5s78e4tanwe5q2znxZ node1_dbs]$ ls -l test/
- total 600004
- -rw-rw---- 1 gbasedbt gbasedbt 307200000 Jun 20 21:06 datadbs2
- -rw-rw---- 1 gbasedbt gbasedbt 102400000 Jun 20 21:06 rootchk2
- -rw-rw---- 1 gbasedbt gbasedbt 204800000 Jun 20 21:06 rootdbs
- --取消阻塞
- [gbasedbt@iZ2ze5s78e4tanwe5q2znxZ node1_dbs]$ onmode -c unblock
- Your evaluation license will expire on 2025-05-26 00:00:00
- --插入两条数据
- [gbasedbt@iZ2ze5s78e4tanwe5q2znxZ node1_dbs]$ dbaccess test3 -
- Your evaluation license will expire on 2025-05-26 00:00:00
- Database selected.
- > select * from test;
- id
- 1
- 3
- 10
- 11
- 11
- 11
- 11
- 11
- 11
- 9 row(s) retrieved.
- Elapsed time: 0.001 sec
- > insert into test values(12);
- 1 row(s) inserted.
- Elapsed time: 0.002 sec
- > insert into test values(13);
- 1 row(s) inserted.
- Elapsed time: 0.002 sec
- --切换日志和检查点
- [gbasedbt@iZ2ze5s78e4tanwe5q2znxZ node1_dbs]$ onmode -l
- Your evaluation license will expire on 2025-05-26 00:00:00
- [gbasedbt@iZ2ze5s78e4tanwe5q2znxZ node1_dbs]$ onmode -c
- Your evaluation license will expire on 2025-05-26 00:00:00
-
- --插入第二批数据
- [gbasedbt@iZ2ze5s78e4tanwe5q2znxZ node1_dbs]$ dbaccess test3 -
- Your evaluation license will expire on 2025-05-26 00:00:00
- Database selected.
- > insert into test values(23);
- 1 row(s) inserted.
- Elapsed time: 0.001 sec
- > insert into test values(24);
- 1 row(s) inserted.
- Elapsed time: 0.004 sec
-
- --再次进行切换日志和检查点
- [gbasedbt@iZ2ze5s78e4tanwe5q2znxZ node1_dbs]$ onmode -c
- Your evaluation license will expire on 2025-05-26 00:00:00
- [gbasedbt@iZ2ze5s78e4tanwe5q2znxZ node1_dbs]$ onmode -l
- Your evaluation license will expire on 2025-05-26 00:00:00
- [gbasedbt@iZ2ze5s78e4tanwe5q2znxZ node1_dbs]$ onmode -c
- Your evaluation license will expire on 2025-05-26 00:00:00
-
- [gbasedbt@iZ2ze5s78e4tanwe5q2znxZ node1_dbs]$ onclean -ky
- Your evaluation license will expire on 2025-05-26 00:00:00
- onclean: Cleaning up processes and resources for 'node1'...
- - Looking for the master daemon process: 1527798
- - Looking for the shmem key: 52574803
- - Looking for the shmem key: 52574804
- - Looking for semaphore ID: 131118
- - Looking for the shmem key: 52574801
- - Looking for the shmem key: 52574802
- - Looking for the shmem key: 52574805
- - Looking for the shmem key: 52574806
- - Looking for the shmem key: 52574807
-
-
- [gbasedbt@iZ2ze5s78e4tanwe5q2znxZ node1_dbs]$ rm -rf rootdbs rootchk2 datadbs2
- [gbasedbt@iZ2ze5s78e4tanwe5q2znxZ node1_dbs]$ cp test/* ./
-
-
-
- [gbasedbt@iZ2ze5s78e4tanwe5q2znxZ node1_dbs]$ ls -l
- total 16888032
- -rw-rw---- 1 gbasedbt gbasedbt 2097152000 Jun 20 21:06 bindbs
- -rw-rw---- 1 gbasedbt gbasedbt 2097152000 Jun 20 21:06 datadbs1
- -rw-rw---- 1 gbasedbt gbasedbt 4096000000 Jun 20 21:06 datadbs1_2
- -rw-rw---- 1 gbasedbt gbasedbt 307200000 Jun 20 21:08 datadbs2
- -rw-rw---- 1 gbasedbt gbasedbt 2097152000 Jun 20 21:07 llogdbs
- -rw-rw-r-- 1 gbasedbt gbasedbt 0 Jun 17 13:42 plog2
- -rw-rw---- 1 gbasedbt gbasedbt 2097152000 Jun 20 21:07 plogdbs
- -rw-rw---- 1 gbasedbt gbasedbt 102400000 Jun 20 21:08 rootchk2
- -rw-rw---- 1 gbasedbt gbasedbt 204800000 Jun 20 21:08 rootdbs
- -rw-rw---- 1 gbasedbt gbasedbt 2097152000 Jun 20 21:06 sbdbs
- -rw-rw---- 1 gbasedbt gbasedbt 2097152000 Jun 20 21:06 tempdbs1
- drwxrwxr-x 2 gbasedbt gbasedbt 4096 Jun 20 21:06 test
- [gbasedbt@iZ2ze5s78e4tanwe5q2znxZ node1_dbs]$ ontape -S
- Your evaluation license will expire on 2025-05-26 00:00:00
- Do you want to back up the logs? (y/n)y
- File created: /home/gbasedbt/BACKUP/LOGICAL/iZ2ze5s78e4tanwe5q2znxZ_1_Log0000000029
- File created: /home/gbasedbt/BACKUP/LOGICAL/iZ2ze5s78e4tanwe5q2znxZ_1_Log0000000030
-
- Program over.
- [gbasedbt@iZ2ze5s78e4tanwe5q2znxZ node1_dbs]$ ontape -p -e
- Your evaluation license will expire on 2025-05-26 00:00:00
- Your evaluation license will expire on 2025-05-26 00:00:00
- External restore failed.
- External restore of critical dbspace 'llogdbs' failed.
- External restore cannot continue.
- Program over.
-
-
- [gbasedbt@iZ2ze5s78e4tanwe5q2znxZ node1_dbs]$ ontape -l
- Your evaluation license will expire on 2025-05-26 00:00:00
- Logical restore failed
- rootdbs which is the ROOT DBspace
- is being restored and llogdbs has not been physically restored.
- If the ROOT DBspace or a DBspace containing the physical log or a logical
- log file is restored, then the ROOT DBspace and all DBspaces containing
- a logical log file or physical log file must be physically restored.
- Program over.
-
-
- [gbasedbt@iZ2ze5s78e4tanwe5q2znxZ node1_dbs]$ onstat -
- Your evaluation license will expire on 2025-05-26 00:00:00
- Fast Recovery -- Up 00:00:23 -- 250152 Kbytes
-
- [gbasedbt@iZ2ze5s78e4tanwe5q2znxZ node1_dbs]$ onclean -ky
- Your evaluation license will expire on 2025-05-26 00:00:00
- onclean: Cleaning up processes and resources for 'node1'...
- - Looking for the master daemon process: 1529353
- - Looking for the shmem key: 52574803
- - Looking for the shmem key: 52574804
- - Looking for semaphore ID: 163846
- - Looking for the shmem key: 52574801
- - Looking for the shmem key: 52574802
- - Looking for the shmem key: 52574805
- - Looking for the shmem key: 52574806
- [gbasedbt@iZ2ze5s78e4tanwe5q2znxZ node1_dbs]$ oninit -vy
-
- [gbasedbt@iZ2ze5s78e4tanwe5q2znxZ node1_dbs]$ onstat -d
- Your evaluation license will expire on 2025-05-26 00:00:00
- On-Line -- Up 00:16:14 -- 258344 Kbytes
-
- Dbspaces
- address number flags fchunk nchunks pgsize flags owner name
- 452a5028 1 0x40001 1 2 2048 N BA gbasedbt rootdbs
- 453bd308 2 0x40001 2 1 2048 N BA gbasedbt llogdbs
- 453bd538 3 0x1040001 3 1 2048 N PBA gbasedbt plogdbs
- 453bd768 4 0x40001 4 2 16384 N BA gbasedbt datadbs1
- 453bd998 5 0x42001 5 1 16384 N TBA gbasedbt tempdbs1
- 453bdbc8 6 0x40011 6 1 32768 N BBA gbasedbt bindbs
- 453bddf8 7 0x48001 7 1 2048 N SBA gbasedbt sbdbs
- 52c7c028 8 0x40001 8 1 16384 N BA gbasedbt datadbs2
- 8 active, 2047 maximum
-
- Note: For BLOB chunks, the number of free pages shown is out of date.
- Run 'onstat -d update' for current stats.
-
- Chunks
- address chunk/dbs offset size free bpages flags pathname
- 452a5258 1 1 0 100000 80759 PO-B-- /home/gbasedbt/gbase/node1_dbs/rootdbs
- 52c7c258 2 2 0 1024000 123947 PO-B-- /home/gbasedbt/gbase/node1_dbs/llogdbs
- 52c7d028 3 3 0 1024000 0 PO-BE- /home/gbasedbt/gbase/node1_dbs/plogdbs
- 52c7e028 4 4 0 128000 125489 PO-B-- /home/gbasedbt/gbase/node1_dbs/datadbs1
- 52c7f028 5 5 0 128000 127947 PO-B-- /home/gbasedbt/gbase/node1_dbs/tempdbs1
- 52c80028 6 6 0 1024000 ~63984 64000 POBB-- /home/gbasedbt/gbase/node1_dbs/bindbs
- 52c81028 7 7 0 1024000 955003 955004 POSB-- /home/gbasedbt/gbase/node1_dbs/sbdbs
- Metadata 68943 51302 68943
- 52c82028 8 8 0 18750 17551 PO-B-- /home/gbasedbt/gbase/node1_dbs/datadbs2
- 52c83028 9 1 0 50000 36955 PO-B-- /home/gbasedbt/gbase/node1_dbs/rootchk2
- 52c84028 10 4 0 250000 249997 PO-B-- /home/gbasedbt/gbase/node1_dbs/datadbs1_2
- 10 active, 32766 maximum
-
- NOTE: The values in the "size" and "free" columns for DBspace chunks are
- displayed in terms of "pgsize" of the DBspace to which they belong.
-
-
- Expanded chunk capacity mode: always
-
- [gbasedbt@iZ2ze5s78e4tanwe5q2znxZ node1_dbs]$
- [gbasedbt@iZ2ze5s78e4tanwe5q2znxZ node1_dbs]$ dbaccess test3 -
- Your evaluation license will expire on 2025-05-26 00:00:00
-
- Database selected.
-
- > select * from test;
-
-
- id
-
- 1
- 3
- 10
- 11
- 11
- 11
- 11
- 11
- 11
- 12
- 13
- 23
- 24
-
- 13 row(s) retrieved.
-
- Elapsed time: 0.003 sec
-
- >
-
-