You are on page 1of 175

Obeth, Sadock Nyaluke

My own blog in IT Systems


Administration: Together We Learn!!!
Classic

Home

Oracle DB

SQL Server DB

Oracle 12c DB

Heterogeneous Services

My Resume

1.
FEB

Using RMAN Backups to Perform Disaster Recovery Following Server


or Storage Crush beyond Repair
Disaster implies the loss of the entire target database, the recovery catalog database, and all current
control files, all online redo log files, and all parameter files following server or storage crush beyond
repair
At minimum to successful perform a disaster recovery, you must have the following
Backups
of
all
datafiles
Corresponding
archived
redo
logs
files
At
least
one
control
file
autobackup
A record of the DBID of the database
Assumption: This scenario assumes that the Linux server on which your database was running has
been damaged beyond repair. Fortunately, you have necessary backups to restore your database.
The
scenario
assumes
the
following:
Oracle
Database
Software
is
already
installed
on
the
new
host
The
new
Linux
host
has
different
directory
structure
as
the
old
host
You are not using recovery catalog with the database

How to Go About
Get DBID of the Database
Restoring SPFILE from Autobackups
Edit the Restored SPFILE
Restoring ControlFile from Autobackups
Catalog Backup Files
Get the Structure of Datafiles and Redo Log
Prepare and Execute the Restoration Script
Recover the Database Instance
Open the Database with RESETLOGS Option

Get DBID of the Database

You must set DBID prior to execute the command to restore the SPFILE and ControlFile from
autobackups. It is the best practice to keep in the safe place a record of DBID of your database.
Alternatively if you have autobackup of control file created with substitution variable %F in
the FORMAT clause you can find the DBID of the database. The variable %F is translated into cIIIIIIIIII-YYYYMMDD-QQ where
IIIIIIII is the DBID
YYYYMMDD is a time stamp of the day the backup is generated

QQ is the hex sequence that starts with 00 and has a maximum of FF


Example: The DBID in these control file autobackup is 132566208
[oracle@Lugao-srv03 OraBkps]$ ls
backupset pcbdbcf_c-132566208-20150202-07
old
pcbdbcf_c-132566208-20150202-09
[oracle@Lugao-srv03 OraBkps]$

Restoring SPFILE from Autobackups


To restore the SPFILE from Autobackups, set ORACLE_SID environmental variable, start RMAN by
connecting to the target database, set the DBID of the database then start the database instance in
nomount state using dummy parameter file
[oracle@Lugao-srv03 ~]$ export ORACLE_SID=PCBDB
[oracle@Lugao-srv03 ~]$ rman target/
Recovery Manager: Release 11.2.0.1.0 - Production on Mon Feb 2 19:38:57 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database (not started)
RMAN> set dbid 132566208;
executing command: SET DBID
RMAN> startup nomount;
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file
'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initPCBDB.ora'
starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started
Total System Global Area
Fixed Size
Variable Size
Database Buffers
Redo Buffers

159019008 bytes

1335192 bytes
75497576 bytes
79691776 bytes
2494464 bytes

Set RMAN CONTROLFILE AUTOBACKUP FORMAT parameter to the format mode used during
control file auto backup before you run RESTORE SPFILE FROM AUTOBACKUP command. It
important you have kept these RMAN information in safe place as part of your backup and recovery
strategy for the smooth disaster recover.
RMAN> SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO
'/u01/OraBkps/pcbdbcf_%F';

executing command: SET CONTROLFILE AUTOBACKUP FORMAT


RMAN> RESTORE SPFILE FROM AUTOBACKUP;
Starting restore at 02-FEB-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20150202
channel ORA_DISK_1: AUTOBACKUP found: /u01/OraBkps/pcbdbcf_c-132566208-2015020209
channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/OraBkps/pcbdbcf_c132566208-20150202-09
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 02-FEB-15

Edit the Restored SPFILE

After restoration of SPFILE from autobackup you need to edit some setting to reflect the new
environment because it possible that the structure of the new server is not the same as the old
server. So shutdown the nomounted database instance then export the binary SPFILE settings to
text PFILE as follows
RMAN> shutdown immediate;
Oracle instance shut down
RMAN>
[oracle@Lugao-srv03 OraBkps]$ export ORACLE_SID=PCBDB
[oracle@Lugao-srv03 OraBkps]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Mon Feb 2 19:41:30 2015
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
SQL> create pfile='/home/oracle/initPDBDB.ora' from spfile;
File created.

Edit the text PFILE similar to the following


PCBDB.__db_cache_size=310378496
PCBDB.__java_pool_size=4194304
PCBDB.__large_pool_size=4194304
PCBDB.__oracle_base='/u01/app/oracle'
PCBDB.__pga_aggregate_target=297795584
PCBDB.__sga_target=553648128
PCBDB.__shared_io_pool_size=0

PCBDB.__shared_pool_size=226492416
PCBDB.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/PCBDB/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u01/PCBDB/log/control01.ctl','/u02/PCBDB/log/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='PCBDB'
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=4039114752
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=PCBDBXDB)'
*.log_archive_format='%t_%s_%r.dbf'
*.memory_target=848297984
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'

Create the missing file system on the new server, export back the PFILE settings to SPFILE then
start the database instance in nomount state
[oracle@Lugao-srv03 OraBkps]$ mkdir -p /u01/app/oracle/admin/PCBDB/adump
[oracle@Lugao-srv03 OraBkps]$ mkdir -p /u01/PCBDB/log
[oracle@Lugao-srv03 OraBkps]$ mkdir -p /u02/PCBDB/log
[oracle@Lugao-srv03 OraBkps]$ mkdir -p /u01/app/oracle/flash_recovery_area
[oracle@Lugao-srv03 OraBkps]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Mon Feb 2 19:41:30 2015
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
SQL> create spfile from pfile='/home/oracle/initPDBDB.ora';
File created.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 849530880 bytes
Fixed Size
1339824 bytes
Variable Size
499125840 bytes
Database Buffers
343932928 bytes
Redo Buffers
5132288 bytes

Restoring ControlFile from Autobackups


To restore the control file from autobackup set ORACLE_SID environmental variable, start the RMAN
by connecting to the target, set the DBID of the database, Set CONTROLFILE AUTOBACKUP

FORMAT parameter to the format mode used during control file autobackup then execute RESTORE
CONTROLFILE FROM AUTOBACKUP command as follows
[oracle@Lugao-srv03 ~]$ export ORACLE_SID=PCBDB
[oracle@Lugao-srv03 ~]$ rman target/
Recovery Manager: Release 11.2.0.1.0 - Production on Mon Feb 2 20:02:37 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: PCBDB (not mounted)
RMAN> set dbid 132566208;
executing command: SET DBID
RMAN> SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO
'/u01/OraBkps/pcbdbcf_%F';
executing command: SET CONTROLFILE AUTOBACKUP FORMAT
RMAN> RESTORE CONTROLFILE FROM AUTOBACKUP;
Starting restore at 02-FEB-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK
recovery area destination: /u01/app/oracle/flash_recovery_area
database name (or database unique name) used for search: PCBDB
channel ORA_DISK_1: no AUTOBACKUPS found in the recovery area
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20150202
channel ORA_DISK_1: AUTOBACKUP found: /u01/OraBkps/pcbdbcf_c-132566208-2015020209
channel ORA_DISK_1: restoring control file from AUTOBACKUP /u01/OraBkps/pcbdbcf_c132566208-20150202-09
channel ORA_DISK_1: control file restore from AUTOBACKUP complete
output file name=/u01/PCBDB/log/control01.ctl
output file name=/u02/PCBDB/log/control02.ctl
Finished restore at 02-FEB-15

Catalog Backup Files

It is possible that the backup files on new server are accessible through the location not yet known to
the restored control file thus you may need to catalog them. So mount the database instance then
execute the CATALOG command as follows
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN> catalog start with '/u01/OraBkps/backupset';

searching for all files that match the pattern /u01/OraBkps/backupset


List of Files Unknown to the Database
=====================================
File Name:
/u01/OraBkps/backupset/2015_02_02/o1_mf_annnn_TAG20150202T184845_bdz72xn8_.bkp
File Name:
/u01/OraBkps/backupset/2015_02_02/o1_mf_nnndf_TAG20150202T135041_bdyon1nd_.bkp
File Name:
/u01/OraBkps/backupset/2015_02_02/o1_mf_nnndf_TAG20150202T140537_bdypj1mr_.bkp
File Name:
/u01/OraBkps/backupset/2015_02_02/o1_mf_annnn_TAG20150202T121514_bdyj1309_.bkp
File Name:
/u01/OraBkps/backupset/2015_02_02/o1_mf_nnndf_TAG20150202T141356_bdypznr9_.bkp
File Name:
/u01/OraBkps/backupset/2015_02_02/o1_mf_annnn_TAG20150202T184845_bdz730t8_.bkp
File Name:
/u01/OraBkps/backupset/2015_02_02/o1_mf_annnn_TAG20150202T185026_bdz762gs_.bkp
File Name:
/u01/OraBkps/backupset/2015_02_02/o1_mf_nnndf_TAG20150202T184849_bdz73240_.bkp
File Name:
/u01/OraBkps/backupset/2015_02_02/o1_mf_annnn_TAG20150202T114402_bdyg6lfx_.bkp
File Name:
/u01/OraBkps/backupset/2015_02_02/o1_mf_nnndf_TAG20150202T121349_bdyhyffm_.bkp
File Name:
/u01/OraBkps/backupset/2015_02_02/o1_mf_annnn_TAG20150202T121347_bdyhycwx_.bkp
Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name:
/u01/OraBkps/backupset/2015_02_02/o1_mf_annnn_TAG20150202T184845_bdz72xn8_.bkp
File Name:
/u01/OraBkps/backupset/2015_02_02/o1_mf_nnndf_TAG20150202T135041_bdyon1nd_.bkp
File Name:
/u01/OraBkps/backupset/2015_02_02/o1_mf_nnndf_TAG20150202T140537_bdypj1mr_.bkp
File Name:
/u01/OraBkps/backupset/2015_02_02/o1_mf_annnn_TAG20150202T121514_bdyj1309_.bkp
File Name:
/u01/OraBkps/backupset/2015_02_02/o1_mf_nnndf_TAG20150202T141356_bdypznr9_.bkp
File Name:
/u01/OraBkps/backupset/2015_02_02/o1_mf_annnn_TAG20150202T184845_bdz730t8_.bkp
File Name:
/u01/OraBkps/backupset/2015_02_02/o1_mf_annnn_TAG20150202T185026_bdz762gs_.bkp
File Name:
/u01/OraBkps/backupset/2015_02_02/o1_mf_nnndf_TAG20150202T184849_bdz73240_.bkp
File Name:
/u01/OraBkps/backupset/2015_02_02/o1_mf_annnn_TAG20150202T114402_bdyg6lfx_.bkp
File Name:
/u01/OraBkps/backupset/2015_02_02/o1_mf_nnndf_TAG20150202T121349_bdyhyffm_.bkp

File Name:
/u01/OraBkps/backupset/2015_02_02/o1_mf_annnn_TAG20150202T121347_bdyhycwx_.bkp

Get the Structure of Datafiles and Redo Log


It is possible that the directory structure of new server is not the same as the old server. Query the
metadata of restored control file though V$DATAFILE view to get the structure of datafile and redo
log of the old server as follows
SQL> COLUMN name FORMAT A47
SQL> select file#, name from v$datafile;
FILE# NAME
---------- ----------------------------------------------1 /u01/app/oracle/oradata/PCBDB/system01.dbf
2 /u01/app/oracle/oradata/PCBDB/sysaux01.dbf
3 /u01/app/oracle/oradata/PCBDB/undotbs01.dbf
4 /u02/app/oracle/oradata/PCBDB/users01.dbf
5 /u02/app/oracle/oradata/PCBDB/example01.dbf
6 /u01/app/oracle/oradata/PCBDB/DEV_odi_user.dbf
6 rows selected.
SQL> select member from v$logfile;
MEMBER
-------------------------------------------------------------------------------/u01/app/oracle/oradata/PCBDB/redo02.log
/u01/app/oracle/oradata/PCBDB/redo01.log
/u01/app/oracle/oradata/PCBDB/redo03.log

Prepare and Execute the Restoration Script

Prepare the RMAN script that include the following parameters SET NEWNAME, SQL ALTER
DATABASE RENAME FILE and SWITCH DATAFILE similar to the following
RUN {
SET NEWNAME FOR DATAFILE 1 TO '/u01/PCBDB/dbs/system01.dbf';
SET NEWNAME FOR DATAFILE 2 TO '/u01/PCBDB/dbs/sysaux01.dbf';
SET NEWNAME FOR DATAFILE 3 TO '/u01/PCBDB/dbs/undotbs01.dbf';
SET NEWNAME FOR DATAFILE 4 TO '/u01/PCBDB/dbs/users01.dbf';
SET NEWNAME FOR DATAFILE 5 TO '/u01/PCBDB/dbs/example01.dbf';
SET NEWNAME FOR DATAFILE 6 TO '/u01/PCBDB/dbs/DEV_odi_user.dbf';
SQL "ALTER DATABASE RENAME FILE ''/u01/app/oracle/oradata/PCBDB/redo02.log'' TO
''/u02/PCBDB/log/redo02.log''";
SQL "ALTER DATABASE RENAME FILE ''/u01/app/oracle/oradata/PCBDB/redo01.log'' TO
''/u01/PCBDB/log/redo01.log''";
SQL "ALTER DATABASE RENAME FILE ''/u01/app/oracle/oradata/PCBDB/redo03.log'' TO
''/u02/PCBDB/log/redo03.log''";
RESTORE DATABASE;
SWITCH DATAFILE ALL;
}
Finally execute the script as follows

RMAN> @restore
RMAN> RUN {
2> SET NEWNAME FOR DATAFILE 1 TO '/u01/PCBDB/dbs/system01.dbf';
3> SET NEWNAME FOR DATAFILE 2 TO '/u01/PCBDB/dbs/sysaux01.dbf';
4> SET NEWNAME FOR DATAFILE 3 TO '/u01/PCBDB/dbs/undotbs01.dbf';
5> SET NEWNAME FOR DATAFILE 4 TO '/u01/PCBDB/dbs/users01.dbf';
6> SET NEWNAME FOR DATAFILE 5 TO '/u01/PCBDB/dbs/example01.dbf';
7> SET NEWNAME FOR DATAFILE 6 TO '/u01/PCBDB/dbs/DEV_odi_user.dbf';
8> SQL "ALTER DATABASE RENAME FILE ''/u01/app/oracle/oradata/PCBDB/redo02.log'' TO
''/u02/PCBDB/log/redo02.log''";
9> SQL "ALTER DATABASE RENAME FILE ''/u01/app/oracle/oradata/PCBDB/redo01.log'' TO
''/u01/PCBDB/log/redo01.log''";
10> SQL "ALTER DATABASE RENAME FILE ''/u01/app/oracle/oradata/PCBDB/redo03.log'' TO
''/u02/PCBDB/log/redo03.log''";
11> RESTORE DATABASE;
12> SWITCH DATAFILE ALL;
13> }
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
sql statement: ALTER DATABASE RENAME FILE ''/u01/app/oracle/oradata/PCBDB/redo02.log''
TO ''/u02/PCBDB/log/redo02.log''
sql statement: ALTER DATABASE RENAME FILE ''/u01/app/oracle/oradata/PCBDB/redo01.log''
TO ''/u01/PCBDB/log/redo01.log''
sql statement: ALTER DATABASE RENAME FILE ''/u01/app/oracle/oradata/PCBDB/redo03.log''
TO ''/u02/PCBDB/log/redo03.log''
Starting restore at 02-FEB-15
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 /u01/PCBDB/dbs/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/PCBDB/dbs/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/PCBDB/dbs/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/PCBDB/dbs/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/PCBDB/dbs/example01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /u01/PCBDB/dbs/DEV_odi_user.dbf
channel ORA_DISK_1: reading from backup piece
/u01/OraBkps/backupset/2015_02_02/o1_mf_nnndf_TAG20150202T184849_bdz73240_.bkp

channel ORA_DISK_1: piece


handle=/u01/OraBkps/backupset/2015_02_02/o1_mf_nnndf_TAG20150202T184849_bdz7324
0_.bkp tag=TAG20150202T184849
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:25
Finished restore at 02-FEB-15
datafile 1 switched to datafile copy
input datafile copy RECID=7 STAMP=870648471 file name=/u01/PCBDB/dbs/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=8 STAMP=870648471 file name=/u01/PCBDB/dbs/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=9 STAMP=870648471 file name=/u01/PCBDB/dbs/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=10 STAMP=870648471 file name=/u01/PCBDB/dbs/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=11 STAMP=870648471 file
name=/u01/PCBDB/dbs/example01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=12 STAMP=870648471 file
name=/u01/PCBDB/dbs/DEV_odi_user.dbf
RMAN> **end-of-file**

Recover the Database Instance


