Showing posts with label RMAN. Show all posts
Showing posts with label RMAN. Show all posts

Thursday, January 19, 2012

BACKUP AND RESTORE DATABASE WITH RMAN IN ORACLE

BACKUP AND RESTORE DATABASE WITH RMAN IN ORACLE:
I had configured the RMAN BACKUP in one of the database and it creates the backupsets. After awhile there was an issue with db as it was crashed, so what did is a normal restore from the database backup set....

Thought it may help other in restoring database from rman backup sets.. It is good practice to check with oracle online documentation before doing any db changes.....


BACKUP AND RESTORE DATABASE WITH RMAN IN ORACLE:
-------------------------------------------------
 run
{
shutdown immediate;
startup mount;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'D:\TESTDELETE\ora\%F';
configure backup optimization on;
configure controlfile autobackup on;
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
backup database format 'D:\TESTDELETE\ora\%u';
sql 'alter database open';
}

}

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

RMAN>
 run
2> {
3> shutdown immediate;
4> startup mount;
5> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'D:\TESTDELET
E\ora\%F';
6> configure backup optimization on;
7> configure controlfile autobackup on;
8> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
9> backup database format 'D:\TESTDELETE\ora\%u';
10> sql 'alter database open';
11> }

database closed
database dismounted
Oracle instance shut down

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

Total System Global Area 640286720 bytes

Fixed Size 1376492 bytes
Variable Size 289410836 bytes
Database Buffers 343932928 bytes
Redo Buffers 5566464 bytes

old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'D:\TESTDELETE\o
ra\%F';
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'D:\TESTDELETE\o
ra\%F';
new RMAN configuration parameters are successfully stored

old RMAN configuration parameters:
CONFIGURE BACKUP OPTIMIZATION ON;
new RMAN configuration parameters:
CONFIGURE BACKUP OPTIMIZATION ON;
new RMAN configuration parameters are successfully stored

old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored

Starting backup at 19-JAN-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=133 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=F:\APP\HOME\ORADATA\ORCL\SYSTEM01.DBF
input datafile file number=00002 name=F:\APP\HOME\ORADATA\ORCL\SYSAUX01.DBF
input datafile file number=00003 name=F:\APP\HOME\ORADATA\ORCL\UNDOTBS01.DBF
input datafile file number=00005 name=F:\APP\HOME\ORADATA\ORCL\TDE_TEST.DBF
input datafile file number=00004 name=F:\APP\HOME\ORADATA\ORCL\USERS01.DBF
channel ORA_DISK_1: starting piece 1 at 19-JAN-12
channel ORA_DISK_1: finished piece 1 at 19-JAN-12
piece handle=D:\TESTDELETE\ORA\05N16C6A tag=TAG20120119T205329 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:06
Finished backup at 19-JAN-12

Starting Control File and SPFILE Autobackup at 19-JAN-12
piece handle=D:\TESTDELETE\ORA\C-1298596975-20120119-01 comment=NONE
Finished Control File and SPFILE Autobackup at 19-JAN-12

sql statement: alter database open

RMAN>

RMAN>

RMAN>

RMAN> exit


Recovery Manager complete.

C:\Users\HOME>sqlplus "/as sysdba"

SQL*Plus: Release 11.2.0.1.0 Production on Thu Jan 19 20:56:08 2012

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>
SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Pr
oduction
With the Partitioning, OLAP, Data Mining and Real Application Testing options

C:\Users\HOME>
C:\Users\HOME>rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Thu Jan 19 20:58:39 2012

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

connected to target database (not started)

RMAN> startup nomount;

Oracle instance started

Total System Global Area 640286720 bytes

Fixed Size 1376492 bytes
Variable Size 247467796 bytes
Database Buffers 385875968 bytes
Redo Buffers 5566464 bytes

RMAN> restore spfile from 'D:\TESTDELETE\ORA\C-1298596975-20120119-01';

Starting restore at 19-JAN-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=134 device type=DISK

channel ORA_DISK_1: restoring spfile from AUTOBACKUP D:\TESTDELETE\ORA\C-1298596
975-20120119-01
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 19-JAN-12

RMAN> RESTORE CONTROLFILE FROM 'D:\TESTDELETE\ORA\C-1298596975-20120119-01';

Starting restore at 19-JAN-12
using channel ORA_DISK_1

channel ORA_DISK_1: restoring control file
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 01/19/2012 21:00:17
ORA-19870: error while restoring backup piece D:\TESTDELETE\ORA\C-1298596975-201
20119-01
ORA-19504: failed to create file "F:\APP\HOME\ORADATA\ORCL\CONTROL01.CTL"
ORA-27040: file create error, unable to create file
OSD-04002: unable to open file
O/S-Error: (OS 3) The system cannot find the path specified.

-- create a directory with name F:\APP\HOME\ORADATA\ORCL
RMAN> RESTORE CONTROLFILE FROM 'D:\TESTDELETE\ORA\C-1298596975-20120119-01';

Starting restore at 19-JAN-12
using channel ORA_DISK_1

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
output file name=F:\APP\HOME\ORADATA\ORCL\CONTROL01.CTL
output file name=F:\APP\HOME\FLASH_RECOVERY_AREA\ORCL\CONTROL02.CTL
Finished restore at 19-JAN-12


RMAN> sql 'alter database mount';

sql statement: alter database mount

RMAN> run {
2> ALLOCATE CHANNEL disk1 DEVICE TYPE DISK FORMAT 'D:\TESTDELETE\ORA\05N16C6A ta
g=TAG20120119T205329';
3> restore database;
4> }

allocated channel: disk1
channel disk1: SID=134 device type=DISK

Starting restore at 19-JAN-12
Starting implicit crosscheck backup at 19-JAN-12
Crosschecked 1 objects
Finished implicit crosscheck backup at 19-JAN-12

Starting implicit crosscheck copy at 19-JAN-12
Finished implicit crosscheck copy at 19-JAN-12

searching for all files in the recovery area
cataloging files...
no files cataloged


channel disk1: starting datafile backup set restore
channel disk1: specifying datafile(s) to restore from backup set
channel disk1: restoring datafile 00001 to F:\APP\HOME\ORADATA\ORCL\SYSTEM01.DBF

channel disk1: restoring datafile 00002 to F:\APP\HOME\ORADATA\ORCL\SYSAUX01.DBF

channel disk1: restoring datafile 00003 to F:\APP\HOME\ORADATA\ORCL\UNDOTBS01.DB
F
channel disk1: restoring datafile 00004 to F:\APP\HOME\ORADATA\ORCL\USERS01.DBF
channel disk1: restoring datafile 00005 to F:\APP\HOME\ORADATA\ORCL\TDE_TEST.DBF

channel disk1: reading from backup piece D:\TESTDELETE\ORA\05N16C6A
channel disk1: piece handle=D:\TESTDELETE\ORA\05N16C6A tag=TAG20120119T205329
channel disk1: restored backup piece 1
channel disk1: restore complete, elapsed time: 00:02:15
Finished restore at 19-JAN-12
released channel: disk1

RMAN>
------ did not do recover database as it is No Archive Mode-- as moreover it is dev db --
RMAN> recover database;
---------------------------------

RMAN> sql 'alter database open resetlogs';

sql statement: alter database open resetlogs

RMAN>


RMAN> exit


Recovery Manager complete.

C:\Users\HOME>sqlplus "/as sysdba"

SQL*Plus: Release 11.2.0.1.0 Production on Thu Jan 19 21:16:56 2012

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select name, open_mode from v$database;

NAME OPEN_MODE
--------- --------------------
ORCL READ WRITE

SQL> exit


-------- Have a fun working in oracle technologies ............ Cheers...

BACKUP AND RESTORE DATABASE WITH RMAN IN ORACLE

BACKUP AND RESTORE DATABASE WITH RMAN IN ORACLE:
I had configured the RMAN BACKUP in one of the database and it creates the backupsets. After awhile there was an issue with db as it was crashed, so what did is a normal restore from the database backup set....

Thought it may help other in restoring database from rman backup sets.. It is good practice to check with oracle online documentation before doing any db changes.....


BACKUP AND RESTORE DATABASE WITH RMAN IN ORACLE:
-------------------------------------------------
run
{
shutdown immediate;
startup mount;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'D:\TESTDELETE\ora\%F';
configure backup optimization on;
configure controlfile autobackup on;
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
backup database format 'D:\TESTDELETE\ora\%u';
sql 'alter database open';
}

}

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

