Monday, October 20, 2014

RMAN>Recovery through RESETLOGS and reset of the incarnation of the database


Prior to Oracle 10g, the redo log files generated after opening the database with RESETLOGS could not be used with the backups taken before the RESETLOGS was performed.
Therefore, whenever a resetlogs was done, it was important to take an immediate full database backup, since all previous backups became invalid.

Just to recap, a RESETLOGS needs to be performed when we

1)         Do a point in time recovery
2)         Recover a database using a backup of the control file

What does a RESETLOGS do?

• Archives the current online redo logs (if they are accessible) and then erases the contents of the online redo logs and resets the log sequence number to 1.
• Creates the online redo log files if they do not currently exist.
• Updates all current datafiles and online redo logs and all subsequent archived redo logs with a new RESETLOGS SCN and time stamp

The Recovery through Resetlogs feature provides the following benefits:

* There is no need to perform a full backup after an incomplete recovery.
* There is no need to recreate a new standby database after a failover operation.
* You can take incremental backups based on full backups of a previous incarnation when you use RMAN.
* Block media recovery can restore backups from parent incarnation backups and recover the corrupted blocks through a RESETLOGS operation.
* You can use the newly generated logs with an earlier incarnation of the database.

Important:

To perform recovery through RESETLOGS you must have all archived logs generated after the most recent backup.

The new log_archive_format introduced in 10g

Oracle 10g introduces a new format specification for archived log files. This new format avoids overwriting archived redo log files with the same sequence number across incarnations.

SQL> show parameter log_archive_format
NAME TYPE VALUE
----------------------- ----------- ----------------
log_archive_format string %t_%s_%r.dbf

The format specification of the log_archive_format string "%"r represents the resetlogs id. It will ensure that a unique name is constructed for the archived redo log file during RMAN restore and as well as restoring via SQL*plus auto recovery mode.

Note: The database would not start if you remove the %r from the log archive format specification.

What is an incarnation?

A database incarnation is created whenever you open the database with the RESETLOGS option.

The Current incarnation is the one in which the database is running at present

The incarnation from which the current incarnation branched after a ALTER DATABASE OPEN RESETLOGS  was performed is called the Parent incarnation.

If you want to go back to some SCN which is not part of the Current database incarnation, we need to use the RESET DATABASE TO INCARNATION 
command as shown in the example below

The purpose of incarnations

An incarnation helps to identify redo streams which have the same SCN, but occurred at different points in time. This prevents the possibility of applying the wrong archive log file from a previous incarnation which could corrupt the database.

Suppose we are at incarnation 1 and are at SCN 100 in the database. I do a resetlogs and now the incarnation of the database becomes 2. Suppose we do another resetlogs and it so happens that the SCN at the time we did the resetlogs was also 100. Somewhere down the line later  we want to do a point in time recovery and want to recover the database until SCN 100. How does Oracle know which is the correct SCN and how far back in time should the database be rolled back to and which archive logs need to be applied?

This is where incarnations come in and we will see how we can set the database to a particular incarnation to enable RMAN to do a point in time recovery.

Example

Let us now run the LIST INCARNATION OF DATABASE command from RMAN and this is the output.

List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1       1       TEST11G  916751459        PARENT  1          15-AUG-09
2       2       TEST11G  916751459        CURRENT 945184     18-OCT-11


What is the current SCN of the database?

SQL> select current_scn from v$database;

CURRENT_SCN
-----------
     991395

Now, let us make a change in the database which we will then try to undo by restoring  and recovering the database to a point in time before the media failure or as in this case, a wrong transaction has happened.

SQL> conn sh/sh
Connected.

SQL> select count(*) from sales;

  COUNT(*)
----------
    918843

SQL> delete from sales where rownum < 1001;

1000 rows deleted.

SQL> commit;

Commit complete.

SQL> select count(*) from sales;

  COUNT(*)
----------
    917843

We now will roll the database back to an SCN before the delete operation was performed.


SQL> conn / as sysdba
Connected.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;


[oracle@orasql-001 u01]$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Tue Oct 18 09:41:08 2011

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

connected to target database: TEST11G (DBID=916751459, not open)

RMAN> run {
2> set until scn 991395;
3> restore database;
4> recover database;
5> }

executing command: SET until clause

Starting restore at 18-OCT-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=63 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 /u01/oradata/TEST11G/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/oradata/TEST11G/sysaux01.dbf

….
….

channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 18-OCT-11

Starting recover at 18-OCT-11
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:00

Finished recover at 18-OCT-11

RMAN> alter database open resetlogs;

database opened



We can now see that the deleted rows have been recovered and the number of rows in the table is now the same as before the delete operation was performed.

SQL> select count(*) from sh.sales;

  COUNT(*)
----------
    918843


Let us check what the incarnation of the database is.

RMAN> list incarnation of database;

using target database control file instead of recovery catalog

List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1       1       TEST11G  916751459        PARENT  1          15-AUG-09
2       2       TEST11G  916751459        PARENT  945184     18-OCT-11
3       3       TEST11G  916751459        CURRENT 991396     18-OCT-11


The current incarnation of the database is 3 and since we have recovered the database until SCN 991395, the RESET SCN has been set to the SCN 991396.

The alert log of the database will also log this resetlogs operation and we will see lines the ones shown below:

Incomplete Recovery applied until change 991395 time 10/18/2011 09:39:19
Media Recovery Complete (TEST11G)
Completed: alter database recover if needed
 start until change 991395
Tue Oct 18 09:42:14 2011
alter database open resetlogs
Archived Log entry 3 added for thread 1 sequence 5 ID 0x36a3e663 dest 1:
RESETLOGS after incomplete recovery UNTIL CHANGE 991395

Setting recovery target incarnation to 3
Tue Oct 18 09:42:15 2011
Assigning activation ID 916768223 (0x36a4c5df)



Now let us make another delete from the sales table.

SQL> delete from sh.sales where rownum < 10001;

10000 rows deleted.

SQL> commit;

Commit complete.

SQL> select count(*) from sh.sales;

  COUNT(*)
----------
    908843


Now, let us shutdown the database, startup and mount it and try the same incomplete recovery which we tried earlier until the SCN 991395


oracle@orasql-001 u01]$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Tue Oct 18 09:46:29 2011

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

connected to target database: TEST11G (DBID=916751459, not open)

RMAN> run {
2>  set until scn 991395;
3> restore database;
4> recover database;
5> }

executing command: SET until clause

Starting restore at 18-OCT-11
using target database control file instead of recovery catalog
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 10/18/2011 09:46:55
RMAN-20208: UNTIL CHANGE is before RESETLOGS change





We get the error RMAN-20208 because since the current incarnation of the database is 3 and we trying to go to an SCN before this incarnation.


So how do we go back to SCN 993195?

For this to happen, we need to change the current incarnation (3) of the database to an older incarnation (2). The SCN 993195 was present during the incarnation 2.


After resetting the incarnation to 2, we now see that the restore is proceeding fine.


RMAN> reset database to incarnation 2;

database reset to incarnation 2

RMAN>  run {
2>  set until scn 991395;
3>  restore database;
4> recover database;
5> }

