Para el presente caso la tabla será premeditadamente borrada. Tal como fue mencionada en la parte inicial del artículo, el caso que estamos desarrollando es el planteamiento de recuperación en caso de que una tabla sea accidentalmente borrada, corrupta, etc y la misma necesite ser recuperada/restaurada a un determinado punto del tiempo, disponiendo para la tarea un backup de la BBDD realizado con RMAN.
sandbox1(orawiss):/home/oracle>sqlplus / as sysdba SQL*Plus: Release 12.1.0.1.0 Production on Wed Jun 26 14:45:21 2013 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics and Real Application Testing options SQL> alter session set container=ORAWISS12C; Session altered. SQL> DROP TABLE wissem.test_rec PURGE; Table dropped. SQL> select * from wissem.test_rec; select * from wissem.test_rec * ERROR at line 1: ORA-00942: table or view does not exist SQL> exit Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics and Real Application Testing options sandbox1(orawiss):/home/oracle>
Sintaxis
Antes de la ejecución veamos la sintaxis del comando a ser utilizado:
RMAN> RECOVER TABLE username.tablename UNTIL TIME 'TIMESTAMP…' AUXILIARY DESTINATION '/u01/tablerecovery' DATAPUMP DESTINATION '/u01/dpump' DUMP FILE 'tablename.dmp' NOTABLEIMPORT REMAP TABLE 'username.tablename': 'username.new_table_name';
TABLE username.tablename: Tabla objeto de recuperación
UNTIL TIME 'TIMESTAMP…': Tiempo hasta el cual se establecerá la recuperación de la tabla
AUXILIARY DESTINATION: Directorio de alojamiento para la BBDD Auxiliar a ser creada
DATAPUMP DESTINATION: Directorio de alojamiento para el “Data Pump export dump file” a ser generado
DUMP FILE: Nombre de “Data Pump export dump file” a ser generado
NOTABLEIMPORT: Opción de control para establecer el posible restaurado de la tabla y/o particiones en la BBDD “Target”
REMAP TABLE 'username.tablename': 'username.new_table_name': Opción para renombrar la tabla a restaurar en la BBDD “Target”
UNTIL TIME 'TIMESTAMP…': Tiempo hasta el cual se establecerá la recuperación de la tabla
AUXILIARY DESTINATION: Directorio de alojamiento para la BBDD Auxiliar a ser creada
DATAPUMP DESTINATION: Directorio de alojamiento para el “Data Pump export dump file” a ser generado
DUMP FILE: Nombre de “Data Pump export dump file” a ser generado
NOTABLEIMPORT: Opción de control para establecer el posible restaurado de la tabla y/o particiones en la BBDD “Target”
REMAP TABLE 'username.tablename': 'username.new_table_name': Opción para renombrar la tabla a restaurar en la BBDD “Target”
Ejecución
En la presente ejecución la clausula “NOTABLEIMPORT” no esta presente en la conformación del comando “RECOVER TABLE”. Cuando la mencionada clausula es omitida, el proceso importa de forma automática la tabla en la BBDD “Target”.
sandbox1(orawiss):/home/oracle>rman Recovery Manager: Release 12.1.0.1.0 - Production on Wed Jun 26 15:28:04 2013 Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved. RMAN> CONNECT TARGET "sys AS SYSBACKUP"; target database Password: connected to target database: ORAWISS (DBID=3257067578) RMAN> RECOVER TABLE WISSEM.TEST_REC OF PLUGGABLE DATABASE ORAWISS12C UNTIL TIME "to_date('2013-06-26:14:45:00','YYYY-MM-DD:HH24:MI:SS')" AUXILIARY DESTINATION '/tmp' DATAPUMP DESTINATION '/tmp' DUMP FILE 'tst_dump2.dmp'; Starting recover at 06/26/2013 15:28:37 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=272 device type=DISK 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='AAxr' initialization parameters used for automatic instance: db_name=ORAWISS db_unique_name=AAxr_pitr_ORAWISS12C_ORAWISS compatible=12.1.0.0.0 db_block_size=8192 db_files=200 sga_target=1G processes=80 diagnostic_dest=/opt/app/oracle db_create_file_dest=/tmp log_archive_dest_1='location=/tmp' enable_pluggable_database=true _clone_one_pdb_recovery=true #No auxiliary parameter file used starting up automatic instance ORAWISS Oracle instance started Total System Global Area 1068937216 bytes Fixed Size 2296576 bytes Variable Size 281019648 bytes Database Buffers 780140544 bytes Redo Buffers 5480448 bytes Automatic instance created contents of Memory Script: { # set requested point in time set until time "to_date('2013-06-26:14:45:00','YYYY-MM-DD:HH24:MI:SS')"; # restore the controlfile restore clone controlfile; # mount the controlfile sql clone 'alter database mount clone database'; # archive current online log sql 'alter system archive log current'; } executing Memory Script executing command: SET until clause Starting restore at 06/26/2013 15:28:50 allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: SID=82 device type=DISK channel ORA_AUX_DISK_1: starting datafile backup set restore channel ORA_AUX_DISK_1: restoring control file channel ORA_AUX_DISK_1: reading from backup piece +DATA/ORAWISS/AUTOBACKUP/2013_06_26/s_819125085.301.819125085 channel ORA_AUX_DISK_1: piece handle=+DATA/ORAWISS/AUTOBACKUP/2013_06_26/s_819125085.301.819125085 tag=TAG20130626T144445 channel ORA_AUX_DISK_1: restored backup piece 1 channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07 output file name=/tmp/ORAWISS/controlfile/o1_mf_8wpj7slx_.ctl Finished restore at 06/26/2013 15:28:58 sql statement: alter database mount clone database sql statement: alter system archive log current contents of Memory Script: { # set requested point in time set until time "to_date('2013-06-26:14:45:00','YYYY-MM-DD:HH24:MI:SS')"; # set destinations for recovery set and auxiliary set datafiles set newname for clone datafile 1 to new; set newname for clone datafile 4 to new; set newname for clone datafile 3 to new; set newname for clone datafile 8 to new; set newname for clone datafile 9 to new; set newname for clone tempfile 1 to new; set newname for clone tempfile 3 to new; # switch all tempfiles switch clone tempfile all; # restore the tablespaces in the recovery set and the auxiliary set restore clone datafile 1, 4, 3, 8, 9; switch clone datafile all; } executing Memory Script executing command: SET until clause executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME renamed tempfile 1 to /tmp/ORAWISS/datafile/o1_mf_temp_%u_.tmp in control file renamed tempfile 3 to /tmp/ORAWISS/datafile/o1_mf_temp_%u_.tmp in control file Starting restore at 06/26/2013 15:29:04 using channel ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: starting datafile backup set restore channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set channel ORA_AUX_DISK_1: restoring datafile 00001 to /tmp/ORAWISS/datafile/o1_mf_system_%u_.dbf channel ORA_AUX_DISK_1: restoring datafile 00004 to /tmp/ORAWISS/datafile/o1_mf_undotbs1_%u_.dbf channel ORA_AUX_DISK_1: restoring datafile 00003 to /tmp/ORAWISS/datafile/o1_mf_sysaux_%u_.dbf channel ORA_AUX_DISK_1: reading from backup piece +DATA/ORAWISS/BACKUPSET/2013_06_26/nnndf0_tag20130626t123856_0.282.819117537 channel ORA_AUX_DISK_1: piece handle=+DATA/ORAWISS/BACKUPSET/2013_06_26/nnndf0_tag20130626t123856_0.282.819117537 tag=TAG20130626T123856 channel ORA_AUX_DISK_1: restored backup piece 1 channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15 channel ORA_AUX_DISK_1: starting datafile backup set restore channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set channel ORA_AUX_DISK_1: restoring datafile 00008 to /tmp/ORAWISS/datafile/o1_mf_system_%u_.dbf channel ORA_AUX_DISK_1: restoring datafile 00009 to /tmp/ORAWISS/datafile/o1_mf_sysaux_%u_.dbf channel ORA_AUX_DISK_1: reading from backup piece +DATA/ORAWISS/E011004AA64F0CF9E0433514DA0A096B/BACKUPSET/2013_06_26/nnndf0_tag20130 626t144437_0.298.819125079 channel ORA_AUX_DISK_1: piece handle=+DATA/ORAWISS/E011004AA64F0CF9E0433514DA0A096B/BACKUPSET/2013_06_26/nnndf0_t ag20130626t144437_0.298.819125079 tag=TAG20130626T144437 channel ORA_AUX_DISK_1: restored backup piece 1 channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07 Finished restore at 06/26/2013 15:29:27 datafile 1 switched to datafile copy input datafile copy RECID=8 STAMP=819127767 file name=/tmp/ORAWISS/datafile/o1_mf_system_8wpj8191_.dbf datafile 4 switched to datafile copy input datafile copy RECID=9 STAMP=819127767 file name=/tmp/ORAWISS/datafile/o1_mf_undotbs1_8wpj819j_.dbf datafile 3 switched to datafile copy input datafile copy RECID=10 STAMP=819127767 file name=/tmp/ORAWISS/datafile/o1_mf_sysaux_8wpj8199_.dbf datafile 8 switched to datafile copy input datafile copy RECID=11 STAMP=819127767 file name=/tmp/ORAWISS/datafile/o1_mf_system_8wpj8jf1_.dbf datafile 9 switched to datafile copy input datafile copy RECID=12 STAMP=819127767 file name=/tmp/ORAWISS/datafile/o1_mf_sysaux_8wpj8jdt_.dbf contents of Memory Script: { # set requested point in time set until time "to_date('2013-06-26:14:45:00','YYYY-MM-DD:HH24:MI:SS')"; # 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 'ORAWISS12C' "alter database datafile 8 online"; sql clone 'ORAWISS12C' "alter database datafile 9 online"; # recover and open database read only recover clone database tablespace "SYSTEM", "UNDOTBS1", "SYSAUX", "ORAWISS12C":"SYSTEM", "ORAWISS12C":"SYSAUX"; sql clone 'alter database open read only'; } executing Memory Script executing command: SET until clause sql statement: alter database datafile 1 online sql statement: alter database datafile 4 online sql statement: alter database datafile 3 online sql statement: alter database datafile 8 online sql statement: alter database datafile 9 online Starting recover at 06/26/2013 15:29:28 using channel ORA_AUX_DISK_1 starting media recovery archived log for thread 1 with sequence 15 is already on disk as file +DATA/ORAWISS/ARCHIVELOG/2013_06_26/thread_1_seq_15.279.819117567 archived log for thread 1 with sequence 16 is already on disk as file +DATA/ORAWISS/ARCHIVELOG/2013_06_26/thread_1_seq_16.278.819123911 archived log for thread 1 with sequence 17 is already on disk as file +DATA/ORAWISS/ARCHIVELOG/2013_06_26/thread_1_seq_17.294.819123955 archived log for thread 1 with sequence 18 is already on disk as file +DATA/ORAWISS/ARCHIVELOG/2013_06_26/thread_1_seq_18.296.819123981 archived log for thread 1 with sequence 19 is already on disk as file +DATA/ORAWISS/ARCHIVELOG/2013_06_26/thread_1_seq_19.295.819124251 archived log for thread 1 with sequence 20 is already on disk as file +DATA/ORAWISS/ARCHIVELOG/2013_06_26/thread_1_seq_20.297.819124297 archived log for thread 1 with sequence 21 is already on disk as file +DATA/ORAWISS/ARCHIVELOG/2013_06_26/thread_1_seq_21.299.819124453 archived log for thread 1 with sequence 22 is already on disk as file +DATA/ORAWISS/ARCHIVELOG/2013_06_26/thread_1_seq_22.286.819125213 archived log file name=+DATA/ORAWISS/ARCHIVELOG/2013_06_26/thread_1_seq_15.279.819117567 thread=1 sequence=15 archived log file name=+DATA/ORAWISS/ARCHIVELOG/2013_06_26/thread_1_seq_16.278.819123911 thread=1 sequence=16 archived log file name=+DATA/ORAWISS/ARCHIVELOG/2013_06_26/thread_1_seq_17.294.819123955 thread=1 sequence=17 archived log file name=+DATA/ORAWISS/ARCHIVELOG/2013_06_26/thread_1_seq_18.296.819123981 thread=1 sequence=18 archived log file name=+DATA/ORAWISS/ARCHIVELOG/2013_06_26/thread_1_seq_19.295.819124251 thread=1 sequence=19 archived log file name=+DATA/ORAWISS/ARCHIVELOG/2013_06_26/thread_1_seq_20.297.819124297 thread=1 sequence=20 archived log file name=+DATA/ORAWISS/ARCHIVELOG/2013_06_26/thread_1_seq_21.299.819124453 thread=1 sequence=21 archived log file name=+DATA/ORAWISS/ARCHIVELOG/2013_06_26/thread_1_seq_22.286.819125213 thread=1 sequence=22 media recovery complete, elapsed time: 00:00:04 Finished recover at 06/26/2013 15:29:34 sql statement: alter database open read only contents of Memory Script: { sql clone 'alter pluggable database ORAWISS12C open read only'; } executing Memory Script sql statement: alter pluggable database ORAWISS12C open read only contents of Memory Script: { sql clone "create spfile from memory"; shutdown clone immediate; startup clone nomount; sql clone "alter system set control_files = ''/tmp/ORAWISS/controlfile/o1_mf_8wpj7slx_.ctl'' comment= ''RMAN set'' scope=spfile"; shutdown clone immediate; startup clone nomount; # mount database sql clone 'alter database mount clone database'; } executing Memory Script sql statement: create spfile from memory database closed database dismounted Oracle instance shut down connected to auxiliary database (not started) Oracle instance started Total System Global Area 1068937216 bytes Fixed Size 2296576 bytes Variable Size 285213952 bytes Database Buffers 775946240 bytes Redo Buffers 5480448 bytes sql statement: alter system set control_files = ''/tmp/ORAWISS/controlfile/o1_mf_8wpj7slx_.ctl'' comment= ''RMAN set'' scope=spfile Oracle instance shut down connected to auxiliary database (not started) Oracle instance started Total System Global Area 1068937216 bytes Fixed Size 2296576 bytes Variable Size 285213952 bytes Database Buffers 775946240 bytes Redo Buffers 5480448 bytes sql statement: alter database mount clone database contents of Memory Script: { # set requested point in time set until time "to_date('2013-06-26:14:45:00','YYYY-MM-DD:HH24:MI:SS')"; # set destinations for recovery set and auxiliary set datafiles set newname for datafile 13 to new; # restore the tablespaces in the recovery set and the auxiliary set restore clone datafile 13; switch clone datafile all; } executing Memory Script executing command: SET until clause executing command: SET NEWNAME Starting restore at 06/26/2013 15:30:08 allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: SID=15 device type=DISK channel ORA_AUX_DISK_1: starting datafile backup set restore channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set channel ORA_AUX_DISK_1: restoring datafile 00013 to /tmp/AAXR_PITR_ORAWISS12C_ORAWISS/datafile/o1_mf_tbs_rec_%u_.dbf channel ORA_AUX_DISK_1: reading from backup piece +DATA/ORAWISS/E011004AA64F0CF9E0433514DA0A096B/BACKUPSET/2013_06_26/nnndf0_tag20130 626t144437_0.298.819125079 channel ORA_AUX_DISK_1: piece handle=+DATA/ORAWISS/E011004AA64F0CF9E0433514DA0A096B/BACKUPSET/2013_06_26/nnndf0_t ag20130626t144437_0.298.819125079 tag=TAG20130626T144437 channel ORA_AUX_DISK_1: restored backup piece 1 channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01 Finished restore at 06/26/2013 15:30:10 datafile 13 switched to datafile copy input datafile copy RECID=14 STAMP=819127810 file name=/tmp/AAXR_PITR_ORAWISS12C_ORAWISS/datafile/o1_mf_tbs_rec_8wpjb1c3_.dbf contents of Memory Script: { # set requested point in time set until time "to_date('2013-06-26:14:45:00','YYYY-MM-DD:HH24:MI:SS')"; # online the datafiles restored or switched sql clone 'ORAWISS12C' "alter database datafile 13 online"; # recover and open resetlogs recover clone database tablespace "ORAWISS12C":"TBS_REC", "SYSTEM", "UNDOTBS1", "SYSAUX", "ORAWISS12C":"SYSTEM", "ORAWISS12C":"SYSAUX" delete archivelog; alter clone database open resetlogs; } executing Memory Script executing command: SET until clause sql statement: alter database datafile 13 online Starting recover at 06/26/2013 15:30:10 using channel ORA_AUX_DISK_1 starting media recovery archived log for thread 1 with sequence 22 is already on disk as file +DATA/ORAWISS/ARCHIVELOG/2013_06_26/thread_1_seq_22.286.819125213 archived log file name=+DATA/ORAWISS/ARCHIVELOG/2013_06_26/thread_1_seq_22.286.819125213 thread=1 sequence=22 media recovery complete, elapsed time: 00:00:00 Finished recover at 06/26/2013 15:30:11 database opened contents of Memory Script: { sql clone 'alter pluggable database ORAWISS12C open'; } executing Memory Script sql statement: alter pluggable database ORAWISS12C open contents of Memory Script: { # create directory for datapump import sql 'ORAWISS12C' "create or replace directory TSPITR_DIROBJ_DPDIR as '' /tmp''"; # create directory for datapump export sql clone 'ORAWISS12C' "create or replace directory TSPITR_DIROBJ_DPDIR as '' /tmp''"; } executing Memory Script sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/tmp'' sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/tmp'' Performing export of tables... EXPDP> Starting "SYS"."TSPITR_EXP_AAxr_wgmi": EXPDP> Estimate in progress using BLOCKS method... EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA EXPDP> Total estimation using BLOCKS method: 64 KB EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER EXPDP> . . exported "WISSEM"."TEST_REC" 5.031 KB 1 rows EXPDP> Master table "SYS"."TSPITR_EXP_AAxr_wgmi" successfully loaded/unloaded EXPDP> ****************************************************************************** EXPDP> Dump file set for SYS.TSPITR_EXP_AAxr_wgmi is: EXPDP> /tmp/tst_dump2.dmp EXPDP> Job "SYS"."TSPITR_EXP_AAxr_wgmi" successfully completed at Wed Jun 26 15:30:51 2013 elapsed 0 00:00:22 Export completed contents of Memory Script: { # shutdown clone before import shutdown clone abort } executing Memory Script Oracle instance shut down Performing import of tables... IMPDP> Master table "SYSBACKUP"."TSPITR_IMP_AAxr_yzka" successfully loaded/unloaded IMPDP> Starting "SYSBACKUP"."TSPITR_IMP_AAxr_yzka": IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA IMPDP> . . imported "WISSEM"."TEST_REC" 5.031 KB 1 rows IMPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS IMPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER IMPDP> Job "SYSBACKUP"."TSPITR_IMP_AAxr_yzka" successfully completed at Wed Jun 26 15:31:23 2013 elapsed 0 00:00:08 Import completed Removing automatic instance Automatic instance removed auxiliary instance file /tmp/ORAWISS/datafile/o1_mf_temp_8wpj92wr_.tmp deleted auxiliary instance file /tmp/ORAWISS/datafile/o1_mf_temp_8wpj8zhc_.tmp deleted auxiliary instance file /tmp/AAXR_PITR_ORAWISS12C_ORAWISS/onlinelog/o1_mf_3_8wpjb4l3_.log deleted auxiliary instance file /tmp/AAXR_PITR_ORAWISS12C_ORAWISS/onlinelog/o1_mf_2_8wpjb49s_.log deleted auxiliary instance file /tmp/AAXR_PITR_ORAWISS12C_ORAWISS/onlinelog/o1_mf_1_8wpjb434_.log deleted auxiliary instance file /tmp/AAXR_PITR_ORAWISS12C_ORAWISS/datafile/o1_mf_tbs_rec_8wpjb1c3_.dbf deleted auxiliary instance file /tmp/ORAWISS/datafile/o1_mf_sysaux_8wpj8jdt_.dbf deleted auxiliary instance file /tmp/ORAWISS/datafile/o1_mf_system_8wpj8jf1_.dbf deleted auxiliary instance file /tmp/ORAWISS/datafile/o1_mf_sysaux_8wpj8199_.dbf deleted auxiliary instance file /tmp/ORAWISS/datafile/o1_mf_undotbs1_8wpj819j_.dbf deleted auxiliary instance file /tmp/ORAWISS/datafile/o1_mf_system_8wpj8191_.dbf deleted auxiliary instance file /tmp/ORAWISS/controlfile/o1_mf_8wpj7slx_.ctl deleted auxiliary instance file tst_dump2.dmp deleted Finished recover at 06/26/2013 15:31:28 RMAN> exit
Verificado de resultado
La tabla que fue anteriormente borrada fue recuperada por el proceso.
Recovery Manager complete. sandbox1(orawiss):/home/oracle>sqlplus / as sysdba SQL*Plus: Release 12.1.0.1.0 Production on Wed Jun 26 15:31:36 2013 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics and Real Application Testing options SQL> alter session set container=ORAWISS12C; Session altered. SQL> select * from wissem.test_rec; ID ---------- 1 SQL>
Durante la ejecución se pudieron observar detalles importantes que harán que usted como lector pueda entender los procesos internos realizados. Veamos detalles del mismo:
• Ejecución del comando “RECOVER TABLE”
RMAN> RECOVER TABLE WISSEM.TEST_REC OF PLUGGABLE DATABASE ORAWISS12C UNTIL TIME "to_date('2013-06-26:14:45:00','YYYY-MM-DD:HH24:MI:SS')" AUXILIARY DESTINATION '/tmp' DATAPUMP DESTINATION '/tmp' DUMP FILE 'tst_dump2.dmp';
• Establecimiento de Parámetros de Inicialización para la Instancia Auxiliar con bajo consumo de recursos
initialization parameters used for automatic instance: db_name=ORAWISS db_unique_name=AAxr_pitr_ORAWISS12C_ORAWISS compatible=12.1.0.0.0 db_block_size=8192 db_files=200 sga_target=1G processes=80 diagnostic_dest=/opt/app/oracle db_create_file_dest=/tmp log_archive_dest_1='location=/tmp' enable_pluggable_database=true _clone_one_pdb_recovery=true
• Restaurado de “Controlfiles” para iniciar el proceso de recuperación
# set requested point in time set until time "to_date('2013-06-26:14:45:00','YYYY-MM-DD:HH24:MI:SS')"; # restore the controlfile restore clone controlfile; # mount the controlfile
• Proceso de Restauración de “Tablespaces”
# set requested point in time set until time "to_date('2013-06-26:14:45:00','YYYY-MM-DD:HH24:MI:SS')"; # set destinations for recovery set and auxiliary set datafiles set newname for clone datafile 1 to new; set newname for clone datafile 4 to new; set newname for clone datafile 3 to new; set newname for clone datafile 8 to new; set newname for clone datafile 9 to new; set newname for clone tempfile 1 to new; set newname for clone tempfile 3 to new; # switch all tempfiles switch clone tempfile all; # restore the tablespaces in the recovery set and the auxiliary set restore clone datafile 1, 4, 3, 8, 9; switch clone datafile all;
• Restaurado de “Datafiles” en la ruta indicada por el parámetro “AUXILIARY DESTINATION”
channel ORA_AUX_DISK_1: starting datafile backup set restore channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set channel ORA_AUX_DISK_1: restoring datafile 00001 to /tmp/ORAWISS/datafile/o1_mf_system_%u_.dbf channel ORA_AUX_DISK_1: restoring datafile 00004 to /tmp/ORAWISS/datafile/o1_mf_undotbs1_%u_.dbf channel ORA_AUX_DISK_1: restoring datafile 00003 to /tmp/ORAWISS/datafile/o1_mf_sysaux_%u_.dbf
• Recuperación “Until Time” de la BBDD Auxiliar
Starting recover at 06/26/2013 15:23:16 using channel ORA_AUX_DISK_1 starting media recovery archived log for thread 1 with sequence 15 is already on disk as file +DATA/ORAWISS/ARCHIVELOG/2013_06_26/thread_1_seq_15.279.819117567 …
# set requested point in time set until time "to_date('2013-06-26:14:45:00','YYYY-MM-DD:HH24:MI:SS')"; # set destinations for recovery set and auxiliary set datafiles set newname for datafile 13 to new; # restore the tablespaces in the recovery set and the auxiliary set restore clone datafile 13; switch clone datafile all;
• Generación del “Data Pump export dump file”
sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/tmp'' Performing export of tables... EXPDP> Starting "SYS"."TSPITR_EXP_AAxr_wgmi": EXPDP> Estimate in progress using BLOCKS method... EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA EXPDP> Total estimation using BLOCKS method: 64 KB EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER EXPDP> . . exported "WISSEM"."TEST_REC" 5.031 KB 1 rows EXPDP> Master table "SYS"."TSPITR_EXP_AAxr_wgmi" successfully loaded/unloaded EXPDP> ***************************************************************** EXPDP> Dump file set for SYS.TSPITR_EXP_AAxr_wgmi is: EXPDP> /tmp/tst_dump2.dmp EXPDP> Job "SYS"."TSPITR_EXP_AAxr_wgmi" successfully completed at Wed Jun 26 15:30:51 2013 elapsed 0 00:00:22 Export completed
“Data Pump export dump file” resultante: EXPDP> /tmp/tst_dump2.dmp
• “Import” automático de la tabla en la BBDD “Target”
Performing import of tables... IMPDP> Master table "SYSBACKUP"."TSPITR_IMP_AAxr_yzka" successfully loaded/unloaded IMPDP> Starting "SYSBACKUP"."TSPITR_IMP_AAxr_yzka": IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA IMPDP> . . imported "WISSEM"."TEST_REC" 5.031 KB 1 rows IMPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS IMPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER IMPDP> Job "SYSBACKUP"."TSPITR_IMP_AAxr_yzka" successfully completed at Wed Jun 26 15:31:23 2013 elapsed 0 00:00:08 Import completed
• Remoción automática de los componentes de la BBDD “Auxiliar”
Removing automatic instance Automatic instance removed auxiliary instance file /tmp/ORAWISS/datafile/o1_mf_temp_8wpj92wr_.tmp deleted auxiliary instance file /tmp/ORAWISS/datafile/o1_mf_temp_8wpj8zhc_.tmp deleted auxiliary instance file /tmp/AAXR_PITR_ORAWISS12C_ORAWISS/onlinelog/o1_mf_3_8wpjb4l3_.log deleted auxiliary instance file /tmp/AAXR_PITR_ORAWISS12C_ORAWISS/onlinelog/o1_mf_2_8wpjb49s_.log deleted auxiliary instance file /tmp/AAXR_PITR_ORAWISS12C_ORAWISS/onlinelog/o1_mf_1_8wpjb434_.log deleted auxiliary instance file /tmp/AAXR_PITR_ORAWISS12C_ORAWISS/datafile/o1_mf_tbs_rec_8wpjb1c3_.dbf deleted auxiliary instance file /tmp/ORAWISS/datafile/o1_mf_sysaux_8wpj8jdt_.dbf deleted auxiliary instance file /tmp/ORAWISS/datafile/o1_mf_system_8wpj8jf1_.dbf deleted auxiliary instance file /tmp/ORAWISS/datafile/o1_mf_sysaux_8wpj8199_.dbf deleted auxiliary instance file /tmp/ORAWISS/datafile/o1_mf_undotbs1_8wpj819j_.dbf deleted auxiliary instance file /tmp/ORAWISS/datafile/o1_mf_system_8wpj8191_.dbf deleted auxiliary instance file /tmp/ORAWISS/controlfile/o1_mf_8wpj7slx_.ctl deleted auxiliary instance file tst_dump2.dmp deleted Finished recover at 06/26/2013 15:31:28
Conclusiones
Tal como se ha señalado en el desarrollo del artículo, esta nueva característica nos brinda la facilidad de recuperar tablas y/o particiones de tablas con un proceso directo haciendo uso optimo de recursos como: disco, memoria y otros relacionados con el proceso.
El comando “RECOVER TABLE” no solo tiene impacto en la acción directa que realiza, sino también en como lograra cambiar en concepto del papel que juegan los respaldos lógicos que muchas empresas llevaban a cabo para prevenir la posible recuperación de objetos sin tener que restaurar la BBDD completa.
Antes de finalizar el presente artículo veamos cuadro comparativo de las ventajas que posee el nuevo “RECOVER TABLE” con respecto a TSPITR ( Tablespace Point-in-Time Recovery )
No hay comentarios:
Publicar un comentario