RMAN> run
2> {
3> shutdown immediate;
4> startup mount;
5> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'D:\TESTDELET
E\ora\%F';
6> configure backup optimization on;
7> configure controlfile autobackup on;
8> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
9> backup database format 'D:\TESTDELETE\ora\%u';
10> sql 'alter database open';
11> }

database closed
database dismounted
Oracle instance shut down

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

Total System Global Area 640286720 bytes

Fixed Size 1376492 bytes
Variable Size 289410836 bytes
Database Buffers 343932928 bytes
Redo Buffers 5566464 bytes

old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'D:\TESTDELETE\o
ra\%F';
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'D:\TESTDELETE\o
ra\%F';
new RMAN configuration parameters are successfully stored

old RMAN configuration parameters:
CONFIGURE BACKUP OPTIMIZATION ON;
new RMAN configuration parameters:
CONFIGURE BACKUP OPTIMIZATION ON;
new RMAN configuration parameters are successfully stored

old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored

Starting backup at 19-JAN-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=133 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=F:\APP\HOME\ORADATA\ORCL\SYSTEM01.DBF
input datafile file number=00002 name=F:\APP\HOME\ORADATA\ORCL\SYSAUX01.DBF
input datafile file number=00003 name=F:\APP\HOME\ORADATA\ORCL\UNDOTBS01.DBF
input datafile file number=00005 name=F:\APP\HOME\ORADATA\ORCL\TDE_TEST.DBF
input datafile file number=00004 name=F:\APP\HOME\ORADATA\ORCL\USERS01.DBF
channel ORA_DISK_1: starting piece 1 at 19-JAN-12
channel ORA_DISK_1: finished piece 1 at 19-JAN-12
piece handle=D:\TESTDELETE\ORA\05N16C6A tag=TAG20120119T205329 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:06
Finished backup at 19-JAN-12

Starting Control File and SPFILE Autobackup at 19-JAN-12
piece handle=D:\TESTDELETE\ORA\C-1298596975-20120119-01 comment=NONE
Finished Control File and SPFILE Autobackup at 19-JAN-12

sql statement: alter database open

RMAN>

RMAN>

RMAN>

RMAN> exit


Recovery Manager complete.

C:\Users\HOME>sqlplus "/as sysdba"

SQL*Plus: Release 11.2.0.1.0 Production on Thu Jan 19 20:56:08 2012

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>
SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Pr
oduction
With the Partitioning, OLAP, Data Mining and Real Application Testing options

C:\Users\HOME>
C:\Users\HOME>rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Thu Jan 19 20:58:39 2012

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

connected to target database (not started)

RMAN> startup nomount;

Oracle instance started

Total System Global Area 640286720 bytes

Fixed Size 1376492 bytes
Variable Size 247467796 bytes
Database Buffers 385875968 bytes
Redo Buffers 5566464 bytes

RMAN> restore spfile from 'D:\TESTDELETE\ORA\C-1298596975-20120119-01';

Starting restore at 19-JAN-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=134 device type=DISK

channel ORA_DISK_1: restoring spfile from AUTOBACKUP D:\TESTDELETE\ORA\C-1298596
975-20120119-01
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 19-JAN-12

RMAN> RESTORE CONTROLFILE FROM 'D:\TESTDELETE\ORA\C-1298596975-20120119-01';

Starting restore at 19-JAN-12
using channel ORA_DISK_1

channel ORA_DISK_1: restoring control file
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 01/19/2012 21:00:17
ORA-19870: error while restoring backup piece D:\TESTDELETE\ORA\C-1298596975-201
20119-01
ORA-19504: failed to create file "F:\APP\HOME\ORADATA\ORCL\CONTROL01.CTL"
ORA-27040: file create error, unable to create file
OSD-04002: unable to open file
O/S-Error: (OS 3) The system cannot find the path specified.

-- create a directory with name F:\APP\HOME\ORADATA\ORCL
RMAN> RESTORE CONTROLFILE FROM 'D:\TESTDELETE\ORA\C-1298596975-20120119-01';

Starting restore at 19-JAN-12
using channel ORA_DISK_1

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
output file name=F:\APP\HOME\ORADATA\ORCL\CONTROL01.CTL
output file name=F:\APP\HOME\FLASH_RECOVERY_AREA\ORCL\CONTROL02.CTL
Finished restore at 19-JAN-12


RMAN> sql 'alter database mount';

sql statement: alter database mount

RMAN> run {
2> ALLOCATE CHANNEL disk1 DEVICE TYPE DISK FORMAT 'D:\TESTDELETE\ORA\05N16C6A ta
g=TAG20120119T205329';
3> restore database;
4> }

allocated channel: disk1
channel disk1: SID=134 device type=DISK

Starting restore at 19-JAN-12
Starting implicit crosscheck backup at 19-JAN-12
Crosschecked 1 objects
Finished implicit crosscheck backup at 19-JAN-12

Starting implicit crosscheck copy at 19-JAN-12
Finished implicit crosscheck copy at 19-JAN-12

searching for all files in the recovery area
cataloging files...
no files cataloged


channel disk1: starting datafile backup set restore
channel disk1: specifying datafile(s) to restore from backup set
channel disk1: restoring datafile 00001 to F:\APP\HOME\ORADATA\ORCL\SYSTEM01.DBF

channel disk1: restoring datafile 00002 to F:\APP\HOME\ORADATA\ORCL\SYSAUX01.DBF

channel disk1: restoring datafile 00003 to F:\APP\HOME\ORADATA\ORCL\UNDOTBS01.DB
F
channel disk1: restoring datafile 00004 to F:\APP\HOME\ORADATA\ORCL\USERS01.DBF
channel disk1: restoring datafile 00005 to F:\APP\HOME\ORADATA\ORCL\TDE_TEST.DBF

channel disk1: reading from backup piece D:\TESTDELETE\ORA\05N16C6A
channel disk1: piece handle=D:\TESTDELETE\ORA\05N16C6A tag=TAG20120119T205329
channel disk1: restored backup piece 1
channel disk1: restore complete, elapsed time: 00:02:15
Finished restore at 19-JAN-12
released channel: disk1

RMAN>
------ did not do recover database as it is No Archive Mode-- as moreover it is dev db --
RMAN> recover database;
---------------------------------

RMAN> sql 'alter database open resetlogs';

sql statement: alter database open resetlogs

RMAN>


RMAN> exit


Recovery Manager complete.

C:\Users\HOME>sqlplus "/as sysdba"

SQL*Plus: Release 11.2.0.1.0 Production on Thu Jan 19 21:16:56 2012

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select name, open_mode from v$database;

NAME OPEN_MODE
--------- --------------------
ORCL READ WRITE

SQL> exit



-------- Have a fun working in oracle technologies ............ Cheers...

Friday, December 23, 2011

CREATE DB FROM RMAN BACKUPS WITH SAME DBNAME ON SAME HOST OR REMOTE HOST

CREATE DB FROM RMAN BACKUPS WITH SAME DBNAME ON SAME HOST OR REMOTE HOST IN ORACLE 11G:

Please do check with oracle online documentation before we do any backup and recovery steps, I think it is good.. having complete failed backup of db/dbfiles storage would help us if something goes wrong in our recovery.. have a copy of it...


One should ensure that Database has valid RMAN full backup all the available......at least three places...

Problem: All the files are lost, including spfile, controlfile, dbf files, redo logs.. only we have good rman backup..

C:\Users\HOME>rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Wed Dec 21 20:53:09 2011

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

connected to target database: TSTDEV01 (DBID=874354934)

RMAN> SHOW ALL;

using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name TSTDEV01 are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOA
D TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO 'F:\APP\HOME\PRODUCT\11.2.0\DBHOME_1\DATA
BASE\SNCFTSTDEV01.ORA'; # default

set oracle_sid
C:\Users\HOME>set ORACLE_SID=TSTDEV01


Connect rman to take database backup
C:\Users\HOME>rman target /
connected to target database: TSTDEV01 (DBID=874354934)

3. take the database backup using one of the way shown below

run
{
ALLOCATE CHANNEL disk1 DEVICE TYPE DISK FORMAT 'd:\testdelete\dbf\%U';
backup database plus archivelog delete input;
}

or

run
{
ALLOCATE CHANNEL disk1 DEVICE TYPE DISK FORMAT 'd:\testdelete\dbf\%U';
backup database plus archivelog delete input;
backup current controlfile format 'd:\testdelete\dbf\control.back';
BACKUP SPFILE TO DESTINATION 'd:\testdelete\dbf';
BACKUP AS COPY CURRENT CONTROLFILE FORMAT 'd:\testdelete\dbf\control01.ctl';
}

