Thứ Tư, 20 tháng 1, 2021

Thủ tục khôi phục cơ sở dữ liệu Oracle từ bản backup full sang máy chủ mới (test)

Keywords: Restoring an RMAN Backup to Another Node, Use RMAN to copy/clone a database

Thủ tục này giúp khôi phục cơ sở dữ liệu Oracle từ bản backup full sang máy chủ mới (test)
(Backup database trên DBChinh, RMAN> backup database plus archivelog;)

1. Xóa DB hiện tại
- C1: Kết nối qua Xmanager
# emca -> xóa database hiện tại

2. Copy bản backup từ DB chính sang DB test:
DBChinh>scp *20120229* oracle@192.168.1.142:/u03/test_recovery/dbaviet

3. Restore spfile  from backupset
(bash)#rman target /
RMAN> startup nomount force;
RMAN>RESTORE SPFILE FROM '/u03/test_recovery/dbaviet/c-3348841439-20120229-00';   // c-3348841439-20120229-01 chua spfile, controlfile

3. Startup nomount DB
RMAN> shutdown immediate
RMAN> startup nomount;

4. Restore controlfile from backupset
RMAN>restore controlfile from '/u03/test_recovery/dbaviet/c-3348841439-20120229-00';

5. Alter database mount
RMAN> alter database mount;

6. Reset repository RMAN
-- Xoa cac ban backup expired
RMAN> crosscheck backup;
RMAN> delete expired backup;

RMAN> run{
catalog backuppiece '/u03/test_recovery/dbaviet/ora_df20120229_s15042_s2';
catalog backuppiece '/u03/test_recovery/dbaviet/ora_df20120229_s15042_s1';
catalog backuppiece '/u03/test_recovery/dbaviet/ora_df20120229_s15043_s1';
catalog backuppiece '/u03/test_recovery/dbaviet/ora_df20120229_s15044_s1';
catalog backuppiece '/u03/test_recovery/dbaviet/ora_df20120229_s15045_s1';
catalog backuppiece '/u03/test_recovery/dbaviet/ora_df20120229_s15046_s1';
catalog backuppiece '/u03/test_recovery/dbaviet/ora_df20120229_s15047_s1';
catalog backuppiece '/u03/test_recovery/dbaviet/ora_df20120229_s15048_s1';
catalog backuppiece '/u03/test_recovery/dbaviet/ora_df20120229_s15049_s1';
catalog backuppiece '/u03/test_recovery/dbaviet/ora_df20120229_s15050_s1';
catalog backuppiece '/u03/test_recovery/dbaviet/ora_df20120229_s15051_s1';
catalog backuppiece '/u03/test_recovery/dbaviet/ora_df20120229_s15052_s1';
catalog backuppiece '/u03/test_recovery/dbaviet/ora_df20120229_s15053_s1';
catalog backuppiece '/u03/test_recovery/dbaviet/ora_df20120229_s15054_s1';
catalog backuppiece '/u03/test_recovery/dbaviet/ora_df20120229_s15055_s1';
catalog backuppiece '/u03/test_recovery/dbaviet/ora_df20120229_s15056_s1';
catalog backuppiece '/u03/test_recovery/dbaviet/ora_df20120229_s15057_s1';
catalog backuppiece '/u03/test_recovery/dbaviet/ora_df20120229_s15058_s1';
catalog backuppiece '/u03/test_recovery/dbaviet/ora_df20120229_s15059_s1';
catalog backuppiece '/u03/test_recovery/dbaviet/ora_df20120229_s15060_s1';
catalog backuppiece '/u03/test_recovery/dbaviet/ora_df20120229_s15061_s1';
catalog backuppiece '/u03/test_recovery/dbaviet/ora_df20120229_s15062_s1';
catalog backuppiece '/u03/test_recovery/dbaviet/ora_df20120229_s15063_s1';
catalog backuppiece '/u03/test_recovery/dbaviet/ora_df20120229_s15064_s1';
catalog backuppiece '/u03/test_recovery/dbaviet/ora_df20120229_s15065_s1';
catalog backuppiece '/u03/test_recovery/dbaviet/ora_df20120229_s15066_s1';
catalog backuppiece '/u03/test_recovery/dbaviet/ora_df20120229_s15067_s1';
catalog backuppiece '/u03/test_recovery/dbaviet/ora_df20120229_s15068_s1';
catalog backuppiece '/u03/test_recovery/dbaviet/ora_df20120229_s15069_s1';
catalog backuppiece '/u03/test_recovery/dbaviet/ora_df20120229_s15070_s1';
catalog backuppiece '/u03/test_recovery/dbaviet/ora_df20120229_s15071_s1';
catalog backuppiece '/u03/test_recovery/dbaviet/ora_df20120229_s15072_s1';
catalog backuppiece '/u03/test_recovery/dbaviet/c-3348841439-20120229-00';
}

7. Set newname cho phân vùng restore
- Set newname: thay đổi đường dẫn mới extract bản backup
run{
allocate channel t1 type DISK;
allocate channel t2 type DISK;
allocate channel t3 type DISK;
allocate channel t4 type DISK;
allocate channel t5 type DISK;
allocate channel t6 type DISK;
allocate channel t7 type DISK;
allocate channel t8 type DISK;
set newname for datafile 00002 to '/u02/oradata/dbaviet/undotbs01.dbf';
set newname for datafile 00022 to '/u02/oradata/dbaviet/data2010_002.dbf';
set newname for datafile 00070 to '/u02/oradata/dbaviet/data2010_024.dbf';
...
restore database;
switch datafile all;
release channel t1;
release channel t2;
release channel t3;
release channel t4;
release channel t5;
release channel t6;
release channel t7;
release channel t8;
}
Tạo script thực  hiện cho tất cả các file
(Thời gian resore mất khoảng 5h, bản backup 70GB, restore DF 860GB)

7. Recover database 
RMAN> recover database;

8. Open database with resetlogs
RMAN> alter database open resetlogs;

==================================
KẾT NỐI VỚI CHUYÊN GIA TRẦN VĂN BÌNH:
📧 Mail: binhoracle@gmail.com
☎️ Mobile: 0902912888
⚡️ Skype: tranbinh48ca
👨 Facebook: https://www.facebook.com/BinhOracleMaster
👨 Inbox Messenger: https://m.me/101036604657441 (profile)
👨 Fanpage: https://www.facebook.com/tranvanbinh.vn
👨 Inbox Fanpage: https://m.me/tranvanbinh.vn
👨👩 Group FB: https://www.facebook.com/groups/DBAVietNam
👨 Website: https://www.tranvanbinh.vn
👨 Blogger: https://tranvanbinhmaster.blogspot.com
🎬 Youtube: http://bit.ly/ytb_binhoraclemaster
👨 Tiktok: https://www.tiktok.com/@binhoraclemaster?lang=vi
👨 Linkin: https://www.linkedin.com/in/binhoracle
👨 Twitter: https://twitter.com/binhoracle
👨 Địa chỉ: Tòa nhà Sun Square - 21 Lê Đức Thọ - Phường Mỹ Đình 1 - Quận Nam Từ Liêm - TP.Hà Nội

#học oracle database
#Oracle Database Administration
#Oracle Tutorial
#Oracle DBA
#tự học oracle
#oca
#ocp

ĐỌC NHIỀU

Trần Văn Bình - Oracle Database Master