Oracle 12c versiyonunda container ve pluggable database’ lerin backuplarını nasıl alabileceğimizden bahsetmiştik. Şimdide almış olduğumuz bu backupları ihtiyaç olması durumunda nasıl kullanabileceğimizden bahsedelim. Bir önceki yazıda olduğu gibi yine sık karşılaşılacak senaryoları çıkartmaya çalıştım. Bol örnekli bir yazı oldu. Loglar çok fazla olduğundan dolayı kısaltarak ekledim.
Container veya pluggable database’ in backupını almak veya restore etmek için SYSBACKUP veya SYSDBA yetkilerine sahip olmak gerektiğini unutmayalım.
Örnek senaryolarımız ;
• Full database restore / recover,
• Full pluggable database restore / recover,
• Root database restore / recover,
• Archivelog restore,
• Pluggable database’ e ait olan tablespace’ in restore / recover,
• Pluggable database’ e ait olan bir tablespace’ e ait datafile’ in restore / recover işlemi,
• Container Database, Point In Time Recovery,
• Pluggable Database , Point In Time Recovery
tablo bazında restore-recover işleminden daha önce bahsetmiştik.
(http://www.kamilturkyilmaz.com/2015/07/20/oracle-12c-new-features-tablo-bazinda-recover-islemi/)
Şimdi sırayla testlerimize başlayalım ;
• Full database restore / recover,
Container database’ i (dolayısıyla container içerisinde yer alan tüm pluggable db’ leri) kaybettiğimiz de nasıl son backupdan dönebiliriz onu test ediyor olacaz. Öncelikle container db’ imiz içerisindeki tüm datafile, controlfile, pfile, spfile ve redolarımızı silip ve test senaryomuzu oluşturalım ve sonrasında restore’ umuzu başlatalım;
Öncelikle spfile’ i restore ediyoruz;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
[oracle@Redhat70 ~]$ rman target / catalog tcdb/PasswordX@CAT_RMAN Recovery Manager: Release 12.1.0.2.0 - Production on Wed Sep 2 09:49:16 2015 Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved. connected to target database: DUMMY (not mounted) connected to recovery catalog database RMAN> run 2> { 3> ALLOCATE CHANNEL ch1 DEVICE TYPE sbt_tape ; 4> set dbid 1730207577 5> restore spfile from 'c-1730207577-20150901-01'; 6> } allocated channel: ch1 channel ch1: SID=6 device type=SBT_TAPE channel ch1: Veritas NetBackup for Oracle - Release 7.5 (2013061020) executing command: SET DBID database name is "TCDB" and DBID is 1730207577 Starting restore at 02-SEP-15 channel ch1: restoring spfile from AUTOBACKUP c-1730207577-20150901-01 channel ch1: SPFILE restore from AUTOBACKUP complete Finished restore at 02-SEP-15 released channel: ch1 RMAN> |
Control file’ i restore ediyoruz ;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
RMAN> run 2> { 3> ALLOCATE CHANNEL ch1 DEVICE TYPE sbt_tape ; 4> set dbid 1730207577 5> restore controlfile from 'c-1730207577-20150901-01'; 6> release channel ch1; 7> } allocated channel: ch1 channel ch1: SID=6 device type=SBT_TAPE channel ch1: Veritas NetBackup for Oracle - Release 7.5 (2013061020) executing command: SET DBID database name is "TCDB" and DBID is 1730207577 Starting restore at 02-SEP-15 channel ch1: restoring control file channel ch1: restore complete, elapsed time: 00:00:15 output file name=/u01/sq/ora_3/oracle/db/12.1.0.2/dbs/cntrltcdb.dbf Finished restore at 02-SEP-15 released channel: ch1 RMAN> |
Artık database’ i mount moda alabiliriz;
RMAN> alter database mount ;
Statement processed
Datafile’ lerimizi restore / recover edelim ;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
[oracle@Redhat70 ~]$ rman target / Recovery Manager: Release 12.1.0.2.0 - Production on Wed Sep 2 15:05:07 2015 Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved. connected to target database: TCDB (DBID=1730207577, not open) RMAN> run 2> { 3> ALLOCATE CHANNEL ch1 DEVICE TYPE sbt_tape ; 4> ALLOCATE CHANNEL ch2 DEVICE TYPE sbt_tape ; 5> ALLOCATE CHANNEL ch3 DEVICE TYPE sbt_tape ; 6> ALLOCATE CHANNEL ch4 DEVICE TYPE sbt_tape ; 7> ALLOCATE CHANNEL ch5 DEVICE TYPE sbt_tape ; 8> ALLOCATE CHANNEL ch6 DEVICE TYPE sbt_tape ; 9> restore database force; 10> recover database; 11> release channel ch1; 12> release channel ch2; 13> release channel ch3; 14> release channel ch4; 15> release channel ch5; 16> release channel ch6; 17> } using target database control file instead of recovery catalog allocated channel: ch1 channel ch1: SID=355 device type=SBT_TAPE channel ch1: Veritas NetBackup for Oracle - Release 7.5 (2013061020) allocated channel: ch2 channel ch2: SID=6 device type=SBT_TAPE channel ch2: Veritas NetBackup for Oracle - Release 7.5 (2013061020) … Starting restore at 02-SEP-15 channel ch1: starting datafile backup set restore channel ch1: specifying datafile(s) to restore from backup set channel ch1: restoring datafile 00045 to /u03/oradata/tcdb/pdbtcdb3/TCDB/datafile/o1_mf_sysaux_byf8qs8m_.dbf channel ch1: reading from backup piece bk_3921_1_889354202 channel ch2: starting datafile backup set restore channel ch2: specifying datafile(s) to restore from backup set channel ch2: restoring datafile 00044 to /u03/oradata/tcdb/pdbtcdb3/TCDB/datafile/o1_mf_system_byf8rl22_.dbf channel ch2: reading from backup piece bk_3926_1_889354203 … … channel ch4: restoring datafile 00047 to /u03/oradata/tcdb/pdbtcdb3/TCDB/datafile/o1_mf_sysaux_byf8rsfq_.dbf channel ch4: reading from backup piece bk_3922_1_889354202 channel ch5: piece handle=bk_3927_1_889354203 tag=TCDB_TEST_20150902 channel ch5: restored backup piece 1 channel ch5: restore complete, elapsed time: 00:00:26 channel ch5: starting datafile backup set restore channel ch5: specifying datafile(s) to restore from backup set channel ch5: restoring datafile 00048 to /u02/oradata/tcdb/dbf/plug1_db/data1.dbf channel ch5: reading from backup piece bk_3929_1_889354238 channel ch6: piece handle=bk_3924_1_889354203 tag=TCDB_TEST_20150902 channel ch6: restored backup piece 1 channel ch6: restore complete, elapsed time: 00:00:26 channel ch6: starting datafile backup set restore channel ch6: specifying datafile(s) to restore from backup set … … channel ch5: restore complete, elapsed time: 00:00:44 channel ch6: piece handle=bk_3936_1_889354246 tag=TCDB_TEST_20150902 channel ch6: restored backup piece 1 channel ch6: restore complete, elapsed time: 00:00:28 … … Finished restore at 02-SEP-15 Starting recover at 02-SEP-15 starting media recovery archived log for thread 1 with sequence 14 is already on disk as file /u04/oradata/tcdb/archive/tcdb_arch_1_14_889353798.arc archived log for thread 1 with sequence 15 is already on disk as file /u04/oradata/tcdb/archive/tcdb_arch_1_15_889353798.arc archived log for thread 1 with sequence 16 is already on disk as file /u04/oradata/tcdb/archive/tcdb_arch_1_16_889353798.arc … … archived log file name=/u04/oradata/tcdb/archive/tcdb_arch_1_39_889353798.arc thread=1 sequence=39 archived log file name=/u04/oradata/tcdb/archive/tcdb_arch_1_40_889353798.arc thread=1 sequence=40 media recovery complete, elapsed time: 00:00:45 Finished recover at 02-SEP-15 released channel: ch1 released channel: ch2 released channel: ch3 released channel: ch4 released channel: ch5 released channel: ch6 |
Recover işlemi de bittiğine göre artık database’ i açabiliriz.
RMAN> alter database open ;
Statement processed
• Full pluggable database restore / recover,
Container database’ i full olarak restore ettikden sonra şimdi container içerisinde yer alan birden fazla pluggable database’ lerden sadece birini restore etmeyi deneyelim. Bu arada backuplar full container db backup’ ı olacak şekilde alındı yani sadece restore etmeye çalıştığımız db’ nin backupını almadık.
Aşağıdaki pluggable database’ lerden PLUG1_DB’ yi restore edelim ;
1 2 3 4 5 6 7 8 9 |
===> select name from v$pdbs NAME ------------------------------ PDB$SEED PLUG1_DB TCDB_PLUG2_DB TCDB_PLUG3_DB 4 rows selected. |
Şimdi kaybettiğimiz bu database’ i restore edelim;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
RMAN> run 2> { 3> ALLOCATE CHANNEL ch1 DEVICE TYPE sbt_tape ; 4> ALLOCATE CHANNEL ch2 DEVICE TYPE sbt_tape ; 5> ALLOCATE CHANNEL ch3 DEVICE TYPE sbt_tape ; 6> ALLOCATE CHANNEL ch4 DEVICE TYPE sbt_tape ; 7> ALLOCATE CHANNEL ch5 DEVICE TYPE sbt_tape ; 8> ALLOCATE CHANNEL ch6 DEVICE TYPE sbt_tape ; 10> RESTORE PLUGGABLE DATABASE plug1_db force; 11> RECOVER PLUGGABLE DATABASE plug1_db; 12> ALTER PLUGGABLE DATABASE plug1_db OPEN; 13> release channel ch1; 14> release channel ch2; 15> release channel ch3; 16> release channel ch4; 17> release channel ch5; 18> release channel ch6; 19> } using target database control file instead of recovery catalog allocated channel: ch1 channel ch1: SID=256 device type=SBT_TAPE channel ch1: Veritas NetBackup for Oracle - Release 7.5 (2013061020) … … Starting restore at 03-SEP-15 allocated channel: ORA_SBT_TAPE_1 channel ORA_SBT_TAPE_1: SID=255 device type=SBT_TAPE channel ORA_SBT_TAPE_1: Veritas NetBackup for Oracle - Release 7.5 (2013061020) allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=379 device type=DISK channel ORA_SBT_TAPE_1: starting datafile backup set restore channel ORA_SBT_TAPE_1: specifying datafile(s) to restore from backup set channel ORA_SBT_TAPE_1: restoring datafile 00059 to /u02/oradata/tcdb/dbf/tcdb/plug1_db/system01.dbf channel ORA_SBT_TAPE_1: reading from backup piece bk_4036_1_889459657 channel ORA_SBT_TAPE_1: piece handle=bk_4036_1_889459657 tag=TCDB_TEST_20150903 channel ORA_SBT_TAPE_1: restored backup piece 1 channel ORA_SBT_TAPE_1: restore complete, elapsed time: 00:00:35 channel ORA_SBT_TAPE_1: starting datafile backup set restore channel ORA_SBT_TAPE_1: specifying datafile(s) to restore from backup set … … channel ORA_SBT_TAPE_1: restored backup piece 1 channel ORA_SBT_TAPE_1: restore complete, elapsed time: 00:00:15 Finished restore at 03-SEP-15 Starting recover at 03-SEP-15 using channel ORA_SBT_TAPE_1 using channel ORA_DISK_1 starting media recovery … … archived log for thread 1 with sequence 163 is already on disk as file /u04/oradata/tcdb/archive/tcdb_arch_1_163_889353798.arc archived log file name=/u04/oradata/tcdb/archive/tcdb_arch_1_161_889353798.arc thread=1 sequence=161 media recovery complete, elapsed time: 00:00:00 Finished recover at 03-SEP-15 Statement processed released channel: ch1 released channel: ch2 released channel: ch3 released channel: ch4 released channel: ch5 released channel: ch6 RMAN> |
• Root database restore / recover,
Container database’ i restore etmeye çalışalım;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
[oracle@Redhat70 ~]$ rman target / Recovery Manager: Release 12.1.0.2.0 - Production on Fri Sep 4 13:58:36 2015 Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved. connected to target database: TCDB (DBID=1730207577) RMAN> RUN { 2> STARTUP MOUNT; 3> RESTORE DATABASE ROOT; 4> RECOVER DATABASE ROOT; 5> ALTER DATABASE OPEN; 6> } using target database control file instead of recovery catalog database closed database dismounted Oracle instance shut down connected to target database (not started) Oracle instance started database mounted Total System Global Area 5771362304 bytes Fixed Size 2936864 bytes Variable Size 989859808 bytes Database Buffers 3690987520 bytes Redo Buffers 13836288 bytes In-Memory Area 1073741824 bytes Starting restore at 04-SEP-15 allocated channel: ORA_SBT_TAPE_1 channel ORA_SBT_TAPE_1: SID=243 device type=SBT_TAPE channel ORA_SBT_TAPE_1: Veritas NetBackup for Oracle - Release 7.5 (2013061020) allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=355 device type=DISK channel ORA_SBT_TAPE_1: starting datafile backup set restore channel ORA_SBT_TAPE_1: specifying datafile(s) to restore from backup set channel ORA_SBT_TAPE_1: restoring datafile 00004 to /u02/oradata/tcdb/dbf/tcdb/undotbs01.dbf channel ORA_SBT_TAPE_1: reading from backup piece bk_4091_1_889524097 channel ORA_SBT_TAPE_1: piece handle=bk_4091_1_889524097 tag=TCDB_TEST_20150904 … … channel ORA_SBT_TAPE_1: restore complete, elapsed time: 00:00:15 Finished restore at 04-SEP-15 Starting recover at 04-SEP-15 using channel ORA_SBT_TAPE_1 using channel ORA_DISK_1 starting media recovery … … archived log file name=/u04/oradata/tcdb/archive/tcdb_arch_1_178_889353798.arc thread=1 sequence=178 archived log file name=/u04/oradata/tcdb/archive/tcdb_arch_1_179_889353798.arc thread=1 sequence=179 media recovery complete, elapsed time: 00:00:22 Finished recover at 04-SEP-15 Statement processed RMAN> |
• Archivelog restore,
Archivelog restore için 12c ve önceki versiyonlar arasında bir fark bulunmamaktadır. Örnek olarak aşağıdaki scripti verebiliriz.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
[oracle@Redhat70 archive]$ rman target / Recovery Manager: Release 12.1.0.2.0 - Production on Fri Sep 11 09:39:05 2015 Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved. connected to target database: TCDB (DBID=1730207577) RMAN> run 2> { 3> ALLOCATE CHANNEL ch1 DEVICE TYPE sbt_tape ; 4> RESTORE ARCHIVELOG FROM SEQUENCE 290 UNTIL SEQUENCE 295; 5> release channel ch1; 6> } using target database control file instead of recovery catalog allocated channel: ch1 channel ch1: SID=20 device type=SBT_TAPE channel ch1: Veritas NetBackup for Oracle - Release 7.5 (2013061020) Starting restore at 11-SEP-15 channel ch1: starting archived log restore to default destination channel ch1: restoring archived log archived log thread=1 sequence=290 channel ch1: restoring archived log archived log thread=1 sequence=291 channel ch1: restoring archived log archived log thread=1 sequence=292 channel ch1: restoring archived log archived log thread=1 sequence=293 channel ch1: restoring archived log archived log thread=1 sequence=294 channel ch1: restoring archived log archived log thread=1 sequence=295 channel ch1: reading from backup piece arc_4539_1_890127363 channel ch1: piece handle=arc_4539_1_890127363 tag=TCDB_ARC_20150911 channel ch1: restored backup piece 1 channel ch1: restore complete, elapsed time: 00:00:35 Finished restore at 11-SEP-15 released channel: ch1 RMAN> |
• Pluggable database’ e ait olan tablespace’ in restore / recover edilmesi ,
PLUG1 pluggable database’ in DATA1 isimli tablespace’ ini restore etmeyi deneyelim;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
[oracle@Redhat70 admin]$ rman target sys/PasswordX@PLUG1_DB Recovery Manager: Release 12.1.0.2.0 - Production on Mon Sep 21 10:21:07 2015 Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved. connected to target database: TCDB (DBID=1730207577) RMAN> alter tablespace data1 offline ; Statement processed RMAN> run 2> { 3> ALLOCATE CHANNEL ch1 DEVICE TYPE sbt_tape ; 4> ALLOCATE CHANNEL ch2 DEVICE TYPE sbt_tape ; 5> restore TABLESPACE data1; 6> recover TABLESPACE data1; 7> release channel ch1; 8> release channel ch2; 9> } allocated channel: ch1 channel ch1: SID=18 device type=SBT_TAPE channel ch1: Veritas NetBackup for Oracle - Release 7.5 (2013061020) allocated channel: ch2 channel ch2: SID=21 device type=SBT_TAPE channel ch2: Veritas NetBackup for Oracle - Release 7.5 (2013061020) Starting restore at 21-SEP-15 channel ch1: starting datafile backup set restore channel ch1: specifying datafile(s) to restore from backup set channel ch1: restoring datafile 00065 to /u02/oradata/tcdb/dbf/tcdb/plug1_db/data1_01.dbf channel ch1: reading from backup piece bk_5062_1_890992891 channel ch1: piece handle=bk_5062_1_890992891 tag=TCDB_TEST_20150921 channel ch1: restored backup piece 1 channel ch1: restore complete, elapsed time: 00:00:15 Finished restore at 21-SEP-15 Starting recover at 21-SEP-15 starting media recovery archived log for thread 1 with sequence 509 is already on disk as file /u04/oradata/tcdb/archive/tcdb_arch_1_509_889353798.arc archived log for thread 1 with sequence 510 is already on disk as file /u04/oradata/tcdb/archive/tcdb_arch_1_510_889353798.arc archived log for thread 1 with sequence 511 is already on disk as file /u04/oradata/tcdb/archive/tcdb_arch_1_511_889353798.arc archived log file name=/u04/oradata/tcdb/archive/tcdb_arch_1_509_889353798.arc thread=1 sequence=509 media recovery complete, elapsed time: 00:00:00 Finished recover at 21-SEP-15 released channel: ch1 released channel: ch2 RMAN> alter tablespace data1 online ; Statement processed RMAN> |
• Pluggable database’ e ait olan bir tablespace’ e ait datafile’ in restore / recover işlemi,
PLUG1 pluggable database’ indeki data1_01.dbf datafile’ ini restore etmeyi deneyelim ;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
[oracle@Redhat70 admin]$ rman target sys/PasswordX@PLUG1_DB Recovery Manager: Release 12.1.0.2.0 - Production on Mon Sep 21 10:58:17 2015 Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved. connected to target database: TCDB (DBID=1730207577) RMAN> RUN { 2> ALTER DATABASE DATAFILE 65 OFFLINE; 3> RESTORE DATAFILE 65; 4> RECOVER DATAFILE 65; 5> ALTER DATABASE DATAFILE 65 ONLINE; 6> } using target database control file instead of recovery catalog Statement processed Starting restore at 21-SEP-15 allocated channel: ORA_SBT_TAPE_1 channel ORA_SBT_TAPE_1: SID=18 device type=SBT_TAPE channel ORA_SBT_TAPE_1: Veritas NetBackup for Oracle - Release 7.5 (2013061020) allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=21 device type=DISK channel ORA_SBT_TAPE_1: starting datafile backup set restore channel ORA_SBT_TAPE_1: specifying datafile(s) to restore from backup set channel ORA_SBT_TAPE_1: restoring datafile 00065 to /u02/oradata/tcdb/dbf/tcdb/plug1_db/data1_01.dbf channel ORA_SBT_TAPE_1: reading from backup piece vdqhn1f6_1_1 channel ORA_SBT_TAPE_1: piece handle=vdqhn1f6_1_1 tag=TAG20150921TCDB05638 channel ORA_SBT_TAPE_1: restored backup piece 1 channel ORA_SBT_TAPE_1: restore complete, elapsed time: 00:00:15 Finished restore at 21-SEP-15 Starting recover at 21-SEP-15 using channel ORA_SBT_TAPE_1 using channel ORA_DISK_1 starting media recovery media recovery complete, elapsed time: 00:00:01 Finished recover at 21-SEP-15 Statement processed RMAN> |
• Container Database Point In Time Recovery,
Point in time recovery çalışmasını yine bir örnek üzerinden açıklamaya çalışalım. Kamil userı altına PITR_TEST adında bir tablo oluşturalım ve database’ i bu tablonun oluşturulduğu anın hemen sonrasına dönmeye çalışalım.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
===> drop table kamil.PITR_TEST purge Table dropped. ===> drop table kamil.PITR_TEST2 purge Table dropped. ===> create table kamil.PITR_TEST tablespace data1 as select * from dba_tables Table created. ===> select count (*) from kamil.PITR_TEST COUNT(*) ---------- 2338 1 row selected. ===> alter system checkpoint System altered. ===> select current_scn from v$database CURRENT_SCN ----------- 10608269 1 row selected. ===> select max(sequence#) from v$archived_log where dest_id = 1 MAX(SEQUENCE#) -------------- 13601 1 row selected. ===> select to_char(sysdate,'MM/DD/YYYY hh24:mi:ss') current_date from dual CURRENT_DATE ------------------- 09/21/2015 13:57:31 1 row selected. ===> select to_char(sysdate,'MM/DD/YYYY hh24:mi:ss') current_date from dual CURRENT_DATE ------------------- 09/21/2015 14:14:27 1 row selected. ===> create table kamil.PITR_TEST2 tablespace data1 as select * from dba_tables Table created. |
Yukarıdaki kriterleri kullanarak point in time recovery yaptığımız da PITR_TEST tablosunun 2.338 data ile gelmesini ancak 14:14 de oluşturulmuş olan kamil.PITR_TEST2 tablosunun gelmemesini bekliyorum;
1 2 3 4 5 6 7 |
RUN { STARTUP MOUNT; set until SCN 10608269; RESTORE DATABASE; RECOVER DATABASE; ALTER DATABASE OPEN RESETLOGS; } |
Bu işlem için yukarıdaki 3 farklı set until opsiyonundan birini kullanabilriz. Biz SCN ile yapmayı deneyelim ;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
RMAN> RUN { 2> STARTUP MOUNT; 3> set until SCN 10608269; 4> ALLOCATE CHANNEL ch1 DEVICE TYPE sbt_tape ; 5> ALLOCATE CHANNEL ch2 DEVICE TYPE sbt_tape ; 6> ALLOCATE CHANNEL ch3 DEVICE TYPE sbt_tape ; 7> ALLOCATE CHANNEL ch4 DEVICE TYPE sbt_tape ; 8> ALLOCATE CHANNEL ch5 DEVICE TYPE sbt_tape ; 9> ALLOCATE CHANNEL ch6 DEVICE TYPE sbt_tape ; 10> RESTORE DATABASE; 11> RECOVER DATABASE; 12> release channel ch1; 13> release channel ch2; 14> release channel ch3; 15> release channel ch4; 16> release channel ch5; 17> release channel ch6; 18> ALTER DATABASE OPEN RESETLOGS; 19> } Oracle instance started database mounted Total System Global Area 5771362304 bytes Fixed Size 2936864 bytes Variable Size 989859808 bytes Database Buffers 3690987520 bytes Redo Buffers 13836288 bytes In-Memory Area 1073741824 bytes executing command: SET until clause using target database control file instead of recovery catalog allocated channel: ch1 channel ch1: SID=243 device type=SBT_TAPE channel ch1: Veritas NetBackup for Oracle - Release 7.5 (2013061020) … … Starting restore at 21-SEP-15 skipping datafile 5; already restored to file /u02/oradata/tcdb/dbf/tcdb/pdbseed/system01.dbf skipping datafile 7; already restored to file /u02/oradata/tcdb/dbf/tcdb/pdbseed/sysaux01.dbf channel ch1: starting datafile backup set restore channel ch1: specifying datafile(s) to restore from backup set channel ch1: restoring datafile 00045 to /u03/oradata/tcdb/pdbtcdb3/TCDB/datafile/o1_mf_sysaux_byf8qs8m_.dbf channel ch1: reading from backup piece bk_5064_1_890992891 … channel ch5: specifying datafile(s) to restore from backup set channel ch5: restoring datafile 00062 to /u02/oradata/tcdb/dbf/tcdb/plug1_db/data01_01.dbf channel ch5: reading from backup piece bk_5073_1_890992925 channel ch6: starting datafile backup set restore … channel ch1: restoring datafile 00064 to /u02/oradata/tcdb/dbf/tcdb/plug1_db/index01_01.dbf channel ch1: reading from backup piece bk_5075_1_890992936 channel ch6: piece handle=bk_5066_1_890992891 tag=TCDB_TEST_20150921 … channel ch1: restore complete, elapsed time: 00:00:25 Finished restore at 21-SEP-15 Starting recover at 21-SEP-15 starting media recovery … media recovery complete, elapsed time: 00:00:02 Finished recover at 21-SEP-15 … released channel: ch5 released channel: ch6 Statement processed RMAN> |
Şimdi tablolarımızı kontrol edelim ;
1 2 3 4 5 6 7 8 9 10 11 12 |
===> select count (*) from kamil.PITR_TEST COUNT(*) ---------- 2338 1 row selected. ===> select count (*) from kamil.PITR_TEST2 select count (*) from kamil.PITR_TEST2 * Error at line 1 ORA-00942: tablo veya görüntü mevcut degil |
Beklediğimiz sonucu yakalamış olduk.
• Pluggable Database Point In Time Recovery
Pluggable database üzerinde point in time recovery işlemi yapmadan önce mutlaka FRA alanının set edilmesi gerekecektir. Eğer bu işlem sırasında FRA’ yı kullanmak istemiyorsanız o zamanda restore komutu içerisinde AUXILARY DESTINATION’ ı set etmeniz gerekecektir.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
[oracle@Redhat70 ~]$ rman target / Recovery Manager: Release 12.1.0.2.0 - Production on Mon Sep 21 16:24:34 2015 Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved. connected to target database: TCDB (DBID=1730207577) RMAN> RUN { 2> set until sequence 15; 3> ALLOCATE CHANNEL ch1 DEVICE TYPE sbt_tape ; 4> ALLOCATE CHANNEL ch2 DEVICE TYPE sbt_tape ; 5> ALLOCATE CHANNEL ch3 DEVICE TYPE sbt_tape ; 6> ALLOCATE CHANNEL ch4 DEVICE TYPE sbt_tape ; 7> ALLOCATE CHANNEL ch5 DEVICE TYPE sbt_tape ; 8> ALLOCATE CHANNEL ch6 DEVICE TYPE sbt_tape ; 9> ALTER PLUGGABLE DATABASE PLUG1_DB CLOSE immediate ; 10> RESTORE PLUGGABLE DATABASE PLUG1_DB; 11> RECOVER PLUGGABLE DATABASE PLUG1_DB; 12> release channel ch1; 13> release channel ch2; 14> release channel ch3; 15> release channel ch4; 16> release channel ch5; 17> release channel ch6; 18> ALTER PLUGGABLE DATABASE PLUG1_DB OPEN RESETLOGS; 19> } executing command: SET until clause using target database control file instead of recovery catalog allocated channel: ch1 channel ch1: SID=6 device type=SBT_TAPE … Statement processed Starting restore at 21-SEP-15 … channel ORA_DISK_1: SID=124 device type=DISK channel ORA_SBT_TAPE_1: starting datafile backup set restore … Finished restore at 21-SEP-15 Starting recover at 21-SEP-15 using channel ORA_SBT_TAPE_1 using channel ORA_DISK_1 RMAN-05026: WARNING: presuming following set of tablespaces applies to specified Point-in-Time List of tablespaces expected to have UNDO segments Tablespace SYSTEM Tablespace UNDOTBS1 Creating automatic instance, with SID='iFhC' initialization parameters used for automatic instance: db_name=TCDB … _clone_one_pdb_recovery=true control_files=/u01/sq/ora_3/oracle/fast_recovery_area/TCDB/controlfile/o1_mf_c001cs8o_.ctl #No auxiliary parameter file used starting up automatic instance TCDB Oracle instance started Total System Global Area 2684354560 bytes Fixed Size 2928008 bytes Variable Size 603980408 bytes Database Buffers 2063597568 bytes Redo Buffers 13848576 bytes Automatic instance created contents of Memory Script: { # set requested point in time set until logseq 15 thread 1; # restore the controlfile restore clone controlfile; # mount the controlfile sql clone 'alter database mount clone database'; } executing Memory Script executing command: SET until clause Starting restore at 21-SEP-15 allocated channel: ORA_AUX_SBT_TAPE_1 … output file name=/u01/sq/ora_3/oracle/fast_recovery_area/TCDB/controlfile/o1_mf_c001cs8o_.ctl Finished restore at 21-SEP-15 sql statement: alter database mount clone database contents of Memory Script: { # set requested point in time set until logseq 15 thread 1; # switch to valid datafilecopies switch clone datafile 59 to datafilecopy "/u02/oradata/tcdb/dbf/tcdb/plug1_db/system01.dbf"; switch clone datafile 60 to datafilecopy "/u02/oradata/tcdb/dbf/tcdb/plug1_db/sysaux01.dbf"; switch clone datafile 61 to datafilecopy "/u02/oradata/tcdb/dbf/tcdb/plug1_db/plug1_db_users01.dbf"; switch clone datafile 65 to datafilecopy "/u02/oradata/tcdb/dbf/tcdb/plug1_db/data1_01.dbf"; # set destinations for recovery set and auxiliary set datafiles set newname for datafile 1 to "/u01/sq/ora_3/oracle/fast_recovery_area/TCDB/datafile/o1_mf_system_c001d6cy_.dbf"; … set newname for datafile 64 to "/u01/sq/ora_3/oracle/fast_recovery_area/TCDB/datafile/o1_mf_index01_c001dw79_.dbf"; # restore the tablespaces in the recovery set and the auxiliary set restore clone datafile 1, 4, 3, 6, 62, 63, 64; switch clone datafile all; } executing Memory Script executing command: SET until clause datafile 59 switched to datafile copy input datafile copy RECID=3 STAMP=891016013 file name=/u02/oradata/tcdb/dbf/tcdb/plug1_db/system01.dbf … datafile 65 switched to datafile copy input datafile copy RECID=6 STAMP=891016013 file name=/u02/oradata/tcdb/dbf/tcdb/plug1_db/data1_01.dbf executing command: SET NEWNAME … executing command: SET NEWNAME Starting restore at 21-SEP-15 using channel ORA_AUX_SBT_TAPE_1 using channel ORA_AUX_DISK_1 channel ORA_AUX_SBT_TAPE_1: starting datafile backup set restore channel ORA_AUX_SBT_TAPE_1: specifying datafile(s) to restore from backup set channel ORA_AUX_SBT_TAPE_1: restoring datafile 00004 to … channel ORA_AUX_SBT_TAPE_1: restored backup piece 1 channel ORA_AUX_SBT_TAPE_1: restore complete, elapsed time: 00:00:25 channel ORA_AUX_SBT_TAPE_1: starting datafile backup set restore channel ORA_AUX_SBT_TAPE_1: specifying datafile(s) to restore from backup set … channel ORA_AUX_SBT_TAPE_1: reading from backup piece bk_5137_1_891015518 channel ORA_AUX_SBT_TAPE_1: piece handle=bk_5137_1_891015518 tag=TCDB_TEST_20150921 channel ORA_AUX_SBT_TAPE_1: restored backup piece 1 … channel ORA_AUX_SBT_TAPE_1: restore complete, elapsed time: 00:00:07 Finished restore at 21-SEP-15 datafile 1 switched to datafile copy input datafile copy RECID=14 STAMP=891016144 file name=/u01/sq/ora_3/oracle/fast_recovery_area/TCDB/datafile/o1_mf_system_c001d6cy_.dbf … input datafile copy RECID=20 STAMP=891016144 file name=/u01/sq/ora_3/oracle/fast_recovery_area/TCDB/datafile/o1_mf_index01_c001dw79_.dbf contents of Memory Script: { # set requested point in time set until logseq 15 thread 1; # online the datafiles restored or switched sql clone "alter database datafile 1 online"; sql clone "alter database datafile 4 online"; sql clone "alter database datafile 3 online"; sql clone 'PLUG1_DB' "alter database datafile 59 online"; sql clone 'PLUG1_DB' "alter database datafile 60 online"; sql clone 'PLUG1_DB' "alter database datafile 61 online"; sql clone 'PLUG1_DB' "alter database datafile 65 online"; sql clone "alter database datafile 6 online"; sql clone "alter database datafile 62 online"; sql clone "alter database datafile 63 online"; sql clone "alter database datafile 64 online"; # recover pdb recover clone database tablespace "SYSTEM", "UNDOTBS1", "SYSAUX", "USERS", "DATA01", "DATA02", "INDEX01" pluggable database 'PLUG1_DB' delete archivelog; sql clone 'alter database open read only'; plsql <<<begin add_dropped_ts; end; >>>; plsql <<<begin save_pdb_clean_scn; end; >>>; # shutdown clone before import shutdown clone abort plsql <<<begin pdbpitr_inspect(pdbname => 'PLUG1_DB'); end; >>>; } executing Memory Script executing command: SET until clause sql statement: alter database datafile 1 online … sql statement: alter database datafile 64 online Starting recover at 21-SEP-15 using channel ORA_AUX_SBT_TAPE_1 using channel ORA_AUX_DISK_1 starting media recovery archived log for thread 1 with sequence 4 is already on disk as file /u04/oradata/tcdb/archive/tcdb_arch_1_4_891011103.arc … archived log file name=/u04/oradata/tcdb/archive/tcdb_arch_1_14_891011103.arc thread=1 sequence=14 media recovery complete, elapsed time: 00:00:02 Finished recover at 21-SEP-15 sql statement: alter database open read only Oracle instance shut down Removing automatic instance Automatic instance removed auxiliary instance file /u01/sq/ora_3/oracle/fast_recovery_area/TCDB/datafile/o1_mf_sysaux_c001d6dz_.dbf deleted auxiliary instance file /u01/sq/ora_3/oracle/fast_recovery_area/TCDB/controlfile/o1_mf_c001cs8o_.ctl deleted Finished recover at 21-SEP-15 |
AUXILARY DESTINATION kullanımına örnek olarak da aşağıdaki scripti verebiliriz.
RUN {
set until sequence 15;
ALLOCATE CHANNEL ch1 DEVICE TYPE sbt_tape ;
ALLOCATE CHANNEL ch2 DEVICE TYPE sbt_tape ;
ALLOCATE CHANNEL ch3 DEVICE TYPE sbt_tape ;
ALLOCATE CHANNEL ch4 DEVICE TYPE sbt_tape ;
ALLOCATE CHANNEL ch5 DEVICE TYPE sbt_tape ;
ALLOCATE CHANNEL ch6 DEVICE TYPE sbt_tape ;
ALTER PLUGGABLE DATABASE PLUG1_DB CLOSE immediate ;
RESTORE PLUGGABLE DATABASE PLUG1_DB;
RECOVER PLUGGABLE DATABASE PLUG1_DB auxiliary destination =’/u05/restore/plug_dba1′;
release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
release channel ch5;
release channel ch6;
ALTER PLUGGABLE DATABASE PLUG1_DB OPEN RESETLOGS;
}
Reference;
https://oracle-base.com/articles/12c/multitenant-rman-backup-recovery-cdb-and-pdb-12cr1#pdb-backup