Ensure that where control file, spfile backup is being made. it is important. I do like to run second run block no matter how many control files are created... good to safe...
Second run would help us when recovery disk location is lost.. otherwise first run block is okay...



---------------------- Restore database from RMAN backup starts from here....------------------

LOST DATABASE FILES (SPFILE, CONTROL FILES, DBF AND REDO LOGS ).. ONLY HAVE RMAN FULL BACKUP

1. Create instance
C:\Users\HOME>oradim -new -sid TSTDEV01 -intpwd oracle -startmode m
Instance created.

After creation of instance, one can use netmanager and netca to configure listener.ora and tnsnames.ora etc files... or one can go for manuall edit (ensure entries are made in right format)..
2. Add the following entry in listener.ora file

(SID_DESC =
(GLOBAL_DBNAME=TSTDEV01)
(SID_NAME = TSTDEV01)
(ORACLE_HOME = F:\app\HOME\product\11.2.0\dbhome_1)
)

3. Add the following entry into tnsnames.ora file

 TSTDEV01 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = TSTDEV01)
)
)



C:\Users\HOME>lsnrctl reload
C:\Users\HOME>lsnrclt status

Ensure instance is ready and accessible.

C:\Users\HOME>tnsping TSTDEV01

TNS Ping Utility for 32-bit Windows: Version 11.2.0.1.0 - Production on 21-DEC-2
011 21:27:06

Copyright (c) 1997, 2010, Oracle. All rights reserved.

Used parameter files:
F:\app\HOME\product\11.2.0\dbhome_1\network\admin\sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhos
t)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = TSTDEV01))
)
OK (20 msec)

C:\Users\HOME>

I see lsnrctl stop, lsnrctl start would help here .. if u can not able to login using sqlplus sys/pwd@dbname as sysdba..
C:\Users\HOME>SQLPLUS SYS/ORACLE@TSTDEV01 AS SYSDBA

SQL*Plus: Release 11.2.0.1.0 Production on Wed Dec 21 21:34:10 2011

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

Connected to an idle instance.

SQL>

4. Create the spfile from the rman backup

C:\Users\HOME>RMAN TARGET SYS/ORACLE@TSTDEV01

Recovery Manager: Release 11.2.0.1.0 - Production on Wed Dec 21 21:35:03 2011

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

connected to target database (not started)

RMAN> set DBID=9945147239

executing command: SET DBID

RMAN> startup force nomount

startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file 'F:\APP\HOME\PRODUCT\11.2.0\DBHOME_1\DA
TABASE\INITTSTDEV01.ORA'

starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started

Total System Global Area 159019008 bytes

Fixed Size 1373264 bytes
Variable Size 75500464 bytes
Database Buffers 75497472 bytes
Redo Buffers 6647808 bytes

RMAN> restore spfile from 'F:\app\HOME\flash_recovery_area\TSTDEV01\AUTOBACKUP\2011_12_21\O1_MF_S_770504345_7H3YT5T9_.BKP';

Starting restore at 21-DEC-11
using channel ORA_DISK_1

channel ORA_DISK_1: restoring spfile from AUTOBACKUP F:\app\HOME\flash_recovery_
area\TSTDEV01\AUTOBACKUP\2011_12_21\O1_MF_S_770504345_7H3YT5T9_.BKP
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 21-DEC-11

RMAN>

Run the following command at command prompt to create pfile from spfile that is just created from rman backup
sql "create PFILE = ''D:\TESTDELETE\PFILE'' from SPFILE = ''F:\app\HOME\product\11.2.0\dbhome_1\database\SPFILETSTDEV01.ORA''";

RMAN> sql "create PFILE = ''D:\TESTDELETE\PFILE'' from SPFILE = ''F:\app\HOME\pr
oduct\11.2.0\dbhome_1\database\SPFILETSTDEV01.ORA''";

sql statement: create PFILE = ''D:\TESTDELETE\PFILE'' from SPFILE = ''F:\app\HOM
E\product\11.2.0\dbhome_1\database\SPFILETSTDEV01.ORA''

RMAN>exit

5. Create control file from RMAN backups

Shutdown the database and start with spfile (create in step 4)

C:\Users\HOME>SQLPLUS SYS/ORACLE@TSTDEV01 AS SYSDBA

SQL*Plus: Release 11.2.0.1.0 Production on Wed Dec 21 21:46:49 2011

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options


ORACLE instance shut down.
SQL> startup nomount;
ORA-00119: invalid specification for system parameter LOCAL_LISTENER
ORA-00132: syntax error or unresolved network name 'LISTENER_TSTDEV01'

remove the following line from pfile the one just created
*.local_listener='LISTENER_TSTDEV01'


SQL> startup nomount pfile='d:\testdelete\PFILE';
ORACLE instance started.

Total System Global Area 640286720 bytes
Fixed Size 1376492 bytes
Variable Size 197136148 bytes
Database Buffers 436207616 bytes
Redo Buffers 5566464 bytes
SQL>

6. Get the controle file from backup

Here are many ways to get the controlfile from RMAN backup.... shown three ways ( I dont know but some reason I backup control file many times..see the rman backup run script above).

 RMAN> restore controlfile from autobackup;

Starting restore at 23-DEC-11
using channel ORA_DISK_1

recovery area destination: F:\app\HOME\flash_recovery_area
database name (or database unique name) used for search: TSTDEV01
channel ORA_DISK_1: AUTOBACKUP F:\APP\HOME\FLASH_RECOVERY_AREA\TSTDEV01\AUTOBACK
UP\2011_12_22\O1_MF_S_770591689_7H6N3ML1_.BKP found in the recovery area
AUTOBACKUP search with format "%F" not attempted because DBID was not set
channel ORA_DISK_1: restoring control file from AUTOBACKUP F:\APP\HOME\FLASH_REC
OVERY_AREA\TSTDEV01\AUTOBACKUP\2011_12_22\O1_MF_S_770591689_7H6N3ML1_.BKP
channel ORA_DISK_1: control file restore from AUTOBACKUP complete
output file name=F:\APP\HOME\ORADATA\TSTDEV01\CONTROL01.CTL
output file name=F:\APP\HOME\FLASH_RECOVERY_AREA\TSTDEV01\CONTROL02.CTL
Finished restore at 23-DEC-11

RMAN> restore controlfile from 'D:\TESTDELETE\dbf\control.back';

Starting restore at 23-DEC-11
using channel ORA_DISK_1

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
output file name=F:\APP\HOME\ORADATA\TSTDEV01\CONTROL01.CTL
output file name=F:\APP\HOME\FLASH_RECOVERY_AREA\TSTDEV01\CONTROL02.CTL
Finished restore at 23-DEC-11

RMAN> restore controlfile from 'D:\TESTDELETE\dbf\control01.ctl';

Starting restore at 23-DEC-11
using channel ORA_DISK_1

channel ORA_DISK_1: copied control file copy
output file name=F:\APP\HOME\ORADATA\TSTDEV01\CONTROL01.CTL
output file name=F:\APP\HOME\FLASH_RECOVERY_AREA\TSTDEV01\CONTROL02.CTL
Finished restore at 23-DEC-11

RMAN>
RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

RMAN> restore database;

Starting restore at 23-DEC-11
using channel ORA_DISK_1

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 F:\APP\HOME\ORADATA\TSTDEV01\SYS
TEM01.DBF
channel ORA_DISK_1: restoring datafile 00002 to F:\APP\HOME\ORADATA\TSTDEV01\SYS
AUX01.DBF
channel ORA_DISK_1: restoring datafile 00003 to F:\APP\HOME\ORADATA\TSTDEV01\UND
OTBS01.DBF
channel ORA_DISK_1: restoring datafile 00004 to F:\APP\HOME\ORADATA\TSTDEV01\USE
RS01.DBF
channel ORA_DISK_1: reading from backup piece D:\TESTDELETE\DBF\0KMUSIQ7_1_1
channel ORA_DISK_1: piece handle=D:\TESTDELETE\DBF\0KMUSIQ7_1_1 tag=TAG20111222T
211239
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:02:25
Finished restore at 23-DEC-11

RMAN> recover database;

Starting recover at 23-DEC-11
using channel ORA_DISK_1

starting media recovery

channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=16
channel ORA_DISK_1: reading from backup piece D:\TESTDELETE\DBF\0LMUSITS_1_1
channel ORA_DISK_1: piece handle=D:\TESTDELETE\DBF\0LMUSITS_1_1 tag=TAG20111222T
211436
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=F:\APP\HOME\FLASH_RECOVERY_AREA\TSTDEV01\ARCHIVELOG\2011_
12_23\O1_MF_1_16_7H94R2H4_.ARC thread=1 sequence=16
channel default: deleting archived log(s)
archived log file name=F:\APP\HOME\FLASH_RECOVERY_AREA\TSTDEV01\ARCHIVELOG\2011_
12_23\O1_MF_1_16_7H94R2H4_.ARC RECID=16 STAMP=770674266
unable to find archived log
archived log thread=1 sequence=17
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 12/23/2011 20:11:10
RMAN-06054: media recovery requesting unknown archived log for thread 1 with seq
uence 17 and starting SCN of 958969

RMAN> recover database until logseq 17;

Starting recover at 23-DEC-11
using channel ORA_DISK_1

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

Finished recover at 23-DEC-11

RMAN> alter database open;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 12/23/2011 20:12:30
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open


RMAN> alter database open resetlogs;

database opened

RMAN>

Note: Usually resetlogs used when incomplete recovery took place otherwise we should go for noresetlogs option.
RESETLOGS would initialize all the logs, reset the log sequence number from start and start a new incarnation of the database.


RMAN> exit


Recovery Manager complete.

C:\Users\HOME>sqlplus "/as sysdba"

SQL*Plus: Release 11.2.0.1.0 Production on Fri Dec 23 20:22:23 2011

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1
Next log sequence to archive 1
Current log sequence 1
SQL> select name, open_mode from v$database;

NAME OPEN_MODE
--------- --------------------
TSTDEV01 READ WRITE

SQL>


Check everything and have a good backup once everything looks good.. Good to have backup at this moment.

.. Have a great fun in working in oracle technologies... Cheers....

CREATE DB FROM RMAN BACKUPS WITH SAME DBNAME ON SAME HOST OR REMOTE HOST

CREATE DB FROM RMAN BACKUPS WITH SAME DBNAME ON SAME HOST OR REMOTE HOST IN ORACLE 11G:

Please do check with oracle online documentation before we do any backup and recovery steps, I think it is good.. having complete failed backup of db/dbfiles storage would help us if something goes wrong in our recovery.. have a copy of it...


One should ensure that Database has valid RMAN full backup all the available......at least three places...

Problem: All the files are lost, including spfile, controlfile, dbf files, redo logs.. only we have good rman backup..

C:\Users\HOME>rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Wed Dec 21 20:53:09 2011

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

connected to target database: TSTDEV01 (DBID=874354934)

RMAN> SHOW ALL;

using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name TSTDEV01 are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOA
D TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO 'F:\APP\HOME\PRODUCT\11.2.0\DBHOME_1\DATA
BASE\SNCFTSTDEV01.ORA'; # default

set oracle_sid
C:\Users\HOME>set ORACLE_SID=TSTDEV01


Connect rman to take database backup
C:\Users\HOME>rman target /
connected to target database: TSTDEV01 (DBID=874354934)

3. take the database backup using one of the way shown below

run
{
ALLOCATE CHANNEL disk1 DEVICE TYPE DISK FORMAT 'd:\testdelete\dbf\%U';
backup database plus archivelog delete input;
}

or

run
{
ALLOCATE CHANNEL disk1 DEVICE TYPE DISK FORMAT 'd:\testdelete\dbf\%U';
backup database plus archivelog delete input;
backup current controlfile format 'd:\testdelete\dbf\control.back';
BACKUP SPFILE TO DESTINATION 'd:\testdelete\dbf';
BACKUP AS COPY CURRENT CONTROLFILE FORMAT 'd:\testdelete\dbf\control01.ctl';
}

Ensure that where control file, spfile backup is being made. it is important. I do like to run second run block no matter how many control files are created... good to safe...
Second run would help us when recovery disk location is lost.. otherwise first run block is okay...



---------------------- Restore database from RMAN backup starts from here....------------------

LOST DATABASE FILES (SPFILE, CONTROL FILES, DBF AND REDO LOGS ).. ONLY HAVE RMAN FULL BACKUP

1. Create instance
C:\Users\HOME>oradim -new -sid TSTDEV01 -intpwd oracle -startmode m
Instance created.

After creation of instance, one can use netmanager and netca to configure listener.ora and tnsnames.ora etc files... or one can go for manuall edit (ensure entries are made in right format)..
2. Add the following entry in listener.ora file

(SID_DESC =
(GLOBAL_DBNAME=TSTDEV01)
(SID_NAME = TSTDEV01)
(ORACLE_HOME = F:\app\HOME\product\11.2.0\dbhome_1)
)

3. Add the following entry into tnsnames.ora file

TSTDEV01 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = TSTDEV01)
)
)



C:\Users\HOME>lsnrctl reload
C:\Users\HOME>lsnrclt status

Ensure instance is ready and accessible.

C:\Users\HOME>tnsping TSTDEV01

TNS Ping Utility for 32-bit Windows: Version 11.2.0.1.0 - Production on 21-DEC-2
011 21:27:06

Copyright (c) 1997, 2010, Oracle. All rights reserved.

Used parameter files:
F:\app\HOME\product\11.2.0\dbhome_1\network\admin\sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhos
t)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = TSTDEV01))
)
OK (20 msec)

C:\Users\HOME>

I see lsnrctl stop, lsnrctl start would help here .. if u can not able to login using sqlplus sys/pwd@dbname as sysdba..
C:\Users\HOME>SQLPLUS SYS/ORACLE@TSTDEV01 AS SYSDBA

SQL*Plus: Release 11.2.0.1.0 Production on Wed Dec 21 21:34:10 2011

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

Connected to an idle instance.

SQL>

4. Create the spfile from the rman backup

C:\Users\HOME>RMAN TARGET SYS/ORACLE@TSTDEV01

Recovery Manager: Release 11.2.0.1.0 - Production on Wed Dec 21 21:35:03 2011

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

connected to target database (not started)

RMAN> set DBID=9945147239

executing command: SET DBID

RMAN> startup force nomount

startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file 'F:\APP\HOME\PRODUCT\11.2.0\DBHOME_1\DA
TABASE\INITTSTDEV01.ORA'

starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started

Total System Global Area 159019008 bytes

Fixed Size 1373264 bytes
Variable Size 75500464 bytes
Database Buffers 75497472 bytes
Redo Buffers 6647808 bytes

RMAN> restore spfile from 'F:\app\HOME\flash_recovery_area\TSTDEV01\AUTOBACKUP\2011_12_21\O1_MF_S_770504345_7H3YT5T9_.BKP';

Starting restore at 21-DEC-11
using channel ORA_DISK_1

channel ORA_DISK_1: restoring spfile from AUTOBACKUP F:\app\HOME\flash_recovery_
area\TSTDEV01\AUTOBACKUP\2011_12_21\O1_MF_S_770504345_7H3YT5T9_.BKP
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 21-DEC-11

RMAN>

Run the following command at command prompt to create pfile from spfile that is just created from rman backup
sql "create PFILE = ''D:\TESTDELETE\PFILE'' from SPFILE = ''F:\app\HOME\product\11.2.0\dbhome_1\database\SPFILETSTDEV01.ORA''";

RMAN> sql "create PFILE = ''D:\TESTDELETE\PFILE'' from SPFILE = ''F:\app\HOME\pr
oduct\11.2.0\dbhome_1\database\SPFILETSTDEV01.ORA''";

sql statement: create PFILE = ''D:\TESTDELETE\PFILE'' from SPFILE = ''F:\app\HOM
E\product\11.2.0\dbhome_1\database\SPFILETSTDEV01.ORA''

RMAN>exit

5. Create control file from RMAN backups

Shutdown the database and start with spfile (create in step 4)

C:\Users\HOME>SQLPLUS SYS/ORACLE@TSTDEV01 AS SYSDBA

SQL*Plus: Release 11.2.0.1.0 Production on Wed Dec 21 21:46:49 2011

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options


ORACLE instance shut down.
SQL> startup nomount;
ORA-00119: invalid specification for system parameter LOCAL_LISTENER
ORA-00132: syntax error or unresolved network name 'LISTENER_TSTDEV01'

remove the following line from pfile the one just created
*.local_listener='LISTENER_TSTDEV01'