After successful restoration of all data files recover your database instance. It may fail at some point
but dont panic it is likely that following the server or storage crush you may not have all archive logs
RMAN> RECOVER DATABASE;
Starting recover at 02-FEB-15
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=2
channel ORA_DISK_1: reading from backup piece
/u01/OraBkps/backupset/2015_02_02/o1_mf_annnn_TAG20150202T185026_bdz762gs_.bkp
channel ORA_DISK_1: piece
handle=/u01/OraBkps/backupset/2015_02_02/o1_mf_annnn_TAG20150202T185026_bdz762
gs_.bkp tag=TAG20150202T185026
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file
name=/u01/app/oracle/flash_recovery_area/PCBDB/archivelog/2015_02_02/o1_mf_1_2_bdzoc
629_.arc thread=1 sequence=2
channel default: deleting archived log(s)
archived log file
name=/u01/app/oracle/flash_recovery_area/PCBDB/archivelog/2015_02_02/o1_mf_1_2_bdzoc
629_.arc RECID=56 STAMP=870648726
unable to find archived log
archived log thread=1 sequence=3

RMAN-00571:
=======================================================
====
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS
===============
RMAN-00571:
=======================================================
====
RMAN-03002: failure of recover command at 02/02/2015 22:52:07
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 3
and starting SCN of 1605785

Open the Database with RESETLOGS Option

After recovering your database instance, you can open it. You must specify RESETLOGS because
the new control file represents a different instantiation of the database
RMAN> ALTER DATABASE OPEN RESETLOGS;
database opened

References
Oracle Database Backup and Recovery User's Guide11g Release 2 (11.2)
Posted 3rd February by Sadock Obeth
0

Add a comment

2.
FEB

Using RMAN ControlFile Autobackup Feature to Recover from Loss of


All Control files and/or SPFILE
Having recent backups of your Control file and Server Parameter File (SPFILE) is extremely valuable
in many recovery situations. However to increase the possibility that you will have such backups,
Oracle database supports control file and server parameter file autobackups.
RMAN will automatically backs up the control file and the SPFILE at the end of any
successful BACKUP command only when the CONFIGURE CONTROLFILE AUTOBACKUP is set to ON,
and if the database runs in ARCHIVELOG mode, RMAN makes control file autobackups when a
structural change to the database affects the contents of the control file

To check the current control file autobackups setting execute the following command
RMAN> SHOW CONTROLFILE AUTOBACKUP;
RMAN configuration parameters for database with db_unique_name PCBDB are:
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
To enable the control file autobackups feature execute the following command
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored
RMAN> SHOW CONTROLFILE AUTOBACKUP;
RMAN configuration parameters for database with db_unique_name PCBDB are:
CONFIGURE CONTROLFILE AUTOBACKUP ON;

Configuring the Control File Autobackup Format


By default, the format of the autobackup file for all configured devices is the substitution
variable %F in the FORMATclause
RMAN> SHOW CONTROLFILE AUTOBACKUP FORMAT;
RMAN configuration parameters for database with db_unique_name PCBDB are:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; #
default
To change the default format execute the following command and confirm the setting as follows:
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO
'/u01/app/oracle/Backups/cf_%F';
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO
'/u01/app/oracle/Backups/cf_%F';
new RMAN configuration parameters are successfully stored
RMAN> SHOW CONTROLFILE AUTOBACKUP FORMAT;
RMAN configuration parameters for database with db_unique_name PCBDB are:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO
'/u01/app/oracle/Backups/cf_%F';

Control file and SPFIL Autobackup

The following example shows how RMAN perform autobackup of control file and SPFILE at the end
of any successful BACKUP command. The command backup only data file number 1 for simplicity.
Notice the location of autobackup
RMAN> backup datafile 1;
Starting backup at 02-FEB-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=35 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=/u01/app/oracle/oradata/PCBDB/system01.dbf
channel ORA_DISK_1: starting piece 1 at 02-FEB-15
channel ORA_DISK_1: finished piece 1 at 02-FEB-15
piece
handle=/u01/app/oracle/flash_recovery_area/PCBDB/backupset/2015_02_02/o1_mf_nnn
df_TAG20150202T135041_bdyon1nd_.bkp tag=TAG20150202T135041 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:36
Finished backup at 02-FEB-15
Starting Control File and SPFILE Autobackup at 02-FEB-15
piece handle=/u01/app/oracle/Backups/cf_c-132566208-20150202-05 comment=NONE
Finished Control File and SPFILE Autobackup at 02-FEB-15

Overriding the Configured Control File Autobackup Format


The SET CONTROLFILE AUTOBACKUP FORMAT command, specified either within a RUN command
or at the RMANprompt, overrides the configured autobackup format in the current session however all
autobackup formats must include the %F variable. The order of precedence is as follows:
SET CONTROLFILE AUTOBACKUP FORMAT (within a RUN block)
SET CONTROLFILE AUTOBACKUP FORMAT (at RMAN prompt)
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT
The following example shows how RMAN perform autobackup of control file and SPFILE at the end
of any successful BACKUP command when SET CONTROLFILE AUTOBACKUP FORMAT command
is used at RMAN prompt
RMAN> SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO
'/u02/Backups/pcbdbcf_%F';
executing command: SET CONTROLFILE AUTOBACKUP FORMAT
RMAN> backup datafile 2;
Starting backup at 02-FEB-15
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00002 name=/u01/app/oracle/oradata/PCBDB/sysaux01.dbf
channel ORA_DISK_1: starting piece 1 at 02-FEB-15
channel ORA_DISK_1: finished piece 1 at 02-FEB-15

piece
handle=/u01/app/oracle/flash_recovery_area/PCBDB/backupset/2015_02_02/o1_mf_nnn
df_TAG20150202T140537_bdypj1mr_.bkp tag=TAG20150202T140537 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
Finished backup at 02-FEB-15
Starting Control File and SPFILE Autobackup at 02-FEB-15
piece handle=/u02/Backups/pcbdbcf_c-132566208-20150202-06 comment=NONE
Finished Control File and SPFILE Autobackup at 02-FEB-15
The following example shows how RMAN perform autobackup of control file and SPFILE at the end
of any successful BACKUP command when SET CONTROLFILE AUTOBACKUP FORMAT command
is used within a RUN block
RMAN> run{
2> SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO
'/home/oracle/Backups/pcbdbcf_%F';
3> BACKUP DATAFILE 3;
4> }
executing command: SET CONTROLFILE AUTOBACKUP FORMAT
Starting backup at 02-FEB-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=29 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=00003 name=/u01/app/oracle/oradata/PCBDB/undotbs01.dbf
channel ORA_DISK_1: starting piece 1 at 02-FEB-15
channel ORA_DISK_1: finished piece 1 at 02-FEB-15
piece
handle=/u01/app/oracle/flash_recovery_area/PCBDB/backupset/2015_02_02/o1_mf_nnn
df_TAG20150202T141356_bdypznr9_.bkp tag=TAG20150202T141356 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 02-FEB-15
Starting Control File and SPFILE Autobackup at 02-FEB-15
piece handle=/home/oracle/Backups/pcbdbcf_c-132566208-20150202-07
comment=NONE
Finished Control File and SPFILE Autobackup at 02-FEB-15

Restoring SPFILE from Autobackup

If the SPFILE is lost, you can restore it from the autobackup. However you must to set the DBID for
your database before you issue RESTORE SPFILE FROM AUTOBACKUP command otherwise it will
fail. The challenge with DBID (database identifier) is that, it is not something that would be available
until the database is at least mounted

The best practice it is recommended to record the DBID in a safe place or otherwise you can find it
on control file autobackup output file when substitution variable %F in the FORMAT clause is used as
demonstrated above. This variable format translates into c-IIIIIIIIII-YYYYMMDD-QQ, with the
placeholders
defined
as
follows:
IIIIIIIIII stands
for
the
DBID
YYYYMMDD is
a
time
stamp
of
the
day
the
backup
is
generated
QQ is the hex sequence that starts with 00 and has a maximum of FF
Example:
Starting Control File and SPFILE Autobackup at 02-FEB-15
piece handle=/home/oracle/Backups/pcbdbcf_c-132566208-2015020207 comment=NONE
Finished Control File and SPFILE Autobackup at 02-FEB-15
The following example simulate the loss of SPFILE on disk by renaming the file and attempt to
restart the database instance
[oracle@Lugao-odisrv dbs]$ mv spfilePCBDB.ora spfilePCBDB.ora.old
[oracle@Lugao-odisrv dbs]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Mon Feb 2 14:31:07 2015
Copyright (c) 1982, 2009, 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> startup force
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file
'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initPCBDB.ora'
SQL>
The following example shows how to use RMAN to restore the lost SPFILE from autobackup
[oracle@Lugao-odisrv ~]$ export ORACLE_SID=PCBDB
[oracle@Lugao-odisrv ~]$ rman target/
Recovery Manager: Release 11.2.0.1.0 - Production on Mon Feb 2 15:17:08 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database (not started)
RMAN> set dbid 132566208;
executing command: SET DBID
RMAN> startup force nomount;

startup failed: ORA-01078: failure in processing system parameters


LRM-00109: could not open parameter file
'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initPCBDB.ora'
starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started
Total System Global Area
Fixed Size
Variable Size
Database Buffers
Redo Buffers

159019008 bytes

1335192 bytes
75497576 bytes
79691776 bytes
2494464 bytes

RMAN> SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO


'/home/oracle/Backups/pcbdbcf_%F';
executing command: SET CONTROLFILE AUTOBACKUP FORMAT
RMAN> RESTORE SPFILE FROM AUTOBACKUP;
Starting restore at 02-FEB-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20150202
channel ORA_DISK_1: AUTOBACKUP found: /home/oracle/Backups/pcbdbcf_c132566208-20150202-07
channel ORA_DISK_1: restoring spfile from AUTOBACKUP
/home/oracle/Backups/pcbdbcf_c-132566208-20150202-07
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 02-FEB-15
Restart the database instance
RMAN> startup force
Oracle instance started
Database mounted
Database opened
Total System Global Area
Fixed Size
Variable Size
Database Buffers
Redo Buffers

849530880 bytes

1339824 bytes
532680272 bytes
310378496 bytes
5132288 bytes

Restoring Control file from Autobackup

The procedure to restore control file from autobackup is similar to restoring the SPFILE from
autobackup except that you should successful start the database instance to nomount state using
your SPFILE or PFILE.
The following example simulate the loss of all control files by deleting all control files on file system
and attempt to restart the database instance
SQL> select name from v$controlfile;
NAME
-------------------------------------------------------------------------------/u01/app/oracle/oradata/PCBDB/control01.ctl
/u01/app/oracle/flash_recovery_area/PCBDB/control02.ctl
[oracle@Lugao-odisrv ~]$ rm /u01/app/oracle/oradata/PCBDB/control01.ctl
[oracle@Lugao-odisrv ~]$ rm /u01/app/oracle/flash_recovery_area/PCBDB/control02.ctl
[oracle@Lugao-odisrv ~]$
SQL> startup force
ORACLE instance started.
Total System Global Area 849530880 bytes
Fixed Size
1339824 bytes
Variable Size
532680272 bytes
Database Buffers
310378496 bytes
Redo Buffers
5132288 bytes
ORA-00205: error in identifying control file, check alert log for more info

The following example shows how to use RMAN to restore the lost control files from autobackup
[oracle@Lugao-odisrv ~]$ export ORACLE_SID=PCBDB
[oracle@Lugao-odisrv ~]$ rman target/
Recovery Manager: Release 11.2.0.1.0 - Production on Mon Feb 2 16:35:21 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: PCBDB (not mounted)
RMAN> set dbid 132566208;
executing command: SET DBID
RMAN> SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO
'/home/oracle/Backups/pcbdbcf_%F';
executing command: SET CONTROLFILE AUTOBACKUP FORMAT
RMAN> RESTORE CONTROLFILE FROM AUTOBACKUP;
Starting restore at 02-FEB-15

using target database control file instead of recovery catalog


allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK
recovery area destination: /u01/app/oracle/flash_recovery_area
database name (or database unique name) used for search: PCBDB
channel ORA_DISK_1: AUTOBACKUP
/u01/app/oracle/flash_recovery_area/PCBDB/autobackup/2015_02_02/o1_mf_s_870610516_b
dyj157p_.bkp found in the recovery area
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20150202
channel ORA_DISK_1: AUTOBACKUP found: /home/oracle/Backups/pcbdbcf_c-13256620820150202-07
channel ORA_DISK_1: restoring control file from AUTOBACKUP
/home/oracle/Backups/pcbdbcf_c-132566208-20150202-07
channel ORA_DISK_1: control file restore from AUTOBACKUP complete
output file name=/u01/app/oracle/oradata/PCBDB/control01.ctl
output file name=/u01/app/oracle/flash_recovery_area/PCBDB/control02.ctl
Finished restore at 02-FEB-15

Mount the database instance then perform recovery because you now have a backup control file that
contains information about an older version of the database
RMAN> ALTER DATABASE MOUNT;
database mounted
released channel: ORA_DISK_1
RMAN> RECOVER DATABASE;
Starting recover at 02-FEB-15
Starting implicit crosscheck backup at 02-FEB-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=21 device type=DISK
Crosschecked 12 objects
Finished implicit crosscheck backup at 02-FEB-15
Starting implicit crosscheck copy at 02-FEB-15
using channel ORA_DISK_1
Finished implicit crosscheck copy at 02-FEB-15
searching for all files in the recovery area
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name:
/u01/app/oracle/flash_recovery_area/PCBDB/archivelog/2015_02_02/o1_mf_1_8_bdywxmws_.
arc
using channel ORA_DISK_1
starting media recovery

archived log for thread 1 with sequence 8 is already on disk as file


/u01/app/oracle/flash_recovery_area/PCBDB/archivelog/2015_02_02/o1_mf_1_8_bdywxmws_.
arc
archived log for thread 1 with sequence 9 is already on disk as file
/u01/app/oracle/oradata/PCBDB/redo03.log
archived log file
name=/u01/app/oracle/flash_recovery_area/PCBDB/archivelog/2015_02_02/o1_mf_1_8_bdyw
xmws_.arc thread=1 sequence=8
archived log file name=/u01/app/oracle/oradata/PCBDB/redo03.log thread=1 sequence=9
media recovery complete, elapsed time: 00:00:01
Finished recover at 02-FEB-15

After recovering the database, you can open it. You must specify RESETLOGS because the new
control file represents a different instantiation of the database
RMAN> ALTER DATABASE OPEN RESETLOGS;
database opened

Following RESETLOGS command you need immediate to full back up your database because
among other RESETLOGS option invalidate the old backups

References
Oracle Database Backup and Recovery User's Guide11g Release 2 (11.2)
Posted 2nd February by Sadock Obeth
0

Add a comment

3.
JAN

Using Virtual Disks as Shared Storage to Install and Configure Oracle


Database 11gR2 Real Application Cluster (RAC)
One of the major challenge to configure Oracle Real Application Cluster (RAC) for just testing and
training purpose is the requirement of dedicated shared storage such as SAN (expensive). However
you can use a least cost way to simulate testing and learning environment by using Virtual Machine
software such Oracle Virtualbox to create virtual disks and attach/share to all nodes (virtual
machines) wants to participate in cluster to simulate shared storage requirement of RAC

Steps to Go About

Network Setup

Create, Attach and Share Virtual Disks


Create Disks Partitions
Oracle Software Pre-Installation Tasks
Install and Configure Oracle ASM Packages
Install and Configure Oracle Clusterware
Install Oracle Real Application (RAC) Software
Create ASM Diskgroups Using ASMCA
Create RAC Database Using DBCA
Verification
Assumption: Two nodes partipating in this RAC installation are virtual machines with 2GB RAM
each running Red hat Enterprise Linux 5.8 64 bits on Window 7 host machine

Network Setup

One of the essential part prior to the installation and configuration of RAC is network setup in all
nodes participating in RAC. Oracle 11gR2 RAC needs four network names and associated IP
Addresses configurations to work:
Public Host Name (for each node) is the primary name of the host as displayed by
command hostname and should be associated to any public network interface card IP Address
Private Host Name (for each node) associated to the private network interface card IP Address and
should not be accessible by any device not participating in RAC private network should be on
dedicated switch
Virtual Public Host Name (for each node) not assigned to any network interface card, is used to
reroute client requests sent to the node if the node is down
SCAN DNS name not assigned to any network interface card and is resolved by DNS to at least
three IP Addresses using round robin algorithm
SCAN DSN provide a single name for client to access Oracle database in a cluster independent of
which server in the cluster the database is active and should not appear in /etc/hosts file.
Public Host Name, Virtual Host Name and SCAN DNS name must be on the same subnet that is
accessible on public network by other devices (e.g. clients)
Private Host Name need not to be on DNS and should be entered in the /etc/hosts file
Sample IP Address Setup

Host

Public IP

Private IP

VIP

Lugao-srv01.lusam.tz
Lugao-srv02.lusam.tz
Interface --->

192.168.56.40
192.168.56.41
etho

172.16.9.11
172.16.9.12
eth1

192.168.56.50
192.168.56.51

Sample Entries on DNS Server

