Monday, August 26, 2013

Restore database to a different host using disk based backups

##### start database with dummy pfile

[oracle@subhendb dbs]$ vi initORCL.ora
[oracle@subhendb dbs]$ . oraenv
ORACLE_SID = [ORCL] ?
ORACLE_HOME = [/home/oracle] ? /oracle/app/database/11.2.0.3/dbhome_1
The Oracle base for ORACLE_HOME=/oracle/app/database/11.2.0.3/dbhome_1 is /oracle/app
[oracle@subhendb dbs]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Fri Aug 16 10:49:11 2013

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

Connected to an idle instance.

SQL> startup nomount
ORACLE instance started.

Total System Global Area 4275781632 bytes
Fixed Size                  2235208 bytes
Variable Size             822084792 bytes
Database Buffers         3439329280 bytes
Redo Buffers               12132352 bytes
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

#### restore the pfile from backup

[oracle@subhendb dbs]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Fri Aug 16 10:49:57 2013

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

connected to target database: ORCL (not mounted)

RMAN>  set dbid 1363579986

executing command: SET DBID

RMAN> run{
allocate channel c1 device type disk;
restore spfile to pfile '/oracle/app/database/11.2.0.3/dbhome_1/dbs/initORCL.ora' from '/oracle/app/backup_ORCL/s_822546124.21617.822546137';
}2> 3> 4>

using target database control file instead of recovery catalog
allocated channel: c1
channel c1: SID=429 device type=DISK

Starting restore at 16-AUG-13

channel c1: restoring spfile from AUTOBACKUP /oracle/app/backup_ORCL/s_822546124.21617.822546137
channel c1: SPFILE restore from AUTOBACKUP complete
Finished restore at 16-AUG-13
released channel: c1

RMAN> exit


Recovery Manager complete.

Disconnected

##### modify the pfile for required parameter changes

[oracle@subhendb dbs]$ cp /oracle/app/database/11.2.0.3/dbhome_1/dbs/initORCL.ora /oracle/app/database/11.2.0.3/dbhome_1/dbs/initORCL.ora.bkp
[oracle@subhendb dbs]$ vi /oracle/app/database/11.2.0.3/dbhome_1/dbs/initORCL.ora

[oracle@subhendb dbs]$ cat initORCL.ora.bkp1
*.audit_file_dest='/oracle/app/admin/ORCL/adump'
*.audit_trail='db'
#*.cluster_database=true
*.compatible='11.2.0.0.0'
*.control_files='+DATA01/ORCL/controlfile/current.1291.814453203','+DATA01/ORCL/controlfile/current.22974.814453203'
*.db_block_size=8192
*.db_create_file_dest='+DATA01'
*.db_domain=''
*.db_name='ORCL'
*.db_recovery_file_dest='+DATA01'
*.db_recovery_file_dest_size=5G
*.diagnostic_dest='/oracle/app'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)'
*.log_archive_format='%t_%s_%r.dbf'
*.memory_target=4G
*.open_cursors=300
*.processes=1000
#*.remote_listener='subhendbSCAN.esptest.aurtest.national.com.au:1621'
*.local_listener='LISTENER_ORCL'
*.remote_login_passwordfile='exclusive'
*.sessions=1105

[oracle@subhendb dbs]$ echo $ORACLE_SID
ORCL

[oracle@subhendb dbs]$ pwd
/oracle/app/database/11.2.0.3/dbhome_1/dbs

[oracle@subhendb admin]$ vi tnsnames.ora

### make the below entry to tnsnames.ora
LISTENER_ORCL =
  (ADDRESS = (PROTOCOL = TCP)(HOST = subhendb.espdev.aurdev.national.com.au)(PORT = 1621))

##### create dump directory

[oracle@subhendb admin]$ mkdir -p /oracle/app/admin/ORCL/adump

#### start the database using modified pfile

[oracle@subhendb admin]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Fri Aug 16 11:04:08 2013

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

Connected to an idle instance.

SQL> startup nomount
ORACLE instance started.

Total System Global Area 4275781632 bytes
Fixed Size                  2235208 bytes
Variable Size            2298479800 bytes
Database Buffers         1962934272 bytes
Redo Buffers               12132352 bytes
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options


###### create spfile from the pfile and start database using this spfile

[oracle@subhendb admin]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Fri Aug 16 11:04:23 2013

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options

SQL> show parameter pfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string
SQL> create spfile='/oracle/app/database/11.2.0.3/dbhome_1/dbs/spfileORCL' from pfile='/oracle/app/database/11.2.0.3/dbhome_1/dbs/initORCL.ora';

File created.

