DM7使用DMRMAN执行RAC数据库恢复

使用DMRMAN执行RAC数据库恢复
DM7支持RAC环境下的备份还原。RAC环境的备份还原与普通的单机不同的是,它包含多个节点(目前仅支持两个节点,下面以从归档恢复为例说明RAC环境下的备份恢复:
1) 搭建RAC环境。
2) 启动DIsql,联机备份数据库。备份其中任意一个节点即可备份整个RAC环境。

SQL> backup database full to db_full_bak_for_rac backupset '/dm7/backup/db_full_bak_for_rac';
executed successfully
used time: 00:00:01.271. Execute id is 45.

3)将备份文件与两个节点的归档日志传输到目标库

[dmdba@dmrac1 backup]$ scp -r db_full_bak_for_rac/ dmdba@10.13.30.187:/dm_home/dmdbms/backup/
dmdba@10.13.30.187's password:
db_full_bak_for_rac.bak                                                                                                                                                                                   100%   26MB  25.5MB/s   00:01
db_full_bak_for_rac_1.bak                                                                                                                                                                                 100% 5120     5.0KB/s   00:00
db_full_bak_for_rac.meta                                                                                                                                                                                  100%   81KB  80.5KB/s   00:00

[dmdba@dmrac1 data]$ scp -r rac0_arch dmdba@10.13.30.187:/dm_home/dmdbms/backup/
dmdba@10.13.30.187's password:
ARCHIVE_LOCAL1_20200617163125381_0.log                                                                                                                                                                    100%  256MB 128.0MB/s   00:02
ARCHIVE_LOCAL1_20200617154121539_0.log                                                                                                                                                                    100% 8704     8.5KB/s   00:00
ARCHIVE_LOCAL1_20200615164953273_0.log                                                                                                                                                                    100%  160KB 160.0KB/s   00:00
ARCHIVE_LOCAL1_20200615165648166_0.log                                                                                                                                                                    100%  157KB 157.0KB/s   00:00
ARCHIVE_LOCAL1_20200528202150715_0.log                                                                                                                                                                    100%  277KB 277.0KB/s   00:00
ARCHIVE_LOCAL1_20200608151836879_0.log                                                                                                                                                                    100%  158KB 157.5KB/s   00:00
ARCHIVE_LOCAL1_20200609150852829_0.log                                                                                                                                                                    100%  157KB 157.0KB/s   00:00
ARCHIVE_LOCAL1_20200608152638617_0.log                                                                                                                                                                    100%  159KB 158.5KB/s   00:00
ARCHIVE_LOCAL1_20200609170732487_0.log                                                                                                                                                                    100%  161KB 160.5KB/s   00:00
ARCHIVE_LOCAL1_20200615172117341_0.log                                                                                                                                                                    100%  159KB 158.5KB/s   00:00
ARCHIVE_LOCAL1_20200615171042444_0.log                                                                                                                                                                    100%  159KB 159.0KB/s   00:00
ARCHIVE_LOCAL1_20200605154214367_0.log                                                                                                                                                                    100%  157KB 157.0KB/s   00:00
ARCHIVE_LOCAL1_20200616164818700_0.log                                                                                                                                                                    100%  160KB 160.0KB/s   00:00
[dmdba@dmrac1 data]$ scp -r rac1_arch dmdba@10.13.30.187:/dm_home/dmdbms/backup/
dmdba@10.13.30.187's password:
ARCH_REMOTE1_20200608152641970_1.log                                                                                                                                                                      100%  158KB 158.0KB/s   00:00
ARCH_REMOTE1_20200609170737070_1.log                                                                                                                                                                      100%  159KB 159.0KB/s   00:00
ARCH_REMOTE1_20200609150857056_1.log                                                                                                                                                                      100%  158KB 158.0KB/s   00:00
ARCH_REMOTE1_20200616164822181_1.log                                                                                                                                                                      100%  256MB 128.0MB/s   00:02
ARCH_REMOTE1_20200615172121038_1.log                                                                                                                                                                      100%  158KB 158.0KB/s   00:00
ARCH_REMOTE1_20200608151838201_1.log                                                                                                                                                                      100% 5632     5.5KB/s   00:00
ARCH_REMOTE1_20200528202146001_1.log                                                                                                                                                                      100%  158KB 158.0KB/s   00:00
ARCH_REMOTE1_20200615164957743_1.log                                                                                                                                                                      100%  158KB 158.0KB/s   00:00
ARCH_REMOTE1_20200605154211189_1.log                                                                                                                                                                      100%  159KB 159.0KB/s   00:00
ARCH_REMOTE1_20200615165652504_1.log                                                                                                                                                                      100%  158KB 158.0KB/s   00:00
ARCH_REMOTE1_20200615171046600_1.log                                                                                                                                                                      100%  158KB 158.0KB/s   00:00

