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...

Monday, January 2, 2012

Uncommited rows with F5 function key not showing up in TOAD same session

Uncommited rows with F5 function key not showing up in TOAD same session

I use putty -sqlplus for most of the work... as i see easy to handle DML's.

I am inserting rows with insert statements and pressed F9 for execution..
I am able to see records in toad without commiting records..
whereas
I am inserting rows with multiple insert statements and pressed F5 for execution..
I am not able to see the records in both ways either running select statement with f5 and f9.. ..

Should i set any configuration option in toad when i use F5 for statements execution and to see uncommited records without committing or rollback..just to see what records are inserted or modified???

wonder how to see records which are inserted with insert statement and F5 function key??!!!!

Anyone knows how to see ???

Uncommited rows with F5 function key not showing up in TOAD same session

Uncommited rows with F5 function key not showing up in TOAD same session

I use putty -sqlplus for most of the work... as i see easy to handle DML's.

I am inserting rows with insert statements and pressed F9 for execution..
I am able to see records in toad without commiting records..
whereas
I am inserting rows with multiple insert statements and pressed F5 for execution..
I am not able to see the records in both ways either running select statement with f5 and f9.. ..

Should i set any configuration option in toad when i use F5 for statements execution and to see uncommited records without committing or rollback..just to see what records are inserted or modified???

wonder how to see records which are inserted with insert statement and F5 function key??!!!!

Anyone knows how to see ???