SCAN: Lugaoracscan
IP1: 192.168.56.60
IP2: 192.168.56.61
IP3: 192.168.56.62

Regardless of using a DNS server it is recommended to add lines to the/etc/hosts file on each
node, for Public IP, VIP and Private IP addresses similar to the following:
#Public
192.168.56.40 Lugao-srv01.lusam.tz
Lugao-srv01
192.168.56.41 Lugao-srv02.lusam.tz
Lugao-srv02
#Private
172.16.9.11
172.16.9.11

Lgracnode1-priv.lusam.tz
Lgracnode2-priv.lusam.tz

Lgracnode1-priv
Lgracnode2-priv

#Virtual IP address
192.168.56.50 Lgracnode1-vip.lusam.tz
192.168.56.51 Lgracnode2-vip.lusam.tz

Lgracnode1-vip
Lgracnode2-vip

On all nodes change the name resolution search order in /etc/nsswitch.conf file by telling the
host to start looking the DNS server then methods follows. Search the following lines
#hosts:
db files nisplus nis dns
hosts:
files dns
Then change to:
#hosts:
db files nisplus nis dns
hosts:
dns files
After modifying the /etc/nsswitch.conf file, restart the nscd daemon on each node as follows
[root@Lugao-srv01 ~]# /sbin/service nscd restart
Stopping nscd:
[FAILED]
Starting nscd:
[ OK ]
[root@Lugao-srv01 ~]# /sbin/service nscd restart
Stopping nscd:
[ OK ]
Starting nscd:
[ OK ]
[root@Lugao-srv01 ~]#
Confirm SCAN configurations on DNS server is using round-robin name resolution algorithms by
using nslookupcommand. Run the nslookup command at least twice, the result should return a set
of 3 IPs in a different order in each run as follows
[root@Lugao-srv01 ~]# nslookup Lugaorac-scan
Server:
192.168.56.30
Address:
192.168.56.30#53
Name: Lugaorac-scan.lusam.tz
Address: 192.168.56.60
Name: Lugaorac-scan.lusam.tz
Address: 192.168.56.61
Name: Lugaorac-scan.lusam.tz
Address: 192.168.56.62
[root@Lugao-srv01 ~]#
[root@Lugao-srv01 ~]# nslookup Lugaorac-scan
Server:
192.168.56.30

Address:

192.168.56.30#53

Name: Lugaorac-scan.lusam.tz
Address: 192.168.56.61
Name: Lugaorac-scan.lusam.tz
Address: 192.168.56.62
Name: Lugaorac-scan.lusam.tz
Address: 192.168.56.60

Deconfigure NTP
Make sure NTP it is not configured so that Oracle Cluster Time Synchronization Service (ctssd)
can synchronize the times of the RAC nodes as follows
[root@Lugao-srv01 ~]# service ntpd status
ntpd is stopped
[root@Lugao-srv01 ~]# ls -lr /etc/ntp.conf
-rw-r--r-- 1 root root 1833 Oct 25 2011 /etc/ntp.conf
[root@Lugao-srv01 ~]#
[root@Lugao-srv01 ~]# mv /etc/ntp.conf /etc/ntp.conf.bkp

Create, Attach and Share Virtual Disks


The following RAC installation is done on virtual machines that access the shared virtual storage on
the host machine. Shut down all guest machines then execute the following commands from host
machine command prompt to create seven the shared disk
VBoxManage createhd --filename "D:\VMDSK\ASM\OCR_VOTE01.vdi" --size 1024 --format VDI --variant
Fixed
VBoxManage createhd --filename "D:\VMDSK\ASM\OCR_VOTE02.vdi" --size 1024 --format VDI --variant
Fixed
VBoxManage createhd --filename "D:\VMDSK\ASM\OCR_VOTE03.vdi" --size 1024 --format VDI --variant
Fixed
VBoxManage
Fixed
VBoxManage
Fixed
VBoxManage
Fixed
VBoxManage
Fixed

createhd --filename "D:\VMDSK\ASM\ASM_DATA01.vdi" --size 5120 --format VDI --variant


createhd --filename "D:\VMDSK\ASM\ASM_DATA02.vdi --size 5120 --format VDI --variant
createhd --filename "D:\VMDSK\ASM\ASM_FRA01.vdi" --size 5120 --format VDI --variant
createhd --filename "D:\VMDSK\ASM\ASM_FRA02.vdi" --size 5120 --format VDI --variant

Attach the created disks to the Virtual Machine:


VBoxManage storageattach RHEL5.8x86_64-SRV02 --storagectl "SATA" --port 1 --device 0 --type hdd
--medium "D:\VMDSK\ASM\OCR_VOTE01.vdi" --mtype shareable
VBoxManage storageattach RHEL5.8x86_64-SRV02 --storagectl "SATA" --port 2 --device 0 --type hdd
--medium "D:\VMDSK\ASM\OCR_VOTE02.vdi" --mtype shareable
VBoxManage storageattach RHEL5.8x86_64-SRV02 --storagectl "SATA" --port 3 --device 0 --type hdd
--medium "D:\VMDSK\ASM\OCR_VOTE03.vdi" --mtype shareable

VBoxManage storageattach RHEL5.8x86_64-SRV02 --storagectl "SATA" --port 4 --device 0 --type hdd


--medium "D:\VMDSK\ASM\ASM_DATA01.vdi" --mtype shareable

VBoxManage storageattach RHEL5.8x86_64-SRV02 --storagectl "SATA" --port 5 --device 0 --type hdd


--medium "D:\VMDSK\ASM\ASM_DATA02.vdi" --mtype shareable
VBoxManage storageattach RHEL5.8x86_64-SRV02 --storagectl "SATA" --port 6 --device 0 --type hdd
--medium "D:\VMDSK\ASM\ASM_FRA01.vdi" --mtype shareable
VBoxManage storageattach RHEL5.8x86_64-SRV02 --storagectl "SATA" --port 7 --device 0 --type hdd
--medium "D:\VMDSK\ASM\ASM_FRA02.vdi" --mtype shareable

Make the disks sharable:

VBoxManage modifyhd "D:\VMDSK\ASM\OCR_VOTE01.vdi" --type shareable


VBoxManage modifyhd "D:\VMDSK\ASM\OCR_VOTE02.vdi" --type shareable
VBoxManage modifyhd "D:\VMDSK\ASM\OCR_VOTE03.vdi" --type shareable
VBoxManage modifyhd "D:\VMDSK\ASM\ASM_DATA01.vdi" --type shareable
VBoxManage modifyhd "D:\VMDSK\ASM\ASM_DATA02.vdi" --type shareable
VBoxManage modifyhd "D:\VMDSK\ASM\ASM_FRA01.vdi" --type shareable
VBoxManage modifyhd "D:\VMDSK\ASM\ASM_FRA01.vdi" --type shareable

Repeat the procedure to attach the disks on the second virtual machine then power on all virtual
machines to start the process of portioning the attached disks

Create Disks Partitions


As the user root, determine the partitions discovered using cat /proc/partitions command
as follows:
[root@Lugao-srv01 ~]# cat /proc/partitions
major minor #blocks name
3
3
3
3
8
8
8
8
8
8
8
253

0
1
2
3
0
16
32
48
64
80
96
0

36700160 hda
104391 hda1
4192965 hda2
32395072 hda3
1048576 sda
1048576 sdb
1048576 sdc
5242880 sdd
5242880 sde
5242880 sdf
5242880 sdg
32374784 dm-0

From one node only run fdisk against each disk not partitioned to create a single whole-disk
partition and the sequence of answers is "n", "p", "1", "Return", "Return", "p" and "w" as follows
[root@Lugao-srv01 ~]# fdisk /dev/sda
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w (rite)

Command (m for help): n


Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-130, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-130, default 130):
Using default value 130
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@Lugao-srv01 ~]#

Repeat the same for the remaining disks


[root@Lugao-srv01 ~]# fdisk /dev/sdb
[root@Lugao-srv01 ~]# fdisk /dev/sdd
[root@Lugao-srv01 ~]# fdisk /dev/sde
[root@Lugao-srv01 ~]# fdisk /dev/sdf
[root@Lugao-srv01 ~]# fdisk /dev/sdg
Use again cat /proc/partitions command to confirm partitions created on all nodes
partipating in cluster
[root@Lugao-srv01 ~]# cat /proc/partitions
major minor #blocks name
3
0 36700160 hda
3
1
104391 hda1
3
2 4192965 hda2
3
3 32395072 hda3
8
0 1048576 sda
8
1 1044193 sda1
8 16 1048576 sdb
8 17 1044193 sdb1
8 32 1048576 sdc
8 33 1044193 sdc1
8 48 5242880 sdd
8 49 5237158 sdd1
8 64 5242880 sde
8 65 5237158 sde1
8 80 5242880 sdf
8 81 5237158 sdf1
8 96 5242880 sdg
8 97 5237158 sdg1
253
0 32374784 dm-0
[root@Lugao-srv01 ~]#
[root@Lugao-srv02 ~]# cat /proc/partitions
major minor #blocks name

3
0 52428800 hda
3
1
104391 hda1
3
2 52323705 hda2
8
0 1048576 sda
8
1 1044193 sda1
8 16 1048576 sdb
8 17 1044193 sdb1
8 32 1048576 sdc
8 33 1044193 sdc1
8 48 5242880 sdd
8 49 5237158 sdd1
8 64 5242880 sde
8 65 5237158 sde1
8 80 5242880 sdf
8 81 5237158 sdf1
8 96 5242880 sdg
8 97 5237158 sdg1
253
0 46301184 dm-0
253
1 5996544 dm-1
[root@Lugao-srv02 ~]#

Oracle Software Pre-Installation Tasks

Software Requirements
On all nodes Use rpm command to install the following packages from Linux installation media
rpm -Uvh binutils-2.17.50.0.6*
rpm -Uvh compat-libstdc++-33*
rpm -Uvh elfutils-libelf-0*
rpm -Uvh elfutils-libelf-devel-*
rpm -Uvh gcc-4*
rpm -Uvh gcc-c++-4*
rpm -Uvh glibc-2*
rpm -Uvh glibc-common-2*
rpm -Uvh glibc-devel-2.*
rpm -Uvh glibc-headers*
rpm -Uvh ksh*
rpm -Uvh libaio-0*
rpm -Uvh libaio-devel-0*
rpm -Uvh libgcc-4*
rpm -Uvh libgomp*
rpm -Uvh libstdc++-4*
rpm -Uvh libstdc++-devel 4.*
rpm -Uvh make-3.*
rpm -Uvh numactl-devel-0.*
rpm -Uvh nutils-2.*
rpm -Uvh sysstat-7.*
rpm -Uvh unixODBC-2.*
rpm -Uvh unixODBC-devel-2.*
On all nodes use text editor of your choice, add the following lines in "/etc/sysctl.conf" file.
Include only the lines that have values greater than existing values in file
fs.suid_dumpable = 1

fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
# semaphores: semmsl, semmns, semopm, semmni
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default=4194304
net.core.rmem_max=4194304
net.core.wmem_default=262144
net.core.wmem_max=1048586

On all nodes Open shell prompt then run /sbin/sysctl p command to change the current
kernel parameters
[root@avsrv ~]# /sbin/sysctl -p
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 68719476736
kernel.shmall = 4294967296
fs.suid_dumpable = 1
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 4194304
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586
[root@avsrv ~]#
On
all
nodes
use
editor
of
in "/etc/security/limits.conf" file
oracle
soft nproc 2047
oracle
hard nproc 16384
oracle
soft nofile 4096
oracle
hard nofile 65536
oracle
soft stack 10240
grid
soft nproc 2047
grid
hard nproc 16384
grid
soft nofile 4096
grid
hard nofile 65536
grid
soft stack 10240

your

choice

to

add

the

following

On all nodes Use editor of your choice add the following line "/etc/pam.d/login" file
session
required
/lib/security/pam_limits.so

lines

session

required

pam_limits.so

Creating Operating System Groups and Users


Oracle recommend to use Job Role Separation privileges configuration with operating system groups
and users that divide administrative access privileges to the Oracle grid infrastructure installation
from other administrative privileges users and groups associated with other Oracle installations (e.g.
the Oracle Database software).
Administrative privileges access is granted by membership in separate operating system groups,
and installation privileges are granted by using different installation owners for each Oracle
installation typically "grid" for the Oracle grid infrastructure and "oracle" for the Database
software. However both Oracle software owners must have the Oracle Inventory group (oinstall)
as their primary group, so that each Oracle software installation owner can write to the central
inventory (oraInventory)
The following operating system groups and users needs to be created on all nodes that will
participating in Oracle RAC configurations:
Description
Oracle Inventory and Software Owner
Oracle ASM Group
ASM Database Administrator Group

OS Group
oinstall
asmadmin
asmdba

Members
grid, oracle
grid
grid, oracle

Oracle Privilege

Oracle Group

SYSASM
SYSDBA for ASM

ASM Operator Group

asmoper

grid

Database Administrator
Database Operator

dba
oper

oracle
oracle

SYSOPER
ASM
SYSDBA
SYSOPER

OSASM
OSDBA
ASM
OSOPER
ASM
OSDBA
OSOPER

for

for
for

Note: Ensure that the operating system groups and user IDs are identical (the same) on all Oracle
RAC nodes in the cluster otherwise installation checks will fail. As root user run as follows on all
nodes
[root@Lugao-srv01 ~]# groupadd -g 512 oinstall
[root@Lugao-srv01 ~]# groupadd -g 513 dba
[root@Lugao-srv01 ~]# groupadd -g 514 oper
[root@Lugao-srv01 ~]# groupadd -g 515 asmadmin
[root@Lugao-srv01 ~]# groupadd -g 516 asmdba
[root@Lugao-srv01 ~]# groupadd -g 517 asmoper
[root@Lugao-srv01
[root@Lugao-srv01
[root@Lugao-srv01
[root@Lugao-srv01

~]# useradd -u 501 -g oinstall -G dba,oper,asmdba oracle


~]#
~]# useradd -u 502 -g oinstall -G asmadmin,asmdba,asmoper grid
~]#

[root@Lugao-srv01 ~]# passwd oracle


Changing password for user oracle.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@Lugao-srv01 ~]#

[root@Lugao-srv01 ~]# passwd grid


Changing password for user grid.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.

Creating Software Directories