SQL> startup nomount pfile='d:\testdelete\PFILE';
ORACLE instance started.

Total System Global Area 640286720 bytes
Fixed Size 1376492 bytes
Variable Size 197136148 bytes
Database Buffers 436207616 bytes
Redo Buffers 5566464 bytes
SQL>

6. Get the controle file from backup

Here are many ways to get the controlfile from RMAN backup.... shown three ways ( I dont know but some reason I backup control file many times..see the rman backup run script above).

RMAN> restore controlfile from autobackup;

Starting restore at 23-DEC-11
using channel ORA_DISK_1

recovery area destination: F:\app\HOME\flash_recovery_area
database name (or database unique name) used for search: TSTDEV01
channel ORA_DISK_1: AUTOBACKUP F:\APP\HOME\FLASH_RECOVERY_AREA\TSTDEV01\AUTOBACK
UP\2011_12_22\O1_MF_S_770591689_7H6N3ML1_.BKP found in the recovery area
AUTOBACKUP search with format "%F" not attempted because DBID was not set
channel ORA_DISK_1: restoring control file from AUTOBACKUP F:\APP\HOME\FLASH_REC
OVERY_AREA\TSTDEV01\AUTOBACKUP\2011_12_22\O1_MF_S_770591689_7H6N3ML1_.BKP
channel ORA_DISK_1: control file restore from AUTOBACKUP complete
output file name=F:\APP\HOME\ORADATA\TSTDEV01\CONTROL01.CTL
output file name=F:\APP\HOME\FLASH_RECOVERY_AREA\TSTDEV01\CONTROL02.CTL
Finished restore at 23-DEC-11

RMAN> restore controlfile from 'D:\TESTDELETE\dbf\control.back';

Starting restore at 23-DEC-11
using channel ORA_DISK_1

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
output file name=F:\APP\HOME\ORADATA\TSTDEV01\CONTROL01.CTL
output file name=F:\APP\HOME\FLASH_RECOVERY_AREA\TSTDEV01\CONTROL02.CTL
Finished restore at 23-DEC-11

RMAN> restore controlfile from 'D:\TESTDELETE\dbf\control01.ctl';

Starting restore at 23-DEC-11
using channel ORA_DISK_1

channel ORA_DISK_1: copied control file copy
output file name=F:\APP\HOME\ORADATA\TSTDEV01\CONTROL01.CTL
output file name=F:\APP\HOME\FLASH_RECOVERY_AREA\TSTDEV01\CONTROL02.CTL
Finished restore at 23-DEC-11

RMAN>
RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

RMAN> restore database;

Starting restore at 23-DEC-11
using channel ORA_DISK_1

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 F:\APP\HOME\ORADATA\TSTDEV01\SYS
TEM01.DBF
channel ORA_DISK_1: restoring datafile 00002 to F:\APP\HOME\ORADATA\TSTDEV01\SYS
AUX01.DBF
channel ORA_DISK_1: restoring datafile 00003 to F:\APP\HOME\ORADATA\TSTDEV01\UND
OTBS01.DBF
channel ORA_DISK_1: restoring datafile 00004 to F:\APP\HOME\ORADATA\TSTDEV01\USE
RS01.DBF
channel ORA_DISK_1: reading from backup piece D:\TESTDELETE\DBF\0KMUSIQ7_1_1
channel ORA_DISK_1: piece handle=D:\TESTDELETE\DBF\0KMUSIQ7_1_1 tag=TAG20111222T
211239
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:02:25
Finished restore at 23-DEC-11

RMAN> recover database;

Starting recover at 23-DEC-11
using channel ORA_DISK_1

starting media recovery

channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=16
channel ORA_DISK_1: reading from backup piece D:\TESTDELETE\DBF\0LMUSITS_1_1
channel ORA_DISK_1: piece handle=D:\TESTDELETE\DBF\0LMUSITS_1_1 tag=TAG20111222T
211436
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=F:\APP\HOME\FLASH_RECOVERY_AREA\TSTDEV01\ARCHIVELOG\2011_
12_23\O1_MF_1_16_7H94R2H4_.ARC thread=1 sequence=16
channel default: deleting archived log(s)
archived log file name=F:\APP\HOME\FLASH_RECOVERY_AREA\TSTDEV01\ARCHIVELOG\2011_
12_23\O1_MF_1_16_7H94R2H4_.ARC RECID=16 STAMP=770674266
unable to find archived log
archived log thread=1 sequence=17
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 12/23/2011 20:11:10
RMAN-06054: media recovery requesting unknown archived log for thread 1 with seq
uence 17 and starting SCN of 958969

RMAN> recover database until logseq 17;

Starting recover at 23-DEC-11
using channel ORA_DISK_1

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

Finished recover at 23-DEC-11

RMAN> alter database open;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 12/23/2011 20:12:30
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open


RMAN> alter database open resetlogs;

database opened

RMAN>

Note: Usually resetlogs used when incomplete recovery took place otherwise we should go for noresetlogs option.
RESETLOGS would initialize all the logs, reset the log sequence number from start and start a new incarnation of the database.


RMAN> exit


Recovery Manager complete.

C:\Users\HOME>sqlplus "/as sysdba"

SQL*Plus: Release 11.2.0.1.0 Production on Fri Dec 23 20:22:23 2011

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1
Next log sequence to archive 1
Current log sequence 1
SQL> select name, open_mode from v$database;

NAME OPEN_MODE
--------- --------------------
TSTDEV01 READ WRITE

SQL>


Check everything and have a good backup once everything looks good.. Good to have backup at this moment.

.. Have a great fun in working in oracle technologies... Cheers....

Tuesday, December 20, 2011

How to create duplicate oracle database from rman backups in oralce 11g

How to create duplicate oracle database from rman backups in oralce 11g
I think it is not advisable to clone database on same production primary database host to be safe side (excuse me if I am wrong, it does not mean we can not do clone on same host), however please check with oracle online documenation or my oraclesupport for further info if need arise.

I did clone the database from RMAN backups on same host.

Create instance for new oracle database: you my see earlier posts on how to create oracle instance

on target:\-intpwd password=oracle -startmode a -pfile D:\TESTDELETE\initclonedb1.ora
 orapwd file=F:\app\HOME\product\11.2.0\dbhome_1\database\PWDclonedb1.ora password=oracle entries=50
Add entry into listener.ora and tnsnames.ora file.
ensure tnsping clonedb1
ensure tnsping orcl
SET ORACLE_SID=CLONEDB1
lsnrctl reload -- incase required.
startup nomount pfile='D:\TESTDELETE\initclonedb1.ora'
SQL> startup nomount pfile='D:\TESTDELETE\initclonedb1.ora'
ORACLE instance started.

Total System Global Area 640286720 bytes
Fixed Size 1376492 bytes
Variable Size 314576660 bytes
Database Buffers 318767104 bytes
Redo Buffers 5566464 bytes

SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------
clonedb1

SQL>exit

on source db:
-------------
 SET ORACLE_SID=ORCL
rman target /
BACKUP DATABASE PLUS ARCHIVELOG DELETE INPUT;
EXIT;
exit;
open cmd prompt;

 C:\Users\HOME>SET ORACLE_SID=ORCL

C:\Users\HOME>RMAN TARGET / AUXILIARY SYS/ORACLE@CLONEDB1

Recovery Manager: Release 11.2.0.1.0 - Production on Wed Dec 21 05:06:20 2011

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

connected to target database: ORCL (DBID=1297854480)
connected to auxiliary database: CLONEDB1 (not mounted)

RMAN> run {
SET NEWNAME FOR DATAFILE 1 TO 'F:\app\HOME\oradata\clonedb1\SYSTEM01.DBF';
SET NEWNAME FOR DATAFILE 2 TO 'F:\app\HOME\oradata\clonedb1\SYSAUX01.DBF';
SET NEWNAME FOR DATAFILE 3 TO 'F:\app\HOME\oradata\clonedb1\UNDOTBS01.DBF';
SET NEWNAME FOR DATAFILE 4 TO 'F:\app\HOME\oradata\clonedb1\USERS01.DBF';
SET NEWNAME FOR DATAFILE 5 TO 'F:\app\HOME\oradata\clonedb1\EXAMPLE01.DBF';
SET NEWNAME FOR TEMPFILE 1 TO 'F:\app\HOME\oradata\clonedb1\TEMP01.DBF';
DUPLICATE DATABASE TO clonedb1
pfile 'D:\TESTDELETE\initclonedb1.ora'
BACKUP LOCATION 'F:\app\HOME\flash_recovery_area\orcl\'
LOGFILE GROUP 1 ('F:\app\HOME\oradata\clonedb1\REDO01.LOG') SIZE 60M REUSE,
GROUP 2 ('F:\app\HOME\oradata\clonedb1\REDO02.LOG.rdo') SIZE 60M REUSE,
GROUP 3 ('F:\app\HOME\oradata\clonedb1\REDO03.LOG') SIZE 60M REUSE;
}