executing command: SET until clause

Starting restore at 18-OCT-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=63 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 /u01/oradata/TEST11G/system01.dbf

channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 18-OCT-11

Starting recover at 18-OCT-11
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 4 is already on disk as file /u01/oradata/TEST11G/arch/1_4_764845989.arch
archived log for thread 1 with sequence 5 is already on disk as file /u01/oradata/TEST11G/arch/1_5_764845989.arch
archived log file name=/u01/oradata/TEST11G/arch/1_4_764845989.arch thread=1 sequence=4
archived log file name=/u01/oradata/TEST11G/arch/1_5_764845989.arch thread=1 sequence=5
media recovery complete, elapsed time: 00:00:00
Finished recover at 18-OCT-11



Now we open the database with the ALTER DATABASE OPEN RESETOGS command and see that a new incarnation key (4) has been allocated to the database as the CURRENT incarnation and the previous incarnation (3) has become an ORPHAN incarnation.

RMAN> list incarnation of database;


List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1       1       TEST11G  916751459        PARENT  1          15-AUG-09
2       2       TEST11G  916751459        PARENT  945184     18-OCT-11
3       3       TEST11G  916751459        ORPHAN  991396     18-OCT-11
4       4       TEST11G  916751459        CURRENT 991396     18-OCT-11



Now let us do the same procedure once again:

Delete some rows
Set the database to incarnation 2
Recover the database until the same SCN as previous case – 991395
Open the database with resetlogs

Now list the incarnation of the database


RMAN> list incarnation of database;


List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1       1       TEST11G  916751459        PARENT  1          15-AUG-09
2       2       TEST11G  916751459        PARENT  945184     18-OCT-11
4       4       TEST11G  916751459        ORPHAN  991396     18-OCT-11
5       5       TEST11G  916751459        CURRENT 991396     18-OCT-11
3       3       TEST11G  916751459        ORPHAN  991396     18-OCT-11


The incarnation key 5 now is the CURRENT incarnation of the database, and incarnations 3 and 4 both have become ORPHAN.
The current SCN now is 991734

SQL> select current_scn from v$database;

CURRENT_SCN
-----------
     991734

What happens if we change the structure of the database?  And we do not take any new backup after this change was made, but try and recover using a backup before we had changed the structure of the database. We add another datafile to the USERS tablespace. So the current control file has knowledge of the fact that the  USERS tablespace now has not one, but two datafiles.

We now try and do the same delete of rows and try and go back to our old SCN 991395. At this point in time, the control file had only knowledge of the fact that the USERS tablespace has one data file and not two and the restore and recovery process will not try to do anything with regards to the newly added datafile..

This is what we see in the alert log of the database. Note that datafile 6 which is the new datafile added is being taken offline and dropped because at SCN 991735, this datafile did not exist in the database.

Wed Oct 19 10:03:42 2011
alter database datafile 6 offline drop
Completed: alter database datafile 6 offline drop
alter database recover datafile list clear
Completed: alter database recover datafile list clear
alter database recover datafile list
 1 , 2 , 3 , 4 , 5
Completed: alter database recover datafile list
 1 , 2 , 3 , 4 , 5
alter database recover if needed
 start until change 991735



Dictionary check beginning
File #6 in the controlfile not found in data dictionary.
Removing file from controlfile.
data file 6: '/u01/oradata/TEST11G/users02.dbf'
Dictionary check complete

Thursday, September 4, 2014

RMAN>Restore RAC Dataguard RMAN backup to a new server (Non-ASM) !

Need to remember (From Dataguard end rman backup ) :

 db_name = isldb
 db_unique_name = isldg

Always take the backup stopping the 'SYNC' command from Dataguard end .


Restore RAC Dataguard RMAN backup to a new server :

 - Take the RMAN full database backup .

[BACKUP SCRIPT ]

    ----
#!/bin/bash
export ORACLE_HOME=/u01/app/oracle/product/11.2.0.3/dbhome_1
export ORACLE_SID=isldg
TODAY=`date '+%Y%m%d_%H%M%S'`
LOG_FILE=/cloudfs/rmanback/isl/$TODAY/${ORACLE_SID}_FULL_${TODAY}.log
mkdir -p /cloudfs/rmanback/isl/$TODAY

sh /home/oracle/stop_isl.sh

echo "isldb Level 0 Backup started at `date` from node $HOSTNAME" >$LOG_FILE
rman <<! >>$LOG_FILE
connect target /
run{
allocate channel d1  device type disk format '/cloudfs/rmanback/isl/$TODAY/%t_%s_%r.dbf';
allocate channel d2  device type disk format '/cloudfs/rmanback/isl/$TODAY/%t_%s_%r.dbf';
backup CHECK LOGICAL AS COMPRESSED BACKUPSET incremental level 0 database;
backup format '/cloudfs/rmanback/isl/$TODAY/spfile.spbak'
  (spfile);
backup archivelog all;
backup format '/cloudfs/rmanback/isl/$TODAY/controlfile.ctlbk'
  (current controlfile);
release channel d1;
release channel d2;
}
!
sh /home/oracle/start_isl.sh
echo "isldb Level 0 Backup finished at `date` from node $HOSTNAME" >>$LOG_FILE
exit 0
-----

---
[oracle@droda1 ~]$ cat start_isl.sh 
export ORACLE_HOME=/u01/app/oracle/product/11.2.0.3/dbhome_1
export ORACLE_SID=isldg

$ORACLE_HOME/bin/sqlplus / as sysdba <<!
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
EXIT;

[oracle@droda1 ~]$ cat stop_isl.sh 
export ORACLE_HOME=/u01/app/oracle/product/11.2.0.3/dbhome_1
PATH=$HOME/bin:/u01/app/oracle/product/11.2.0.3/dbhome_1/bin:.:/usr/local/bin:/bin:/usr/bin
export PATH
export ORACLE_SID=isldg

$ORACLE_HOME/bin/sqlplus / as sysdba <<!
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
EXIT;
-----

[BACKUP SCRIPT ]

 - Transfer the backup with the logfile to remote server on the SAME LOCATION .



Step 1 : Create pfile for ISLDB database :

[oracle@PRIM ~]$ cat initisldb.ora
isldb.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
*.compatible='11.2.0.3.0'
*.control_files='/u01/app/oracle/oradata/isldg/control01.ctl','/u01/app/oracle/oradata/isldg/control02.ctl'#Restore Controlfile
*.DB_NAME='isldb'
#_allow_resetlogs_corruption = true
#_no_recovery_through_resetlogs=TRUE



Step 2:

   [oracle@PRIM dbs]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Thu Aug 28 15:22:46 2014

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup nomount pfile='initisldb.ora'
ORACLE instance started.

Total System Global Area  329895936 bytes
Fixed Size                  2228024 bytes
Variable Size             255852744 bytes
Database Buffers           67108864 bytes
Redo Buffers                4706304 bytes
SQL>


Step 3 : Restore the Controlfile

[oracle@PRIM dbs]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Thu Aug 28 15:30:33 2014

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

connected to target database: ISLDB (not mounted)

