本次测试环境为集群测试环境。
1)数据库版本:
1-1-56-19.12.23-117493-ENT
--若存在表可以删除
drop table rec_bak;
--17:53全库备份
backup database backupset '/home/dmdba/dmdbms/BAK/db_bak_FULL';
--17:54-34创建表
create table rec_bak(id int,name varchar2(10));
insert into rec_bak values(1,'a');
insert into rec_bak values(2,'c');
insert into rec_bak values(3,'b');
insert into rec_bak values(4,'d');
commit;
alter system switch logfile;
select * from rec_bak;
--查看此时的lsn号
SELECT FILE_LSN FROM V$RLOG;
--268138
select sysdate from dual;
--2020-03-25 17:55:11
--2020-03-25 17:57:25删表中的数据
truncate table rec_bak;
select * from rec_bak;
--关闭数据库
./DmService_RAC0 stop
./DmService_RAC1 stop
--将RAC1节点的归档cp到RAC0
--在节点1上进入RMAN界面
./dmrman dcr_ini=/home/dmdba/dmdbms/config/dmdcr.ini
CHECK BACKUPSET '/home/dmdba/dmdbms/BAK/db_bak_FULL';
RESTORE DATABASE '/home/dmdba/dmdbms/config/rac0_config/dm.ini' FROM BACKUPSET '/home/dmdba/dmdbms/BAK/db_bak_FULL';
--恢复数据库到某一时间点
RECOVER DATABASE '/home/dmdba/dmdbms/config/rac0_config/dm.ini' WITH ARCHIVEDIR '/home/dmdba/dmdbms/arch_0','/home/dmdba/dmdbms/arch_1' UNTIL TIME '2020-03-25 17:55:11';
RECOVER DATABASE '/home/dmdba/dmdbms/config/rac0_config/dm.ini' WITH ARCHIVEDIR '/home/dmdba/dmdbms/arch_0','/home/dmdba/dmdbms/arch_1' UNTIL LSN 268138;
RECOVER DATABASE '/home/dmdba/dmdbms/config/rac0_config/dm.ini' UPDATE DB_MAGIC;
--起库查看数据(数据恢复)
select * from rec_bak;
--其中RMAN恢复整体操作如下
[dmdba@dm8dsc01 bin]$ ./dmrman dcr_ini=/home/dmdba/dmdbms/config/dmdcr.ini
dmrman V8
RMAN> CHECK BACKUPSET '/home/dmdba/dmdbms/BAK/db_bak_FULL';
CHECK BACKUPSET '/home/dmdba/dmdbms/BAK/db_bak_FULL';
CMD END.CODE:[0]
check backupset successfully.
time used: 175.548(ms)
RMAN> RESTORE DATABASE '/home/dmdba/dmdbms/config/rac0_config/dm.ini' FROM BACKUPSET '/home/dmdba/dmdbms/BAK/db_bak_FULL';
RESTORE DATABASE '/home/dmdba/dmdbms/config/rac0_config/dm.ini' FROM BACKUPSET '/home/dmdba/dmdbms/BAK/db_bak_FULL';
file dm.key not found, use default license!
checking if the DSC database under system path [+DMDATA/data/rac] is running with vote disk....
EP [0] is checking....
EP [1] is checking....
RESTORE DATABASE CHECK......
RESTORE DATABASE,data collect......
RESTORE DATABASE,database refresh ......
RESTORE BACKUPSET [/home/dmdba/dmdbms/BAK/db_bak_FULL] START......
total 7 packages processed...
total 8 packages processed...
RESTORE DATABASE,UPDATE ctl file......
RESTORE DATABASE,REBUILD key file......
RESTORE DATABASE,CHECK db info......
RESTORE DATABASE,UPDATE db info......
total 8 packages processed...
total 8 packages processed!
CMD END.CODE:[0]
restore successfully.
time used: 00:00:08.806
RMAN> RECOVER DATABASE '/home/dmdba/dmdbms/config/rac0_config/dm.ini' WITH ARCHIVEDIR '/home/dmdba/dmdbms/arch_0','/home/dmdba/dmdbms/arch_1' UNTIL TIME '2020-03-25 17:55:11';
RECOVER DATABASE '/home/dmdba/dmdbms/config/rac0_config/dm.ini' WITH ARCHIVEDIR '/home/dmdba/dmdbms/arch_0' , '/home/dmdba/dmdbms/arch_1' UNTIL TIME '2020-03-25 17:55:11';
checking if the DSC database under system path [+DMDATA/data/rac] is running with vote disk....
EP [0] is checking....
EP [1] is checking....
Database mode = 0, oguid = 0
EP[0]'s cur_lsn[268095]
EP[1]'s cur_lsn[268095]
EP[0] adjust cur_lsn from [268095] to [268095]
EP:0 total 2 pkgs applied, percent: 15%
EP:1 total 1 pkgs applied, percent: 25%
EP:1 total 2 pkgs applied, percent: 50%
[-6526]:重演超时
RMAN> RECOVER DATABASE '/home/dmdba/dmdbms/config/rac0_config/dm.ini' WITH ARCHIVEDIR '/home/dmdba/dmdbms/arch_0','/home/dmdba/dmdbms/arch_1' UNTIL LSN 268138;
RECOVER DATABASE '/home/dmdba/dmdbms/config/rac0_config/dm.ini' WITH ARCHIVEDIR '/home/dmdba/dmdbms/arch_0' , '/home/dmdba/dmdbms/arch_1' UNTIL LSN 268138;
checking if the DSC database under system path [+DMDATA/data/rac] is running with vote disk....
EP [0] is checking....
EP [1] is checking....
Database mode = 0, oguid = 0
EP[0]'s cur_lsn[268095]
EP[1]'s cur_lsn[268095]
EP[0] adjust cur_lsn from [268095] to [268095]
EP:1 total 1 pkgs applied, percent: 25%
EP:0 total 2 pkgs applied, percent: 15%
EP:0 total 4 pkgs applied, percent: 30%
EP:0 total 6 pkgs applied, percent: 46%
EP:0 total 8 pkgs applied, percent: 61%
Recover from archive log finished, time used:0.013s.
EP(0) slot ctl page(1, 0, 16) trxid[23272], pseg_state[1]
EP[0]'s apply_lsn[268138] >= end_lsn[268099]
EP[1]'s apply_lsn[268095] >= end_lsn[268095]
recover successfully!
time used: 00:00:06.762
RMAN> RECOVER DATABASE '/home/dmdba/dmdbms/config/rac0_config/dm.ini' UPDATE DB_MAGIC;
RECOVER DATABASE '/home/dmdba/dmdbms/config/rac0_config/dm.ini' UPDATE DB_MAGIC;
checking if the DSC database under system path [+DMDATA/data/rac] is running with vote disk....
EP [0] is checking....
EP [1] is checking....
Database mode = 0, oguid = 0
EP[0]'s cur_lsn[268138]
EP[1]'s cur_lsn[268138]
EP[0] adjust cur_lsn from [268138] to [268138]
EP[0]'s apply_lsn[268138] >= end_lsn[268099]
EP[1]'s apply_lsn[268095] >= end_lsn[268095]
EP(0) slot ctl page(1, 0, 16) trxid[23272], pseg_state[1]
recover successfully!
time used: 00:00:07.531
RMAN> exit
time used: 0.002(ms)
登陆查询
SQL> select * from rec_bak;
行号 ID NAME
---------- ----------- ----
1 1 a
2 2 c
3 3 b
4 4 d
已用时间: 7.175(毫秒). 执行号:18.
关于达梦数据库更多的相关问题请浏览达梦云适配技术社区
达梦云适配技术社区
https://eco.dameng.com/