How to create duplicate oracle database from rman backups in oralce 11g

How to create duplicate oracle database from rman backups in oralce 11g
I think it is not advisable to clone database on same production primary database host to be safe side (excuse me if I am wrong, it does not mean we can not do clone on same host), however please check with oracle online documenation or my oraclesupport for further info if need arise.

I did clone the database from RMAN backups on same host.

Create instance for new oracle database: you my see earlier posts on how to create oracle instance

on target:\-intpwd password=oracle -startmode a -pfile D:\TESTDELETE\initclonedb1.ora
orapwd file=F:\app\HOME\product\11.2.0\dbhome_1\database\PWDclonedb1.ora password=oracle entries=50
Add entry into listener.ora and tnsnames.ora file.
ensure tnsping clonedb1
ensure tnsping orcl
SET ORACLE_SID=CLONEDB1
lsnrctl reload -- incase required.
startup nomount pfile='D:\TESTDELETE\initclonedb1.ora'
SQL> startup nomount pfile='D:\TESTDELETE\initclonedb1.ora'
ORACLE instance started.

Total System Global Area 640286720 bytes
Fixed Size 1376492 bytes
Variable Size 314576660 bytes
Database Buffers 318767104 bytes
Redo Buffers 5566464 bytes

SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------
clonedb1

SQL>exit

on source db:
-------------
SET ORACLE_SID=ORCL
rman target /
BACKUP DATABASE PLUS ARCHIVELOG DELETE INPUT;
EXIT;
exit;
open cmd prompt;

C:\Users\HOME>SET ORACLE_SID=ORCL

C:\Users\HOME>RMAN TARGET / AUXILIARY SYS/ORACLE@CLONEDB1

Recovery Manager: Release 11.2.0.1.0 - Production on Wed Dec 21 05:06:20 2011

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

connected to target database: ORCL (DBID=1297854480)
connected to auxiliary database: CLONEDB1 (not mounted)

RMAN> run {
SET NEWNAME FOR DATAFILE 1 TO 'F:\app\HOME\oradata\clonedb1\SYSTEM01.DBF';
SET NEWNAME FOR DATAFILE 2 TO 'F:\app\HOME\oradata\clonedb1\SYSAUX01.DBF';
SET NEWNAME FOR DATAFILE 3 TO 'F:\app\HOME\oradata\clonedb1\UNDOTBS01.DBF';
SET NEWNAME FOR DATAFILE 4 TO 'F:\app\HOME\oradata\clonedb1\USERS01.DBF';
SET NEWNAME FOR DATAFILE 5 TO 'F:\app\HOME\oradata\clonedb1\EXAMPLE01.DBF';
SET NEWNAME FOR TEMPFILE 1 TO 'F:\app\HOME\oradata\clonedb1\TEMP01.DBF';
DUPLICATE DATABASE TO clonedb1
pfile 'D:\TESTDELETE\initclonedb1.ora'
BACKUP LOCATION 'F:\app\HOME\flash_recovery_area\orcl\'
LOGFILE GROUP 1 ('F:\app\HOME\oradata\clonedb1\REDO01.LOG') SIZE 60M REUSE,
GROUP 2 ('F:\app\HOME\oradata\clonedb1\REDO02.LOG.rdo') SIZE 60M REUSE,
GROUP 3 ('F:\app\HOME\oradata\clonedb1\REDO03.LOG') SIZE 60M REUSE;
}

Thursday, July 7, 2011

ORACLE RMAN: HOW TO CONNECT, CONFIGURE AND WORK

Follow the steps to connect, configure and work with RMAN:
--------------------------------------------------------------
set ORACLE_HOME
set ORACLE_SID

When no catelog used (i.e no catalog but control file):

At command prompt:
--------------------
rman target sys@ORCL


Recovery Catalog configuration:
connect as Sys as sysdba
1. Create a tablespace

CREATE SMALLFILE TABLESPACE rman_tbs DATAFILE ‘D:\ORACLE\..\rman_tbs.dbf’ SIZE 100M EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;

2. CREATE USER rman IDENTIFIED BY rman DEFAULT TABLESPACE rman_tbs

Grant connect, resource , recovery_catalog_owner to rman;

3. Create a Recovery Catalog
at cmd command prompt
----------------------
rman catalog=rman/rman@ORCL

CREATE CATALOG;

EXIT;

4. Register Database:
- Each database must be registered only once

rman catalog=rman/rman@orcl target=sys@orcl

register database;


How to connect catalog schema:
rman catalog=rman/rman@orcl target=sys@orcl

target points to the database you are about run RMAN commands on/against.

5. Connect rman client first then connect desired database at rman command prompt

at command prompt:
-------------------
rman catalog=rman/rman@orcl

Recovery Manager: Release 10.2.0.3.0 - Production on Fri Jul 8 05:50:21 2011

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

connected to recovery catalog database

RMAN> connect target sys@orcl

target database Password:
connected to target database: ORCL (DBID=1876906721)

RMAN> report schema;
.... output would be listed....

In Summary:

1. When no catelog used (i.e no catalog but control file):
At command prompt:
--------------------
rman target sys@ORCL

2. When Recovery catalog used:
rman catalog=rman/rman@orcl target=sys@orcl

Hope it helps.. -- Have a fun in working in Oracle Technologies-- Cheers--

ORACLE RMAN: HOW TO CONNECT, CONFIGURE AND WORK

Follow the steps to connect, configure and work with RMAN:
--------------------------------------------------------------
set ORACLE_HOME
set ORACLE_SID

When no catelog used (i.e no catalog but control file):

At command prompt:
--------------------
rman target sys@ORCL


Recovery Catalog configuration:
connect as Sys as sysdba
1. Create a tablespace

CREATE SMALLFILE TABLESPACE rman_tbs DATAFILE ‘D:\ORACLE\..\rman_tbs.dbf’ SIZE 100M EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;

2. CREATE USER rman IDENTIFIED BY rman DEFAULT TABLESPACE rman_tbs

Grant connect, resource , recovery_catalog_owner to rman;

3. Create a Recovery Catalog
at cmd command prompt
----------------------
rman catalog=rman/rman@ORCL

CREATE CATALOG;

EXIT;

4. Register Database:
- Each database must be registered only once

rman catalog=rman/rman@orcl target=sys@orcl

register database;


How to connect catalog schema:
rman catalog=rman/rman@orcl target=sys@orcl

target points to the database you are about run RMAN commands on/against.

5. Connect rman client first then connect desired database at rman command prompt

at command prompt:
-------------------
rman catalog=rman/rman@orcl

Recovery Manager: Release 10.2.0.3.0 - Production on Fri Jul 8 05:50:21 2011

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

connected to recovery catalog database

RMAN> connect target sys@orcl

target database Password:
connected to target database: ORCL (DBID=1876906721)

RMAN> report schema;
.... output would be listed....

In Summary:

1. When no catelog used (i.e no catalog but control file):
At command prompt:
--------------------
rman target sys@ORCL

2. When Recovery catalog used:
rman catalog=rman/rman@orcl target=sys@orcl

Hope it helps.. -- Have a fun in working in Oracle Technologies-- Cheers--

Tuesday, December 29, 2009

BACKUP AND RECOVERY TECHNIQUES IN ORACLE 10G

Recover database from loss of control file in oracle 10g:


We may face problem with loss of control files and the following method can be emploed to restore/recreate control file:

if control files are already multiplexed and few of those are available, then copy a right/good state of control file over a damaged/missing one. ie.. copy surviving control file with copy command giving missing control filename for new control file and open database or edit the parameter file to remove the reference to the missing or damaged controld file, if db SPFILE being used then use alter system set control_files="avaliable controlfiles path" scope=spfile; and startup

Example:

alter system set control_files='/control01.ctl',
'/control02.ctl',
'/control03.ctl' scope=spfile
startup

Note: Any change to control_files requires db restart

if no control files are available then follow below method.

startup nomount;
SHOW PARAMETER CONTROL