RMAN> restore controlfile from '/cloudfs/rmanback/isl/20140827_172834/controlfile.ctlbk';

Starting restore at 28-AUG-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=266 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/product/11.2.0/db_1/dbs/cntrlisldb.dbf
Finished restore at 28-AUG-14

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

RMAN>


Step 4 : Restore all the datafiles :

  1)

RMAN> run {
set newname for datafile '+DATA/isldg/datafile/system.298.849413815'  to  '/u01/app/oracle/oradata/isldg/system1.dbf' ;
restore datafile 1 ;
}2> 3> 4>

executing command: SET NEWNAME

Starting restore at 28-AUG-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=266 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 /u01/app/oracle/oradata/isldg/system1.dbf
channel ORA_DISK_1: reading from backup piece /cloudfs/rmanback/isl/20140827_172834/856718916_67_%r.dbf
channel ORA_DISK_1: piece handle=/cloudfs/rmanback/isl/20140827_172834/856718916_67_%r.dbf tag=TAG20140827T172835
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
Finished restore at 28-AUG-14

RMAN>

2)

run {
set newname for datafile '+DATA/isldg/datafile/sysaux.295.849413813'  to  '/u01/app/oracle/oradata/isldg/sysaux1.dbf' ;
restore datafile 2 ;
}


3)

run {
set newname for datafile '+DATA/isldg/datafile/undotbs1.296.849413813'  to  '/u01/app/oracle/oradata/isldg/undotbs1.dbf' ;
restore datafile 3 ;
}


4)

run {
set newname for datafile '+DATA/isldg/datafile/undotbs2.297.849413815'  to  '/u01/app/oracle/oradata/isldg/undotbs2.dbf' ;
restore datafile 4 ;
}


5)

run {
set newname for datafile '+DATA/isldg/datafile/users.299.849413849'  to  '/u01/app/oracle/oradata/isldg/users1.dbf' ;
restore datafile 5 ;
}


6)

run {
set newname for datafile '+DATA/isldg/datafile/bu_system_tbs.291.849413617'  to '/u01/app/oracle/oradata/isldg/bu_system_tbs1.dbf';
restore datafile 6 ;
}


7)

run {
set newname for datafile '+DATA/isldg/datafile/bu_his_log_tbs.292.849413617'  to '/u01/app/oracle/oradata/isldg/bu_his_log_tbs1.dbf';
restore datafile 7;
}


8)

run {
set newname for datafile '+DATA/isldg/datafile/bu_index_tbs.293.849413617'  to '/u01/app/oracle/oradata/isldg/bu_index_tbs1.dbf';
restore datafile 8 ;
}


9)

run {
set newname for datafile '+DATA/isldg/datafile/bu_image_tbs.294.849413619'  to '/u01/app/oracle/oradata/isldg/bu_image_tbs1.dbf';
restore datafile 9 ;
}


10)

run {
set newname for datafile '+DATA/isldg/tempfile/temp.301.849513611'  to '/u01/app/oracle/oradata/isldg/temp1.dbf';
restore datafile 10 ;
}


Step 5 :

  Run the SWITCH command :

run
{
set newname for datafile '+DATA/isldg/datafile/system.298.849413815'  to  '/u01/app/oracle/oradata/isldg/system1.dbf' ;
set newname for datafile '+DATA/isldg/datafile/sysaux.295.849413813'  to  '/u01/app/oracle/oradata/isldg/sysaux1.dbf' ;
set newname for datafile '+DATA/isldg/datafile/undotbs1.296.849413813'  to  '/u01/app/oracle/oradata/isldg/undotbs1.dbf' ;
set newname for datafile '+DATA/isldg/datafile/undotbs2.297.849413815'  to  '/u01/app/oracle/oradata/isldg/undotbs2.dbf' ;
set newname for datafile '+DATA/isldg/datafile/users.299.849413849'  to  '/u01/app/oracle/oradata/isldg/users1.dbf' ;
set newname for datafile '+DATA/isldg/datafile/bu_system_tbs.291.849413617'  to '/u01/app/oracle/oradata/isldg/bu_system_tbs1.dbf' ;
set newname for datafile '+DATA/isldg/datafile/bu_his_log_tbs.292.849413617'  to '/u01/app/oracle/oradata/isldg/bu_his_log_tbs1.dbf' ;
set newname for datafile '+DATA/isldg/datafile/bu_index_tbs.293.849413617'  to '/u01/app/oracle/oradata/isldg/bu_index_tbs1.dbf' ;
set newname for datafile '+DATA/isldg/datafile/bu_image_tbs.294.849413619'  to '/u01/app/oracle/oradata/isldg/bu_image_tbs1.dbf' ;
set newname for tempfile 1  to  '/u01/app/oracle/oradata/isldb/temp1.dbf' ;
switch datafile all;
switch tempfile all;
}





OR ,

-------------------------------------------

RUN
{
set newname for datafile 1 to '/u01/app/oracle/oradata/isldg/system1.dbf' ;
set newname for datafile 2 to '/u01/app/oracle/oradata/isldg/sysaux1.dbf' ;
set newname for datafile 3 to  '/u01/app/oracle/oradata/isldg/undotbs1.dbf';
set newname for datafile 4 to  '/u01/app/oracle/oradata/isldg/undotbs2.dbf';
set newname for datafile 5 to  '/u01/app/oracle/oradata/isldg/users1.dbf' ;
set newname for datafile 6 to '/u01/app/oracle/oradata/isldg/bu_system_tbs1.dbf' ;
set newname for datafile 7 to '/u01/app/oracle/oradata/isldg/bu_his_log_tbs1.dbf' ;
set newname for datafile 8 to '/u01/app/oracle/oradata/isldg/bu_index_tbs1.dbf' ;
set newname for datafile 9 to '/u01/app/oracle/oradata/isldg/bu_image_tbs1.dbf' ;
set newname for tempfile 1  to  '/u01/app/oracle/oradata/isldg/temp1.dbf' ;
restore database;
switch datafile all;
}


--------------------------------------------------------------




Step 3 :  Recover the Database  [PROCEDURE : A]


SQL> recover database until cancel using backup controlfile;
ORA-00279: change 10219039198 generated at 08/27/2014 11:05:14 needed for
thread 1
ORA-00289: suggestion :
/u01/app/oracle/product/11.2.0/db_1/dbs/arch1_1000_839681983.dbf
ORA-00280: change 10219039198 for thread 1 is in sequence #1000


Specify log: {=suggested | filename | AUTO | CANCEL}
AUTO
ORA-00308: cannot open archived log
'/u01/app/oracle/product/11.2.0/db_1/dbs/arch1_1000_839681983.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3


ORA-00308: cannot open archived log
'/u01/app/oracle/product/11.2.0/db_1/dbs/arch1_1000_839681983.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3


ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: '/u01/app/oracle/oradata/isldg/system1.dbf'


SQL> recover database until cancel using backup controlfile;
ORA-00279: change 10219039198 generated at 08/27/2014 11:05:14 needed for
thread 1
ORA-00289: suggestion :
/u01/app/oracle/product/11.2.0/db_1/dbs/arch1_1000_839681983.dbf
ORA-00280: change 10219039198 for thread 1 is in sequence #1000


