Monday, March 14, 2016

ORA-10873:file 1 needs to be either taken out of backup mode or media recovered ORA-01110: data file 1: '+DATA / testbk/ datafile/ system.256.897496663'

ORA-10873:file 1 needs to be either taken out of backup mode or media recovered  ORA-01110: data file 1: '+DATA / testbk/ datafile/ system.256.897496663'

Cause: ORA-10873
In case you force fully trying to shutdown database with “shutdown abort” OR instance crashes for some reason OR database have not been shutdown gracefully than you would encountered “ORA-10873” error while next startup of your database.

SQL> startup
ORACLE instance started.

Total System Global Area 5127602176 bytes
Fixed Size                  2214432 bytes
Variable Size            4580181472 bytes
Database Buffers          536870912 bytes
Redo Buffers                8335360 bytes
Database mounted.
ORA-10873: file 1 needs to be either taken out of backup mode or media recovered
ORA-01110: data file 1: '+DATA/testbk/datafile/system.256.897496663'

Solution:  Issue following SQL command in order to move out database from hot backup mode:
SQL> alter database end backup;
alter database end backup
*
ERROR at line 1:
ORA-01260: warning: END BACKUP succeeded but some files found not to be in
backup mode

OR

SQL> alter tablespace system end backup;

Open database
SQL> alter database open;
Database altered.

ORA-01149: cannot shutdown - file 1 has online backup set, ORA-01110: data file 1: '+DATA / testbk/ datafile/ system.256.897496663'

ORA-01149: cannot shutdown - file 1 has online backup set, ORA-01110: data file 1: '+DATA / testbk/ datafile/ system.256.897496663'

Oracle Error: While shutdown your database you may encounter following oracle error.
SQL> shutdown immediate
ORA-01149: cannot shutdown - file 1 has online backup set
ORA-01110: data file 1: '+DATA/testbk/datafile/system.256.897496663'

Cause: If you try to shutdown database when database is in hot backup mode, you will encounter above mentioned error. Kindly verify with your team mates with hot backup activity, Oracle will not allow you to shut down your database in above scenario, i.e. shutdown, shutdown immediate, shutdown transactional OR startup force will be failed with ORA-01149 oracle error.

Root cause detection: 
Following query will help you to understand which oracle tablespace datafile is in hot backup mode.
SQL> select a.tablespace_name, b.status from dba_data_files a, v$backup b where a.file_id=b.file# order by tablespace_name;

TABLESPACE_NAME                STATUS
------------------------------ ------------------
NBLT24DATA                     NOT ACTIVE
NBLT24DATA                     NOT ACTIVE
NBLT24DATA                     NOT ACTIVE
NBLT24DATA                     NOT ACTIVE
NBLT24DATA                     NOT ACTIVE
NBLT24INDEX                    NOT ACTIVE
SYSAUX                         NOT ACTIVE
SYSTEM                         ACTIVE
UNDOTBS1                       NOT ACTIVE
USERS                          NOT ACTIVE

10 rows selected.

Note: Status of the SYSTEM datafile seems to be active. i.e. hot backup mode.


Solution:
Issue following SQL command in order to move out database from hot backup mode:
SQL> alter database end backup;
alter database end backup
*
ERROR at line 1:
ORA-01260: warning: END BACKUP succeeded but some files found not to be in
backup mode

OR

SQL> alter tablespace system end backup;


Shutdown database
SQL> shutdown abort/immediate
ORACLE instance shut down.
SQL>

Open database
SQL> startup
ORACLE instance started.

Total System Global Area 5127602176 bytes
Fixed Size                  2214432 bytes
Variable Size            4580181472 bytes
Database Buffers          536870912 bytes
Redo Buffers                8335360 bytes
Database mounted.
Database opened.
SQL>
SQL> select a.tablespace_name, b.status from dba_data_files a, v$backup b where a.file_id=b.file# order by tablespace_name;

TABLESPACE_NAME                STATUS
------------------------------ ------------------
NBLT24DATA                     NOT ACTIVE
NBLT24DATA                     NOT ACTIVE
NBLT24DATA                     NOT ACTIVE
NBLT24DATA                     NOT ACTIVE
NBLT24DATA                     NOT ACTIVE
NBLT24INDEX                    NOT ACTIVE
SYSAUX                         NOT ACTIVE
SYSTEM                         NOT ACTIVE
UNDOTBS1                       NOT ACTIVE
USERS                          NOT ACTIVE
10 rows selected.
SQL>