SQL> shu immediate
ORA-01507: database not mounted


ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options

##### start using spfile

[oracle@subhendb dbs]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Fri Aug 16 11:09:39 2013

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

Connected to an idle instance.

SQL> startup nomount
ORACLE instance started.

Total System Global Area 4275781632 bytes
Fixed Size                  2235208 bytes
Variable Size            2298479800 bytes
Database Buffers         1962934272 bytes
Redo Buffers               12132352 bytes
SQL> show parameter pfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /oracle/app/database/11.2.0.3/
                                                 dbhome_1/dbs/spfileORCL.or
                                                 a
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@subhendb dbs]$ sleep 2d

[oracle@subhendb dbs]$ echo $ORACLE_SID
ORCL

#### restore control from from backup and mount database

[oracle@subhendb dbs]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Fri Aug 16 11:19:01 2013

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

connected to target database: ORCL (not mounted)

RMAN> set dbid 1363579986

executing command: SET DBID

RMAN> run{
allocate channel c1 device type disk;
restore controlfile from '/oracle/app/backup_ORCL/s_822546124.21617.822546137';
}2> 3> 4>

using target database control file instead of recovery catalog
allocated channel: c1
channel c1: SID=7 device type=DISK

Starting restore at 16-AUG-13

channel c1: restoring control file
channel c1: restore complete, elapsed time: 00:00:01
output file name=+DATA01/ORCL/controlfile/current.778.823605623
output file name=+DATA01/ORCL/controlfile/current.609.823605623
Finished restore at 16-AUG-13
released channel: c1

RMAN> sql 'alter database mount'
2> ;

sql statement: alter database mount

RMAN> exit


Recovery Manager complete.

##### catalog backups and restore,recover database

[oracle@subhendb dbs]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Fri Aug 16 11:21:06 2013

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

connected to target database: ORCL (DBID=1363579986, not open)

RMAN> catalog start with '/oracle/app/backup_ORCL/';

Starting implicit crosscheck backup at 16-AUG-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=7 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=769 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=1149 device type=DISK
allocated channel: ORA_DISK_4
channel ORA_DISK_4: SID=8 device type=DISK
Crosschecked 92 objects
Finished implicit crosscheck backup at 16-AUG-13

Starting implicit crosscheck copy at 16-AUG-13
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4
Finished implicit crosscheck copy at 16-AUG-13

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

searching for all files that match the pattern /oracle/app/backup_ORCL/

List of Files Unknown to the Database
=====================================
File Name: /oracle/app/backup_ORCL/nnndn0_tag20130804t050105_0.4413.822546067
File Name: /oracle/app/backup_ORCL/annnf0_tag20130804t050153_0.9689.822546121
File Name: /oracle/app/backup_ORCL/annnf0_tag20130804t050153_0.21432.822546121
File Name: /oracle/app/backup_ORCL/nnndn0_tag20130804t050105_0.20182.822546067
File Name: /oracle/app/backup_ORCL/s_822546124.21617.822546137
File Name: /oracle/app/backup_ORCL/annnf0_tag20130804t050101_0.23436.822546061
File Name: /oracle/app/backup_ORCL/annnf0_tag20130804t050101_0.13860.822546061
File Name: /oracle/app/backup_ORCL/nnndn0_tag20130804t050105_0.4984.822546067
File Name: /oracle/app/backup_ORCL/nnndn0_tag20130804t050105_0.24077.822546067

Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /oracle/app/backup_ORCL/nnndn0_tag20130804t050105_0.4413.822546067
File Name: /oracle/app/backup_ORCL/annnf0_tag20130804t050153_0.9689.822546121
File Name: /oracle/app/backup_ORCL/annnf0_tag20130804t050153_0.21432.822546121
File Name: /oracle/app/backup_ORCL/nnndn0_tag20130804t050105_0.20182.822546067
File Name: /oracle/app/backup_ORCL/s_822546124.21617.822546137
File Name: /oracle/app/backup_ORCL/annnf0_tag20130804t050101_0.23436.822546061
File Name: /oracle/app/backup_ORCL/annnf0_tag20130804t050101_0.13860.822546061
File Name: /oracle/app/backup_ORCL/nnndn0_tag20130804t050105_0.4984.822546067
File Name: /oracle/app/backup_ORCL/nnndn0_tag20130804t050105_0.24077.822546067

RMAN> restore database;

