Experience: is what you get soon after you need it.

Experience: is what you get soon after you need it.

Rasul Allah (sal Allahu alaihi wa sallam) said: "Restore the trusts of those who trust you, and deal not falsely with him who deals falsely with you." [Abu Dawud, Tirmidhi]

Search This Blog

Saturday, August 22, 2015

Manually creating the Oracle standby database

Building Standby Database manually:


SQL> select name,open_mode,database_role from v$database;

NAME      OPEN_MODE           DATABASE_ROLE
--------- -------------------- ----------------
ORCL      READ WRITE           PRIMARY


Make archive log is enabled:
SQL> archive log list;
Database log mode           Archive Mode
Automatic archival           Enabled
Archive destination           USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     44
Next log sequence to archive   46
Current log sequence           46


Create the initialization parameter files:

SQL> show parameter pfile

NAME                    TYPE     VALUE
------------------------------------ ----------- ------------------------------
spfile                    string     +DATA2/orcl/spfileorcl.ora


*.audit_file_dest='/u01/app/oracle/admin/orcl/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='+DATA2/orcl/control01.ctl','+DATA2/orcl/control02.ctl'#Restore Controlfile
*.db_block_size=8192
*.db_domain='shaiksameer'
*.db_name='orcl'
*.db_recovery_file_dest='+DATA2'
*.db_recovery_file_dest_size=12884901888
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP)(DISPATCHERS=2)'
*.job_queue_processes=30
*.large_pool_size=12582912
*.memory_target=432013312
*.open_cursors=300
*.parallel_adaptive_multi_user=FALSE
*.parallel_degree_limit='CPU'
*.parallel_degree_policy='MANUAL'
*.parallel_max_servers=20
*.parallel_min_time_threshold='20'
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
#Additional Parameters added for standby
fal_server=orcl
db_unique_name= orcl
standby_file_management=auto
service_names=orcl.shaiksameer
log_archive_config='DG_CONFIG=(orcl,msft)'
log_archive_dest_1='location=+DATA2 VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=ORCL'
log_archive_dest_2='service=msft VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=msft'
log_archive_dest_state_1=enable
log_archive_dest_state_2=enable



SQL> create pfile='/home/oracle/sshaik/initorcl.ora' from spfile;

File created.

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

Total System Global Area  430075904 bytes
Fixed Size           2214056 bytes
Variable Size         289408856 bytes
Database Buffers      134217728 bytes
Redo Buffers           4235264 bytes
Database mounted.
Database opened.


SQL>  create spfile='+DATA/orcl/spfileorcl.ora' from pfile='/home/oracle/sshaik/initorcl.ora';

File created.

SQL> shut immediate
ORA-01109: database not open


Database dismounted.
ORACLE instance shut down.


SQL> startup
ORACLE instance started.

Total System Global Area  430075904 bytes
Fixed Size           2214056 bytes
Variable Size         289408856 bytes
Database Buffers      134217728 bytes
Redo Buffers           4235264 bytes
Database mounted.
Database opened.




Create necessary directories on Target:
[oracle@collabn2 ~]$ mkdir -p /u01/app/oracle/admin/msft/adump
[oracle@collabn2 ~]$


Take the primary database backup:

run {
allocate channel ch01 type disk format '/home/oracle/sshaik/backup/orcl_%U.bak';
backup tag ‘build_standby’database plus archivelog;
release channel ch01;
}
allocate channel for maintenance type disk;
delete noprompt obsolete device type disk;
release channel;


[oracle@collabn1 backup]$ pwd
/home/oracle/sshaik/backup
[oracle@collabn1 backup]$ rman

Recovery Manager: Release 11.2.0.1.0 - Production on Sat Aug 22 13:16:54 2015

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

RMAN> connect target /

connected to target database: ORCL (DBID=1414564590)


RMAN> run{
2> allocate channel ch01 type disk format '/home/oracle/sshaik/backup/orcl_%u.bak';
3> backup database tag 'Build_standby' plus archivelog;
4> backup spfile;
5> backup current controlfile;
6> }

released channel: ORA_DISK_1
allocated channel: ch01
channel ch01: SID=59 device type=DISK


