DM7使用DMRMAN執行RAC資料庫恢復

eric0435發表於2020-12-24

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


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26015009/viewspace-2744828/,如需轉載,請註明出處,否則將追究法律責任。

相關文章