Previous steps are here:
step 1
step 2
step 3
step 4
- Net Service configuration on your primary to reach your standby database:
Now it's time to configure the Oracle Net Service Name on the primary database to reach the physical standby database. In a later step I will copy this tnsnames.ora file also to the physical standby machine
because of course that machine has to know where is the primary database.
[oracle@vsi08devpom admin]$ vi /opt/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
DB01PRMR =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = vsi08devpom.MYDOMAIN.it)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = DB01prmr)
)
)
DB01SBY1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = vsi10devpom.MYDOMAIN.it)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = DB01sby1)
)
)
- Copy the password file and tnsnames.ora to the physical standby database:
Just remember to rename the password file (located in
$ORACLE_HOME/dbs/orapw) on the physical standby database machine with the SID used on that machine (in my case is DB01sby1)
Check on both machines the file /etc/hosts.
[root@vsi08devpom ~]# vi /etc/hosts
127.0.0.1 vsi08devpom.MYDOMAIN.it vsi08devpom localhost.localdomain localhost
172.16.151.78 vsi08devpom.MYDOMAIN.it vsi08devpom
172.16.151.80 vsi10devpom.MYDOMAIN.it vsi10devpom
[root@vsi10devpom ~]# vi /etc/hosts
127.0.0.1 vsi10devpom.MYDOMAIN.it vsi10devpom localhost.localdomain localhost
172.16.151.80 vsi10devpom.MYDOMAIN.it vsi10devpom
172.16.151.78 vsi08devpom.MYDOMAIN.it vsi08devpom
Copy the password file from the primary database machine ($ORACLE_HOME/dbs/orapwDB01prmr) and rename it to the physical standby database name.
The username is required to be SYS and the password needs to be the same on the Primary and Standby.
The password file name must match the instance name/SID used at the standby site, not the DB_NAME.
[oracle@vsi08devpom dbs]$ cp /opt/app/oracle/product/11.2.0/db_1/dbs/orapwDB01prmr /opt/app/oracle/product/11.2.0/db_1/dbs/orapwDB01sby1
[oracle@vsi08devpom dbs]$ scp /opt/app/oracle/product/11.2.0/db_1/dbs/orapwDB01sby1 vsi10devpom:/opt/app/oracle/product/11.2.0/db_1/dbs/
The authenticity of host 'vsi10devpom (172.16.151.80)' can't be established.
RSA key fingerprint is 8c:0a:81:5e:42:09:5a:60:cd:32:3e:5f:49:35:41:6c.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'vsi10devpom,172.16.151.80' (RSA) to the list of known hosts.
oracle@vsi10devpom's password:
orapwDB01sby1 100% 1536 1.5KB/s 00:00
[oracle@vsi08devpom dbs]$ rm /opt/app/oracle/product/11.2.0/db_1/dbs/orapwDB01sby1
Copy the tnsnames.ora file from the primary database machine to physical standby database
[oracle@vsi08devpom dbs]$ scp /opt/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora vsi10devpom:/opt/app/oracle/product/11.2.0/db_1/network/admin/
oracle@vsi10devpom's password:
tnsnames.ora
- Listener and initialization parameter file configurations on the physical standby database:
Because you have to start your standby database on NO MOUNT mode you have to configure your listener.ora in the following way:
[oracle@vsi10devpom admin]$ vi /opt/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
SID_LIST_LISTENER =
(SID_LIST=
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME=/opt/app/oracle/product/11.2.0/db_1)
(PROGRAM = extproc)
)
(SID_DESC=
(GLOBAL_DBNAME=DB01SBY1)
(ORACLE_HOME=/opt/app/oracle/product/11.2.0/db_1)
(SID_NAME=DB01SBY1)
)
)
ADR_BASE_LISTENER = /opt/app/oracle
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = vsi10devpom.MYDOMAIN.it)(PORT = 1521))
)
and put only the following initialization parameters:
[oracle@vsi10devpom dbs]$ echo "db_name='DB01prmr'" > pfile_DB01prmr.ora
[oracle@vsi10devpom dbs]$ echo "db_unique_name='DB01sby1'" >> pfile_DB01prmr.ora
[oracle@vsi10devpom dbs]$ echo "db_block_size=8192" >> pfile_DB01prmr.ora
[oracle@vsi10devpom dbs]$ cat pfile_DB01prmr.ora
db_name='DB01prmr'
db_unique_name='DB01sby1'
db_block_size=8192
- Create the directory structures on the physical standby:
Under /opt/app/oracle ($ORACLE_BASE) create the audit trail directory, the flash recovery area directory
and the directory for the datafiles:
[oracle@vsi10devpom ~]$ cd $ORACLE_BASE
[oracle@vsi10devpom oracle]$ ll
total 12
drwxr-xr-x 2 oracle oinstall 4096 Jun 6 15:40 checkpoints
drwxrwx--- 7 oracle oinstall 4096 Jun 6 15:34 oraInventory
drwxrwx--- 4 oracle oinstall 4096 Jun 6 14:41 product
[oracle@vsi10devpom oracle]$ mkdir -p admin/DB01sby1/adump
[oracle@vsi10devpom oracle]$ mkdir -p oradata/DB01sby1
[oracle@vsi10devpom oracle]$ mkdir -p flash_recovery_area/DB01sby1
- Start the listener on physical standby:
[oracle@vsi10devpom admin]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 10-JUL-2012 15:18:16
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Starting /opt/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /opt/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Log messages written to /opt/app/oracle/diag/tnslsnr/vsi10devpom/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=vsi10devpom.MYDOMAIN.it)(PORT=1521)))
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 10-JUL-2012 15:18:16
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File /opt/app/oracle/diag/tnslsnr/vsi10devpom/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=vsi10devpom.MYDOMAIN.it)(PORT=1521)))
Services Summary...
Service "DB01sby1" has 2 instance(s).
Instance "DB01sby1", status UNKNOWN, has 1 handler(s) for this service...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
- Set the ORACLE_SID env variable on the standby oracle user and start the standby-instance
Start up the physical standby database in NO MOUNT mode with the previuosly created initialization pfile (export ORACLE_SID=DB01sby1):
SQL> startup nomount pfile=$ORACLE_HOME/dbs/pfile_DB01prmr.ora
- Verify the connection 'AS SYSDBA' is working from and to both machines:
[oracle@vsi08devpom ~]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on Thu Jul 12 13:10:54 2012
Copyright (c) 1982, 2009, Oracle. All rights reserved.
SQL> connect sys/oracle@DB01prmr as sysdba
Connected.
SQL> connect sys/oracle@DB01sby1 as sysdba
Connected.
[oracle@vsi10devpom ~]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on Thu Jul 12 13:12:28 2012
Copyright (c) 1982, 2009, Oracle. All rights reserved.
SQL> connect sys/oracle@DB01prmr as sysdba
Connected.
SQL> connect sys/oracle@DB01sby1 as sysdba
Connected.
- Invoking the RMAN script:
From a rman command line on the primary database machine run the following script:
[oracle@vsi08devpom DB01prmr]$ rman target sys/oracle@db01prmr auxiliary sys/oracle@db01sby1
Recovery Manager: Release 11.2.0.1.0 - Production on Wed Jul 11 14:53:09 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: DB01PRMR (DBID=2874530197)
connected to auxiliary database: DB01PRMR (not mounted)
Copy and paste your RMAN script. My script was the following:
RMAN> run {
allocate channel prmy1 type disk;
allocate channel prmy2 type disk;
allocate auxiliary channel stby type disk;
DUPLICATE TARGET DATABASE FOR STANDBY FROM ACTIVE DATABASE nofilenamecheck
spfile
parameter_value_convert 'DB01prmr','DB01sby1'
set db_unique_name='DB01sby1'
set db_file_name_convert='/DB01prmr/','/DB01sby1/'
set log_file_name_convert='/DB01prmr/','/DB01sby1/'
set control_files='/opt/app/oracle/oradata/DB01sby1.ctl'
set log_archive_max_processes='5'
set fal_client='DB01sby1'
set fal_server='DB01prmr'
set standby_file_management='AUTO'
set log_archive_config='dg_config=(DB01prmr,DB01sby1)'
set log_archive_dest_2='SERVICE=DB01prmr ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=DB01prmr';
}
And here is the output generated:
using target database control file instead of recovery catalog
allocated channel: prmy1
channel prmy1: SID=27 device type=DISK
allocated channel: prmy2
channel prmy2: SID=24 device type=DISK
allocated channel: stby
channel stby: SID=10 device type=DISK
Starting Duplicate Db at 11-JUL-12
contents of Memory Script:
{
backup as copy reuse
targetfile '/opt/app/oracle/product/11.2.0/db_1/dbs/orapwDB01prmr' auxiliary format
'/opt/app/oracle/product/11.2.0/db_1/dbs/orapwDB01sby1' targetfile
'/opt/app/oracle/product/11.2.0/db_1/dbs/spfileDB01prmr.ora' auxiliary format
'/opt/app/oracle/product/11.2.0/db_1/dbs/spfileDB01sby1.ora' ;
sql clone "alter system set spfile= ''/opt/app/oracle/product/11.2.0/db_1/dbs/spfileDB01sby1.ora''";
}
executing Memory Script
Starting backup at 11-JUL-12
Finished backup at 11-JUL-12
sql statement: alter system set spfile= ''/opt/app/oracle/product/11.2.0/db_1/dbs/spfileDB01sby1.ora''
contents of Memory Script:
{
sql clone "alter system set audit_file_dest =
''/opt/app/oracle/admin/DB01sby1/adump'' comment=
'''' scope=spfile";
sql clone "alter system set dispatchers =
''(PROTOCOL=TCP) (SERVICE=DB01sby1XDB)'' comment=
'''' scope=spfile";
sql clone "alter system set db_unique_name =
''DB01sby1'' comment=
'''' scope=spfile";
sql clone "alter system set db_file_name_convert =
''/DB01prmr/'', ''/DB01sby1/'' comment=
'''' scope=spfile";
sql clone "alter system set log_file_name_convert =
''/DB01prmr/'', ''/DB01sby1/'' comment=
'''' scope=spfile";
sql clone "alter system set control_files =
''/opt/app/oracle/oradata/DB01sby1.ctl'' comment=
'''' scope=spfile";
sql clone "alter system set log_archive_max_processes =
5 comment=
'''' scope=spfile";
sql clone "alter system set fal_client =
''DB01sby1'' comment=
'''' scope=spfile";
sql clone "alter system set fal_server =
''DB01prmr'' comment=
'''' scope=spfile";
sql clone "alter system set standby_file_management =
''AUTO'' comment=
'''' scope=spfile";
sql clone "alter system set log_archive_config =
''dg_config=(DB01prmr,DB01sby1)'' comment=
'''' scope=spfile";
sql clone "alter system set log_archive_dest_2 =
''SERVICE=DB01prmr ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=DB01prmr'' comment=
'''' scope=spfile";
shutdown clone immediate;
startup clone nomount;
}
executing Memory Script
sql statement: alter system set audit_file_dest = ''/opt/app/oracle/admin/DB01sby1/adump'' comment= '''' scope=spfile
sql statement: alter system set dispatchers = ''(PROTOCOL=TCP) (SERVICE=DB01sby1XDB)'' comment= '''' scope=spfile
sql statement: alter system set db_unique_name = ''DB01sby1'' comment= '''' scope=spfile
sql statement: alter system set db_file_name_convert = ''/DB01prmr/'', ''/DB01sby1/'' comment= '''' scope=spfile
sql statement: alter system set log_file_name_convert = ''/DB01prmr/'', ''/DB01sby1/'' comment= '''' scope=spfile
sql statement: alter system set control_files = ''/opt/app/oracle/oradata/DB01sby1.ctl'' comment= '''' scope=spfile
sql statement: alter system set log_archive_max_processes = 5 comment= '''' scope=spfile
sql statement: alter system set fal_client = ''DB01sby1'' comment= '''' scope=spfile
sql statement: alter system set fal_server = ''DB01prmr'' comment= '''' scope=spfile
sql statement: alter system set standby_file_management = ''AUTO'' comment= '''' scope=spfile
sql statement: alter system set log_archive_config = ''dg_config=(DB01prmr,DB01sby1)'' comment= '''' scope=spfile
sql statement: alter system set log_archive_dest_2 = ''SERVICE=DB01prmr ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=DB01prmr'' comment= '''' scope=spfile
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 1686925312 bytes
Fixed Size 2213976 bytes
Variable Size 989857704 bytes
Database Buffers 687865856 bytes
Redo Buffers 6987776 bytes
allocated channel: stby
channel stby: SID=396 device type=DISK
contents of Memory Script:
{
backup as copy current controlfile for standby auxiliary format '/opt/app/oracle/oradata/DB01sby1.ctl';
}
executing Memory Script
Starting backup at 11-JUL-12
channel prmy1: starting datafile copy
copying standby control file
output file name=/opt/app/oracle/product/11.2.0/db_1/dbs/snapcf_DB01prmr.f tag=TAG20120711T145336 RECID=5 STAMP=788367217
channel prmy1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 11-JUL-12
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 newname for tempfile 1 to
"/opt/app/oracle/oradata/DB01sby1/temp01.dbf";
switch clone tempfile all;
set newname for datafile 1 to
"/opt/app/oracle/oradata/DB01sby1/system01.dbf";
set newname for datafile 2 to
"/opt/app/oracle/oradata/DB01sby1/sysaux01.dbf";
set newname for datafile 3 to
"/opt/app/oracle/oradata/DB01sby1/undotbs01.dbf";
set newname for datafile 4 to
"/opt/app/oracle/oradata/DB01sby1/users01.dbf";
set newname for datafile 5 to
"/opt/app/oracle/oradata/DB01sby1/example01.dbf";
backup as copy reuse
datafile 1 auxiliary format
"/opt/app/oracle/oradata/DB01sby1/system01.dbf" datafile
2 auxiliary format
"/opt/app/oracle/oradata/DB01sby1/sysaux01.dbf" datafile
3 auxiliary format
"/opt/app/oracle/oradata/DB01sby1/undotbs01.dbf" datafile
4 auxiliary format
"/opt/app/oracle/oradata/DB01sby1/users01.dbf" datafile
5 auxiliary format
"/opt/app/oracle/oradata/DB01sby1/example01.dbf" ;
sql 'alter system archive log current';
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /opt/app/oracle/oradata/DB01sby1/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 backup at 11-JUL-12
channel prmy1: starting datafile copy
input datafile file number=00002 name=/opt/app/oracle/oradata/DB01prmr/sysaux01.dbf
channel prmy2: starting datafile copy
input datafile file number=00001 name=/opt/app/oracle/oradata/DB01prmr/system01.dbf
output file name=/opt/app/oracle/oradata/DB01sby1/system01.dbf tag=TAG20120711T145343
channel prmy2: datafile copy complete, elapsed time: 00:00:45
channel prmy2: starting datafile copy
input datafile file number=00005 name=/opt/app/oracle/oradata/DB01prmr/example01.dbf
output file name=/opt/app/oracle/oradata/DB01sby1/sysaux01.dbf tag=TAG20120711T145343
channel prmy1: datafile copy complete, elapsed time: 00:00:52
channel prmy1: starting datafile copy
input datafile file number=00003 name=/opt/app/oracle/oradata/DB01prmr/undotbs01.dbf
output file name=/opt/app/oracle/oradata/DB01sby1/example01.dbf tag=TAG20120711T145343
channel prmy2: datafile copy complete, elapsed time: 00:00:07
channel prmy2: starting datafile copy
input datafile file number=00004 name=/opt/app/oracle/oradata/DB01prmr/users01.dbf
output file name=/opt/app/oracle/oradata/DB01sby1/undotbs01.dbf tag=TAG20120711T145343
channel prmy1: datafile copy complete, elapsed time: 00:00:03
output file name=/opt/app/oracle/oradata/DB01sby1/users01.dbf tag=TAG20120711T145343
channel prmy2: datafile copy complete, elapsed time: 00:00:03
Finished backup at 11-JUL-12
sql statement: alter system archive log current
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy RECID=5 STAMP=788367279 file name=/opt/app/oracle/oradata/DB01sby1/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=6 STAMP=788367279 file name=/opt/app/oracle/oradata/DB01sby1/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=7 STAMP=788367279 file name=/opt/app/oracle/oradata/DB01sby1/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=8 STAMP=788367279 file name=/opt/app/oracle/oradata/DB01sby1/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=9 STAMP=788367279 file name=/opt/app/oracle/oradata/DB01sby1/example01.dbf
Finished Duplicate Db at 11-JUL-12
released channel: prmy1
released channel: prmy2
released channel: stby
- Starting redo apply (on the standby database):
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
Database altered.
On the primary database enable the transmission of redo log to the physical standby database;
SQL> alter system set LOG_ARCHIVE_DEST_STATE_2=ENABLE scope=both;
System altered.
Redo log are transmitted after a log switch so you can anticipate it using the command ALTER SYSTEM SWITCH LOGFILE
From primary database machine:
SQL> select status, error from v$archive_dest where dest_id = 2;
STATUS ERROR
--------- -----------------------------------------------------------------
VALID
SQL> alter system switch logfile;
System altered.
Now check the alert logs on both machines. From primary alert log:
[oracle@vsi08devpom ~]$ cd /opt/app/oracle/diag/rdbms/db01prmr/DB01prmr/trace/
[oracle@vsi08devpom trace]$ tail -f alert_DB01prmr.log
...
Wed Jul 11 15:54:20 2012
Starting background process SMCO
Wed Jul 11 15:54:20 2012
SMCO started with pid=26, OS id=2732
Wed Jul 11 15:54:24 2012
Thread 1 advanced to log sequence 157 (LGWR switch)
Current log# 1 seq# 157 mem# 0: /opt/app/oracle/oradata/DB01prmr/redo01.log
Wed Jul 11 15:54:24 2012
******************************************************************
LGWR: Setting 'active' archival for destination LOG_ARCHIVE_DEST_2
******************************************************************
Wed Jul 11 15:54:24 2012
Archived Log entry 20 added for thread 1 sequence 156 ID 0xab54ff95 dest 1:
LNS: Standby redo logfile selected for thread 1 sequence 157 for destination LOG_ARCHIVE_DEST_2
...
From physical standby database machine alert log, you can see the logs are arriving:
[oracle@vsi10devpom ~]$ cd /opt/app/oracle/diag/rdbms/db01sby1/DB01sby1/trace/
[oracle@vsi10devpom trace]$ tail -f alert_DB01sby1.log
Wed Jul 11 15:54:24 2012
Using STANDBY_ARCHIVE_DEST parameter default value as USE_DB_RECOVERY_FILE_DEST
Archived Log entry 5 added for thread 1 sequence 156 ID 0xab54ff95 dest 1:
Wed Jul 11 15:54:24 2012
Media Recovery Waiting for thread 1 sequence 157
Wed Jul 11 15:54:24 2012
RFS[12]: Assigned to RFS process 15681
RFS[12]: Identified database type as 'physical standby': Client is LGWR ASYNC pid 2618
Primary database is in MAXIMUM PERFORMANCE mode
RFS[12]: Selected log 4 for thread 1 sequence 157 dbid -1420437099 branch 786034072
Recovery of Online Redo Log: Thread 1 Group 4 Seq 157 Reading mem 0
Mem# 0: /opt/app/oracle/oradata/DB01sby1/standby_redo04.log
Wed Jul 11 15:54:44 2012
Using STANDBY_ARCHIVE_DEST parameter default value as USE_DB_RECOVERY_FILE_DEST
Wed Jul 11 15:55:14 2012
RFS[13]: Assigned to RFS process 15686
RFS[13]: Identified database type as 'physical standby': Client is ARCH pid 2606