Starting backup at 22-AUG-15
current log archived
channel ch01: starting archived log backup set
channel ch01: specifying archived log(s) in backup set
input archived log thread=1 sequence=50 RECID=66 STAMP=888412671
input archived log thread=1 sequence=51 RECID=67 STAMP=888424597
channel ch01: starting piece 1 at 22-AUG-15
channel ch01: finished piece 1 at 22-AUG-15
piece handle=/home/oracle/sshaik/backup/orcl_1dqf8jqf.bak tag=TAG20150822T170519 comment=NONE
channel ch01: backup set complete, elapsed time: 00:00:01
channel ch01: starting archived log backup set
channel ch01: specifying archived log(s) in backup set
input archived log thread=1 sequence=1 RECID=75 STAMP=888424738
input archived log thread=1 sequence=2 RECID=76 STAMP=888424739
input archived log thread=1 sequence=3 RECID=77 STAMP=888425327
channel ch01: starting piece 1 at 22-AUG-15
channel ch01: finished piece 1 at 22-AUG-15
piece handle=/home/oracle/sshaik/backup/orcl_1eqf8jqg.bak tag=TAG20150822T170519 comment=NONE
channel ch01: backup set complete, elapsed time: 00:00:01
channel ch01: starting archived log backup set
channel ch01: specifying archived log(s) in backup set
input archived log thread=1 sequence=52 RECID=68 STAMP=888424597
input archived log thread=1 sequence=53 RECID=69 STAMP=888424597
channel ch01: starting piece 1 at 22-AUG-15
channel ch01: finished piece 1 at 22-AUG-15
piece handle=/home/oracle/sshaik/backup/orcl_1fqf8jqh.bak tag=TAG20150822T170519 comment=NONE
channel ch01: backup set complete, elapsed time: 00:00:01
channel ch01: starting archived log backup set
channel ch01: specifying archived log(s) in backup set
input archived log thread=1 sequence=4 RECID=78 STAMP=888425338
input archived log thread=1 sequence=5 RECID=79 STAMP=888426081
channel ch01: starting piece 1 at 22-AUG-15
channel ch01: finished piece 1 at 22-AUG-15
piece handle=/home/oracle/sshaik/backup/orcl_1gqf8jqi.bak tag=TAG20150822T170519 comment=NONE
channel ch01: backup set complete, elapsed time: 00:00:01
channel ch01: starting archived log backup set
channel ch01: specifying archived log(s) in backup set
input archived log thread=1 sequence=54 RECID=70 STAMP=888424597
input archived log thread=1 sequence=55 RECID=71 STAMP=888424597
channel ch01: starting piece 1 at 22-AUG-15
channel ch01: finished piece 1 at 22-AUG-15
piece handle=/home/oracle/sshaik/backup/orcl_1hqf8jqj.bak tag=TAG20150822T170519 comment=NONE
channel ch01: backup set complete, elapsed time: 00:00:01
channel ch01: starting archived log backup set
channel ch01: specifying archived log(s) in backup set
input archived log thread=1 sequence=6 RECID=80 STAMP=888426081
input archived log thread=1 sequence=7 RECID=81 STAMP=888426319
channel ch01: starting piece 1 at 22-AUG-15
channel ch01: finished piece 1 at 22-AUG-15
piece handle=/home/oracle/sshaik/backup/orcl_1iqf8jqk.bak tag=TAG20150822T170519 comment=NONE
channel ch01: backup set complete, elapsed time: 00:00:01
channel ch01: starting archived log backup set
channel ch01: specifying archived log(s) in backup set
input archived log thread=1 sequence=56 RECID=72 STAMP=888424597
input archived log thread=1 sequence=57 RECID=73 STAMP=888424597
input archived log thread=1 sequence=58 RECID=74 STAMP=888424597
channel ch01: starting piece 1 at 22-AUG-15
channel ch01: finished piece 1 at 22-AUG-15
piece handle=/home/oracle/sshaik/backup/orcl_1jqf8jql.bak tag=TAG20150822T170519 comment=NONE
channel ch01: backup set complete, elapsed time: 00:00:01
Finished backup at 22-AUG-15