Starting restore at 16-AUG-13
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4
allocated channel: ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: SID=770 device type=SBT_TAPE
channel ORA_SBT_TAPE_1: Veritas NetBackup for Oracle - Release 6.5 (2010042404)
allocated channel: ORA_SBT_TAPE_2
channel ORA_SBT_TAPE_2: SID=1150 device type=SBT_TAPE
channel ORA_SBT_TAPE_2: Veritas NetBackup for Oracle - Release 6.5 (2010042404)
allocated channel: ORA_SBT_TAPE_3
channel ORA_SBT_TAPE_3: SID=9 device type=SBT_TAPE
channel ORA_SBT_TAPE_3: Veritas NetBackup for Oracle - Release 6.5 (2010042404)
allocated channel: ORA_SBT_TAPE_4
channel ORA_SBT_TAPE_4: SID=389 device type=SBT_TAPE
channel ORA_SBT_TAPE_4: Veritas NetBackup for Oracle - Release 6.5 (2010042404)

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 00004 to +DATA/ORCL/datafile/users.1292.814453143
channel ORA_DISK_1: restoring datafile 00006 to +DATA/ORCL/datafile/nwxbrl_encrypted.1921.814725889
channel ORA_DISK_1: reading from backup piece /oracle/app/backup_ORCL/nnndn0_tag20130804t050105_0.4984.822546067
channel ORA_DISK_2: starting datafile backup set restore
channel ORA_DISK_2: specifying datafile(s) to restore from backup set
channel ORA_DISK_2: restoring datafile 00007 to +DATA/ORCL/datafile/piddata.1586.819288133
channel ORA_DISK_2: restoring datafile 00008 to +DATA/ORCL/datafile/superstream.1827.819990123
channel ORA_DISK_2: restoring datafile 00010 to +DATA/ORCL/datafile/nwwsrm_tbs_encrypted.1449.821527815
channel ORA_DISK_2: restoring datafile 00013 to +DATA/ORCL/datafile/ebms3_tbs_encrypted.1544.821527975
channel ORA_DISK_2: reading from backup piece /oracle/app/backup_ORCL/nnndn0_tag20130804t050105_0.20182.822546067
channel ORA_DISK_3: starting datafile backup set restore
channel ORA_DISK_3: specifying datafile(s) to restore from backup set
channel ORA_DISK_3: restoring datafile 00001 to +DATA/ORCL/datafile/system.1295.814453143
channel ORA_DISK_3: restoring datafile 00003 to +DATA/ORCL/datafile/undotbs1.1293.814453143
channel ORA_DISK_3: restoring datafile 00009 to +DATA/ORCL/datafile/nwebms3_tbs_encrypted.1450.821527793
channel ORA_DISK_3: restoring datafile 00012 to +DATA/ORCL/datafile/quartz_tbs_encrypted.1543.821527877
channel ORA_DISK_3: reading from backup piece /oracle/app/backup_ORCL/nnndn0_tag20130804t050105_0.24077.822546067
channel ORA_DISK_4: starting datafile backup set restore
channel ORA_DISK_4: specifying datafile(s) to restore from backup set
channel ORA_DISK_4: restoring datafile 00002 to +DATA/ORCL/datafile/sysaux.1294.814453143
channel ORA_DISK_4: restoring datafile 00005 to +DATA/ORCL/datafile/undotbs2.1884.814453325
channel ORA_DISK_4: restoring datafile 00011 to +DATA/ORCL/datafile/afpo_soa_tbs_encrypted.1542.821527853
channel ORA_DISK_4: restoring datafile 00014 to +DATA/ORCL/datafile/wsrm_tbs_encrypted.1539.821527985
channel ORA_DISK_4: reading from backup piece /oracle/app/backup_ORCL/nnndn0_tag20130804t050105_0.4413.822546067
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 08/16/2013 11:23:00
ORA-19870: error while restoring backup piece /oracle/app/backup_ORCL/nnndn0_tag20130804t050105_0.4984.822546067
ORA-19913: unable to decrypt backup
ORA-28365: wallet is not open

###### copy the wallet file and try restore and recover again


RMAN>
RMAN> run{
allocate channel c1 device type disk;
restore database;
}

2> 3> 4>
allocated channel: c1
channel c1: SID=7 device type=DISK

Starting restore at 16-AUG-13

