Recovering NOLOGGING Operations
Scenario:
We have have taken full DB backup and created table with no logging option after rman backup , So crashing DB by deleting all datafiles at os level.
We can see after rman backup restoration when executing query of no logging table it will throw error.
So need to recreate table again and take backup again.
Error:
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 7, block # 4627)
ORA-01110: data file 7: 'C:\APP\TEST\ORADATA\TEST1\USERS01.DBF'
ORA-26040: Data block was loaded using the NOLOGGING option
Recovering NOLOGGING Operations
- Connect to the rman and take full db backup
C:\Users\TEST>rman target /
Recovery Manager: Release 12.2.0.1.0 - Production on Tue May 19 18:53:47 2020
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
connected to target database: TEST1 (DBID=1550500176)
RMAN> backup database plus archivelog;
Starting backup at 19-MAY-20
current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=5 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=33 RECID=6 STAMP=1040841311
input archived log thread=1 sequence=34 RECID=4 STAMP=1040841306
input archived log thread=1 sequence=35 RECID=5 STAMP=1040841310
channel ORA_DISK_1: starting piece 1 at 19-MAY-20
channel ORA_DISK_1: finished piece 1 at 19-MAY-20
piece handle=C:\APP\TEST\PRODUCT\12.2.0\DBHOME_1\DATABASE\05V0JVQ2_1_1 tag=TAG20200519T185602 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=1 RECID=7 STAMP=1040842561
channel ORA_DISK_1: starting piece 1 at 19-MAY-20
channel ORA_DISK_1: finished piece 1 at 19-MAY-20
piece handle=C:\APP\TEST\PRODUCT\12.2.0\DBHOME_1\DATABASE\06V0JVQ9_1_1 tag=TAG20200519T185602 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 19-MAY-20
Starting backup at 19-MAY-20
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00008 name=C:\APP\TEST\ORADATA\TEST1\TESTTBS01.DBF
input datafile file number=00003 name=C:\APP\TEST\ORADATA\TEST1\SYSAUX01.DBF
input datafile file number=00001 name=C:\APP\TEST\ORADATA\TEST1\SYSTEM01.DBF
input datafile file number=00005 name=C:\APP\TEST\ORADATA\TEST1\UNDOTBS01.DBF
input datafile file number=00007 name=C:\APP\TEST\ORADATA\TEST1\USERS01.DBF
channel ORA_DISK_1: starting piece 1 at 19-MAY-20
channel ORA_DISK_1: finished piece 1 at 19-MAY-20
piece handle=C:\APP\TEST\PRODUCT\12.2.0\DBHOME_1\DATABASE\07V0JVQB_1_1 tag=TAG20200519T185611 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:25
Finished backup at 19-MAY-20
Starting backup at 19-MAY-20
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=2 RECID=8 STAMP=1040842717
channel ORA_DISK_1: starting piece 1 at 19-MAY-20
channel ORA_DISK_1: finished piece 1 at 19-MAY-20
piece handle=C:\APP\TEST\PRODUCT\12.2.0\DBHOME_1\DATABASE\08V0JVUT_1_1 tag=TAG20200519T185837 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 19-MAY-20
Starting Control File and SPFILE Autobackup at 19-MAY-20
piece handle=C:\APP\TEST\PRODUCT\12.2.0\DBHOME_1\DATABASE\C-1550500176-20200519-01 comment=NONE
Finished Control File and SPFILE Autobackup at 19-MAY-20
- Create test table with no logging option
C:\Users\TEST>sqlplus / as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on Tue May 19 19:00:26 2020
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL> conn TEST/TEST
Connected.
SQL> CREATE TABLE TEST NOLOGGING AS SELECT SUM(ORDER_TOTAL) TEST_SUM, TO_CHAR(ORDER_DATE,'YYYY-MM') ORDER_MONTH FROM TEST GROUP BY TO_CHAR(ORDER_DATE,'YYYY-MM') ORDER BY TO_CHAR(ORDER_DATE,'YYYY-MM');
Table created.
SQL>
- Remove datafile at os level
SQL> shut immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 5133828096 bytes
Fixed Size 8757472 bytes
Variable Size 1207963424 bytes
Database Buffers 3909091328 bytes
Redo Buffers 8015872 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: 'C:\APP\TEST\ORADATA\TEST1\SYSTEM01.DBF'
SQL>
- Perform restoration and recover datafile using Rman Backup
SQL> SHUTDOWN IMMEDIATE ;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> STARTUP MOUNT ;
ORACLE instance started.
Total System Global Area 5133828096 bytes
Fixed Size 8757472 bytes
Variable Size 1207963424 bytes
Database Buffers 3909091328 bytes
Redo Buffers 8015872 bytes
Database mounted.
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
C:\Users\TEST>rman target /
Recovery Manager: Release 12.2.0.1.0 - Production on Tue May 19 19:21:55 2020
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
connected to target database: TEST1 (DBID=1550500176, not open)
RMAN> RESTORE DATABASE;
Starting restore at 19-MAY-20
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=252 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to C:\APP\TEST\ORADATA\TEST1\SYSTEM01.DBF
channel ORA_DISK_1: restoring datafile 00003 to C:\APP\TEST\ORADATA\TEST1\SYSAUX01.DBF
channel ORA_DISK_1: restoring datafile 00005 to C:\APP\TEST\ORADATA\TEST1\UNDOTBS01.DBF
channel ORA_DISK_1: restoring datafile 00007 to C:\APP\TEST\ORADATA\TEST1\USERS01.DBF
channel ORA_DISK_1: restoring datafile 00008 to C:\APP\TEST\ORADATA\TEST1\TESTTBS01.DBF
channel ORA_DISK_1: reading from backup piece C:\APP\TEST\PRODUCT\12.2.0\DBHOME_1\DATABASE\07V0JVQB_1_1
channel ORA_DISK_1: piece handle=C:\APP\TEST\PRODUCT\12.2.0\DBHOME_1\DATABASE\07V0JVQB_1_1 tag=TAG20200519T185611
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:02:26
Finished restore at 19-MAY-20
RMAN>
RMAN> RECOVER DATABASE;
Starting recover at 19-MAY-20
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:01
Finished recover at 19-MAY-20
RMAN> ALTER DATABASE OPEN;
Statement processed
RMAN>
- Check table after restoration, It will through error below.
SQL> conn TEST/TEST
Connected.
SQL> SELECT * FROM TEST;
SELECT * FROM TEST
*
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 7, block # 4627)
ORA-01110: data file 7: 'C:\APP\TEST\ORADATA\TEST1\USERS01.DBF'
ORA-26040: Data block was loaded using the NOLOGGING option
SQL>
SQL> DROP TABLE TEST PURGE;
Table dropped.
- Recreate table again and take backup , avoid no logging option when creating table
SQL> CREATE TABLE TEST NOLOGGING AS SELECT SUM(ORDER_TOTAL) TEST_SUM, TO_CHAR(ORDER_DATE,'YYYY-MM') ORDER_MONTH FROM TEST GROUP BY TO_CHAR(ORDER_DATE,'YYYY-MM') ORDER BY TO_CHAR(ORDER_DATE,'YYYY-MM');
Table created.
SQL> SELECT * FROM TEST;
TEST_SUM ORDER_M
---------- -------
8707 2020-01
8707 2020-01
No comments:
Post a Comment