Specify log: {=suggested | filename | AUTO | CANCEL}
cancel
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: '/u01/app/oracle/oradata/isldg/system1.dbf'


ORA-01112: media recovery not started


SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: '/u01/app/oracle/oradata/isldg/system1.dbf'

-------



Solution :

I manually put the archivelog to '/u01/app/oracle/product/11.2.0/db_1/dbs/thread_1_seq_1000.652.856710149'
directory and rename to is as 'arch1_1000_839681983.dbf' .

After that it checks , 'arch2_771_839681983.dbf' . I put it manually also



 ---
ERROR :
SQL> recover database until cancel using backup controlfile;
ORA-00279: change 10219039198 generated at 08/27/2014 11:05:14 needed for
thread 1
ORA-00289: suggestion :
/u01/app/oracle/product/11.2.0/db_1/dbs/arch1_1000_839681983.dbf
ORA-00280: change 10219039198 for thread 1 is in sequence #1000


Specify log: {=suggested | filename | AUTO | CANCEL}
AUTO
ORA-00279: change 10219039198 generated at 08/27/2014 11:00:42 needed for
thread 2
ORA-00289: suggestion :
/u01/app/oracle/product/11.2.0/db_1/dbs/arch2_771_839681983.dbf
ORA-00280: change 10219039198 for thread 2 is in sequence #771


ORA-00308: cannot open archived log
'/u01/app/oracle/product/11.2.0/db_1/dbs/arch2_771_839681983.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3


ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: '/u01/app/oracle/oradata/isldg/system1.dbf'

.
.
.
And so on . And After some few logs , make cancel :
-----

SQL>  recover database until cancel using backup controlfile;
ORA-00279: change 10230768222 generated at 08/27/2014 19:01:58 needed for
thread 1
ORA-00289: suggestion :
/u01/app/oracle/product/11.2.0/db_1/dbs/arch1_1002_839681983.dbf
ORA-00280: change 10230768222 for thread 1 is in sequence #1002


Specify log: {=suggested | filename | AUTO | CANCEL}
cancel
Media recovery cancelled.
--


SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-00349: failure obtaining block size for '+red



Step 4 : Open the Database


During open got the below error :

SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-00392: log 2 of thread 2 is being cleared, operation not allowed
ORA-00312: online log 2 thread 2: '+redo'


Solution :

 a) Backup the controlfile from the dataguard host machine  and recreate it like below :

SQL> ALTER DATABASE BACKUP CONTROLFILE TO TRACE AS '/home/oracle/control.sql' resetlogs ;

Database altered.


 b) Edit the controlfile :

   [oracle@PRIM ~]$ cat control.sql
CREATE CONTROLFILE REUSE DATABASE "ISLDB" RESETLOGS FORCE LOGGING ARCHIVELOG
    MAXLOGFILES 192
    MAXLOGMEMBERS 3
    MAXDATAFILES 1024
    MAXINSTANCES 32
    MAXLOGHISTORY 584
LOGFILE
  GROUP 1 '/u01/app/oracle/oradata/isldg/redo01.log'  SIZE 200M BLOCKSIZE 512,
  GROUP 2 '/u01/app/oracle/oradata/isldg/redo02.log'  SIZE 200M BLOCKSIZE 512,
  GROUP 3 '/u01/app/oracle/oradata/isldg/redo03.log'  SIZE 200M BLOCKSIZE 512
DATAFILE
  '/u01/app/oracle/oradata/isldg/system1.dbf',
  '/u01/app/oracle/oradata/isldg/sysaux1.dbf',
  '/u01/app/oracle/oradata/isldg/undotbs1.dbf',
  '/u01/app/oracle/oradata/isldg/undotbs2.dbf',
  '/u01/app/oracle/oradata/isldg/users1.dbf',
  '/u01/app/oracle/oradata/isldg/bu_system_tbs1.dbf',
  '/u01/app/oracle/oradata/isldg/bu_his_log_tbs1.dbf',
  '/u01/app/oracle/oradata/isldg/bu_index_tbs1.dbf',
  '/u01/app/oracle/oradata/isldg/bu_image_tbs1.dbf'
CHARACTER SET WE8ISO8859P1
;


SQL> shutdown immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.


---
[oracle@PRIM ~]$ vi initisldb.ora
isldb.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
*.compatible='11.2.0.3.0'
*.control_files='/u01/app/oracle/oradata/isldb/control01.ctl','/u01/app/oracle/oradata/isldb/control02.ctl'#Restore Controlfile
*.DB_NAME='isldb'
#_allow_resetlogs_corruption = true
#_no_recovery_through_resetlogs=TRUE
--


SQL> startup nomount pfile='/home/oracle/initisldb.ora'
ORACLE instance started.

Total System Global Area  329895936 bytes
Fixed Size                  2228024 bytes
Variable Size             255852744 bytes
Database Buffers           67108864 bytes
Redo Buffers                4706304 bytes
               4706304 bytes
SQL> @/home/oracle/control.sql

Control file created.

SQL> select status from v$instance;

STATUS
------------
MOUNTED



SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-38856: cannot mark instance UNNAMED_INSTANCE_2 (redo thread 2) as enabled




Step 5 :

 Open the database with the "_no_recovery_through_resetlogs=TRUE"

 cat initisldb.ora
isldb.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
*.compatible='11.2.0.3.0'
*.control_files='/u01/app/oracle/oradata/isldb/control01.ctl','/u01/app/oracle/oradata/isldb/control02.ctl'#Restore Controlfile
*.DB_NAME='isldb'
_no_recovery_through_resetlogs=TRUE


SQL> shutdown immediate
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.
SQL> startup pfile='/home/oracle/initisldb.ora'
ORACLE instance started.

Total System Global Area  329895936 bytes
Fixed Size                  2228024 bytes
Variable Size             255852744 bytes
Database Buffers           67108864 bytes
Redo Buffers                4706304 bytes
Database mounted.
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open


SQL> alter database open resetlogs;

Database altered.


Step 9 : Create TEMP File :

SQL>  create temporary tablespace TEMP1  tempfile '/u01/app/oracle/oradata/isldg/temp01.dbf' size 100M;

Tablespace created.

SQL> alter DATABASE DEFAULT TEMPORARY TABLESPACE temp1;

Database altered.

SQL> select name from v$tempfile;

NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/isldg/temp01.dbf


SQL> show parameter spfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string
SQL> create spfile from pfile='/home/oracle/initisldb.ora';

File created.


Step 10 : RESTART DATABASE :

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area  329895936 bytes
Fixed Size                  2228024 bytes
Variable Size             255852744 bytes
Database Buffers           67108864 bytes
Redo Buffers                4706304 bytes
Database mounted.
Database opened.


Fianlly , Change the required Parameter Like : 'sga_target' ,'log_archive' etc ....


Step 3 :  Recover the Database  [PROCEDURE  B]

If archivelog is not avaiable then follow the below steps :

1)

SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1: '/u01/app/oracle/oradata/isldb/system1.dbf'