On all node participating in RAC as root run commands as follows
[root@Lugao-srv01 ~]# mkdir -p /u01/app/grid
[root@Lugao-srv01 ~]# mkdir -p /u01/app/11.2.0/grid
[root@Lugao-srv01 ~]# chown -R grid:oinstall /u01
[root@Lugao-srv01 ~]#
[root@Lugao-srv01 ~]# mkdir -p /u01/app/oracle
[root@Lugao-srv01 ~]# chown -R oracle:oinstall /u01/app/oracle
[root@Lugao-srv01 ~]#
[root@Lugao-srv01 ~]# chmod -R 775 /u01
Note: The Grid Infrastructure home (/u01/app/11.2.0/grid) needs to be separate from other Oracle
base directories because grid infrastructure installation will change the ownership of this home
directory to root and inaccessible to unauthorized user
Create Login Script for the grid User Account
On both Oracle RAC nodes edit /home/grid/.bash_profile file by adding the following line
(When
setting
the
Oracle
environment
variables
for
each
node
replace ORACLE_HOSTNAME and ORACLE_SID variables with appropriate unique values)
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_HOSTNAME=lugao-srv01; export ORACLE_HOSTNAME
ORACLE_SID=+ASM2; export ORACLE_SID
ORACLE_BASE=/u01/app/grid; export ORACLE_BASE
ORACLE_HOME=/u01/app/11.2.0/grid; export ORACLE_HOME
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
if [ $USER = "grid" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi

Create Login Script for the oracle User Account

On both Oracle RAC nodes edit /home/oracle/.bash_profile file by adding the following lines
(When
setting
the
Oracle
environment
variables
for
each
node
replace ORACLE_HOSTNAME and ORACLE_SID variables with appropriate unique values)
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_HOSTNAME=lugao-srv01; export ORACLE_HOSTNAME
ORACLE_UNQNAME=PCBRAC; export ORACLE_UNQNAME
ORACLE_SID=PCBRAC1; export ORACLE_SID
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1; export ORACLE_HOME
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi

Install and Configure Oracle ASM Packages

Oracle provides ASMLib 2.0 which is a support library for the Automatic Storage Management (ASM)
feature of the Oracle Database at OTN page. ASM is highly recommended as the shared file system
and volume manager for Oracle Clusterware files (OCR and voting disk), Oracle Database files
(data, online redo logs, control files, archived redo logs), and the Fast Recovery Area
NOTE: The ASMLib kernel driver MUST match the kernel version number, the kernel version number
can be identified by running the "uname -r" command. Also, be sure to download the set of RPMs
which pertain to your platform architecture
[root@Lugao-srv01 ~]# uname -ri
2.6.18-308.el5 x86_64
[root@Lugao-srv01 ~]#
In our case, install the following packages on all RAC nodes as follows as root user
rpm -Uvh oracleasm-support-2.1.8-1.el5.x86_64.rpm
rpm -Uvh oracleasm-2.6.18-308.el5-debuginfo-2.0.5-1.el5.x86_64.rpm
rpm -Uvh oracleasm-2.6.18-308.el5-2.0.5-1.el5.x86_64.rpm
rpm -Uvh oracleasmlib-2.0.4-1.el5.x86_64.rpm
Configure ASMLib by running the following as the root user on all RAC nodes
[root@Lugao-srv01 ASMLib]# /etc/init.d/oracleasm configure -i
Configuring the Oracle ASM library driver.

This will configure the on-boot properties of the Oracle ASM library
driver. The following questions will determine whether the driver is
loaded on boot and what permissions it will have. The current values
will be shown in brackets ('[]'). Hitting <ENTER> without typing an
answer will keep that current value. Ctrl-C will abort.
Default user to own the driver interface []: grid
Default group to own the driver interface []: asmadmin
Start Oracle ASM library driver on boot (y/n) [n]: y
Scan for Oracle ASM disks on boot (y/n) [y]: y
Writing Oracle ASM library driver configuration: done
Initializing the Oracle ASMLib driver:
[ OK ]
Scanning the system for Oracle ASMLib disks:
[ OK ]
[root@Lugao-srv01 ASMLib]#

Use the oracleasm createdisk command to create the ASM disk label on one node only
[root@Lugao-srv01 ASMLib]# oracleasm createdisk OCR_VOTE01 /dev/sda1
Writing disk header: done
Instantiating disk: done
[root@Lugao-srv01 ASMLib]# oracleasm createdisk OCR_VOTE02 /dev/sdb1
Writing disk header: done
Instantiating disk: done
[root@Lugao-srv01 ASMLib]# oracleasm createdisk OCR_VOTE03 /dev/sdc1
Writing disk header: done
Instantiating disk: done
[root@Lugao-srv01 ASMLib]# oracleasm createdisk ASM_DATA01 /dev/sdd1
Writing disk header: done
Instantiating disk: done
[root@Lugao-srv01 ASMLib]# oracleasm createdisk ASM_DATA02 /dev/sde1
Writing disk header: done
Instantiating disk: done
[root@Lugao-srv01 ASMLib]# oracleasm createdisk ASM_FRA01 /dev/sdf1
Writing disk header: done
Instantiating disk: done
[root@Lugao-srv01 ASMLib]# oracleasm createdisk ASM_FRA02 /dev/sdg1
Writing disk header: done
Instantiating disk: done
[root@Lugao-srv01 ASMLib]#
Check the disks are mounted in the oracleasm file system
[root@Lugao-srv01 ASMLib]# ls -l /dev/oracleasm/disks
total 0
brw-rw---- 1 grid asmadmin 8, 49 Dec 20 16:18 ASM_DATA01
brw-rw---- 1 grid asmadmin 8, 65 Dec 20 16:19 ASM_DATA02
brw-rw---- 1 grid asmadmin 8, 81 Dec 20 16:25 ASM_FRA01
brw-rw---- 1 grid asmadmin 8, 97 Dec 20 16:20 ASM_FRA02
brw-rw---- 1 grid asmadmin 8, 1 Dec 20 16:17 OCR_VOTE01
brw-rw---- 1 grid asmadmin 8, 17 Dec 20 16:17 OCR_VOTE02
brw-rw---- 1 grid asmadmin 8, 33 Dec 20 16:17 OCR_VOTE03
[root@Lugao-srv01 ASMLib]#

On all the other nodes in the cluster, use the scandisks command as the root user to pick-up the
newly created ASM disks. You do not need to create the ASM disks on each node, only on one node
in the cluster
[root@Lugao-srv02 ASMLib]# oracleasm scandisks
Reloading disk partitions: done
Cleaning any stale ASM disks...
Scanning system for ASM disks...
Instantiating disk "OCR_VOTE01"
Instantiating disk "OCR_VOTE02"
Instantiating disk "OCR_VOTE03"
Instantiating disk "ASM_DATA01"
Instantiating disk "ASM_DATA02"
Instantiating disk "ASM_FRA01"
Instantiating disk "ASM_FRA02"
[root@Lugao-srv02 ASMLib]#
[root@Lugao-srv02 ASMLib]# ls -l /dev/oracleasm/disks
total 0
brw-rw---- 1 grid asmadmin 8, 49 Dec 20 16:26 ASM_DATA01
brw-rw---- 1 grid asmadmin 8, 65 Dec 20 16:26 ASM_DATA02
brw-rw---- 1 grid asmadmin 8, 81 Dec 20 16:26 ASM_FRA01
brw-rw---- 1 grid asmadmin 8, 97 Dec 20 16:26 ASM_FRA02
brw-rw---- 1 grid asmadmin 8, 1 Dec 20 16:26 OCR_VOTE01
brw-rw---- 1 grid asmadmin 8, 17 Dec 20 16:26 OCR_VOTE02
brw-rw---- 1 grid asmadmin 8, 33 Dec 20 16:26 OCR_VOTE03
[root@Lugao-srv02 ASMLib]#

Install and Configure Oracle Clusterware


In Oracle Database 11gR2, Oracle Clusterware software is available as part of Oracle Grid
Infrastructure products. Grid infrastructure provide also provide Automatic Storage Management
(ASM) software for Oracle Database. Therefor to get Oracle clusterware and ASM you need to install
and configure Oracle Grid infrastructure
Connect to one of RAC node as user grid, launch universal installer to install grid infrastructure as
follows
[grid@Lugao-srv01 grid]$ ./runInstaller
Starting Oracle Universal Installer...
Checking Temp space: must be greater than 120 MB. Actual 22828 MB Passed
Checking swap space: must be greater than 150 MB. Actual 4094 MB Passed
Checking monitor: must be configured to display at least 256 colors. Actual
16777216 Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2014-12-20_04-55-35PM.
Please wait ...

Node 1
[grid@Lugao-srv01 ~]$ su - root
Password:
[root@Lugao-srv01 ~]# /u01/app/oraInventory/orainstRoot.sh
Changing permissions of /u01/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.
Changing groupname of /u01/app/oraInventory to oinstall.
The execution of the script is complete.
[root@Lugao-srv01 ~]#

Node 2:
[grid@Lugao-srv01 ~]$ su - root
Password:
[root@Lugao-srv02 ~]# /u01/app/oraInventory/orainstRoot.sh
Changing permissions of /u01/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.
Changing groupname of /u01/app/oraInventory to oinstall.
The execution of the script is complete.
[root@Lugao-srv02 ~]#

Node 1:
[root@Lugao-srv01 ~]# /u01/app/11.2.0/grid/root.sh
Running Oracle 11g root.sh script...
The following environment variables are set as:
ORACLE_OWNER= grid
ORACLE_HOME= /u01/app/11.2.0/grid
Enter the full pathname of the local bin directory: [/usr/local/bin]:
Copying dbhome to /usr/local/bin ...
Copying oraenv to /usr/local/bin ...
Copying coraenv to /usr/local/bin ...
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root.sh script.
Now product-specific root actions will be performed.

2014-12-23 14:38:02: Parsing the host name


2014-12-23 14:38:02: Checking for super user privileges
2014-12-23 14:38:02: User has super user privileges
Using configuration parameter file: /u01/app/11.2.0/grid/crs/install/crsconfig_params
Creating trace directory
/home/grid/.bash_profile: line 15: racle: command not found
LOCAL ADD MODE
Creating OCR keys for user 'root', privgrp 'root'..
Operation successful.
root wallet
root wallet cert
root cert export
peer wallet
profile reader wallet
pa wallet
peer wallet keys
pa wallet keys
peer cert request
pa cert request
peer cert
pa cert
peer root cert TP
profile reader root cert TP
pa root cert TP
peer pa cert TP
pa peer cert TP
profile reader pa cert TP
profile reader peer cert TP
peer user cert
pa user cert
Adding daemon to inittab
CRS-4123: Oracle High Availability Services has been started.
ohasd is starting
CRS-2672: Attempting to start 'ora.gipcd' on 'lugao-srv01'
CRS-2672: Attempting to start 'ora.mdnsd' on 'lugao-srv01'
CRS-2676: Start of 'ora.mdnsd' on 'lugao-srv01' succeeded
CRS-2676: Start of 'ora.gipcd' on 'lugao-srv01' succeeded
CRS-2672: Attempting to start 'ora.gpnpd' on 'lugao-srv01'
CRS-2676: Start of 'ora.gpnpd' on 'lugao-srv01' succeeded
CRS-2672: Attempting to start 'ora.cssdmonitor' on 'lugao-srv01'
CRS-2676: Start of 'ora.cssdmonitor' on 'lugao-srv01' succeeded
CRS-2672: Attempting to start 'ora.cssd' on 'lugao-srv01'
CRS-2672: Attempting to start 'ora.diskmon' on 'lugao-srv01'
CRS-2676: Start of 'ora.diskmon' on 'lugao-srv01' succeeded
CRS-2676: Start of 'ora.cssd' on 'lugao-srv01' succeeded
CRS-2672: Attempting to start 'ora.ctssd' on 'lugao-srv01'
CRS-2676: Start of 'ora.ctssd' on 'lugao-srv01' succeeded
ASM created and started successfully.
DiskGroup OCR_VOTE created successfully.
clscfg: -install mode specified
Successfully accumulated necessary OCR keys.

Creating OCR keys for user 'root', privgrp 'root'..


Operation successful.
CRS-2672: Attempting to start 'ora.crsd' on 'lugao-srv01'
CRS-2676: Start of 'ora.crsd' on 'lugao-srv01' succeeded
CRS-4256: Updating the profile
Successful addition of voting disk 9f1d71bfa1bc4f18bfcd9c4b36653fff.
Successful addition of voting disk 39dbb90bc47a4feebf189d8448a6cd41.
Successful addition of voting disk 078e6848f19c4f10bfb344e34bccc0a5.
Successfully replaced voting disk group with +OCR_VOTE.
CRS-4256: Updating the profile
CRS-4266: Voting file(s) successfully replaced
## STATE File Universal Id
File Name Disk group
-- ----- ------------------------- --------1. ONLINE 9f1d71bfa1bc4f18bfcd9c4b36653fff (ORCL:OCR_VOTE01) [OCR_VOTE]
2. ONLINE 39dbb90bc47a4feebf189d8448a6cd41 (ORCL:OCR_VOTE02) [OCR_VOTE]
3. ONLINE 078e6848f19c4f10bfb344e34bccc0a5 (ORCL:OCR_VOTE03) [OCR_VOTE]
Located 3 voting disk(s).
CRS-2673:
CRS-2677:
CRS-2673:
CRS-2677:
CRS-2673:
CRS-2677:
CRS-2673:
CRS-2677:
CRS-2673:
CRS-2677:
CRS-2673:
CRS-2677:
CRS-2673:
CRS-2677:
CRS-2673:
CRS-2677:
CRS-2672:
CRS-2676:
CRS-2672:
CRS-2676:
CRS-2672:
CRS-2676:
CRS-2672:
CRS-2676:
CRS-2672:
CRS-2672:
CRS-2676:
CRS-2676:
CRS-2672:
CRS-2676:
CRS-2672:
CRS-2676:
CRS-2672:
CRS-2676:
CRS-2672:
CRS-2676:
CRS-2672:

Attempting to stop 'ora.crsd' on 'lugao-srv01'


Stop of 'ora.crsd' on 'lugao-srv01' succeeded
Attempting to stop 'ora.asm' on 'lugao-srv01'
Stop of 'ora.asm' on 'lugao-srv01' succeeded
Attempting to stop 'ora.ctssd' on 'lugao-srv01'
Stop of 'ora.ctssd' on 'lugao-srv01' succeeded
Attempting to stop 'ora.cssdmonitor' on 'lugao-srv01'
Stop of 'ora.cssdmonitor' on 'lugao-srv01' succeeded
Attempting to stop 'ora.cssd' on 'lugao-srv01'
Stop of 'ora.cssd' on 'lugao-srv01' succeeded
Attempting to stop 'ora.gpnpd' on 'lugao-srv01'
Stop of 'ora.gpnpd' on 'lugao-srv01' succeeded
Attempting to stop 'ora.gipcd' on 'lugao-srv01'
Stop of 'ora.gipcd' on 'lugao-srv01' succeeded
Attempting to stop 'ora.mdnsd' on 'lugao-srv01'
Stop of 'ora.mdnsd' on 'lugao-srv01' succeeded
Attempting to start 'ora.mdnsd' on 'lugao-srv01'
Start of 'ora.mdnsd' on 'lugao-srv01' succeeded
Attempting to start 'ora.gipcd' on 'lugao-srv01'
Start of 'ora.gipcd' on 'lugao-srv01' succeeded
Attempting to start 'ora.gpnpd' on 'lugao-srv01'
Start of 'ora.gpnpd' on 'lugao-srv01' succeeded
Attempting to start 'ora.cssdmonitor' on 'lugao-srv01'
Start of 'ora.cssdmonitor' on 'lugao-srv01' succeeded
Attempting to start 'ora.cssd' on 'lugao-srv01'
Attempting to start 'ora.diskmon' on 'lugao-srv01'
Start of 'ora.diskmon' on 'lugao-srv01' succeeded
Start of 'ora.cssd' on 'lugao-srv01' succeeded
Attempting to start 'ora.ctssd' on 'lugao-srv01'
Start of 'ora.ctssd' on 'lugao-srv01' succeeded
Attempting to start 'ora.asm' on 'lugao-srv01'
Start of 'ora.asm' on 'lugao-srv01' succeeded
Attempting to start 'ora.crsd' on 'lugao-srv01'
Start of 'ora.crsd' on 'lugao-srv01' succeeded
Attempting to start 'ora.evmd' on 'lugao-srv01'
Start of 'ora.evmd' on 'lugao-srv01' succeeded
Attempting to start 'ora.asm' on 'lugao-srv01'

CRS-2676:
CRS-2672:
CRS-2676:
CRS-2672:
CRS-2676:

Start of 'ora.asm' on 'lugao-srv01' succeeded


Attempting to start 'ora.OCR_VOTE.dg' on 'lugao-srv01'
Start of 'ora.OCR_VOTE.dg' on 'lugao-srv01' succeeded
Attempting to start 'ora.registry.acfs' on 'lugao-srv01'
Start of 'ora.registry.acfs' on 'lugao-srv01' succeeded

lugao-srv01
2014/12/23 14:59:25
/u01/app/11.2.0/grid/cdata/lugaosrv01/backup_20141223_145925.olr
Preparing packages for installation...
cvuqdisk-1.0.7-1
Configure Oracle Grid Infrastructure for a Cluster ... succeeded
Updating inventory properties for clusterware
Starting Oracle Universal Installer...
Checking swap space: must be greater than 500 MB. Actual 4094 MB
The inventory pointer is located at /etc/oraInst.loc
The inventory is located at /u01/app/oraInventory
'UpdateNodeList' was successful.
[root@Lugao-srv01 ~]#

Passed

Node 2:
[root@Lugao-srv02 ~]# /u01/app/11.2.0/grid/root.sh
Running Oracle 11g root.sh script...
The following environment variables are set as:
ORACLE_OWNER= grid
ORACLE_HOME= /u01/app/11.2.0/grid
Enter the full pathname of the local bin directory: [/usr/local/bin]:
Copying dbhome to /usr/local/bin ...
Copying oraenv to /usr/local/bin ...
Copying coraenv to /usr/local/bin ...
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root.sh script.
Now product-specific root actions will be performed.
2014-12-23 15:01:01: Parsing the host name
2014-12-23 15:01:01: Checking for super user privileges
2014-12-23 15:01:01: User has super user privileges
Using configuration parameter file: /u01/app/11.2.0/grid/crs/install/crsconfig_params
Creating trace directory
/home/grid/.bash_profile: line 14: racle: command not found
LOCAL ADD MODE
Creating OCR keys for user 'root', privgrp 'root'..
Operation successful.
Adding daemon to inittab
CRS-4123: Oracle High Availability Services has been started.
ohasd is starting
CRS-4402: The CSS daemon was started in exclusive mode but found an active CSS daemon
on node lugao-srv01, number 1, and is terminating
An active cluster was found during exclusive startup, restarting to join the cluster
CRS-2672: Attempting to start 'ora.mdnsd' on 'lugao-srv02'

CRS-2676:
CRS-2672:
CRS-2676:
CRS-2672:
CRS-2676:
CRS-2672:
CRS-2676:
CRS-2672:
CRS-2672:
CRS-2676:
CRS-2676:
CRS-2672:
CRS-2676:
CRS-2672:
CRS-2676:
CRS-2672:
CRS-2676:
CRS-2672:
CRS-2676:
CRS-2672:
CRS-2676:

Start of 'ora.mdnsd' on 'lugao-srv02' succeeded


Attempting to start 'ora.gipcd' on 'lugao-srv02'
Start of 'ora.gipcd' on 'lugao-srv02' succeeded
Attempting to start 'ora.gpnpd' on 'lugao-srv02'
Start of 'ora.gpnpd' on 'lugao-srv02' succeeded
Attempting to start 'ora.cssdmonitor' on 'lugao-srv02'
Start of 'ora.cssdmonitor' on 'lugao-srv02' succeeded
Attempting to start 'ora.cssd' on 'lugao-srv02'
Attempting to start 'ora.diskmon' on 'lugao-srv02'
Start of 'ora.diskmon' on 'lugao-srv02' succeeded
Start of 'ora.cssd' on 'lugao-srv02' succeeded
Attempting to start 'ora.ctssd' on 'lugao-srv02'
Start of 'ora.ctssd' on 'lugao-srv02' succeeded
Attempting to start 'ora.drivers.acfs' on 'lugao-srv02'
Start of 'ora.drivers.acfs' on 'lugao-srv02' succeeded
Attempting to start 'ora.asm' on 'lugao-srv02'
Start of 'ora.asm' on 'lugao-srv02' succeeded
Attempting to start 'ora.crsd' on 'lugao-srv02'
Start of 'ora.crsd' on 'lugao-srv02' succeeded
Attempting to start 'ora.evmd' on 'lugao-srv02'
Start of 'ora.evmd' on 'lugao-srv02' succeeded

lugao-srv02
2014/12/23 15:06:22
/u01/app/11.2.0/grid/cdata/lugaosrv02/backup_20141223_150622.olr
Preparing packages for installation...
cvuqdisk-1.0.7-1
Configure Oracle Grid Infrastructure for a Cluster ... succeeded
Updating inventory properties for clusterware
Starting Oracle Universal Installer...
Checking swap space: must be greater than 500 MB. Actual 5855 MB
The inventory pointer is located at /etc/oraInst.loc
The inventory is located at /u01/app/oraInventory
'UpdateNodeList' was successful.
[root@Lugao-srv02 ~]#

Passed

Install Oracle Real Application (RAC) Software


Connect to one of RAC node as user oracle, launch Oracle universal installer to install Oracle RAC
Software on servers as follows
[oracle@Lugao-srv01 oracle]$ ./runInstaller
Starting Oracle Universal Installer...
Checking Temp space: must be greater than 120 MB. Actual 22828 MB Passed
Checking swap space: must be greater than 150 MB. Actual 4094 MB Passed
Checking monitor: must be configured to display at least 256 colors. Actual
16777216 Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2014-12-20_04-55-35PM.
Please wait ...

Node 1:
[oracle@Lugao-srv01 ~]$ su - root
Password:
[root@Lugao-srv01 ~]#
[root@Lugao-srv01 ~]# /u01/app/oracle/product/11.2.0/dbhome_1/root.sh
Running Oracle 11g root.sh script...
The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /u01/app/oracle/product/11.2.0/dbhome_1
Enter the full pathname of the local bin directory: [/usr/local/bin]:
The file "dbhome" already exists in /usr/local/bin. Overwrite it? (y/n)
[n]:
The file "oraenv" already exists in /usr/local/bin. Overwrite it? (y/n)
[n]:
The file "coraenv" already exists in /usr/local/bin. Overwrite it? (y/n)
[n]:
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root.sh script.
Now product-specific root actions will be performed.
Finished product-specific root actions.
[root@Lugao-srv01 ~]#

Node 2:
[oracle@Lugao-srv01 ~]$ su - root
Password:
[root@Lugao-srv02 app]# /u01/app/oracle/product/11.2.0/dbhome_1/root.sh
Running Oracle 11g root.sh script...
The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /u01/app/oracle/product/11.2.0/dbhome_1
Enter the full pathname of the local bin directory: [/usr/local/bin]:
The file "dbhome" already exists in /usr/local/bin. Overwrite it? (y/n)
[n]:
The file "oraenv" already exists in /usr/local/bin. Overwrite it? (y/n)
[n]:
The file "coraenv" already exists in /usr/local/bin. Overwrite it? (y/n)
[n]:
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root.sh script.

Now product-specific root actions will be performed.


Finished product-specific root actions.
You have new mail in /var/spool/mail/root
[root@Lugao-srv02 app]#

Using Oracle ASMCA Utility to Create ASM Diskgroups


Connect to one of RAC node as user grid, start the asmca utility to create ASM disk group for
Oracle database as follows
[oracle@Lugao-srv01 grid]$ asmca

Using Oracle DBCA Utility to Create RAC Database


Connect to one of RAC node as user oracle, start the dbcautility to create database as follows
[oracle@Lugao-srv01 grid]$ dbca

VERIFICATION
Finally the installation of Oracle Database Real Application Cluster on two nodes using virtual disk
as shared storage is over.
Use several commands to verify working of RAC on all cluster nodes as follows
[oracle@Lugao-srv01 bin]$ srvctl status database -d PCBRAC
Instance PCBRAC1 is running on node lugao-srv01
Instance PCBRAC2 is running on node lugao-srv02
[oracle@Lugao-srv01 bin]$
[grid@Lugao-srv02 ~]$ srvctl status database -d PCBRAC
Instance PCBRAC1 is running on node lugao-srv01
Instance PCBRAC2 is running on node lugao-srv02
[grid@Lugao-srv02 ~]$

[oracle@Lugao-srv02 ~]$ sqlplus / as sysdba


SQL*Plus: Release 11.2.0.1.0 Production on Wed Dec 24 16:27:29 2014
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 * from v$active_instances;
INST_NUMBER INST_NAME
----------- -----------------------------------------------------------1 Lugao-srv01:PCBRAC1
2 Lugao-srv02:PCBRAC2
SQL>

Verify working of SCAN Name


SCAN DSN name provide a single name for clients to access Oracle database in a cluster
independent of which server in the cluster.
From the machine separate from nodes forming cluster use Oracle Easy Connect method that
involve SCAN Name to connect to the RAC database as follows
C:\Users\Administrator>sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on Wed Dec 24 05:29:28 2014
Copyright (c) 1982, 2010, Oracle. All rights reserved.
SQL> connect system/manager@Lugaorac-scan.Lusam.tz:1521/PCBRAC.LUSAM.TZ
Connected.
SQL>
SQL> col instance_name format a15
SQL> col hostnames format a25
SQL> select instance_name, host_name, status from v$instance;
INSTANCE_NAME HOST_NAME
STATUS
--------------- ------------------------- -----------PCBRAC2
Lugao-srv02
OPEN

Now, switch off the node shown on the above query (e.g. Lugao-srv02) then from any client use
Oracle Easy connect method that involve SCAN Name to connect to the RAC database. Verify that
you can connect to another active instance
C:\Users\Administrator>
C:\Users\Administrator>sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on Wed Dec 24 05:32:24 2014


Copyright (c) 1982, 2010, Oracle. All rights reserved.
SQL> connect system/manager@Lugaorac-scan.Lusam.tz:1521/PCBRAC.LUSAM.TZ
Connected.
SQL>
SQL> col instance_name format a15
SQL> col host_name format a25
SQL> select instance_name, host_name, status from v$instance;
INSTANCE_NAME HOST_NAME
STATUS
--------------- ------------------------- -----------PCBRAC1
Lugao-srv01
OPEN

Posted 8th January by Sadock Obeth


Labels: RAC Real Application Cluter
0

Add a comment

4.
JAN

Moving Oracle Database Datafiles to Other Directory


Sometimes you may have requirement to move Oracle Datafiles to other locations due to several
reasons such as the datafiles locations was not planned properly during database creation, you want
to spread datafiles to different disks to improve I/O performance, the disk where datafiles reside is
full and you want to give some free space, etc.
In Oracle database, the control file act like a map that show locations of all datafiles in the server.
Thus for Oracle to identify the new locations of datafiles, controlfile needs to be edited. However the
controlfile is binary file which cannot be edited direct by text editors. Oracle provide command to
export the binary controlfile to a text file version where it can be edited

This capability can be utilized as one way to move Oracle Database datafile to other location. In fact
this capability can be used also as a backup strategy for controlfile. It easy to recover from loss of all
multiplexed binary versions of the control file due to a catastrophic failure from a trace file than most
of the other methods. Thus Oracle recommend to backup to trace (create text file version of
controlfile) controlfile at least each time the structure of database is changed e.g. adding or deleting
datafiles on the tablespace

Steps to Go About
Determine Existing Locations of Datafiles
Create Editable Text Version of Controfile
Shutdown the Instance
Move the Datafiles to New Locations
Edit the Text Controlfile
Create New Binary Controlfiles From Text File Version
Verification

Determine Existing Locations of All Datafiles

Use SQL*Plus to query V$DATAFILE data dictionary view to determine the location of all database
datafiles in the server as follows
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------/prod1/app/oracle/oradata/PCBDB/system01.dbf
/prod1/app/oracle/oradata/PCBDB/sysaux01.dbf
/prod1/app/oracle/oradata/PCBDB/undotbs01.dbf
/prod1/app/oracle/oradata/PCBDB/users01.dbf
/prod1/app/oracle/oradata/PCBDB/example01.dbf
/prod1/app/oracle/oradata/PCBDB/DEV_odi_user.dbf
6 rows selected.

Create Editable Text Version of Controlfile


Oracle database has command ALTER DATABASE BACKUP CONTROLFILE TO TRACE to create a
text version of controlfile from the binary file. Use the command as follows
SQL> alter database backup controlfile to trace as '/home/oracle/pcbdbcontrolfile.sql';
Database altered.

Shutdown the Instance

Make a clean shutdown of the database instance as follows


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

Move the Datafiles to New Locations


Use operating system utilizes such mv to move the desired datafile to new locations. For example
the
following
command
move
the
database
datafiles users01.dbf and example01.dbf for USERS and EXAMPLES tablespaces respectively
from mount point /prod1 to /prod2
[oracle@Lugao-srv01~]$ mv /prod1/app/oracle/oradata/PCBDB/users01.dbf
/prod2/app/oracle/oradata/PCBDB/users01.dbf
[oracle@Lugao-srv01~]$

[oracle@Lugao-srv01~]$ mv /prod1/app/oracle/oradata/PCBDB/example01.dbf
/prod2/app/oracle/oradata/PCBDB/example01.dbf

Edit the Text Version of Controlfile


The text version of controlfile has two sets of scripts: #1. NORESETLOGS case and #2.
RESETLOGS case. For this case remove all other entries except the entries on the first script set to
reflect the new locations of datafiles similar to the following entries
-Set #1. NORESETLOGS case
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "PCBDB" NORESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/prod1/app/oracle/oradata/PCBDB/redo01.log' SIZE 50M BLOCKSIZE 512,
GROUP 2 '/prod1/app/oracle/oradata/PCBDB/redo02.log' SIZE 50M BLOCKSIZE 512,
GROUP 3 '/prod1/app/oracle/oradata/PCBDB/redo03.log' SIZE 50M BLOCKSIZE 512
DATAFILE
'/prod1/app/oracle/oradata/PCBDB/system01.dbf',
'/prod1/app/oracle/oradata/PCBDB/sysaux01.dbf',
'/prod1/app/oracle/oradata/PCBDB/undotbs01.dbf',
'/prod2/app/oracle/oradata/PCBDB/users01.dbf',
'/prod2/app/oracle/oradata/PCBDB/example01.dbf',
'/prod1/app/oracle/oradata/PCBDB/DEV_odi_user.dbf'
CHARACTER SET AL32UTF8;
RECOVER DATABASE
ALTER SYSTEM ARCHIVE LOG ALL;
ALTER DATABASE OPEN;
ALTER TABLESPACE TEMP ADD TEMPFILE '/prod1/app/oracle/oradata/PCBDB/temp01.dbf'
SIZE 30408704 REUSE AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;
ALTER TABLESPACE DEV_ODI_TEMP ADD TEMPFILE
'/prod1/app/oracle/oradata/PCBDB/DEV_odi_temp.dbf'
SIZE 104857600 REUSE AUTOEXTEND ON NEXT 52428800 MAXSIZE 1048576000;

Create New Binary Controlfiles from Text File Version


Finally create new binary version of controlfile from edited text file version buy executing the script
file from SQL*Plus. The REUSE option on the script instruct Oracle to overwrite any existing
controfiles with new files
SQL> @/home/oracle/pcbdbcontrolfile.sql;
ORACLE instance started.
Total System Global Area 849530880 bytes
Fixed Size
1339824 bytes
Variable Size
532680272 bytes
Database Buffers
310378496 bytes
Redo Buffers
5132288 bytes

Control file created.


ORA-00283: recovery session canceled due to errors
ORA-00264: no recovery required
System altered.
Database altered.
Tablespace altered.
Tablespace altered.

Note: Ignore any error thrown that indicates the Oracle was attempting to recover the instance as no
any recovery was required, the database was brought down clean

Verification

Run few commands as follows to very new locations of datafiles


SQL> select instance_name, status from v$instance;
INSTANCE_NAME STATUS
---------------- -----------PCBDB
OPEN
SQL> select name from v$datafile;
NAME
-------------------------------------------------------------------------------/prod1/app/oracle/oradata/PCBDB/system01.dbf
/prod1/app/oracle/oradata/PCBDB/sysaux01.dbf
/prod1/app/oracle/oradata/PCBDB/undotbs01.dbf
/prod2/app/oracle/oradata/PCBDB/users01.dbf
/prod2/app/oracle/oradata/PCBDB/example01.dbf
/prod1/app/oracle/oradata/PCBDB/DEV_odi_user.dbf
6 rows selected.

Posted 7th January by Sadock Obeth


1

View comments

5.
DEC

12

Using RMAN Incremental Backup to Recover Standby Database in


Oracle Data Guard

It may happen in Oracle data guard environment that the standby database is behind the primary
database and some archivelogs to recover the standby database have been deleted at primary
server before being shipped to the standby server. In this case the alert log will have entries with
complain about Oracle failed to resolve the gap sequence automatically similar to the following
Thu Dec 11 15:19:26 2014
FAL[client]: Failed to request gap sequence
GAP - thread 1 sequence 11498-11519
DBID 1691272038 branch 632153977
FAL[client]: All defined FAL servers have been attempted.
------------------------------------------------------------Check that the CONTROL_FILE_RECORD_KEEP_TIME initialization
parameter is defined to a value that is sufficiently large
enough to maintain adequate log switch information to resolve
archivelog gaps.
------------------------------------------------------------Here the archivelogs from 11498-11519 not found at primary database. In this case you have many
options to solve the problem, one is to recreate the standby database that may require movement of
the whole database to standby server if you have time to do so. However the least cost option is to
take the missing gaps only from primary database though incremental backup

The Steps to Go About

Get the Current SCN at Standby Database


Create RMAN Incremental Backup
Create Standby Controlfile at Primary Database
Move the Backup files to the Standby Server
Shutdown the Standby Database
Copy the Standby Controlfile to all Locations
Mount the Standby Database
Use RMAN to Recover the Database
Start Managed Recovery Process
Verification
Assumption: Standby database is running fine, only some archive log not applied at standby
database but deleted/lost at primary database and not available to any server

Get the Current SCN at Standby Database

[Standby Database] Query the standby database to get the current SCN, it will be used as
demarcation point to start incremental backup at primary database
SQL> select to_char(current_scn) from v$database;
TO_CHAR(CURRENT_SCN)
---------------------------------------5993380642292

SQL>

Create RMAN Incremental Backup

[Primary Database] Create RMAN incremental backup at primary database. Use the SCN from
above step to mark demarcation point to start backup
FDIDB-/home/oracle> export ORACLE_SID=FDIDB
FDIDB-/home/oracle> rman target /
Recovery Manager: Release 11.2.0.1.0 - Production on Fri Dec 12 12:41:45 2014
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: FDIDB (DBID=1691272038)
RMAN> BACKUP DEVICE TYPE DISK INCREMENTAL FROM
SCN 5993380642292 DATABASE FORMAT '/prod2/backup/fdidb/incr_for_stdby_%U';
Starting backup at 12-DEC-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=43 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=53 device type=DISK
backup will be obsolete on date 19-DEC-14
archived logs will not be kept or backed up
RMAN-06755: WARNING: datafile 10: incremental-start SCN is too recent; using
checkpoint SCN 5979602355940 instead
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/prod1/fdidb/dbs/users01.dbf
input datafile file number=00011 name=/prod1/fdidb/dbs/users03.dbf
input datafile file number=00003 name=/prod1/fdidb/dbs/sysaux01.dbf
input datafile file number=00005 name=/prod2/fdidb/dbs/cwmlite01.dbf
input datafile file number=00006 name=/prod2/fdidb/dbs/drsys01.dbf
input datafile file number=00008 name=/prod2/fdidb/dbs/tools01.dbf
input datafile file number=00013 name=/prod1/fdidb/dbs/sysaux02.dbf
channel ORA_DISK_1: starting piece 1 at 12-DEC-14
channel ORA_DISK_2: starting full datafile backup set
channel ORA_DISK_2: specifying datafile(s) in backup set
input datafile file number=00010 name=/prod1/fdidb/dbs/users02.dbf
skipping datafile 00010 because it has not changed
input datafile file number=00001 name=/prod1/fdidb/dbs/system01.dbf
input datafile file number=00014 name=/prod1/fdidb/dbs/system03.dbf
input datafile file number=00012 name=/prod1/fdidb/dbs/system02.dbf
input datafile file number=00002 name=/prod1/fdidb/dbs/undotbs01.dbf
input datafile file number=00009 name=/prod2/fdidb/dbs/xdb01.dbf
input datafile file number=00007 name=/prod2/fdidb/dbs/indx01.dbf
channel ORA_DISK_2: starting piece 1 at 12-DEC-14
channel ORA_DISK_2: finished piece 1 at 12-DEC-14

piece handle=/prod2/backup/fdidb/incr_for_stdby_3ippvroh_1_1
tag=TAG20141212T124352 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:01:15
channel ORA_DISK_1: finished piece 1 at 12-DEC-14
piece handle=/prod2/backup/fdidb/incr_for_stdby_3hppvrof_1_1
tag=TAG20141212T124352 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:37
using channel ORA_DISK_1
using channel ORA_DISK_2
backup will be obsolete on date 19-DEC-14
archived logs will not be kept or backed up
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 12-DEC-14
channel ORA_DISK_1: finished piece 1 at 12-DEC-14
piece handle=/prod2/backup/fdidb/incr_for_stdby_3jppvrri_1_1
tag=TAG20141212T124352 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 12-DEC-14

Create Standby Controlfile at Primary Database


[Primary Database] Use SQL*Plus to create standby database at primary. It is better to create the
standby controlfile after incremental backup operation this will avoid the necessity to catalog backup
files when moved to standby server
FDIDB-/home/oracle> sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Fri Dec 12 12:51:21 2014
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, OLAP, Data Mining and Real Application Testing options
SQL> alter database create standby controlfile as
'/prod2/backup/fdidb/fdidb_standby.ctl';
Database altered.

Move the Backup files to the Standby Server


[Primary Database] Use any utility to move the backup files to the standby server ready for recovery
as follows. Use the same file structure as in primary server otherwise you will have to catalog the
backup file at standby database (which is not bad actually)
FDIDB-/prod2/backup/fdidb>
total 716080
568983 -rw-rw---- 1 oracle
568826 -rw-rw---- 1 oracle
568829 -rw-rw---- 1 oracle

ls -li
oinstall 10731520 Dec 12 12:51 fdidb_standby.ctl
oinstall 250331136 Dec 12 12:45 incr_for_stdby_3hppvrof_1_1
oinstall 94765056 Dec 12 12:45 incr_for_stdby_3ippvroh_1_1

568834 -rw-rw---- 1 oracle


oinstall 10780672 Dec 12 12:45 incr_for_stdby_3jppvrri_1_1
FDIDB-/prod2/backup/fdidb>
FDIDB-/prod2/backup/fdidb> scp * oracle@192.168.28.15:/prod2/backup/fdidb
Password:
fdidb_standby.ctl
100% 10MB 5.1MB/s 2.5MB/s 00:02
Max throughput: 7.7MB/s
incr_for_stdby_3hppvrof_1_1
Max throughput: 8.8MB/s

100% 239MB 5.3MB/s 1.4MB/s 00:45

incr_for_stdby_3ippvroh_1_1
Max throughput: 10.0MB/s

100% 90MB 5.7MB/s 1.8MB/s 00:16

incr_for_stdby_3jppvrri_1_1
Max throughput: 10.0MB/s

100% 10MB 5.1MB/s 3.3MB/s 00:02

FDIDB-/prod2/backup/fdidb>

Shutdown the Standby Database

[Standby Database] However before shutting down the standby database, query the data dictionary
to get the locations of all controlfiles
SQL> select name from v$controlfile;
NAME
----------------------------------------/prod1/fdidb/log/control01.ctl
/prod2/fdidb/log/control02.ctl
/prod3/fdidb/log/control03.ctl
SQL> shutdown immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.

Copy the Standby Controlfile to all Locations


[Standby Database] Copy the standby controlfile moved from primary database to all location
specified by above query to v$controlfile view as follows
FDIDB-/prod2/backup/fdidb> ls -li
total 716064
769 -rw-r----- 1 oracle
users
10731520 Dec 12 11:31 fdidb_standby.ctl
873 -rw-r----- 1 oracle
users
250331136 Dec 12 11:32 incr_for_stdby_3hppvrof_1_1
874 -rw-r----- 1 oracle
users
94765056 Dec 12 11:32 incr_for_stdby_3ippvroh_1_1
875 -rw-r----- 1 oracle
users
10780672 Dec 12 11:32 incr_for_stdby_3jppvrri_1_1
FDIDB-/prod2/backup/fdidb>
FDIDB-/prod2/backup/fdidb>
FDIDB-/prod2/backup/fdidb> cp -f fdidb_standby.ctl /prod1/fdidb/log/control01.ctl
FDIDB-/prod2/backup/fdidb> cp -f fdidb_standby.ctl /prod2/fdidb/log/control02.ctl
FDIDB-/prod2/backup/fdidb> cp -f fdidb_standby.ctl /prod3/fdidb/log/control03.ctl

Mount the Standby Database

[Standby Database] Mount the Standby Database ready for recovery


SQL> startup nomount
ORACLE instance started.
Total System Global Area 217157632 bytes
Fixed Size
2168376 bytes
Variable Size
159386056 bytes
Database Buffers
50331648 bytes
Redo Buffers
5271552 bytes
SQL>
SQL> alter database mount standby database;
Database altered.

Use RMAN to Recover the Database


[Standby Database] Finally use the command "recover database noredo" to apply the
incremental backups only created from primary database. If noredo option is omitted, RMAN will
attempt to continue recovery using archivelogs, where at some point it will fail when it attempt to
apply archived log not yet generated. Thus to be safe use noredooption as follows
FDIDB-/home/oracle/product/11.2.0/dbhome_1> rman target/
Recovery Manager: Release 11.2.0.1.0 - Production on Fri Dec 12 11:40:54 2014
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: FDIDB (DBID=1451242038, not open)
RMAN> recover database noredo;
Starting recover at 12-DEC-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=14 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=100 device type=DISK
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: /prod3/fdidb/dbs/system01.dbf
destination for restore of datafile 00002: /prod3/fdidb/dbs/undotbs01.dbf
destination for restore of datafile 00007: /prod3/fdidb/dbs/indx01.dbf
destination for restore of datafile 00009: /prod3/fdidb/dbs/xdb01.dbf
destination for restore of datafile 00012: /prod3/fdidb/dbs/system02.dbf
destination for restore of datafile 00014: /prod3/fdidb/dbs/system03.dbf
channel ORA_DISK_1: reading from backup piece
/prod2/backup/fdidb/incr_for_stdby_3ippvroh_1_1
channel ORA_DISK_2: starting incremental datafile backup set restore
channel ORA_DISK_2: specifying datafile(s) to restore from backup set
destination for restore of datafile 00003: /prod3/fdidb/dbs/sysaux01.dbf
destination for restore of datafile 00004: /prod3/fdidb/dbs/users01.dbf
destination for restore of datafile 00005: /prod3/fdidb/dbs/cwmlite01.dbf

destination for restore of datafile 00006: /prod3/fdidb/dbs/drsys01.dbf


destination for restore of datafile 00008: /prod3/fdidb/dbs/tools01.dbf
destination for restore of datafile 00011: /prod3/fdidb/dbs/users03.dbf
destination for restore of datafile 00013: /prod3/fdidb/dbs/sysaux02.dbf
channel ORA_DISK_2: reading from backup piece
/prod2/backup/fdidb/incr_for_stdby_3hppvrof_1_1
channel ORA_DISK_1: piece handle=/prod2/backup/fdidb/incr_for_stdby_3ippvroh_1_1
tag=TAG20141212T124352
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
channel ORA_DISK_2: piece handle=/prod2/backup/fdidb/incr_for_stdby_3hppvrof_1_1
tag=TAG20141212T124352
channel ORA_DISK_2: restored backup piece 1
channel ORA_DISK_2: restore complete, elapsed time: 00:00:07
Finished recover at 12-DEC-14

Start Managed Recovery Process


[Standby Database] Optionally if you want use automatic apply start MRP at standby database as
follows
SQL> alter database recover managed standby database disconnect from session;
Database altered.

Verification
At this point the gap sequence has been resolved and the standby database is at par with primary
database. You may query the maximum sequence number applied at primary and standby database
to justify as follows
[Primary Database]
SQL> select max(sequence#)
2 from v$archived_log
3 where applied='YES';
MAX(SEQUENCE#)
-------------11576
[Standby Database]
SQL> select max(sequence#)
2 from v$archived_log
3 where applied='YES';
MAX(SEQUENCE#)
-------------11576

No more complain that Failed to request gap sequence in alert file. In fact the next atchivelog
here 11577 is on the way in transit from primary database
alter database recover managed standby database disconnect from session
Attempt to start background Managed Standby Recovery process (FDIDB)
Fri Dec 12 11:44:02 2014
MRP0 started with pid=28, OS id=8011
MRP0: Background Managed Standby Recovery process started (FDIDB)
started logmerger process
Fri Dec 12 11:44:07 2014
Managed Standby Recovery not using Real Time Apply
Parallel Media Recovery started with 2 slaves
Fri Dec 12 11:44:08 2014
Warning: recovery process PR01 cannot use async I/O
Fri Dec 12 11:44:08 2014
Warning: recovery process PR02 cannot use async I/O
Warning: Datafile 10 (/prod1/fdidb/dbs/users02.dbf) is offline during full database
recovery and will not be recovered
Waiting for all non-current ORLs to be archived...
All non-current ORLs have been archived.
Media Recovery Log /prod2/fdidb/arch/1_11576_632153977.arc
Media Recovery Waiting for thread 1 sequence 11577 (in transit)
Completed: alter database recover managed standby database disconnect from session
Obtain the latest RCU from Oracle, unzip then run the file RCU_HOME/bin/rcu to starts
the wizards
Posted 12th December 2014 by Sadock Obeth
0

Add a comment

6.
OCT

27

Install Oracle Data Integrator (ODI) 11gR1 (11.1.1.7.0) without


Weblogic Server on Linux
You can choose a combination of three ODI 11gR1 installation types: Developer Installation,
Standalone Installation and Java EE Installation. Any combination that will include Java EE
components require installation of application server such as Oracle Weblogic Server prior to
installation of ODI
Generally, Developer option adds ODI Studio and SDK, Standalone adds ODI standalone agent
while Java EE Installation includes Java EE agent, ODI Console, and Public Web Services

.Therefore, if you are not planning to use Java EE components, you dont need any application
server prior to ODI installation

The Key Steps to Remember


Create Database for ODI Master and Work Repositories
Run RCU to create Master and Work Repository
Install Java SE Development Kit (JDK)
Install ODI Software
Verify Installation

Database for ODI Master and Work Repositories

ODI keeps configurations information, metadata, objects and execution logs in database schema.
Thus database needs to be created prior to run RCU to create the repositories. The database can be
Oracle, Microsoft SQL Server or IBM DB2. Both Master and Work Repositories can be in a single
schema
This installation steps use Oracle Database 11gR2 installed on Red Hat Enterprise Linux 5.9
(32bits). The database for repositories and ODI software is on same server, however is not
mandatory

Run RCU to Create Master and Work Repository

Creation of repositories prior to install ODI is option. You can choose to create and configure later
using ODI studio. However if you want all in hands after installation of ODI complete, use Repository
Creation Utility (RCU) to create the repository.
Obtain the latest RCU from Oracle, unzip then run the file RCU_HOME/bin/rcu to starts the wizards

On the welcome screen click Next

Select Create button them click Next

Select the Database Type then enter connection information to the database you want to keep
the repositories as shown above

Click OK

On Select Components screen, enter the prefix on Create a new Prefix text box,
expand Oracle Data Integrator then select Master and Work Repository. Click Next

Click OK

Select Use same password for all schema, enter the password, confirm the password then
click Next

On Custom variable enter the values for Master and Work Repository as show above then
click Next

Click Next

Accept by clicking OK

On the Summary screen click Create button to start creation process

Click Close to complete

Install Java SE Development Kit (JDK)


ODI Standalone Agents run in their own JVM container, thus why you need to install proper JDK to
run the agents. The ODI 11gR1 (11.1.1.7.0) is supported with minimum java version of 1.6.0_04 and
a maximum version less than 1.7
Obtain the proper JDK version for this product at Java SE 6 Downloads. This installation is using jdk6u45-linux-i586-rpm.bin. Extract the RPM file then install as follows:
[root@Lugao-odisrv ~]# ./jdk-6u45-linux-i586-rpm.bin -x
Unpacking...
Checksumming...
Extracting...
UnZipSFX 5.50 of 17 February 2002, by Info-ZIP (Zip-Bugs@lists.wku.edu).
inflating: jdk-6u45-linux-i586.rpm
inflating: sun-javadb-common-10.6.2-1.1.i386.rpm
inflating: sun-javadb-core-10.6.2-1.1.i386.rpm
inflating: sun-javadb-client-10.6.2-1.1.i386.rpm
inflating: sun-javadb-demo-10.6.2-1.1.i386.rpm

inflating: sun-javadb-docs-10.6.2-1.1.i386.rpm
inflating: sun-javadb-javadoc-10.6.2-1.1.i386.rpm
Extraction of RPM Done.
Done.
[root@Lugao-odisrv ~]# ls
anaconda-ks.cfg
scsrun.log
Desktop
sun-javadb-client-10.6.2-1.1.i386.rpm
install.log
sun-javadb-common-10.6.2-1.1.i386.rpm
install.log.syslog
sun-javadb-core-10.6.2-1.1.i386.rpm
jdk-6u45-linux-i586.rpm
sun-javadb-demo-10.6.2-1.1.i386.rpm
jdk-6u45-linux-i586-rpm.bin sun-javadb-docs-10.6.2-1.1.i386.rpm
jdk-7-linux-i586.rpm
sun-javadb-javadoc-10.6.2-1.1.i386.rpm
jdk-8u25-linux-i586.rpm
[root@Lugao-odisrv ~]#
[root@Lugao-odisrv ~]# rpm -ivh jdk-6u45-linux-i586.rpm
Preparing...
##########################################
# [100%]
1:jdk
###########################################
[100%]
Unpacking JAR files...
rt.jar...
jsse.jar...
charsets.jar...
tools.jar...
localedata.jar...
plugin.jar...
javaws.jar...
deploy.jar...
[root@Lugao-odisrv ~]#

Install ODI Software

Finally you are ready to run ODI software installer. Go to the directory where you unpacked the
archive file and switch to the Disk1 directory then run Installer file. You must supply the full path of
JDK home installed on your system when prompted as follows
[oracle@Lugao-odisrv Disk1]$ ./runInstaller
Starting Oracle Universal Installer...
Checking if CPU speed is above 300 MHz. Actual 3247 MHz Passed
Checking Temp space: must be greater than 300 MB. Actual 4558 MB Passed
Checking swap space: must be greater than 512 MB. Actual 5122 MB Passed
Checking monitor: must be configured to display at least 256 colors. Actual
16777216 Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2014-10-24_07-27-22PM.
Please wait ...
Please specify JDK location ( Ex. /home/jdk ),
<location>/bin/java should
exist :/usr/java/jdk1.6.0_45
[oracle@Lugao-odisrv Disk1]$ Log: /u01/app/oraInventory/logs/install2014-10-24_07-2722PM.log

On Select
Installation
Type select
any
combination
option
from Developer
Installation and Standalone Installationdepending on components you want to install as
shown above (Do not select any option from Java EE Installation this require application
server installation exist on server) then click Next

Enter Oracle Directory for ODI. The wizard will create for you if the directory does not exist

Choose to Configure Repositories then click Next

Enter database connect string to the repositories created. Enter the username and password of
repository schema then clickNext

Enter ODI password as supplied during creation of repository using RCU on custom variable
screen then click Next

Enter the Agent Name and Agent Port then click Next

You may unselect I Wish to receive security updates via My Oracle Support if you dont
have MOS credentials then clickNext

Accept the fact by clicking Yes

Click Install button to start installation process

Click Finish to complete the installation process

Verification
To verify installation of ODI start ODI studio from ODI_HOME/oracledi/client as follow
[oracle@Lugao-odisrv ~]$ cd /u01/app/oracle/Middleware/ODI_11G/oracledi/client
[oracle@Lugao-odisrv client]$ ls
ant
jdev log
odi64.exe rdbms
ide
jlib modules odi.exe sleepycat
integration jviews odi
odi.sh
timingframework
[oracle@Lugao-odisrv client]$
[oracle@Lugao-odisrv client]$ ./odi.sh
Oracle Data Integrator 11g
Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.

ODI studio

References
Oracle Fusion Middleware Installation Guide for Oracle Data Integrator 11g Release 1 (11.1.1.7.0)

Posted 27th October 2014 by Sadock Obeth


0

Add a comment

7.
OCT

16

Create Physical Standby Database Using RMAN Duplicate Command


from Backups

Primary Server: Lugao-srv01

Standby Server: Lugao-srv02


Primary Database: LGPROD
Standby Database: LGPROD_STBY

Prepare Primary database


Force Logging and Archivelog Modes
To configure the primary database for standby the database must be running in force logging and
archivelog mode.
SQL> select force_logging, log_mode from v$database;
FOR LOG_MODE
--- -----------NO ARCHIVELOG
SQL> alter database force logging;
Database altered.
SQL> select force_logging, log_mode from v$database;
FOR LOG_MODE
--- -----------YES ARCHIVELOG

Enable archivelog mode as follow:


shutdown immediate;
startup mount;
alter database archivelog;
alter database open;

Set Initialization Parameters

Primary database needs initialization parameters that control redo transport service while the
database is in the primary role. It is recommended also the primary database to have parameters
that control the receipt of redo when the role is reversed to standby
[Primary Database] Check the value assigned to db_unique_name parameter and then use that
value

and

unique

name

of

standby

databases

to

set dg_config setting

of log_archive_config parameter to identify the databases in data guard configuration


SQL> show parameter db_unique_name;
NAME

TYPE

VALUE

------------------------------------ ----------- -----------------------------db_unique_name


SQL>

alter

string

system

set

LGPROD

log_archive_config='DG_CONFIG=(LGPROD,LGPROD_STBY)'

scope=both;
System altered.

[Primary Database] Use log_archive_dest_n parameter to set suitable local and remote archive
log destinations. This case is using Fast Recovery Area for local location.
SQL> alter system set log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST' scope=both;
System altered.
SQL> show parameter db_recovery_file_dest;
NAME

TYPE

VALUE

------------------------------------ ----------- -----------------------------db_recovery_file_dest


db_recovery_file_dest_size

string

/u01/app/oracle/flash_recovery_area

big integer 3852M

SQL> alter system set log_archive_dest_state_1=ENABLE scope=both;


System altered.
SQL> alter system set log_archive_dest_2='SERVICE=LGPROD_STBY ASYNC
VALID_FOR=(ONLINE_LOGFILE, PRIMARY_ROLE) COMPRESSION=ENABLE
DB_UNIQUE_NAME=LGPROD_STBY' scope=both;
System altered.
SQL> alter system set log_archive_dest_state_2=ENABLE scope=both;
System altered.

[Primary Database] Log archive format and password file use


SQL> alter system set REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE scope=spfile;
System altered.
SQL> alter system set LOG_ARCHIVE_FORMAT='%t_%s_%r.arc' scope=spfile;
System altered.
SQL> alter system set STANDBY_FILE_MANAGEMENT=AUTO scope=both;
System altered.

[Primary Database] The fal_server and fal_client parameters are purely option but they
recommended to make sure the primary is ready to switch roles to become a standby
SQL> alter system set FAL_SERVER=PCB_STBY scope=both;
System altered.
SQL> alter system set FAL_CLIENT=PCB scope=both;
System altered.

[Primary Database]Some of the initialization parameters modified above are static, so the database
needs to be restarted before for them to take effect
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 613797888 bytes
Fixed Size

2215824 bytes

Variable Size

406847600 bytes

Database Buffers
Redo Buffers

201326592 bytes
3407872 bytes

Database mounted.
Database opened.

Prepare Initialization Parameter File for Standby Database


[Primary Database] Create PFILE from SPFILE
SQL> create pfile='/home/oracle/pfilelgprod.ora' from spfile;
File created.

Edit and amend some parameters in the file to make it relevant for standby database similar to the
following
*.audit_file_dest='/u01/app/oracle/admin/LGPROD/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u01/app/oracle/oradata/LGPROD_STBY/control01.ctl','/u01/app/oracle/oradat
a/LGPROD_STBY/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='LGPROD'
*.db_unique_name='LGPROD_STBY'
*.db_file_name_convert='/u01/app/oracle/oradata/LGPROD/','/u01/app/oracle/oradata/LGPRO
D_STBY/'
*.log_file_name_convert='/u01/app/oracle/oradata/LGPROD/',
'/u01/app/oracle/oradata/LGPROD_STBY/'
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'

*.db_recovery_file_dest_size=4039114752
*.diagnostic_dest='/u01/app/oracle'
*.fal_client='LGPROD_STBY'
*.fal_server='LGPROD'
*.log_archive_config='DG_CONFIG= (LGPROD, LGPROD_STBY)'
*.log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST'
*.log_archive_dest_2='SERVICE=LGPROD ASYNC VALID_FOR= (ONLINE_LOGFILE,
PRIMARY_ROLE) COMPRESSION=ENABLE DB_UNIQUE_NAME=LGPROD'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.log_archive_format='%t_%s_%r.arc'
*.remote_login_passwordfile='EXCLUSIVE'
*.standby_file_management='AUTO'
*.undo_tablespace='UNDOTBS1'

Set Oracle Network Environments


Apart from physical and logical network connectivity (e.g. TCP/IP) between the primary and standby
servers Oracle Net services need to be properly configures for primary database to be able to send
redo data to the standby database
[Standby

Database]

Edit $ORACLE_HOME/network/admin/tnsnames.ora file

on

standby

server as follow. The first descriptor is connection to the primary database while the second
descriptor is connection to the auxiliary instance (standby database)
LGPROD =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.120.130)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = LGPROD)
)
)
LGPROD_STBY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.120.131)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = LGPROD_STBY)
)
)