Starting backup at 22-AUG-15
channel ch01: starting full datafile backup set
channel ch01: specifying datafile(s) in backup set
input datafile file number=00001 name=+DATA2/orcl/system01.dbf
input datafile file number=00002 name=+DATA2/orcl/sysaux01.dbf
input datafile file number=00003 name=+DATA2/orcl/undotbs01.dbf
input datafile file number=00004 name=+DATA2/orcl/users01.dbf
input datafile file number=00005 name=+DATA2/orcl/example01.dbf
input datafile file number=00006 name=+DATA/orcl/datafile/hr_test.293.888424601
input datafile file number=00008 name=+DATA2/orcl/datafile/tbs1.348.888424599
input datafile file number=00007 name=+DATA2/orcl/datafile/tt_temp_sales.347.888424599
input datafile file number=00009 name=+DATA2/orcl/datafile/tbs2.360.888424601
channel ch01: starting piece 1 at 22-AUG-15
channel ch01: finished piece 1 at 22-AUG-15
piece handle=/home/oracle/sshaik/backup/orcl_1kqf8jqn.bak tag=BUILD_STANDBY comment=NONE
channel ch01: backup set complete, elapsed time: 00:00:07
Finished backup at 22-AUG-15

Starting backup at 22-AUG-15
current log archived
channel ch01: starting archived log backup set
channel ch01: specifying archived log(s) in backup set
input archived log thread=1 sequence=8 RECID=82 STAMP=888426334
channel ch01: starting piece 1 at 22-AUG-15
channel ch01: finished piece 1 at 22-AUG-15
piece handle=/home/oracle/sshaik/backup/orcl_1lqf8jqu.bak tag=TAG20150822T170534 comment=NONE
channel ch01: backup set complete, elapsed time: 00:00:01
Finished backup at 22-AUG-15

Starting backup at 22-AUG-15
channel ch01: starting full datafile backup set
channel ch01: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ch01: starting piece 1 at 22-AUG-15
channel ch01: finished piece 1 at 22-AUG-15
piece handle=/home/oracle/sshaik/backup/orcl_1mqf8jqv.bak tag=TAG20150822T170535 comment=NONE
channel ch01: backup set complete, elapsed time: 00:00:01
Finished backup at 22-AUG-15

Starting backup at 22-AUG-15
channel ch01: starting full datafile backup set
channel ch01: specifying datafile(s) in backup set
including current control file in backup set
channel ch01: starting piece 1 at 22-AUG-15
channel ch01: finished piece 1 at 22-AUG-15
piece handle=/home/oracle/sshaik/backup/orcl_1nqf8jr0.bak tag=TAG20150822T170536 comment=NONE
channel ch01: backup set complete, elapsed time: 00:00:01
Finished backup at 22-AUG-15

Starting Control File and SPFILE Autobackup at 22-AUG-15
piece handle=+DATA2/orcl/autobackup/2015_08_22/s_888426339.390.888426339 comment=NONE
Finished Control File and SPFILE Autobackup at 22-AUG-15
released channel: ch01



[oracle@collabn1 backup]$ ls -lrt
total 1505976
-rw-r----- 1 oracle dba   93743104 Aug 22 13:17 orcl_12qf86fn_1_1.bak
-rw-r----- 1 oracle dba 1448353792 Aug 22 13:17 orcl_13qf86fo_1_1.bak
-rw-r----- 1 oracle dba      14336 Aug 22 13:17 orcl_14qf86fv_1_1.bak


Backup the controlfile for standby:

[oracle@collabn1 ~]$ rman

Recovery Manager: Release 11.2.0.1.0 - Production on Sat Aug 22 15:45:02 2015

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

RMAN> connect target /

connected to target database: ORCL (DBID=1414564590)

RMAN>  backup current controlfile for standby format '/home/oracle/sshaik/backup/orclcontrol.ctl';

Starting backup at 22-AUG-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=64 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including standby control file in backup set
channel ORA_DISK_1: starting piece 1 at 22-AUG-15
channel ORA_DISK_1: finished piece 1 at 22-AUG-15
piece handle=/home/oracle/sshaik/backup/orclcontrol.ctl tag=TAG20150822T154511 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 22-AUG-15

Starting Control File and SPFILE Autobackup at 22-AUG-15
piece handle=+DATA2/orcl/autobackup/2015_08_22/s_888421513.321.888421513 comment=NONE
Finished Control File and SPFILE Autobackup at 22-AUG-15

RMAN>



Make listener.ora & tnsnames.ora files are created on the source and the servicenames are working.