SQL> recover database until cancel using backup controlfile;
ORA-00279: change 10276863887 generated at 08/31/2014 18:11:50 needed for
thread 1
ORA-00289: suggestion :
/u01/app/oracle/product/11.2.0/db_1/dbs/arch1_1029_839681983.dbf
ORA-00280: change 10276863887 for thread 1 is in sequence #1029


Specify log: {=suggested | filename | AUTO | CANCEL}
cancel
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1: '/u01/app/oracle/oradata/isldb/system1.dbf'


ORA-01112: media recovery not started



Solution :

[oracle@PRIM ~]$ vi initisldb.ora
isldb.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
*.compatible='11.2.0.3.0'
*.control_files='/u01/app/oracle/oradata/isldb/control01.ctl','/u01/app/oracle/oradata/isldb/control02.ctl'#Restore Controlfile
*.DB_NAME='isldb'
_allow_resetlogs_corruption = true
#_no_recovery_through_resetlogs=TRUE
~



For logfile missing ,
Open the database using above pfile (_allow_resetlogs_corruption = true)  but again during open got the below error :

SQL> startup pfile='/home/oracle/initisldb.ora';
ORACLE instance started.

Total System Global Area  329895936 bytes
Fixed Size                  2228024 bytes
Variable Size             255852744 bytes
Database Buffers           67108864 bytes
Redo Buffers                4706304 bytes
Database mounted.
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open


SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-38856: cannot mark instance UNNAMED_INSTANCE_2 (redo thread 2) as enabled



[oracle@PRIM ~]$ vi initisldb.ora
isldb.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
*.compatible='11.2.0.3.0'
*.control_files='/u01/app/oracle/oradata/isldb/control01.ctl','/u01/app/oracle/oradata/isldb/control02.ctl'#Restore Controlfile
*.DB_NAME='isldb'
_allow_resetlogs_corruption = true
_no_recovery_through_resetlogs=TRUE


Now, Open the database using above pfile (_no_recovery_through_resetlogs=TRUE)  :


SQL> startup mount pfile='/home/oracle/initisldb.ora'
ORACLE instance started.

Total System Global Area  329895936 bytes
Fixed Size                  2228024 bytes
Variable Size             255852744 bytes
Database Buffers           67108864 bytes
Redo Buffers                4706304 bytes
Database mounted.
SQL> alter database open resetlogs;

Database altered.


SQL> select instance_name,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
isldb            OPEN



Finally , create spfile from the pfile=/home/oracle/initisldb.ora



Step 9 :Create Temp File :

SQL> create temporary tablespace temp1 tempfile '/u01/app/oracle/oradata/isldb/temp1.dbf' size 100M;

Tablespace created.

SQL> alter database default temporary tablespace temp1;

Database altered.

SQL> select * from v$tablespace;

       TS# NAME                           INC BIG FLA ENC
---------- ------------------------------ --- --- --- ---
         0 SYSTEM                         YES NO  YES
         1 SYSAUX                         YES NO  YES
         2 UNDOTBS1                       YES NO  YES
         4 UNDOTBS2                       YES NO  YES
         5 USERS                          YES NO  YES
         6 BU_SYSTEM_TBS                  YES NO  YES
         7 BU_HIS_LOG_TBS                 YES NO  YES
         8 BU_INDEX_TBS                   YES NO  YES
         9 BU_IMAGE_TBS                   YES NO  YES
         3 TEMP                           NO  NO  YES
        10 TEMP1                          NO  NO  YES

11 rows selected.

SQL>  drop tablespace TEMP including contents and datafiles;

Tablespace dropped.

SQL> drop tablespace undotbs2 including contents and datafiles;

Tablespace dropped.










========================

USING  'PRIM' End RMAN Backup :


Need to remember (From Primary HOST end rman backup ) :

 db_name = isldb
 db_unique_name = isldb


Restore RAC Dataguard RMAN backup to a new server :

 - Take the RMAN full database backup .

 - Transfer the backup with the logfile to remote server on the SAME LOCATION .



Step 1 : Create pfile for ISLDB database :

[oracle@PRIM ~]$ cat initisldb.ora
isldb.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
*.compatible='11.2.0.3.0'
*.control_files='/u01/app/oracle/oradata/isldb/control01.ctl','/u01/app/oracle/oradata/isldb/control02.ctl'#Restore Controlfile
*.DB_NAME='isldb'
#_allow_resetlogs_corruption = true
#_no_recovery_through_resetlogs=TRUE



Step 2:

   [oracle@PRIM dbs]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Thu Aug 28 15:22:46 2014

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup nomount pfile='initisldb.ora'
ORACLE instance started.

Total System Global Area  329895936 bytes
Fixed Size                  2228024 bytes
Variable Size             255852744 bytes
Database Buffers           67108864 bytes
Redo Buffers                4706304 bytes
SQL>


Step 3 : Restore the Controlfile

[oracle@PRIM dbs]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Thu Aug 28 15:30:33 2014

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

connected to target database: ISLDB (not mounted)

RMAN> restore controlfile from '/cloudfs/rmanback/isl/20140827_172834/controlfile.ctlbk';

Starting restore at 28-AUG-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=266 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/product/11.2.0/db_1/dbs/cntrlisldb.dbf
Finished restore at 28-AUG-14

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

RMAN>


Step 4 : Restore all the datafiles :

  1)

RMAN> run {
set newname for datafile '+DATA/isldg/datafile/system.298.849413815'  to  '/u01/app/oracle/oradata/isldg/system1.dbf' ;
restore datafile 1 ;
}2> 3> 4>

executing command: SET NEWNAME

Starting restore at 28-AUG-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=266 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 /u01/app/oracle/oradata/isldg/system1.dbf
channel ORA_DISK_1: reading from backup piece /cloudfs/rmanback/isl/20140827_172834/856718916_67_%r.dbf
channel ORA_DISK_1: piece handle=/cloudfs/rmanback/isl/20140827_172834/856718916_67_%r.dbf tag=TAG20140827T172835
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
Finished restore at 28-AUG-14

RMAN>

2)

run {
set newname for datafile '+DATA/isldg/datafile/sysaux.295.849413813'  to  '/u01/app/oracle/oradata/isldg/sysaux1.dbf' ;
restore datafile 2 ;
}


3)

run {
set newname for datafile '+DATA/isldg/datafile/undotbs1.296.849413813'  to  '/u01/app/oracle/oradata/isldg/undotbs1.dbf' ;
restore datafile 3 ;
}


4)

run {
set newname for datafile '+DATA/isldg/datafile/undotbs2.297.849413815'  to  '/u01/app/oracle/oradata/isldg/undotbs2.dbf' ;
restore datafile 4 ;
}


5)

run {
set newname for datafile '+DATA/isldg/datafile/users.299.849413849'  to  '/u01/app/oracle/oradata/isldg/users1.dbf' ;
restore datafile 5 ;
}


6)

run {
set newname for datafile '+DATA/isldg/datafile/bu_system_tbs.291.849413617'  to '/u01/app/oracle/oradata/isldg/bu_system_tbs1.dbf';
restore datafile 6 ;
}


7)