[Standby

Database]

Edit $ORACLE_HOME/network/admin/listener.ora file

on

standby

server. The auxiliary instance location must to be hard-coded in this file otherwise RMAN Duplicate
command will fail
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = LGPROD_STBY)

(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = LGPROD)

)
)
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = Lugao-srv02)(PORT = 1521))
)
ADR_BASE_LISTENER = /u01/app/oracle

[Standby Database] Refresh the listener to register the new entries


[oracle@Lugao-srv02 ~]$ lsnrctl reload
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 26-SEP-2014 15:03:25
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=Lugao-srv02)
(PORT=1521)))
The command completed successfully
[oracle@Lugao-srv02 ~]$
[oracle@Lugao-srv02 ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 26-SEP-2014 15:03:35
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=Lugao-srv02)
(PORT=1521)))
STATUS of the LISTENER
-----------------------Alias
LISTENER
Version
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date
26-SEP-2014 15:02:57
Uptime
0 days 0 hr. 0 min. 38 sec
Trace Level
off
Security
ON: Local OS Authentication
SNMP
OFF
Listener Parameter
File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File
/u01/app/oracle/diag/tnslsnr/Lugao-srv02/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=Lugao-srv02)(PORT=1521)))
Services Summary...
Service "LGPROD_STBY" has 1 instance(s).
Instance "LGPROD", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@Lugao-srv02 ~]$