4)还原数据库。还原数据库之前可选择对备份文件进行校验。需要注意的是,待还原的目标库可以单机库,也可以RAC库,且节点个数允许不同。这里目标库为单机。

RMAN> restore database '/dm_home/dmdbms/data/dameng_for_recover/dm.ini' from backupset '/dm_home/dmdbms/backup/db_full_bak_for_rac';
restore database '/dm_home/dmdbms/data/dameng_for_recover/dm.ini' from backupset '/dm_home/dmdbms/backup/db_full_bak_for_rac';
file dm.key not found, use default license!
checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[4].
checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[3].
checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[2].
checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[1].
checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[0].
checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running, write dmrman info.
RESTORE DATABASE  CHECK......
RESTORE DATABASE , dbf collect......
RESTORE DATABASE , dbf refresh ......
RESTORE BACKUPSET [/dm_home/dmdbms/backup/db_full_bak_for_rac] START......
total 5 packages processed...
RESTORE DATABASE , UPDATE ctl file......
RESTORE DATABASE , REBUILD key file......
RESTORE DATABASE , CHECK db info......
RESTORE DATABASE , UPDATE db info......
total 6 packages processed!
CMD END.CODE:[0]
restore successfully.
time used: 16608.914(ms)

5)恢复数据库。假设节点1和节点2的归档日志在目标库中分别在/dm_home/dmdbms/backup/rac0_arch , /dm_home/dmdbms/backup/rac1_arch目录下。RAC库恢复要求各节点归档完整性由用户保证,即各节点的本地归档都能够访问到,若本地存在REMOTE归档,则可以使用REMOTE归档代替远程节点的本地归档。

RMAN> recover database '/dm_home/dmdbms/data/dameng_for_recover/dm.ini' with archivedir '/dm_home/dmdbms/backup/rac0_arch' , '/dm_home/dmdbms/backup/rac1_arch';
recover database '/dm_home/dmdbms/data/dameng_for_recover/dm.ini' with archivedir '/dm_home/dmdbms/backup/rac0_arch' , '/dm_home/dmdbms/backup/rac1_arch';
checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[4].
checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[3].
checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[2].
checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[1].
checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[0].
checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running, write dmrman info.
EP[0] max_lsn: 80023
EP 0's ckpt_lsn = 80135
min_ckpt_lsn = 80135
The RAC redo archive log 1 ptx
The RAC redo archive log 2 ptx
The RAC recover total redo 2 ptx
EP(0) slot ctl page(1, 0, 16) trxid = 10107
EP(1) slot ctl page(1, 0, 17) trxid = 8457
EP[0] Recover LSN from 80135 to 80136.
EP[1] Recover LSN from 80024 to 80023.
Recover from archive log finished, time used:0.025s.
recover successfully!
time used: 7039.164(ms)

6)验证数据

[root@dmks init.d]# service DmServicedmrc start
Starting DmServicedmrc: [ OK ]

SQL> select * from tab_for_recover_01;
no rows

used time: 0.373(ms). Execute id is 4.
SQL> select * from tab_for_recover_02;

LINEID     C1
---------- -----------
1          1

used time: 1.121(ms). Execute id is 5.

发表评论

电子邮件地址不会被公开。