run {
set newname for datafile '+DATA/isldg/datafile/bu_his_log_tbs.292.849413617'  to '/u01/app/oracle/oradata/isldg/bu_his_log_tbs1.dbf';
restore datafile 7;
}


8)

run {
set newname for datafile '+DATA/isldg/datafile/bu_index_tbs.293.849413617'  to '/u01/app/oracle/oradata/isldg/bu_index_tbs1.dbf';
restore datafile 8 ;
}


9)

run {
set newname for datafile '+DATA/isldg/datafile/bu_image_tbs.294.849413619'  to '/u01/app/oracle/oradata/isldg/bu_image_tbs1.dbf';
restore datafile 9 ;
}


10)

run {
set newname for datafile '+DATA/isldg/tempfile/temp.301.849513611'  to '/u01/app/oracle/oradata/isldg/temp1.dbf';
restore datafile 10 ;
}


Step 5 :

  Run the SWITCH command :

run
{
set newname for datafile '+DATA/isldg/datafile/system.298.849413815'  to  '/u01/app/oracle/oradata/isldg/system1.dbf' ;
set newname for datafile '+DATA/isldg/datafile/sysaux.295.849413813'  to  '/u01/app/oracle/oradata/isldg/sysaux1.dbf' ;
set newname for datafile '+DATA/isldg/datafile/undotbs1.296.849413813'  to  '/u01/app/oracle/oradata/isldg/undotbs1.dbf' ;
set newname for datafile '+DATA/isldg/datafile/undotbs2.297.849413815'  to  '/u01/app/oracle/oradata/isldg/undotbs2.dbf' ;
set newname for datafile '+DATA/isldg/datafile/users.299.849413849'  to  '/u01/app/oracle/oradata/isldg/users1.dbf' ;
set newname for datafile '+DATA/isldg/datafile/bu_system_tbs.291.849413617'  to '/u01/app/oracle/oradata/isldg/bu_system_tbs1.dbf' ;
set newname for datafile '+DATA/isldg/datafile/bu_his_log_tbs.292.849413617'  to '/u01/app/oracle/oradata/isldg/bu_his_log_tbs1.dbf' ;
set newname for datafile '+DATA/isldg/datafile/bu_index_tbs.293.849413617'  to '/u01/app/oracle/oradata/isldg/bu_index_tbs1.dbf' ;
set newname for datafile '+DATA/isldg/datafile/bu_image_tbs.294.849413619'  to '/u01/app/oracle/oradata/isldg/bu_image_tbs1.dbf' ;
set newname for tempfile 1  to  '/u01/app/oracle/oradata/isldb/temp1.dbf' ;
switch datafile all;
switch tempfile all;
}



OR,

----------------------------------------
RUN
{
set newname for datafile 1 to '/u01/app/oracle/oradata/isldb/system1.dbf' ;
set newname for datafile 2 to '/u01/app/oracle/oradata/isldb/sysaux1.dbf' ;
set newname for datafile 3 to  '/u01/app/oracle/oradata/isldb/undotbs1.dbf';
set newname for datafile 4 to  '/u01/app/oracle/oradata/isldb/undotbs2.dbf';
set newname for datafile 5 to  '/u01/app/oracle/oradata/isldb/users1.dbf' ;
set newname for datafile 6 to '/u01/app/oracle/oradata/isldb/bu_system_tbs1.dbf' ;
set newname for datafile 7 to '/u01/app/oracle/oradata/isldb/bu_his_log_tbs1.dbf' ;
set newname for datafile 8 to '/u01/app/oracle/oradata/isldb/bu_index_tbs1.dbf' ;
set newname for datafile 9 to '/u01/app/oracle/oradata/isldb/bu_image_tbs1.dbf' ;
set newname for tempfile 1  to  '/u01/app/oracle/oradata/isldb/temp1.dbf' ;
restore database;
switch datafile all;
}


------------------------------------------------------------

Step 6 :  Recover the Database :

Error :--------

SQL> recover database until cancel using backup controlfile;
ORA-00279: change 10219039198 generated at 08/27/2014 11:05:14 needed for
thread 1
ORA-00289: suggestion :
/u01/app/oracle/product/11.2.0/db_1/dbs/arch1_1000_839681983.dbf
ORA-00280: change 10219039198 for thread 1 is in sequence #1000


Specify log: {=suggested | filename | AUTO | CANCEL}
AUTO
ORA-00308: cannot open archived log
'/u01/app/oracle/product/11.2.0/db_1/dbs/arch1_1000_839681983.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3


ORA-00308: cannot open archived log
'/u01/app/oracle/product/11.2.0/db_1/dbs/arch1_1000_839681983.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3


ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: '/u01/app/oracle/oradata/isldg/system1.dbf'


SQL> recover database until cancel using backup controlfile;
ORA-00279: change 10219039198 generated at 08/27/2014 11:05:14 needed for
thread 1
ORA-00289: suggestion :
/u01/app/oracle/product/11.2.0/db_1/dbs/arch1_1000_839681983.dbf
ORA-00280: change 10219039198 for thread 1 is in sequence #1000


Specify log: {=suggested | filename | AUTO | CANCEL}
cancel
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: '/u01/app/oracle/oradata/isldg/system1.dbf'


ORA-01112: media recovery not started


SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: '/u01/app/oracle/oradata/isldg/system1.dbf'

-------



Solution :

I manually put the archivelog to '/u01/app/oracle/product/11.2.0/db_1/dbs/thread_1_seq_1000.652.856710149'
directory and rename to is as 'arch1_1000_839681983.dbf' .

After that it checks , 'arch2_771_839681983.dbf' . I put it manually also



 ---
ERROR :
SQL> recover database until cancel using backup controlfile;
ORA-00279: change 10219039198 generated at 08/27/2014 11:05:14 needed for
thread 1
ORA-00289: suggestion :
/u01/app/oracle/product/11.2.0/db_1/dbs/arch1_1000_839681983.dbf
ORA-00280: change 10219039198 for thread 1 is in sequence #1000


Specify log: {=suggested | filename | AUTO | CANCEL}
AUTO
ORA-00279: change 10219039198 generated at 08/27/2014 11:00:42 needed for
thread 2
ORA-00289: suggestion :
/u01/app/oracle/product/11.2.0/db_1/dbs/arch2_771_839681983.dbf
ORA-00280: change 10219039198 for thread 2 is in sequence #771


ORA-00308: cannot open archived log
'/u01/app/oracle/product/11.2.0/db_1/dbs/arch2_771_839681983.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3


ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: '/u01/app/oracle/oradata/isldg/system1.dbf'

.
.
.
And so on . And After some few logs , make cancel :
-----

SQL>  recover database until cancel using backup controlfile;
ORA-00279: change 10230768222 generated at 08/27/2014 19:01:58 needed for
thread 1
ORA-00289: suggestion :
/u01/app/oracle/product/11.2.0/db_1/dbs/arch1_1002_839681983.dbf
ORA-00280: change 10230768222 for thread 1 is in sequence #1002


Specify log: {=suggested | filename | AUTO | CANCEL}
cancel
Media recovery cancelled.
--


SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-00349: failure obtaining block size for '+red



Step 7 : Open the Database


During open got the below error :

SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-00392: log 2 of thread 2 is being cleared, operation not allowed
ORA-00312: online log 2 thread 2: '+redo'


Sol :

 a) Backup the logfile and recreate it like below :

SQL> ALTER DATABASE BACKUP CONTROLFILE TO TRACE AS '/home/oracle/control.sql' resetlogs ;

Database altered.


 b) Edit the controlfile :

   [oracle@PRIM ~]$ cat control.sql
CREATE CONTROLFILE REUSE DATABASE "ISLDB" RESETLOGS FORCE LOGGING ARCHIVELOG
    MAXLOGFILES 192
    MAXLOGMEMBERS 3
    MAXDATAFILES 1024
    MAXINSTANCES 32
    MAXLOGHISTORY 584
LOGFILE
  GROUP 1 '/u01/app/oracle/oradata/isldb/redo01.log'  SIZE 200M BLOCKSIZE 512,
  GROUP 2 '/u01/app/oracle/oradata/isldb/redo02.log'  SIZE 200M BLOCKSIZE 512,
  GROUP 3 '/u01/app/oracle/oradata/isldb/redo03.log'  SIZE 200M BLOCKSIZE 512
DATAFILE
  '/u01/app/oracle/oradata/isldb/system1.dbf',
  '/u01/app/oracle/oradata/isldb/sysaux1.dbf',
  '/u01/app/oracle/oradata/isldb/undotbs1.dbf',
  '/u01/app/oracle/oradata/isldb/undotbs2.dbf',
  '/u01/app/oracle/oradata/isldb/users1.dbf',
  '/u01/app/oracle/oradata/isldb/bu_system_tbs1.dbf',
  '/u01/app/oracle/oradata/isldb/bu_his_log_tbs1.dbf',
  '/u01/app/oracle/oradata/isldb/bu_index_tbs1.dbf',
  '/u01/app/oracle/oradata/isldb/bu_image_tbs1.dbf'
CHARACTER SET WE8ISO8859P1
;


SQL> shutdown immediate
ORA-01109: database not open


Database dismounted.
ORACLE instance shut down.


---
[oracle@PRIM ~]$ vi initisldb.ora
isldb.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
*.compatible='11.2.0.3.0'
*.control_files='/u01/app/oracle/oradata/isldb/control01.ctl','/u01/app/oracle/oradata/isldb/control02.ctl'#Restore Controlfile
*.DB_NAME='isldb'
#_allow_resetlogs_corruption = true
#_no_recovery_through_resetlogs=TRUE
--


SQL> startup nomount pfile='/home/oracle/initisldb.ora'
ORACLE instance started.

Total System Global Area  329895936 bytes
Fixed Size                  2228024 bytes
Variable Size             255852744 bytes
Database Buffers           67108864 bytes
Redo Buffers                4706304 bytes
               4706304 bytes
SQL> @/home/oracle/control.sql

Control file created.

SQL> select status from v$instance;

STATUS
------------
MOUNTED



SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-38856: cannot mark instance UNNAMED_INSTANCE_2 (redo thread 2) as enabled




Step 8 :

 Open the database with the "_no_recovery_through_resetlogs=TRUE"

 cat initisldb.ora
isldb.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
*.compatible='11.2.0.3.0'
*.control_files='/u01/app/oracle/oradata/isldb/control01.ctl','/u01/app/oracle/oradata/isldb/control02.ctl'#Restore Controlfile
*.DB_NAME='isldb'
#_allow_resetlogs_corruption = true
_no_recovery_through_resetlogs=TRUE


SQL> shutdown immediate
ORA-01109: database not open


Database dismounted.
ORACLE instance shut down.
SQL> startup pfile='/home/oracle/initisldb.ora'
ORACLE instance started.

Total System Global Area  329895936 bytes
Fixed Size                  2228024 bytes
Variable Size             255852744 bytes
Database Buffers           67108864 bytes
Redo Buffers                4706304 bytes
Database mounted.
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open


SQL> alter database open resetlogs;

Database altered.


Step 9 : Create TEMP File :

SQL>  create temporary tablespace TEMP1  tempfile '/u01/app/oracle/oradata/isldg/temp01.dbf' size 100M;

Tablespace created.

SQL> alter DATABASE DEFAULT TEMPORARY TABLESPACE temp1;

Database altered.

SQL> select name from v$tempfile;

NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/isldg/temp01.dbf


SQL> show parameter spfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string
SQL> create spfile from pfile='/home/oracle/initisldb.ora';

File created.


Step 10 : RESTART DATABASE :

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area  329895936 bytes
Fixed Size                  2228024 bytes
Variable Size             255852744 bytes
Database Buffers           67108864 bytes
Redo Buffers                4706304 bytes
Database mounted.
Database opened.


Fianlly , Change the required Parameter Like : 'sga_target' ,'log_archive' etc ....



                          ----controlfile example of pbldb------------

RUN
{
set newname for datafile 1 to '/u01/app/oracle/oradata/pbldb/system1.dbf' ;
set newname for datafile 2 to '/u01/app/oracle/oradata/pbldb/sysaux1.dbf' ;
set newname for datafile 3 to  '/u01/app/oracle/oradata/pbldb/undotbs1.dbf';
set newname for datafile 4 to  '/u01/app/oracle/oradata/pbldb/undotbs2.dbf';
set newname for datafile 5 to  '/u01/app/oracle/oradata/pbldb/users1.dbf' ;
set newname for datafile 6 to  '/u01/app/oracle/oradata/pbldb/users2.dbf' ;
set newname for datafile 25 to  '/u01/app/oracle/oradata/pbldb/users3.dbf' ;
set newname for datafile 26 to  '/u01/app/oracle/oradata/pbldb/users4.dbf' ;
set newname for datafile 7 to '/disk4/oradata/pbldb/bu_system_tbs1.dbf' ;
set newname for datafile 8 to '/disk4/oradata/pbldb/bu_system_tbs2.dbf' ;
set newname for datafile 9 to '/disk2/oradata/pbldb/bu_his_log_tbs1.dbf' ;
set newname for datafile 10 to '/disk2/oradata/pbldb/bu_his_log_tbs2.dbf' ;
set newname for datafile 11 to '/disk2/oradata/pbldb/bu_his_log_tbs3.dbf' ;
set newname for datafile 12 to '/disk2/oradata/pbldb/bu_his_log_tbs4.dbf' ;
set newname for datafile 13 to '/disk2/oradata/pbldb/bu_his_log_tbs5.dbf' ;
set newname for datafile 14 to '/disk2/oradata/pbldb/bu_his_log_tbs6.dbf' ;
set newname for datafile 15 to '/disk2/oradata/pbldb/bu_his_log_tbs7.dbf' ;
set newname for datafile 16 to '/disk2/oradata/pbldb/bu_his_log_tbs8.dbf' ;
set newname for datafile 17 to '/disk2/oradata/pbldb/bu_his_log_tbs9.dbf' ;
set newname for datafile 18 to '/disk2/oradata/pbldb/bu_his_log_tbs10.dbf' ;
set newname for datafile 19 to '/disk2/oradata/pbldb/bu_his_log_tbs11.dbf' ;
set newname for datafile 20 to '/disk4/oradata/pbldb/bu_index_tbs1.dbf' ;
set newname for datafile 21 to '/disk4/oradata/pbldb/bu_index_tbs2.dbf' ;
set newname for datafile 22 to '/disk4/oradata/pbldb/bu_index_tbs3.dbf' ;
set newname for datafile 23 to '/disk4/oradata/pbldb/bu_index_tbs4.dbf' ;
set newname for datafile 24 to '/u01/app/oracle/oradata/pbldb/bu_image_tbs5.dbf' ;
set newname for tempfile 1  to  '/u01/app/oracle/oradata/pbldb/temp1.dbf' ;
restore database;
switch datafile all;
}





CREATE CONTROLFILE REUSE DATABASE "ISLDB" RESETLOGS FORCE LOGGING ARCHIVELOG
    MAXLOGFILES 192
    MAXLOGMEMBERS 3
    MAXDATAFILES 1024
    MAXINSTANCES 32
    MAXLOGHISTORY 584
LOGFILE
  GROUP 1 '/u01/app/oracle/oradata/isldg/redo01.log'  SIZE 200M BLOCKSIZE 512,
  GROUP 2 '/u01/app/oracle/oradata/isldg/redo02.log'  SIZE 200M BLOCKSIZE 512,
  GROUP 3 '/u01/app/oracle/oradata/isldg/redo03.log'  SIZE 200M BLOCKSIZE 512
DATAFILE
  '/u01/app/oracle/oradata/isldg/system1.dbf',
  '/u01/app/oracle/oradata/isldg/sysaux1.dbf',
  '/u01/app/oracle/oradata/isldg/undotbs1.dbf',
  '/u01/app/oracle/oradata/isldg/undotbs2.dbf',
  '/u01/app/oracle/oradata/isldg/users1.dbf',
  '/u01/app/oracle/oradata/isldg/bu_system_tbs1.dbf',
  '/u01/app/oracle/oradata/isldg/bu_his_log_tbs1.dbf',
  '/u01/app/oracle/oradata/isldg/bu_index_tbs1.dbf',
  '/u01/app/oracle/oradata/isldg/bu_image_tbs1.dbf'
CHARACTER SET WE8ISO8859P1
;





CREATE CONTROLFILE REUSE DATABASE "PBLDB" RESETLOGS FORCE LOGGING ARCHIVELOG
    MAXLOGFILES 192
    MAXLOGMEMBERS 3
    MAXDATAFILES 1024
    MAXINSTANCES 32
    MAXLOGHISTORY 4672
LOGFILE
  GROUP 1 '/u01/app/oracle/oradata/pbldb/redo01.log'  SIZE 200M BLOCKSIZE 512,
  GROUP 2 '/u01/app/oracle/oradata/pbldb/redo02.log'  SIZE 200M BLOCKSIZE 512,
  GROUP 3 '/u01/app/oracle/oradata/pbldb/redo03.log'  SIZE 200M BLOCKSIZE 512
DATAFILE
  '/u01/app/oracle/oradata/pbldb/system1.dbf',
  '/u01/app/oracle/oradata/pbldb/sysaux1.dbf' ,
  '/u01/app/oracle/oradata/pbldb/undotbs1.dbf',
  '/u01/app/oracle/oradata/pbldb/undotbs2.dbf',
  '/u01/app/oracle/oradata/pbldb/users1.dbf' ,
  '/u01/app/oracle/oradata/pbldb/users2.dbf' ,
  '/u01/app/oracle/oradata/pbldb/users3.dbf' ,
  '/u01/app/oracle/oradata/pbldb/users4.dbf' ,
  '/disk4/oradata/pbldb/bu_system_tbs1.dbf' ,
  '/disk4/oradata/pbldb/bu_system_tbs2.dbf' ,
  '/disk2/oradata/pbldb/bu_his_log_tbs1.dbf' ,
  '/disk2/oradata/pbldb/bu_his_log_tbs2.dbf' ,
  '/disk2/oradata/pbldb/bu_his_log_tbs3.dbf' ,
  '/disk2/oradata/pbldb/bu_his_log_tbs4.dbf' ,
  '/disk2/oradata/pbldb/bu_his_log_tbs5.dbf' ,
  '/disk2/oradata/pbldb/bu_his_log_tbs6.dbf' ,
  '/disk2/oradata/pbldb/bu_his_log_tbs7.dbf' ,
  '/disk2/oradata/pbldb/bu_his_log_tbs8.dbf' ,
  '/disk2/oradata/pbldb/bu_his_log_tbs9.dbf' ,
  '/disk2/oradata/pbldb/bu_his_log_tbs10.dbf',
  '/disk2/oradata/pbldb/bu_his_log_tbs11.dbf',
  '/disk4/oradata/pbldb/bu_index_tbs1.dbf',
  '/disk4/oradata/pbldb/bu_index_tbs2.dbf',
  '/disk4/oradata/pbldb/bu_index_tbs3.dbf',
  '/disk4/oradata/pbldb/bu_index_tbs4.dbf',
  '/u01/app/oracle/oradata/pbldb/bu_image_tbs5.dbf'
CHARACTER SET WE8ISO8859P1
;

-----------------------------END----------------------


Tuesday, September 2, 2014

Securing the Listener



Setting Listener Password :

step 1 :

  1.  Stop the listener.
  2.  Add the following parameter in the listener.ora: LOCAL_OS_AUTHENTICATION_listener_name = OFF
  3.  Restart the listener



Step 2 :

 set the password using lsnrctl :

   [oracle@pbltest ~]$ lsnrctl

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 02-SEP-2014 16:29:32

Copyright (c) 1991, 2011, Oracle.  All rights reserved.

Welcome to LSNRCTL, type "help" for information.

LSNRCTL> change_password
Old password:
New password:
Reenter new password:
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.41)(PORT=1521)))
Password changed for LISTENER
The command completed successfully
LSNRCTL> save_config
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.41)(PORT=1521)))
Saved LISTENER configuration parameters.
Listener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Old Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.bak
The command completed successfully
LSNRCTL>
LSNRCTL> set password
Password:
The command completed successfully
LSNRCTL> save_config
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.41)(PORT=1521)))
No changes to save for LISTENER.
The command completed successfully
LSNRCTL> exit


Step 3 :

 Check the below entry on the listener.ora file :

  LOCAL_OS_AUTHENTICATION_listener = OFF

#----ADDED BY TNSLSNR 02-SEP-2014 16:30:00---
PASSWORDS_LISTENER = ADD733DA61CD19A5


step 4 : Bounce the Listener .

[oracle@pbltest admin]$ lsnrctl

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 02-SEP-2014 16:32:30

Copyright (c) 1991, 2011, Oracle.  All rights reserved.

Welcome to LSNRCTL, type "help" for information.

LSNRCTL> stop
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.41)(PORT=1521)))
TNS-01169: The listener has not recognized the password


Step 5 : How to access to LISTENER


 using 'set password' command .


Metalink Note Password Not Required When Administering 10g or Newer Listeners Using Lsnrctl Utility (Doc ID 372717.1)