[Primary Database] The $ORACLE_HOME/network/admin/tnsnames.ora file on primary server


needs the following entry to establish connection to the standby database

LGPROD_STBY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.120.131)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = LGPROD_STBY)
)
)

[Primary Database] Test connection to the standby database listener


[oracle@Lugao-srv01 ~]$ tnsping LGPROD_STBY
TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 26-SEP-2014 15:05:31
Copyright (c) 1997, 2009, Oracle. All rights reserved.
Used parameter files:
/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
(HOST = 192.168.120.131)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME =
LGPROD_STBY)))
OK (0 msec)
[oracle@Lugao-srv01 ~]$

[Standby Database] Test connection to the primary database listener


[oracle@Lugao-srv02 ~]$ tnsping LGPROD
TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 26-SEP-2014 15:04:44
Copyright (c) 1997, 2009, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
(HOST = 192.168.120.130)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME =
LGPROD)))
OK (10 msec)
[oracle@Lugao-srv02 ~]$

Create backup of Primary Database


[Primary Database] if you dont have good RMAN backup of primary database use RMAN backup
databasecommand to create backupsets as follows, otherwise execute RMAN backup current
controlfile for standbycommand only to create copy of control file for standby database
[oracle@Lugao-srv01 ~]$ rman

Recovery Manager: Release 11.2.0.1.0 - Production on Fri Sep 26 15:25:51 2014


Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
RMAN> connect target
Connected to target database: LGPROD (DBID=2845440310)
RMAN> backup database include current controlfile for standby plus archivelog;
Starting backup at 26-SEP-14
current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=43 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=4 RECID=1 STAMP=859293903
input archived log thread=1 sequence=5 RECID=2 STAMP=859293921
input archived log thread=1 sequence=6 RECID=3 STAMP=859294105
input archived log thread=1 sequence=7 RECID=4 STAMP=859294108
input archived log thread=1 sequence=8 RECID=5 STAMP=859303195
input archived log thread=1 sequence=9 RECID=6 STAMP=859303195
input archived log thread=1 sequence=10 RECID=7 STAMP=859303635
channel ORA_DISK_1: starting piece 1 at 26-SEP-14
channel ORA_DISK_1: finished piece 1 at 26-SEP-14
piece
handle=/u01/app/oracle/flash_recovery_area/LGPROD/backupset/2014_09_26/o1_mf_annnn_
TAG20140926T152716_b2bpx4kx_.bkp tag=TAG20140926T152716 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 26-SEP-14
Starting backup at 26-SEP-14
using channel ORA_DISK_1
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=/u01/app/oracle/oradata/LGPROD/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/LGPROD/sysaux01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/LGPROD/example01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/LGPROD/undotbs01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/LGPROD/users01.dbf
channel ORA_DISK_1: starting piece 1 at 26-SEP-14
channel ORA_DISK_1: finished piece 1 at 26-SEP-14
piece
handle=/u01/app/oracle/flash_recovery_area/LGPROD/backupset/2014_09_26/o1_mf_nnndf_T
AG20140926T152719_b2bpx7wn_.bkp tag=TAG20140926T152719 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:16
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 26-SEP-14
channel ORA_DISK_1: finished piece 1 at 26-SEP-14
piece
handle=/u01/app/oracle/flash_recovery_area/LGPROD/backupset/2014_09_26/o1_mf_ncnnf_T
AG20140926T152719_b2bpzp9j_.bkp tag=TAG20140926T152719 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01


Finished backup at 26-SEP-14
Starting backup at 26-SEP-14
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=11 RECID=8 STAMP=859303719
channel ORA_DISK_1: starting piece 1 at 26-SEP-14
channel ORA_DISK_1: finished piece 1 at 26-SEP-14
piece
handle=/u01/app/oracle/flash_recovery_area/LGPROD/backupset/2014_09_26/o1_mf_annnn_
TAG20140926T152840_b2bpzr9d_.bkp tag=TAG20140926T152840 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 26-SEP-14
Starting Control File and SPFILE Autobackup at 26-SEP-14
piece
handle=/u01/app/oracle/flash_recovery_area/LGPROD/autobackup/2014_09_26/o1_mf_s_859
303721_b2bpzwp7_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 26-SEP-14

Copy Files to the Standby Server


[Standby Database] Create any missing Oracle directories on the standby server as specified in text
initialization file for standby database as follows:
[oracle@Lugao-srv02 ~]$ mkdir -p /u01/app/oracle/admin/LGPROD/adump
[oracle@Lugao-srv02 ~]$ mkdir -p /u01/app/oracle/oradata/LGPROD_STBY/
[oracle@Lugao-srv02 ~]$ mkdir /u01/app/oracle/flash_recovery_area
[Primary Database] Move the files (parameter file, password file and backup files) to the standby
server as follows:
[oracle@Lugao-srv01 ~]$ scp -r /home/oracle/pfilelgprod.ora
192.168.120.131:/home/oracle/pfilelgprod.ora
The authenticity of host '192.168.120.131 (192.168.120.131)' can't be established.
RSA key fingerprint is 8d:7e:35:28:0f:c9:50:ef:31:ae:b2:84:96:ea:24:9d.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.120.131' (RSA) to the list of known hosts.
oracle@192.168.120.131's password:
pfilelgprod.ora
100%
1134
1.1KB/s 00:00
[oracle@Lugao-srv01 ~]$
[oracle@Lugao-srv01 ~]$
[oracle@Lugao-srv01 ~]$ scp -r /u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwLGPROD
192.168.120.131:/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwLGPROD
oracle@192.168.120.131's password:
orapwLGPROD
100%
1536
1.5KB/s 00:00
[oracle@Lugao-srv01 ~]$
[oracle@Lugao-srv01 ~]$
[oracle@Lugao-srv01 ~]$ scp -r /u01/app/oracle/flash_recovery_area/LGPROD/backupset
192.168.120.131:/u01/app/oracle/flash_recovery_area/LGPROD/backupset/

oracle@192.168.120.131's password:
o1_mf_annnn_TAG20140926T152840_b2bpzr9d_.bkp
36KB 35.5KB/s 00:00
o1_mf_annnn_TAG20140926T152716_b2bpx4kx_.bkp
14MB 14.3MB/s 00:01
o1_mf_nnndf_TAG20140926T152719_b2bpx7wn_.bkp
1015MB 9.5MB/s 01:47
o1_mf_ncnnf_TAG20140926T152719_b2bpzp9j_.bkp
9568KB 9.3MB/s 00:01
[oracle@Lugao-srv01 ~]$

100%
100%
100%
100%

Prepare Auxiliary Instance


RMAN Duplicate command use auxiliary instance to create standby database
[Standby Database] Use the parameter files shipped from primary database to start the auxiliary
instance to the no mount state
[oracle@Lugao-srv02 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Fri Sep 26 16:07:33 2014
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount pfile='/home/oracle/pfilelgprod.ora'
ORACLE instance started.
Total System Global Area 146472960 bytes
Fixed Size
1335080 bytes
Variable Size
92274904 bytes
Database Buffers
50331648 bytes
Redo Buffers
2531328 bytes

[Standby Database] Make SPFILE for auxiliary instance, shutdown the instance then start the
instance in nomount state with a new parameter file
SQL> create spfile from pfile='/home/oracle/pfilelgprod.ora';
File created.
SQL>
SQL> shutdown immediate;
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 146472960 bytes
Fixed Size
1335080 bytes
Variable Size
92274904 bytes
Database Buffers
50331648 bytes
Redo Buffers
2531328 bytes

Duplicate the Database


[Standby Database] Start RMAN executable, connect to the primary database, connect to the
auxiliary instance and then duplicate the database using duplicate target database for
standby nofilenamecheck dorecovercommand
[oracle@Lugao-srv02 ~]$ rman
Recovery Manager: Release 11.2.0.1.0 - Production on Fri Sep 26 16:09:20 2014
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
RMAN> connect target sys@LGPROD
target database Password:
connected to target database: LGPROD (DBID=2845440310)
RMAN> connect auxiliary sys@LGPROD_STBY
auxiliary database Password:
connected to auxiliary database: LGPROD (not mounted)
RMAN> duplicate target database for standby nofilenamecheck dorecover;
Starting Duplicate Db at 26-SEP-14
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=20 device type=DISK
contents of Memory Script:
{
set until scn 857665;
restore clone standby controlfile;
}
executing Memory Script
executing command: SET until clause
Starting restore at 26-SEP-14
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece
/u01/app/oracle/flash_recovery_area/LGPROD/backupset/2014_09_26/o1_mf_ncnnf_TAG2014
0926T152719_b2bpzp9j_.bkp
channel ORA_AUX_DISK_1: piece
handle=/u01/app/oracle/flash_recovery_area/LGPROD/backupset/2014_09_26/o1_mf_ncnnf_T
AG20140926T152719_b2bpzp9j_.bkp tag=TAG20140926T152719
channel ORA_AUX_DISK_1: restored backup piece 1

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03


output file name=/u01/app/oracle/oradata/LGPROD_STBY/control01.ctl
output file name=/u01/app/oracle/oradata/LGPROD_STBY/control02.ctl
Finished restore at 26-SEP-14
contents of Memory Script:
{
sql clone 'alter database mount standby database';
}
executing Memory Script
sql statement: alter database mount standby database
contents of Memory Script:
{
set until scn 857665;
set newname for tempfile 1 to
"/u01/app/oracle/oradata/LGPROD_STBY/temp01.dbf";
switch clone tempfile all;
set newname for datafile 1 to
"/u01/app/oracle/oradata/LGPROD_STBY/system01.dbf";
set newname for datafile 2 to
"/u01/app/oracle/oradata/LGPROD_STBY/sysaux01.dbf";
set newname for datafile 3 to
"/u01/app/oracle/oradata/LGPROD_STBY/undotbs01.dbf";
set newname for datafile 4 to
"/u01/app/oracle/oradata/LGPROD_STBY/users01.dbf";
set newname for datafile 5 to
"/u01/app/oracle/oradata/LGPROD_STBY/example01.dbf";
restore
clone database
;
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
renamed tempfile 1 to /u01/app/oracle/oradata/LGPROD_STBY/temp01.dbf in control file
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 26-SEP-14

using channel ORA_AUX_DISK_1


channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to
/u01/app/oracle/oradata/LGPROD_STBY/system01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00002 to
/u01/app/oracle/oradata/LGPROD_STBY/sysaux01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to
/u01/app/oracle/oradata/LGPROD_STBY/undotbs01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to
/u01/app/oracle/oradata/LGPROD_STBY/users01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00005 to
/u01/app/oracle/oradata/LGPROD_STBY/example01.dbf
channel ORA_AUX_DISK_1: reading from backup piece
/u01/app/oracle/flash_recovery_area/LGPROD/backupset/2014_09_26/o1_mf_nnndf_TAG2014
0926T152719_b2bpx7wn_.bkp
channel ORA_AUX_DISK_1: piece
handle=/u01/app/oracle/flash_recovery_area/LGPROD/backupset/2014_09_26/o1_mf_nnndf_T
AG20140926T152719_b2bpx7wn_.bkp tag=TAG20140926T152719
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:15
Finished restore at 26-SEP-14
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy RECID=2 STAMP=859306707 file
name=/u01/app/oracle/oradata/LGPROD_STBY/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=3 STAMP=859306707 file
name=/u01/app/oracle/oradata/LGPROD_STBY/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=4 STAMP=859306707 file
name=/u01/app/oracle/oradata/LGPROD_STBY/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=5 STAMP=859306707 file
name=/u01/app/oracle/oradata/LGPROD_STBY/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=6 STAMP=859306707 file
name=/u01/app/oracle/oradata/LGPROD_STBY/example01.dbf
contents of Memory Script:
{
set until scn 857665;
recover
standby
clone database
delete archivelog
;

}
executing Memory Script
executing command: SET until clause
Starting recover at 26-SEP-14
using channel ORA_AUX_DISK_1
starting media recovery
channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=11
channel ORA_AUX_DISK_1: reading from backup piece
/u01/app/oracle/flash_recovery_area/LGPROD/backupset/2014_09_26/o1_mf_annnn_TAG2014
0926T152840_b2bpzr9d_.bkp
channel ORA_AUX_DISK_1: piece
handle=/u01/app/oracle/flash_recovery_area/LGPROD/backupset/2014_09_26/o1_mf_annnn_
TAG20140926T152840_b2bpzr9d_.bkp tag=TAG20140926T152840
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
archived log file
name=/u01/app/oracle/flash_recovery_area/LGPROD_STBY/archivelog/2014_09_26/o1_mf_1_
11_b2bsx5y8_.arc thread=1 sequence=11
channel clone_default: deleting archived log(s)
archived log file
name=/u01/app/oracle/flash_recovery_area/LGPROD_STBY/archivelog/2014_09_26/o1_mf_1_
11_b2bsx5y8_.arc RECID=1 STAMP=859306709
media recovery complete, elapsed time: 00:00:02
Finished recover at 26-SEP-14
Finished Duplicate Db at 26-SEP-14

Start Automatic Apply


[Standby Database] Issue the following commands to start Automatic Redo Apply then initiate redo
log shipping by doing several log switch on the primary database
SQL> shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL>
SQL> startup nomount
ORACLE instance started.
Total System Global Area 146472960 bytes
Fixed Size
1335080 bytes
Variable Size
92274904 bytes
Database Buffers
50331648 bytes
Redo Buffers
2531328 bytes
SQL>
SQL> alter database mount standby database;

Database altered.
SQL> alter database recover managed standby database disconnect;
Database altered.
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
SQL> /
System altered.
SQL> /
System altered.
SQL>

Verification
Now that the standby database is up and running you need to make sure redo is getting transferred
properly to the standby.
[Primary Database] Check the status of online redo log
SQL> select group#, sequence#, status from v$log;
GROUP# SEQUENCE# STATUS
---------- ---------- ---------------1
19 CURRENT
2
17 INACTIVE
3
18 INACTIVE

[Standby Database] Check the status of online redo log. Inactive log (sequence# 17 and 18) from
primary database already applied to the standby database
SQL> select group#, sequence#, status from v$log;
GROUP# SEQUENCE# STATUS
---------- ---------- ---------------1
19 CLEARING_CURRENT
3
18 CLEARING
2
17 CLEARING

[Standby Database] Verify automatic apply process (Managed Recovery Process, MRP) on standby
database is started
SQL> select process, status, sequence# from v$managed_standby;
PROCESS STATUS
SEQUENCE#
--------- ------------ ---------ARCH
CONNECTED
0
ARCH
CONNECTED
0
ARCH
CONNECTED
0
ARCH
CONNECTED
0
RFS
IDLE
0
RFS
IDLE
19
MRP0
WAIT_FOR_LOG
19
7 rows selected.

Posted 16th October 2014 by Sadock Obeth


0

Add a comment

8.
JUL

22

SQL to Split Full Name into First Name, Middle Names, and Last
Name in Oracle
Today morning my colleague ask me the query to split the full name stored in a single filed in the
table into First Name, Middle Names and Last name in Oracle database. After a lot of brainstorming,
using SUBSTR and INSTR functions I came out with just simple query as follows
SQL to Create Sample Table
SQL> create table testnames (fullname varchar2(30));
Table created.
SQL>
SQL to Insert Sample Data
SQL> insert into testnames values ('Sadock Obeth');
1 row created.
SQL> insert into testnames values ('Emmanuel Obeth Nyaluke');
1 row created.
SQL> insert into testnames values ('William Obeth Salon Nyaluke');

1 row created.
SQL>
Sample Data in Table
SQL> select * from testnames;
FULLNAME
-----------------------------Sadock Obeth
Emmanuel Obeth Nyaluke
William Obeth Salon Nyaluke
SQL>
Query to Split Names
SQL> select
2 SUBSTR(fullname, 1, INSTR(fullname, ' ', 1, 1)-1) fname,
3 SUBSTR(fullname,
INSTR(fullname, ' ', 1)+1,
INSTR(fullname, ' ', -1,1) - INSTR(fullname, ' ', 1,1)-1) Mnames,
4 SUBSTR(fullname, INSTR(fullname, ' ', -1)+1) lname
5 from testnames;
FNAME
MNAMES
LNAME
---------- ------------- ---------Sadock
Obeth
Emmanuel Obeth
Nyaluke
William Obeth Salon Nyaluke
SQL>
Posted 22nd July 2014 by Sadock Obeth
2

View comments

9.
MAY

Creating Snapshot Standby Database


A snapshot standby database is a fully read-write standby database that is created from physical
standby database. Snapshot standby database continue to receive archive log from primary
database but stop applying them. When snapshot standby database is brought back to physical
standby database, it discard all local changes made to the database then start to accept redo apply

A snapshot standby database provides disaster recovery and data protection benefits that are similar
to those of a physical standby database, however it should be used in case you need to benefit from
temporary read-write standby database
When a physical standby database is converted into a snapshot standby database an implicit
guaranteed restore point is created. This guaranteed restore point is used to flashback a snapshot
standby to its original state when it is converted back into a physical standby database.
The following example shows the physical standby database is running in ready only which does not
permit update to the data
SQL> select status,instance_name,database_role,open_mode
2 from v$database,v$instance;
STATUS
INSTANCE_NAME DATABASE_ROLE OPEN_MODE
------------ ---------------- ---------------- -------------------OPEN
PCB_STBY
PHYSICAL STANDBY READ ONLY WITH APPLY
SQL> update hr.departments set department_name= 'Admin'
2 where department_id=10;
update hr.departments set department_name= 'Admin'
*
ERROR at line 1:
ORA-16000: database open for read-only access

How to Setup?

To throw away all local changes made to the database when it is switched back to physical standby
state snapshot standby database use flashback database, however the standby database does not
need to have flashback database explicitly enabled.
Step 1: Shutdown the database then bring back to mount state
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
SQL> startup mount
ORACLE instance started.
Total System Global Area 613797888 bytes
Fixed Size
2215824 bytes
Variable Size
369098864 bytes
Database Buffers
239075328 bytes
Redo Buffers
3407872 bytes
Database mounted.
SQL>
SQL> select flashback_on FROM v$database;
FLASHBACK_ON
-----------------NO

Step 2: Convert the Standby to a Snapshot Standby


SQL> ALTER DATABASE CONVERT TO SNAPSHOT STANDBY;
Database altered.
SQL> alter database open;
Database altered.
SQL> SELECT flashback_on FROM v$database;
FLASHBACK_ON
-----------------RESTORE POINT ONLY
Step 3: Verification
Once the standby is snapshot you can do almost any kind of DML operations that change the
data as the following example shows
SQL> select status,instance_name,database_role,open_mode from v$database,v$instance;
STATUS
INSTANCE_NAME DATABASE_ROLE OPEN_MODE
------------ ---------------- ---------------- -------------------OPEN
PCB_STBY
SNAPSHOT STANDBY READ WRITE
SQL> update hr.departments set department_name= 'Admin'
2 where department_id=10;
1 row updated.
SQL> commit;
Commit complete.
SQL> select * from hr.departments where department_id=10;
DEPARTMENT_ID DEPARTMENT_NAME
MANAGER_ID LOCATION_ID
------------- ------------------------------ ---------- ----------10 Admin
200
1700

Converting Snapshot Standby Back to Physical Standby Database

As stated once the snapshot is bought back to physical all changes after guarantee restore point
created are lost and the restore point is dropped, redo apply can be started and all redo received by
the snapshot standby database will be applied
Step 1: Shutdown the database then bring back to mount state
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
SQL>
SQL> startup mount
ORACLE instance started.

Total System Global Area 613797888 bytes


Fixed Size
2215824 bytes
Variable Size
369098864 bytes
Database Buffers
239075328 bytes
Redo Buffers
3407872 bytes
Database mounted.

Step 2: Covert the Snapshot to Physical Standby

SQL> ALTER DATABASE CONVERT TO PHYSICAL STANDBY;


Database altered.
SQL>

Step 3: Start Redo Apply


Depending on your requirements, you may want to start MRP to automate standby recovery or use
manual standby recovery. This example start MRP
SQL> shutdown immediate
ORA-01507: database not mounted
ORACLE instance shut down.
SQL>
SQL> startup nomount
ORACLE instance started.
Total System Global Area 613797888 bytes
Fixed Size
2215824 bytes
Variable Size
369098864 bytes
Database Buffers
239075328 bytes
Redo Buffers
3407872 bytes
SQL>
SQL> alter database mount standby database;
Database altered.
SQL> alter database open;
Database altered.
SQL>
SQL> alter database recover managed standby database using current logfile disconnect
from session;
Database altered.
Step 4: Verification:
Notice the restore point dropped and local changes of department name discarded
SQL> select flashback_on FROM v$database;
FLASHBACK_ON
-----------------NO
SQL> select status,instance_name,database_role,open_mode from v$database,v$instance;
STATUS
INSTANCE_NAME DATABASE_ROLE OPEN_MODE
------------ ---------------- ---------------- -------------------OPEN
PCB_STBY
PHYSICAL STANDBY READ ONLY WITH APPLY
SQL> select * from hr.departments where department_id=10;

DEPARTMENT_ID DEPARTMENT_NAME
MANAGER_ID LOCATION_ID
------------- ------------------------------ ---------- ----------10 Administration
200
1700

Note from Oracle doc: Flashback Database is used to convert a snapshot standby database back
into a physical standby database. Any operation that cannot be reversed using Flashback Database
technology will prevent a snapshot standby from being converted back to a physical standby
Thanks, Sadock

References
Oracle Database Document Library: Oracle Data Guard Concepts and Administration 11g R2
Oracle Base: Data Guard Physical Standby Setup in Oracle Database 11g Release 2
Posted 8th May 2014 by Sadock Obeth
0

Add a comment

10.
MAY

Oracle Database Active Data Guard (Real-time Query)


In Oracle data guard configuration standby database is often opened in mount state that allow query
against fixed tables only but not against users data
SQL> select * from hr.departments;
select * from hr.departments
*
ERROR at line 1:
ORA-01219: database not open: queries allowed on fixed tables/views only
SQL> select status,instance_name,database_role,open_mode
2 from v$database,v$instance;
STATUS
INSTANCE_NAME DATABASE_ROLE OPEN_MODE
------------ ---------------- ---------------- -------------------MOUNTED
PCB_STBY
PHYSICAL STANDBY MOUNTED

However, it can be opened in ready only mode to allow queries against users data. This help to
offload some of the operations against production database to the standby database such as
backups and reporting

SQL> alter database open read only;


Database altered.
SQL> select status,instance_name,database_role,open_mode
2 from v$database,v$instance;
STATUS
INSTANCE_NAME DATABASE_ROLE OPEN_MODE
------------ ---------------- ---------------- -------------------OPEN
PCB_STBY
PHYSICAL STANDBY READ ONLY
SQL> select * from hr.departments
2 where department_id=10;
DEPARTMENT_ID DEPARTMENT_NAME
MANAGER_ID LOCATION_ID
------------- ------------------------------ ---------- ----------10 Administration
200
1700
SQL> select process,status,sequence#
2> from v$managed_standby;
PROCESS STATUS
SEQUENCE#
--------- ------------ ---------ARCH
CONNECTED
0
ARCH
CONNECTED
0
ARCH
CONNECTED
0
ARCH
CLOSING
81
RFS
IDLE
82
RFS
IDLE
0
6 rows selected.

When the database is open in ready only mode, archive log shipping from primary database
continue but Managed Recover Process (MRP) stops applying them on the standby database. This
makes the standby database to becomes increasingly out of date until MRP is resumed

Active Data Guard


Oracle Database 11g introduced Active Data Guard feature which permit to open the database in
ready only mode while allowing the MRP continue to apply the redo data to the standby database on
background. However there are licensing implications for this feature, but the following test
configuration shows to how to enable
SQL> alter database recover managed standby database using current logfile disconnect
from session;
Database altered.
SQL> select process,status,sequence#
2>from v$managed_standby;

PROCESS STATUS
SEQUENCE#
--------- ------------ ---------ARCH
CONNECTED
0
ARCH
CONNECTED
0
ARCH
CONNECTED
0
ARCH
CLOSING
81
RFS
IDLE
82
RFS
IDLE
0
MRP0
APPLYING_LOG
82
7 rows selected.
SQL> select status,instance_name,database_role,open_mode
2 from v$database, v$instance;
STATUS
INSTANCE_NAME DATABASE_ROLE OPEN_MODE
------------ ---------------- ---------------- -------------------OPEN
PCB_STBY
PHYSICAL STANDBY READ ONLY WITH APPLY
SQL> select * from hr.departments
2 where department_id=10;
DEPARTMENT_ID DEPARTMENT_NAME
MANAGER_ID LOCATION_ID
------------- ------------------------------ ---------- ----------10 Administration
200
1700

Here, you can see that the MRP is active and is applying log sequence 82 and also the physical
standby database is opened in READ-ONLY mode which allow users to use the standby database
for querying data
Note the following:
Mounted Standby database cannot be opened if MRP is active on background. See example below
SQL> shutdown immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL>
SQL> startup nomount
ORACLE instance started.
Total System Global Area 613797888 bytes
Fixed Size
2215824 bytes
Variable Size
369098864 bytes
Database Buffers
239075328 bytes
Redo Buffers
3407872 bytes
SQL>
SQL> alter database mount standby database;
Database altered.
SQL> select process,status,sequence#
2> from v$managed_standby;

PROCESS STATUS
SEQUENCE#
--------- ------------ ---------ARCH
CONNECTED
0
ARCH
CONNECTED
0
ARCH
CONNECTED
0
ARCH
CONNECTED
0
SQL> alter database recover managed standby database using current logfile disconnect
from session;
Database altered.
SQL> select process,status,sequence#
2> from v$managed_standby;
PROCESS STATUS
SEQUENCE#
--------- ------------ ---------ARCH
CONNECTED
0
ARCH
CONNECTED
0
ARCH
CONNECTED
0
ARCH
CONNECTED
0
MRP0
APPLYING_LOG
103
SQL> select status,instance_name,database_role,open_mode
2>from v$database,v$instance;
STATUS
INSTANCE_NAME DATABASE_ROLE OPEN_MODE
------------ ---------------- ---------------- ---------MOUNTED
PCB_STBY
PHYSICAL STANDBY MOUNTED
SQL> alter database open read only;
alter database open read only
*
ERROR at line 1:
ORA-10456: cannot open standby database; media recovery session may be in
progress

You will end up getting the error message "ORA-10456: cannot open standby database;
media recovery session may be in progress" when you attempt to open the standby database
having MRP active. In this case you need stop MRP first, open a standby instance read-only, and
then turn on Active Data Guard as follows:
SQL> alter database recover managed standby database cancel;
Database altered.
SQL> alter database open read only;
Database altered.

SQL> alter database recover managed standby database using current logfile disconnect
from session;
Database altered.
SQL> select process,status,sequence# from v$managed_standby;
PROCESS STATUS
SEQUENCE#
--------- ------------ ---------ARCH
CLOSING
103
ARCH
CONNECTED
0
ARCH
CONNECTED
0
ARCH
CONNECTED
0
MRP0
APPLYING_LOG
104
RFS
IDLE
104
RFS
IDLE
0
7 rows selected.
SQL> select status,instance_name,database_role,open_mode from v$database,v$instance;
STATUS
INSTANCE_NAME DATABASE_ROLE OPEN_MODE
------------ ---------------- ---------------- -------------------OPEN
PCB_STBY
PHYSICAL STANDBY READ ONLY WITH APPLY

Posted 7th May 2014 by Sadock Obeth


0

Add a comment

Loading
Dynamic Views template. Powered by Blogger.