SQL> CREATE CONTROLFILE REUSE DATABASE "MYDB" RESETLOGS NOARCHIVELOG
2 NOARCHIVELOG
3 MAXLOGFILES 16
4 MAXLOGMEMBERS 3
5 MAXDATAFILES 100
6 MAXINSTANCES 10
7 MAXLOGHISTORY 10000
8 LOGFILE
9 GROUP 1 'F:\oracle\product\10.2.0\oradata\MYDB\REDO01.LOG' SIZE
10 100M,
11 GROUP 2 'F:\oracle\product\10.2.0\oradata\MYDB\REDO02.LOG' SIZE
12 100M,
13 GROUP 3 'F:\oracle\product\10.2.0\oradata\MYDB\REDO03.LOG' SIZE
14 100M
15 DATAFILE
16 'F:\oracle\product\10.2.0\oradata\MYDB\SYSTEM01.DBF',
17 'F:\oracle\product\10.2.0\oradata\MYDB\SYSAUX01.DBF',
18 'F:\oracle\product\10.2.0\oradata\MYDB\EXAMPLE01.DBF',
19 'F:\oracle\product\10.2.0\oradata\MYDB\UNDOTBS01.DBF',
20 'F:\oracle\product\10.2.0\oradata\MYDB\USERS01.DBF'
21 CHARACTER SET UTF8
22 ;

Control file created.

Note:
check alert_sid.log file for character set incase if you dont have an idea what character set of db is..
alert_sid.log default location is background_dump_dest (show parameter background_dump_dest)
RESETLOGS synchronizes the SCN between the database files and control files and redo log files and oracle redo log files will be recreated when we open with resetlogs option.

SQL> SHOW PARAMETER CONTROL

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time integer 7
control_files string F:\ORACLE\PRODUCT\10.2.0\ORADA
TA\MYDB\CONTROL01.CTL, F:\ORAC
LE\PRODUCT\10.2.0\ORADATA\MYDB
\CONTROL02.CTL, F:\ORACLE\PROD
UCT\10.2.0\ORADATA\MYDB\CONTRO
L03.CTL
SQL> ALTER DATABASE OPEN;
ALTER DATABASE OPEN
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open


SQL> ALTER DATABASE OPEN RESETLOGS;

Database altered.

SQL> DESC V$CONTROLFILE;
Name Null? Type
----------------------------------------- -------- ----------------------------
STATUS VARCHAR2(7)
NAME VARCHAR2(513)
IS_RECOVERY_DEST_FILE VARCHAR2(3)
BLOCK_SIZE NUMBER
FILE_SIZE_BLKS NUMBER

SQL> SELECT NAME, STATUS FROM V$CONTROLFILE;

NAME
--------------------------------------------------------------------------------
STATUS
-------
F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\CONTROL01.CTL
F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\CONTROL02.CTL
F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\CONTROL03.CTL
SQL>


SQL> select file#,status,enabled,name from V$tempfile;

no rows selected

SQL>

Create temporary tablespace:

It may be necessary to add files to these tablespaces. That can be done using the SQL statement:

ALTER TABLESPACE temp ADD TEMPFILE 'F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\TEMP01.DBF' REUSE;
SQL> select file#,status,enabled,name from V$tempfile;

no rows selected

SQL> ALTER TABLESPACE temp ADD TEMPFILE 'F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\TEMP01.DBF'
REUSE;

Tablespace altered.

SQL> select file#,status,enabled,name from V$tempfile;

FILE# STATUS ENABLED
---------- ------- ----------
NAME
--------------------------------------------------------------------------------
1 ONLINE READ WRITE
F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\TEMP01.DBF


SQL> ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp;

Note:

1. multiplex Control files and Redo log files.
2. Backup of the database regularly with either RMAN or in traditional method.
3. execute alter database backup controlfile to trace; after each change to the database, USE alter session set tracefile_identifier before you take control file backup to have meaning full name. check user_dump_dest (show parameter user_dump_dest as sys)


how to multiplex control files in oracle 10g:

steps:
1. shutdown immediate;
2. copy existing controld file to new control file.
cp existingcontrolfile.ctl newcontrolfile.ctl
3. startup nomount
4. show parameter control
5.
alter system set control_files='F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\CONTROL01.CTL',
'F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\CONTROL02.CTL',
'F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\CONTROL03.CTL',
'F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\CONTROL04.CTL' scope=spfile

6. startup force;
7. select name from v$controlfile;
8. show parameter control;

How to multiplex Online redo log files

1. select * from v$log;
2. select * from v$logfile;
if there is one member in each group, then it is the time to multiplex redo log files.. the minimum is that each group at least consist two members i.e. not less than 2 members in each group.
3. alter system swith logfile; -- do this couple of times till you find all the groups are gone through it.

4. Adding A New Member To An Existing Group

alter database add logfile member 'F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\REDO01B.LOG' TO GROUP
alter database add logfile member 'F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\REDO2B.LOG' TO GROUP 2
alter database add logfile member 'F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\REDO3B.LOG' TO GROUP 3

5. SELECT GROUP#,MEMBER FROM V$LOGFILE -- To see the logfile members
select group#, members, status from v$log; -- To see log group level.

Optimal size of redo log files can be find using

select optimal_logfile_size from v$instance_recovery;


size of redo log files:
select sum(bytes)/1024/1024 "Meg" from sys.v_$log;

select group#,sum(bytes)/1024/1024 "Meg" from sys.v_$log group by group#;

it gives u size of each redo log file from each group... not all the redo log files size if group has more than 1 redo log files...



very nice post on redo log files addition or deletion can be seen at

http://oralog.wordpress.com/2009/12/16/how-to-add-remove-or-relocate-online-redolog-files-and-groups/

Recovering Database from lost multiplexed online redo log files

select group#,status from v$log;
select group#,status,member from v$logfile order by group#
Ensure two members at least there in each group
now to test how we do recover from redo log file is

1. shutdown immediate;
2. remove one of the mulitplexed redo log file either using del on windows or rm on unix
3. startup
database will open normally but there is an error entry in alert log file.. see the details in alert log file.

4. alter system switch logfile; run this more then number of total number of groups.
5. select group#,status,member from v$logfile order by group#
there will an entry with status = invalid.

6. select group#, status from v$log;

ensure that the about to restore group not in active or current i.e. should be inactive state.

7. alter database clear logfile group 1;

which will delete and re-create the members of given logfile group.

8.alter system switch logfile; run this more then number of total number of groups.
9. select group#,status,member from v$logfile order by group#;
run this to find all are in well state...

Backup No Archive Mode oracle 10g Database with RMAN


open command prompt
set ORACLE_SID=ORCL OR export ORACLE_SID=ORCL --- ORCL is sid here

rman target /

run
{
shutdown immediate;
startup mount;
backup as copy database;
alter database open;
}

it would start backup now...

output of this process when default configuration is being used:

it will create a directory with sid i.e. ORCL in this case in flash recovery area
show parameter db_recovery_file_dest
D:\oracle\product\10.2.0\flash_recovery_area\ORCL
Three direcotries will be created automatically
1. backupset -- spfile will be backed up in backup set format
2. controlfile -- where control file being backed up in copy format
3. DATAFILE -- All the dbf files are backed up here....

no temp files , no redo log files are backed up and it is normal...

as last step .. database will be open for ready..

How to restore and recover a Temporary Tablespace:

The first thing to know that the temporary tablespaces and temp files are never backed up and even RMAN do not do the backup of thses and backup of those never needed.

The only way to restore and recover of temparary tablespace/temp file is to recreate when one is missing.
Method :

Add another temp filee:
alter tablespace temp_ts add tempfile '' size 1000M;
take the damaged tempfile offline
alter database tempfile '' offline;
drop the damaged temp file;
alter database tempfile '' drop;

or

create new temp tablespace;
create temporary tablespace temp1 tempfile '' size 1000M;
switch database to use newly created temp tablespace;
alter database default temporary tablespace temp1;
drop damaged temp tablespace;
drop tablespace temp_old including contents and datafiles;

this is fastest method as as file being created is not formated.


.. Hope this will help you all... cheers...

BACKUP AND RECOVERY TECHNIQUES IN ORACLE 10G

Recover database from loss of control file in oracle 10g:


We may face problem with loss of control files and the following method can be emploed to restore/recreate control file:

if control files are already multiplexed and few of those are available, then copy a right/good state of control file over a damaged/missing one. ie.. copy surviving control file with copy command giving missing control filename for new control file and open database or edit the parameter file to remove the reference to the missing or damaged controld file, if db SPFILE being used then use alter system set control_files="avaliable controlfiles path" scope=spfile; and startup