[oracle@collabn1 admin]$ lsnrctl status orcl

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 22-AUG-2015 14:02:11

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=collabn1.shaiksameer)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl.shaiksameer)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date                21-AUG-2015 15:38:17
Uptime                    0 days 22 hr. 23 min. 53 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/12.1.0/grid/network/admin/listener.ora
Listener Log File         /u01/app/ora_base/diag/tnslsnr/collabn1/listener/alert/log.xml
Listening Endpoints Summary...
 (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.78.51)(PORT=1521)))
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.78.61)(PORT=1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
 Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "orcl.shaiksameer" has 1 instance(s).
 Instance "orcl", status READY, has 3 handler(s) for this service...
The command completed successfully


[oracle@collabn1 admin]$ vi tnsnames.ora

ORCL =
 (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = collabn1.shaiksameer)(PORT = 1521))
    (CONNECT_DATA =
     (SERVER = DEDICATED)
     (SERVICE_NAME = orcl.shaiksameer)
    )
 )

Add the standby entry into the tnsnames.ora file.

[oracle@collabn1 admin]$ vi tnsnames.ora

ORCL =
 (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = collabn1.shaiksameer)(PORT = 1521))
    (CONNECT_DATA =
     (SERVER = DEDICATED)
     (SERVICE_NAME = orcl.shaiksameer)
    )
 )

msft =
 (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = collabn2.shaiksameer)(PORT = 1621))
    (CONNECT_DATA =
     (SERVER = DEDICATED)
     (SERVICE_NAME = msft.shaiksameer)
    )
 )

Copy the orapassword of primary:

[oracle@collabn1 dbs]$ cp orapworcl /media/sf_stage/backup/



Move the backup,controlfile,orapassword and standby pfile to the target server:

[oracle@collabn1 backup]$ cp /home/oracle/sshaik/initmsft.ora /media/sf_stage/backup/


[oracle@collabn1 backup]$ cp * /media/sf_stage/backup

[oracle@collabn1 dbs]$ ls -lrt /media/sf_stage/backup/
total 1515532
-rwxrwx--- 1 root vboxsf   93743104 Aug 22 13:46 orcl_12qf86fn_1_1.bak
-rwxrwx--- 1 root vboxsf    9781248 Aug 22 13:46 orclcontrol.ctl
-rwxrwx--- 1 root vboxsf      14336 Aug 22 13:46 orcl_14qf86fv_1_1.bak
-rwxrwx--- 1 root vboxsf 1448353792 Aug 22 13:46 orcl_13qf86fo_1_1.bak
-rwxrwx--- 1 root vboxsf       1172 Aug 22 14:00 initmsft.ora
-rwxrwx--- 1 root vboxsf       1536 Aug 22 15:18 orapworcl





On Target:

=======

Configure listener.ora and tnsnames.ora

Add the msft db details to the listener.ora file
vi $TNS_ADMIN/listener.ora
LISTENER =
 (ADDRESS_LIST=
       (ADDRESS=(PROTOCOL=tcp)(HOST=collabn2.shaiksameer)(PORT=1621))
       #(ADDRESS=(PROTOCOL=ipc)(KEY=PNPKEY))
 )
SID_LIST_LISTENER=
  (SID_LIST=
       (SID_DESC=
         (GLOBAL_DBNAME=PROD2)
         (SID_NAME=PROD2)
         (ORACLE_HOME=/u01/app/oracle/product/11.2.0.2/SHAIKPROD)
        )
       (SID_DESC=
         (GLOBAL_DBNAME=msft.shaiksameer)
         (SID_NAME=msft)
         (ORACLE_HOME=/u01/app/oracle/product/11.2.0.2/SHAIKPROD)
        )
  )



[oracle@collabn2 admin]$ vi tnsnames.ora

ORCL =
 (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = collabn1.shaiksameer)(PORT = 1521))
    (CONNECT_DATA =
     (SERVER = DEDICATED)
     (SERVICE_NAME = orcl.shaiksameer)
    )
 )

msft =
 (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = collabn2.shaiksameer)(PORT = 1621))
    (CONNECT_DATA =
     (SERVER = DEDICATED)
     (SERVICE_NAME = msft.shaiksameer)
    )
 )

Start the listener & Verify that you are able to ping the service name:

[oracle@collabn2 admin]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 22-AUG-2015 14:54:47

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