channel c1: starting datafile backup set restore
channel c1: specifying datafile(s) to restore from backup set
channel c1: restoring datafile 00004 to +DATA/ORCL/datafile/users.1292.814453143
channel c1: restoring datafile 00006 to +DATA/ORCL/datafile/nwxbrl_encrypted.1921.814725889
channel c1: reading from backup piece /oracle/app/backup_ORCL/nnndn0_tag20130804t050105_0.4984.822546067
channel c1: piece handle=/oracle/app/backup_ORCL/nnndn0_tag20130804t050105_0.4984.822546067 tag=TAG20130804T050105
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:06:45
channel c1: starting datafile backup set restore
channel c1: specifying datafile(s) to restore from backup set
channel c1: restoring datafile 00007 to +DATA/ORCL/datafile/piddata.1586.819288133
channel c1: restoring datafile 00008 to +DATA/ORCL/datafile/superstream.1827.819990123
channel c1: restoring datafile 00010 to +DATA/ORCL/datafile/nwwsrm_tbs_encrypted.1449.821527815
channel c1: restoring datafile 00013 to +DATA/ORCL/datafile/ebms3_tbs_encrypted.1544.821527975
channel c1: reading from backup piece /oracle/app/backup_ORCL/nnndn0_tag20130804t050105_0.20182.822546067
channel c1: piece handle=/oracle/app/backup_ORCL/nnndn0_tag20130804t050105_0.20182.822546067 tag=TAG20130804T050105
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:05:45
channel c1: starting datafile backup set restore
channel c1: specifying datafile(s) to restore from backup set
channel c1: restoring datafile 00001 to +DATA/ORCL/datafile/system.1295.814453143
channel c1: restoring datafile 00003 to +DATA/ORCL/datafile/undotbs1.1293.814453143
channel c1: restoring datafile 00009 to +DATA/ORCL/datafile/nwebms3_tbs_encrypted.1450.821527793
channel c1: restoring datafile 00012 to +DATA/ORCL/datafile/quartz_tbs_encrypted.1543.821527877
channel c1: reading from backup piece /oracle/app/backup_ORCL/nnndn0_tag20130804t050105_0.24077.822546067
channel c1: piece handle=/oracle/app/backup_ORCL/nnndn0_tag20130804t050105_0.24077.822546067 tag=TAG20130804T050105
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:05:45
channel c1: starting datafile backup set restore
channel c1: specifying datafile(s) to restore from backup set
channel c1: restoring datafile 00002 to +DATA/ORCL/datafile/sysaux.1294.814453143
channel c1: restoring datafile 00005 to +DATA/ORCL/datafile/undotbs2.1884.814453325
channel c1: restoring datafile 00011 to +DATA/ORCL/datafile/afpo_soa_tbs_encrypted.1542.821527853
channel c1: restoring datafile 00014 to +DATA/ORCL/datafile/wsrm_tbs_encrypted.1539.821527985
channel c1: reading from backup piece /oracle/app/backup_ORCL/nnndn0_tag20130804t050105_0.4413.822546067
channel c1: piece handle=/oracle/app/backup_ORCL/nnndn0_tag20130804t050105_0.4413.822546067 tag=TAG20130804T050105
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:06:05
Finished restore at 16-AUG-13
released channel: c1

RMAN>
RMAN>

RMAN>

RMAN> run{
allocate channel c1 device type disk;
recover database;
}2> 3> 4>

allocated channel: c1
channel c1: SID=7 device type=DISK

Starting recover at 16-AUG-13

starting media recovery

channel c1: starting archived log restore to default destination
channel c1: restoring archived log
archived log thread=2 sequence=125
channel c1: reading from backup piece /oracle/app/backup_ORCL/annnf0_tag20130804t050153_0.21432.822546121
channel c1: piece handle=/oracle/app/backup_ORCL/annnf0_tag20130804t050153_0.21432.822546121 tag=TAG20130804T050153
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:00:01
archived log file name=+DATA01/ORCL/archivelog/2013_08_16/thread_2_seq_125.729.823609331 thread=2 sequence=125
channel c1: starting archived log restore to default destination
channel c1: restoring archived log
archived log thread=1 sequence=130
channel c1: reading from backup piece /oracle/app/backup_ORCL/annnf0_tag20130804t050153_0.9689.822546121
channel c1: piece handle=/oracle/app/backup_ORCL/annnf0_tag20130804t050153_0.9689.822546121 tag=TAG20130804T050153
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:00:01
archived log file name=+DATA01/ORCL/archivelog/2013_08_16/thread_1_seq_130.790.823609333 thread=1 sequence=130
channel default: deleting archived log(s)
archived log file name=+DATA01/ORCL/archivelog/2013_08_16/thread_2_seq_125.729.823609331 RECID=256 STAMP=823609331
unable to find archived log
archived log thread=2 sequence=126
released channel: c1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 08/16/2013 12:22:14
RMAN-06054: media recovery requesting unknown archived log for thread 2 with sequence 126 and starting SCN of 13935816

RMAN> sql 'alter database open resetlogs';

sql statement: alter database open resetlogs

RMAN> exit


Recovery Manager complete.
[oracle@subhendb dbs]$ sleep 2d



No comments:

Post a Comment