Tuesday 19 May 2020

RMAN - ORA-01578| ORA-26040: Data block was loaded using the NOLOGGING option

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
  

RMAN - Restore the Loss of All Control Files using autobackup

Restore the Loss of All Control Files 

Scenario:
All control files are deleted we have auto backup control file configured. 

SQL> sho parameter control_files

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_files                        string      C:\APP\VARUNYADAV\ORADATA\SMRP
                                                 LM\CONTROL01.CTL, C:\APP\VARUN
                                                 YADAV\ORADATA\SMRPLM\CONTROL02
                                                 .CTL
SQL>


  • Remove controlfile at OS level, Check database by running query

SQL> select * from v$datafile;
select * from v$datafile
              *
ERROR at line 1:
ORA-01507: database not mounted


SQL>

  • Alert.log files details 

O/S-Error: (OS 2) The system cannot find the file specified.
2020-05-19T18:05:18.415109+05:30
Errors in file C:\APP\VARUNYADAV\diag\rdbms\smrplm\smrplm\trace\smrplm_m000_23056.trc:
ORA-00202: control file: 'C:\APP\VARUNYADAV\ORADATA\SMRPLM\CONTROL02.CTL'
ORA-27041: unable to open file
OSD-04002: unable to open file
O/S-Error: (OS 2) The system cannot find the file specified.
ORA-00210: cannot open the specified control file
ORA-00202: control file: 'C:\APP\VARUNYADAV\ORADATA\SMRPLM\CONTROL01.CTL'
ORA-27041: unable to open file
OSD-04002: unable to open file
O/S-Error: (OS 2) The system cannot find the file specified.
Checker run found 1 new persistent data failures

  • Recover controlfile using autobackup

C:\Users\varunyadav>rman target /

Recovery Manager: Release 12.2.0.1.0 - Production on Tue May 19 18:30:01 2020

Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.

connected to target database (not started)

RMAN> SET DBID 1550500176;

executing command: SET DBID

RMAN> STARTUP NOMOUNT;

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

RMAN> RESTORE CONTROLFILE FROM AUTOBACKUP;

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: looking for AUTOBACKUP on day: 20200519
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20200518
channel ORA_DISK_1: AUTOBACKUP found: c-1550500176-20200518-00
channel ORA_DISK_1: restoring control file from AUTOBACKUP c-1550500176-20200518-00
channel ORA_DISK_1: control file restore from AUTOBACKUP complete
output file name=C:\APP\VARUNYADAV\ORADATA\SMRPLM\CONTROL01.CTL
output file name=C:\APP\VARUNYADAV\ORADATA\SMRPLM\CONTROL02.CTL
Finished restore at 19-MAY-20

RMAN> SHUTDOWN ;

Oracle instance shut down

RMAN> STARTUP MOUNT

connected to target database (not started)
Oracle instance started
database mounted

Total System Global Area    5133828096 bytes

Fixed Size                     8757472 bytes
Variable Size               1207963424 bytes
Database Buffers            3909091328 bytes
Redo Buffers                   8015872 bytes

RMAN> RECOVER DATABASE;

Starting recover at 19-MAY-20
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=5 device type=DISK

starting media recovery

archived log for thread 1 with sequence 34 is already on disk as file C:\APP\VARUNYADAV\ORADATA\SMRPLM\REDO01.LOG
archived log for thread 1 with sequence 35 is already on disk as file C:\APP\VARUNYADAV\ORADATA\SMRPLM\REDO02.LOG
archived log file name=C:\APP\VARUNYADAV\ORADATA\SMRPLM\REDO01.LOG thread=1 sequence=34
archived log file name=C:\APP\VARUNYADAV\ORADATA\SMRPLM\REDO02.LOG thread=1 sequence=35
media recovery complete, elapsed time: 00:00:03
Finished recover at 19-MAY-20

  • Open database in resetlogs
RMAN> ALTER DATABASE OPEN RESETLOGS;

Statement processed

RMAN>

RMAN - ORA-00210: cannot open the specified control file

Recovery from the Loss of Subset of the Control Files

Scenario:

Control files deleted at OS level.  We got the error while executing queries it will through error.

One of the scenario solution is shutdown database and copy control file  and rename it or remove control from pfile and start database with pfile

Error:

ORA-00210: cannot open the specified control file
ORA-00202: control file: 'C:\APP\VARUNYADAV\ORADATA\SMRPLM\CONTROL02.CTL'
ORA-27041: unable to open file
OSD-04002: unable to open file
O/S-Error: (OS 2) The system cannot find the file specified.
ORA-205 signalled during: alter database mount exclusive...



  • 2 Control file present on location we will remove control02.ctl at OS level
SQL> sho parameter control_files

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_files                        string      C:\APP\VARUNYADAV\ORADATA\SMRP
                                                 LM\CONTROL01.CTL, C:\APP\VARUN
                                                 YADAV\ORADATA\SMRPLM\CONTROL02
                                                 .CTL
SQL>


Remove controlfile from os level C:\APP\VARUNYADAV\ORADATA\SMRPLM\CONTROL02.CTL


  • Shutdown and start database it through an error below:
SQL> select name,open_mode,database_role from v$database;
select name,open_mode,database_role from v$database
                                         *
ERROR at line 1:
ORA-01507: database not mounted


SQL>


ORA-00210: cannot open the specified control file
ORA-00202: control file: 'C:\APP\VARUNYADAV\ORADATA\SMRPLM\CONTROL02.CTL'
ORA-27041: unable to open file
OSD-04002: unable to open file
O/S-Error: (OS 2) The system cannot find the file specified.
ORA-205 signalled during: alter database mount exclusive...
2020-05-18T22:26:50.469919+05:30


  • Just copy existing controlfile which CONTROL01.CTL to CONTROL02.CTL at OS level and start database .


C:\Users\varunyadav>sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Mon May 18 22:34:08 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> shut abort
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.
Database opened.
SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
C:\APP\VARUNYADAV\ORADATA\SMRPLM\SYSTEM01.DBF
C:\APP\VARUNYADAV\ORADATA\SMRPLM\SYSAUX01.DBF
C:\APP\VARUNYADAV\ORADATA\SMRPLM\UNDOTBS01.DBF
C:\APP\VARUNYADAV\ORADATA\SMRPLM\USERS01.DBF
C:\APP\VARUNYADAV\ORADATA\SMRPLM\SOETBS01.DBF

SQL>