Starting /u01/app/oracle/product/11.2.0.2/SHAIKPROD/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0.2/SHAIKPROD/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/collabn2/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=collabn2.shaiksameer)(PORT=1621)))

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=collabn2.shaiksameer)(PORT=1621))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                22-AUG-2015 14:54:47
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0.2/SHAIKPROD/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/collabn2/listener/alert/log.xml
Listening Endpoints Summary...
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=collabn2.shaiksameer)(PORT=1621)))
Services Summary...
Service "PROD2" has 1 instance(s).
 Instance "PROD2", status UNKNOWN, has 1 handler(s) for this service...
Service "msft.shaiksameer" has 1 instance(s).
 Instance "msft", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

[oracle@collabn2 admin]$ tnsping msft

TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 22-AUG-2015 15:07:17

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

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = collabn2.shaiksameer)(PORT = 1621)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = msft.shaiksameer)))
OK (0 msec)
[oracle@collabn2 admin]$


Create the env file to setup the Oracle environment

[oracle@collabn2 ~]$ vi msft.env

ORACLE_SID=msft
ORACLE_HOME=/u01/app/oracle/product/11.2.0.2/SHAIKPROD
ORAENV_ASK=NO
export ORACLE_SID ORACLE_HOME ORAENV_ASK
export ORACLE_BASE=/u01/app/oracle
export PATH=$PATH:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export TNS_ADMIN=$ORACLE_HOME/network/admin


[oracle@collabn2 ~]$
[oracle@collabn2 ~]$ . ./msft.env

Copy the init parameter file into the $ORACLE_HOME/dbs location

[oracle@collabn2 ~]$ cd $ORACLE_HOME/dbs
[oracle@collabn2 dbs]$ cp /media/sf_stage/backup/initmsft.ora .

Edit the parameter file to include the new controlfile location:

vi $ORACLE_HOME/dbs/initmsft.ora
control_files=’+DATA2’,’+DATA2’


Restore the password file on the standby db:

[oracle@collabn2 admin]$ cd $ORACLE_HOME/dbs
[oracle@collabn2 dbs]$ cp /media/sf_stage/backup/orapworcl orapwmsft
[oracle@collabn2 dbs]$

Copy the backup files onto the local storage to NFS errors:

like
WARNING:NFS file system /media/sf_stage mounted with incorrect options(rw,nodev,relatime)
WARNING:Expected NFS mount options: rsize>=32768,wsize>=32768,hard,
or
If you are not using the NFS then you can catalog the files and start the restore:


[oracle@collabn2 ~]$ cd sshaik
[oracle@collabn2 sshaik]$ mkdir backup
[oracle@collabn2 sshaik]$ cd backup/
[oracle@collabn2 backup]$ cp /media/sf_stage/backup/*.bak .
[oracle@collabn2 backup]$ pwd
/home/oracle/sshaik/backup

[oracle@collabn2 backup]$ ls -lrt
total 1505976
-rwxr-x--- 1 oracle oinstall   93743104 Aug 22 15:35 orcl_12qf86fn_1_1.bak
-rwxr-x--- 1 oracle oinstall 1448353792 Aug 22 15:35 orcl_13qf86fo_1_1.bak
-rwxr-x--- 1 oracle oinstall      14336 Aug 22 15:35 orcl_14qf86fv_1_1.bak


Make sure you are able to startup the database in nomount state

[oracle@collabn2 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Sat Aug 22 14:49:32 2015

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

Connected to an idle instance.

SQL> startup nomount;
ORACLE instance started.

Total System Global Area  430075904 bytes
Fixed Size           2214056 bytes
Variable Size         289408856 bytes
Database Buffers      134217728 bytes
Redo Buffers           4235264 bytes


SQL> shut immediate;
ORA-01507: database not mounted


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

Mount the database:


[oracle@collabn2 dbs]$ rman

Recovery Manager: Release 11.2.0.1.0 - Production on Sat Aug 22 15:29:29 2015

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

RMAN> connect target /

connected to target database (not started)

RMAN> startup nomount;

Oracle instance started

Total System Global Area     430075904 bytes

Fixed Size                     2214056 bytes
Variable Size                289408856 bytes
Database Buffers             134217728 bytes
Redo Buffers                   4235264 bytes

Restore controlfile:


RMAN> restore standby controlfile from '/home/oracle/sshaik/backup/orclcontrol.ctl';

Starting restore at 22-AUG-15
using channel ORA_DISK_1

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=+DATA2/msft/controlfile/current.326.888421771
output file name=+DATA2/msft/controlfile/current.313.888421771
Finished restore at 22-AUG-15

RMAN>

Mount the database:
RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

RMAN>


Catlog the backup files if you copied the backup to a different location from the source Host.

RMAN> catalog start with '/media/sf_stage/backup';

Starting implicit crosscheck backup at 22-AUG-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=30 device type=DISK
Crosschecked 27 objects
Finished implicit crosscheck backup at 22-AUG-15

Starting implicit crosscheck copy at 22-AUG-15
using channel ORA_DISK_1
Finished implicit crosscheck copy at 22-AUG-15

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

searching for all files that match the pattern /media/sf_stage/backup

List of Files Unknown to the Database
=====================================
File Name: /media/sf_stage/backup/initmsft.ora
File Name: /media/sf_stage/backup/orapworcl
File Name: /media/sf_stage/backup/orcl_12qf86fn_1_1.bak
File Name: /media/sf_stage/backup/orcl_13qf86fo_1_1.bak
File Name: /media/sf_stage/backup/orcl_14qf86fv_1_1.bak
File Name: /media/sf_stage/backup/orclcontrol.ctl

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

Restore the database:
RMAN> restore database;

Starting restore at 22-AUG-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=35 device type=DISK

skipping datafile 6; already restored to file +DATA/orcl/datafile/hr_test.291.887468169
skipping datafile 7; already restored to file +DATA2/msft/datafile/tt_temp_sales.319.887131035
skipping datafile 8; already restored to file +DATA2/msft/datafile/tbs1.371.887724323
skipping datafile 9; already restored to file +DATA2/msft/datafile/tbs2.373.887725645
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 +DATA2/msft/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to +DATA2/msft/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to +DATA2/msft/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to +DATA2/msft/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to +DATA2/msft/example01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/sshaik/backup/orcl_13qf86fo_1_1.bak
channel ORA_DISK_1: piece handle=/home/oracle/sshaik/backup/orcl_13qf86fo_1_1.bak tag=BUILD_STANDBY
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 22-AUG-15


Verify the standby database and log shipping:

[oracle@collabn2 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Sat Aug 22 15:57:48 2015

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


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

SQL> select name,open_mode,database_role from v$database;

NAME      OPEN_MODE           DATABASE_ROLE
--------- -------------------- ----------------
ORCL      MOUNTED           PHYSICAL STANDBY

Start the recovery on the standby

SQL> alter database recover managed standby database disconnect from session;

Database altered.

On Primary switch the current log file:

SQL> select name,open_mode,database_role from v$database;

NAME      OPEN_MODE           DATABASE_ROLE
--------- -------------------- ----------------
ORCL      READ WRITE           PRIMARY

SQL> archive log list;
Database log mode           Archive Mode
Automatic archival           Enabled
Archive destination           +DATA2
Oldest online log sequence     7
Next log sequence to archive   9
Current log sequence           9


SQL> alter system archive log current;

System altered.

SQL> archive log list;
Database log mode           Archive Mode
Automatic archival           Enabled
Archive destination           +DATA2
Oldest online log sequence     9
Next log sequence to archive   11
Current log sequence           11
SQL>


Verify the new log arrived safely and applied on standby:

SQL> select name,open_mode,database_role from v$database;

NAME      OPEN_MODE           DATABASE_ROLE
--------- -------------------- ----------------
ORCL      MOUNTED           PHYSICAL STANDBY

SQL> select process,sequence#,status from V$MANAGED_STANDBY;

SQL> /

PROCESS    SEQUENCE# STATUS
--------- ---------- ------------
ARCH           0 CONNECTED
ARCH           0 CONNECTED
ARCH           0 CONNECTED
ARCH           0 CONNECTED
MRP0           8 WAIT_FOR_GAP
RFS           0 IDLE
RFS         11 IDLE
RFS           0 IDLE

8 rows selected.

SQL> /

PROCESS    SEQUENCE# STATUS
--------- ---------- ------------
ARCH           0 CONNECTED
ARCH           0 CONNECTED
ARCH           0 CONNECTED
ARCH           0 CONNECTED
MRP0         11 WAIT_FOR_LOG
RFS           0 IDLE
RFS         11 IDLE
RFS           0 IDLE

8 rows selected.

Logs are shipped and applied successfully at the destination standby database.

No comments: