达梦数据库支持在基于数据库完全备份的基础上,利用 REDO 日志,重做数据库恢复到第一个时间点,该时间点必须是数据库完全备份之后的时间点。同时支持再次基于 REDO 日志,重做数据恢复到第二个时间点,但第二个时间点必须在第一个时间点之后。同理,还支持第三次、第 N 次恢复,但第 N 次恢复的时间点必须要大于第 N-1 次恢复的时间点。在第 N 次恢复前,若想启动数据库进行查询操作,必须要确保不能产生 REDO 日志,即只能以备机模式来启动数据库,如何设置备机模式在下述步骤中有详细描述。
此例子采用的是主机数据库备份,备机归档备份来还原恢复数据库,详细步骤如下:
disql /nolog
SQL>conn SYSDBA/SYSDBA@10.1.242.169:5236
SQL>CREATE TABLE T1(C1 VARCHAR(20),C2 VARCHAR(20));
SQL>INSERT INTO T1 SELECT LEVEL,LEVEL+1 FROM DUAL CONNECT BY LEVEL<=10000;
SQL>COMMIT;
SQL>BACKUP DATABASE BACKUPSET 'db_bak_01';
SQL>SELECT SF_BAKSET_CHECK('DISK','/dbbak/CNDT/db_bak_01');
SQL>SELECT SYSDATE();
–查询当前数据库时间并记录:‘2016-05-19 19:49:12’
SQL>INSERT INTO T1 SELECT LEVEL,LEVEL+1 FROM DUAL CONNECT BY LEVEL<=10000;
SQL>COMMIT;
SQL>conn SYSDBA/SYSDBA@10.1.242.170:5236
SQL>BACKUP ARCHIVE LOG ALL BACKUPSET 'arch_bak_01';
SQL>SELECT SF_BAKSET_CHECK('DISK','/dbbak/CNDT/arch_bak_01');
SQL>SELECT SYSDATE();
–查询当前数据库时间并记录:‘2016-05-19 19:55:12’
dmrman
RMAN>restore archive log from backupset '/dbbak/CNDT/arch_bak_01' to archivedir '/arch/all'
dmrachk arch_fil=/arch/all/ ARCHIVE_LOCAL1_20160519194834438.log
rachk V7.1.5.81-Build(2016.05.10-68432trunc-debug)
/*******************************************************************/
archive file ARCHIVE_LOCAL1_20160519194834438.log itemize.
arch_status : INACTIVE
arch n_rpags : 992
arch_db_magic : 1463364211
arch_pemnt_magic : 1463364245
arch_next_seq : 12669
arch_lsn : 34548
arch_seq : 11678
clsn : 40135
rarch file len : 512000
rarch file free: 512000
rarch create time : 2016- 5-19 19:48:34
rarch close time : 2016- 5-19 19:55:12
/*******************************************************************/
The SUMMARY:
total files: 1
okey files: 1
fail file: 0
the rachk tool running cost 0.901 ms
dmrman
RMAN>restore database to '/dbdata/all' from backupset '/dbbak/CNDT/db_bak_01'
RMAN>recover database '/dbdata/all/dm.ini ' with archivedir '/arch/all' use db_magic 1463364211 until time '2016-05-19 19:49:12'
./dmserver /dbdata/all/dm.ini mount
disql /nolog
SQL>conn SYSDBA/SYSDBA@localhost:5236
--设置本地归档
SQL> ALTER DATABASE ADD ARCHIVELOG 'DEST = /dbdata/all, TYPE = local,FILE_SIZE = 128, SPACE_LIMIT = 2048';
SQL>ALTER DATABASE STANDBY;
SQL>ALTER DATABASE OPEN FORCE;
SQL>SELECT COUNT(*) FROM T1;
--结果集为 10000
dmrman
RMAN>recover database '/dbdata/all/dm.ini ' with archivedir '/arch/all' use db_magic 1463364211 until time '2016-05-19 19:55:12'
./dmserver /dbdata/all/dm.ini mount
disql /nolog
SQL>conn SYSDBA/SYSDBA@localhost:5236
SQL>ALTER DATABASE OPEN FORCE;
SQL>SELECT COUNT(*) FROM T1;
–结果集为 20000
./dmserver /dbdata/all/dm.ini mount
disql /nolog
SQL>conn SYSDBA/SYSDBA@localhost:5236
SQL>ALTER DATABASE PRIMARY;
SQL>ALTER DATABASE OPEN FORCE;
SQL>INSERT INTO T1 SELECT LEVEL,LEVEL+1 FROM DUAL CONNECT BY LEVEL<=10000;
SQL>COMMIT;
SQL>SELECT COUNT(*) FROM T1;
–结果集为 30000
文章
阅读量
获赞