Example:

alter system set control_files='/control01.ctl',
'/control02.ctl',
'/control03.ctl' scope=spfile
startup

Note: Any change to control_files requires db restart

if no control files are available then follow below method.

startup nomount;
SHOW PARAMETER CONTROL


SQL> CREATE CONTROLFILE REUSE DATABASE "MYDB" RESETLOGS NOARCHIVELOG
2 NOARCHIVELOG
3 MAXLOGFILES 16
4 MAXLOGMEMBERS 3
5 MAXDATAFILES 100
6 MAXINSTANCES 10
7 MAXLOGHISTORY 10000
8 LOGFILE
9 GROUP 1 'F:\oracle\product\10.2.0\oradata\MYDB\REDO01.LOG' SIZE
10 100M,
11 GROUP 2 'F:\oracle\product\10.2.0\oradata\MYDB\REDO02.LOG' SIZE
12 100M,
13 GROUP 3 'F:\oracle\product\10.2.0\oradata\MYDB\REDO03.LOG' SIZE
14 100M
15 DATAFILE
16 'F:\oracle\product\10.2.0\oradata\MYDB\SYSTEM01.DBF',
17 'F:\oracle\product\10.2.0\oradata\MYDB\SYSAUX01.DBF',
18 'F:\oracle\product\10.2.0\oradata\MYDB\EXAMPLE01.DBF',
19 'F:\oracle\product\10.2.0\oradata\MYDB\UNDOTBS01.DBF',
20 'F:\oracle\product\10.2.0\oradata\MYDB\USERS01.DBF'
21 CHARACTER SET UTF8
22 ;

Control file created.

Note:
check alert_sid.log file for character set incase if you dont have an idea what character set of db is..
alert_sid.log default location is background_dump_dest (show parameter background_dump_dest)
RESETLOGS synchronizes the SCN between the database files and control files and redo log files and oracle redo log files will be recreated when we open with resetlogs option.

SQL> SHOW PARAMETER CONTROL

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time integer 7
control_files string F:\ORACLE\PRODUCT\10.2.0\ORADA
TA\MYDB\CONTROL01.CTL, F:\ORAC
LE\PRODUCT\10.2.0\ORADATA\MYDB
\CONTROL02.CTL, F:\ORACLE\PROD
UCT\10.2.0\ORADATA\MYDB\CONTRO
L03.CTL
SQL> ALTER DATABASE OPEN;
ALTER DATABASE OPEN
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open


SQL> ALTER DATABASE OPEN RESETLOGS;

Database altered.

SQL> DESC V$CONTROLFILE;
Name Null? Type
----------------------------------------- -------- ----------------------------
STATUS VARCHAR2(7)
NAME VARCHAR2(513)
IS_RECOVERY_DEST_FILE VARCHAR2(3)
BLOCK_SIZE NUMBER
FILE_SIZE_BLKS NUMBER

SQL> SELECT NAME, STATUS FROM V$CONTROLFILE;

NAME
--------------------------------------------------------------------------------
STATUS
-------
F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\CONTROL01.CTL
F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\CONTROL02.CTL
F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\CONTROL03.CTL
SQL>


SQL> select file#,status,enabled,name from V$tempfile;

no rows selected

SQL>

Create temporary tablespace:

It may be necessary to add files to these tablespaces. That can be done using the SQL statement:

ALTER TABLESPACE temp ADD TEMPFILE 'F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\TEMP01.DBF' REUSE;
SQL> select file#,status,enabled,name from V$tempfile;

no rows selected

SQL> ALTER TABLESPACE temp ADD TEMPFILE 'F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\TEMP01.DBF'
REUSE;

Tablespace altered.

SQL> select file#,status,enabled,name from V$tempfile;

FILE# STATUS ENABLED
---------- ------- ----------
NAME
--------------------------------------------------------------------------------
1 ONLINE READ WRITE
F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\TEMP01.DBF


SQL> ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp;

Note:

1. multiplex Control files and Redo log files.
2. Backup of the database regularly with either RMAN or in traditional method.
3. execute alter database backup controlfile to trace; after each change to the database, USE alter session set tracefile_identifier before you take control file backup to have meaning full name. check user_dump_dest (show parameter user_dump_dest as sys)


how to multiplex control files in oracle 10g:

steps:
1. shutdown immediate;
2. copy existing controld file to new control file.
cp existingcontrolfile.ctl newcontrolfile.ctl
3. startup nomount
4. show parameter control
5.
alter system set control_files='F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\CONTROL01.CTL',
'F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\CONTROL02.CTL',
'F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\CONTROL03.CTL',
'F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\CONTROL04.CTL' scope=spfile

6. startup force;
7. select name from v$controlfile;
8. show parameter control;

How to multiplex Online redo log files

1. select * from v$log;
2. select * from v$logfile;
if there is one member in each group, then it is the time to multiplex redo log files.. the minimum is that each group at least consist two members i.e. not less than 2 members in each group.
3. alter system swith logfile; -- do this couple of times till you find all the groups are gone through it.

4. Adding A New Member To An Existing Group

alter database add logfile member 'F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\REDO01B.LOG' TO GROUP
alter database add logfile member 'F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\REDO2B.LOG' TO GROUP 2
alter database add logfile member 'F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\REDO3B.LOG' TO GROUP 3

5. SELECT GROUP#,MEMBER FROM V$LOGFILE -- To see the logfile members
select group#, members, status from v$log; -- To see log group level.

Optimal size of redo log files can be find using

select optimal_logfile_size from v$instance_recovery;


size of redo log files:
select sum(bytes)/1024/1024 "Meg" from sys.v_$log;

select group#,sum(bytes)/1024/1024 "Meg" from sys.v_$log group by group#;

it gives u size of each redo log file from each group... not all the redo log files size if group has more than 1 redo log files...



very nice post on redo log files addition or deletion can be seen at

http://oralog.wordpress.com/2009/12/16/how-to-add-remove-or-relocate-online-redolog-files-and-groups/

Recovering Database from lost multiplexed online redo log files

select group#,status from v$log;
select group#,status,member from v$logfile order by group#
Ensure two members at least there in each group
now to test how we do recover from redo log file is

1. shutdown immediate;
2. remove one of the mulitplexed redo log file either using del on windows or rm on unix
3. startup
database will open normally but there is an error entry in alert log file.. see the details in alert log file.

4. alter system switch logfile; run this more then number of total number of groups.
5. select group#,status,member from v$logfile order by group#
there will an entry with status = invalid.

6. select group#, status from v$log;

ensure that the about to restore group not in active or current i.e. should be inactive state.

7. alter database clear logfile group 1;

which will delete and re-create the members of given logfile group.

8.alter system switch logfile; run this more then number of total number of groups.
9. select group#,status,member from v$logfile order by group#;
run this to find all are in well state...

Backup No Archive Mode oracle 10g Database with RMAN


open command prompt
set ORACLE_SID=ORCL OR export ORACLE_SID=ORCL --- ORCL is sid here

rman target /

run
{
shutdown immediate;
startup mount;
backup as copy database;
alter database open;
}

it would start backup now...

output of this process when default configuration is being used:

it will create a directory with sid i.e. ORCL in this case in flash recovery area
show parameter db_recovery_file_dest
D:\oracle\product\10.2.0\flash_recovery_area\ORCL
Three direcotries will be created automatically
1. backupset -- spfile will be backed up in backup set format
2. controlfile -- where control file being backed up in copy format
3. DATAFILE -- All the dbf files are backed up here....

no temp files , no redo log files are backed up and it is normal...

as last step .. database will be open for ready..

How to restore and recover a Temporary Tablespace:

The first thing to know that the temporary tablespaces and temp files are never backed up and even RMAN do not do the backup of thses and backup of those never needed.

The only way to restore and recover of temparary tablespace/temp file is to recreate when one is missing.
Method :

Add another temp filee:
alter tablespace temp_ts add tempfile '' size 1000M;
take the damaged tempfile offline
alter database tempfile '' offline;
drop the damaged temp file;
alter database tempfile '' drop;

or

create new temp tablespace;
create temporary tablespace temp1 tempfile '' size 1000M;
switch database to use newly created temp tablespace;
alter database default temporary tablespace temp1;
drop damaged temp tablespace;
drop tablespace temp_old including contents and datafiles;

this is fastest method as as file being created is not formated.


.. Hope this will help you all... cheers...