Step by Step Guide on Creating Physical Standby Using RMAN DUPLICATE FROM ACTIVE DATABASE
=======================================================================
Database Name :- hr
Primary db_unique_name :- hr
standby db_unique_name :- hrsty
#########################################################################
Primary database information
Host: pri.localdomain
IP Address : 192.168.1.12
Database name = hr
Standby database information
Host: stby.localdomain
IP Address : 192.168.1.13
Database name = hrsty
1. Make the necessary changes to the primary database.
a. Enable force logging.
b. Creating the password file if one does not exist.
c. Create standby redologs.
d. Modify the parameter file suitable for Dataguard.
2. Ensure that the sql*net connectivity is working fine.
3. Create the standby database over the network using the active(primary) database files.
a. Create the password file
b. Create the initialization parameter file for the standby database (auxiliary database)
c. Create the necessary mount points or the folders for the database files
d. Run the standby creation ON STANDBY by connecting to primary as target database.
1. Prepare the production database to be the primary database
a. Ensure that the database is in archivelog mode .
SQL> select log_mode from v$database;
LOG_MODE
------------
ARCHIVELOG
SQL>
b. Enable force logging
SQL> select force_logging from v$database;
FOR
---
NO
SQL> alter database force logging;
Database altered.
SQL> select force_logging from v$database;
FOR
---
YES
c. Create standby redologs (redologs+1)
SQL> select group#, thread#, bytes/1024/1024
from v$log; 2
GROUP# THREAD# BYTES/1024/1024
---------- ---------- ---------------
1 1 50
2 1 50
3 1 50
SQL>
SQL> select * from v$logfile;
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- -------------------------------------------------------------------------------- ---
3 ONLINE /u01/app/oracle/oradata/hr/redo03.log NO
2 ONLINE /u01/app/oracle/oradata/hr/redo02.log NO
1 ONLINE /u01/app/oracle/oradata/hr/redo01.log NO
SQL> alter database add standby logfile '/u01/app/oracle/oradata/hr/stby_redo01.log' size 50M;
Database altered.
SQL> alter database add standby logfile '/u01/app/oracle/oradata/hr/stby_redo02.log' size 50M;
Database altered.
SQL> alter database add standby logfile '/u01/app/oracle/oradata/hr/stby_redo03.log' size 50M;
Database altered.
SQL> alter database add standby logfile '/u01/app/oracle/oradata/hr/stby_redo04.log' size 50M;
Database altered.
SQL>
SQL> select * from v$logfile;
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- -------------------------------------------------------------------------------- ---
3 ONLINE /u01/app/oracle/oradata/hr/redo03.log NO
2 ONLINE /u01/app/oracle/oradata/hr/redo02.log NO
1 ONLINE /u01/app/oracle/oradata/hr/redo01.log NO
4 STANDBY /u01/app/oracle/oradata/hr/stby_redo01.log NO
5 STANDBY /u01/app/oracle/oradata/hr/stby_redo02.log NO
6 STANDBY /u01/app/oracle/oradata/hr/stby_redo03.log NO
7 STANDBY /u01/app/oracle/oradata/hr/stby_redo04.log NO
d. Modify the primary initialization parameter for dataguard on primary.
SQL> show parameter db_name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name string hr
SQL>
SQL> show parameter db_unique_name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_unique_name string hr
SQL>
The DB_NAME parameter will be hr for the both the primary database and the standby database.
The DB_UNIQUE_NAME will be hr for the primary database and hrsty for the standby.
The DB_UNIQUE_NAME will be used in the LOG_ARCHIVE_CONFIG parameter to enable the sending and receiving of redo logs to remote destinations.
SQL> alter system set log_archive_config='DG_CONFIG=(hr,hrsty)';
System altered.
SQL>
SQL> show parameter LOG_ARCHIVE_CONFIG
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_config string DG_CONFIG=(hr,hrsty)
SQL>
Set value for LOG_ARCHIVE_DEST_1 and LOG_ARCHIVE_DEST_2
SQL> show parameter log_archive_dest_1
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_1 string
log_archive_dest_10 string
log_archive_dest_11 string
log_archive_dest_12 string
log_archive_dest_13 string
log_archive_dest_14 string
log_archive_dest_15 string
log_archive_dest_16 string
log_archive_dest_17 string
log_archive_dest_18 string
log_archive_dest_19 string
SQL> alter system set log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=hr';
System altered.
SQL> show parameter log_archive_dest_1
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_1 string LOCATION=USE_DB_RECOVERY_FILE_
DEST VALID_FOR=(ALL_LOGFILES,A
LL_ROLES) DB_UNIQUE_NAME=hr
log_archive_dest_10 string
log_archive_dest_11 string
log_archive_dest_12 string
log_archive_dest_13 string
The redo transport mode is set in the parameter LOG_ARCHIVE_DEST_2. Below we configure redo transport mode for Maximum performance by setting ASYNC NOAFFIRM.
Instead of a location a service name is provided to send the archive logs.
SQL> show parameter log_archive_dest_2
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_2 string
log_archive_dest_20 string
log_archive_dest_21 string
log_archive_dest_22 string
log_archive_dest_23 string
log_archive_dest_24 string
log_archive_dest_25 string
log_archive_dest_26 string
log_archive_dest_27 string
log_archive_dest_28 string
log_archive_dest_29 string
SQL>
SQL> alter system set log_archive_dest_2='SERVICE=hrsty LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=hrsty';
System altered.
SQL> show parameter log_archive_dest_2
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_2 string SERVICE=hrsty LGWR ASYNC VALID
_FOR=(ONLINE_LOGFILES,PRIMARY_
ROLE) DB_UNIQUE_NAME=hrsty
log_archive_dest_20 string
log_archive_dest_21 string
log_archive_dest_22 string
log_archive_dest_23 string
log_archive_dest_24 string
log_archive_dest_25 string
log_archive_dest_26 string
log_archive_dest_27 string
SQL> show parameter LOG_ARCHIVE_DEST_STATE
log_archive_dest_state_1 string enable
log_archive_dest_state_2 string enable
The FAL_SERVER specifies the fetch archive log (FAL) server for the standby database.
The FAL_CLIENT specifies the FAL client name. Both are used by the FAL service. The FAL_SERVER is the primary and FAL_CLIENT is the standby.
In Primary site:
FAL_SERVER=STANDBY
FAL_CLIENT=PRIMARY
In Standby site:
FAL_SERVER=PRIMARY
FAL_CLIENT=STANDB
SQL> alter system set FAL_SERVER=hrsty;
System altered.
SQL> alter system set FAL_CLIENT=hr;
System altered.
SQL>
SQL> show parameter fal
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
fal_client string HR
fal_server string HRSTY
SQL>
Operating system file additions and deletions can be replicated to the physical standby database setting STANDBY_FILE_MANAGEMENT to auto.
SQL> show parameter standby_file_management
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
standby_file_management string MANUAL
SQL>
SQL>
SQL>
SQL> alter system set standby_file_management=auto;
System altered.
SQL> show parameter standby_file_management
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
standby_file_management string AUTO
SQL>
SQL> show parameter remote_login_passwordfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
remote_login_passwordfile string EXCLUSIVE
SQL>
SQL> select name from v$datafile;
NAME
----------------------------------------------------------------------
/u01/app/oracle/oradata/hr/system01.dbf
/u01/app/oracle/oradata/hr/sysaux01.dbf
/u01/app/oracle/oradata/hr/undotbs01.dbf
/u01/app/oracle/oradata/hr/users01.dbf
/u01/app/oracle/oradata/hr/example01.dbf
/u01/app/oracle/oradata/hr/test01.dbf
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/hr/redo03.log
/u01/app/oracle/oradata/hr/redo02.log
/u01/app/oracle/oradata/hr/redo01.log
/u01/app/oracle/oradata/hr/stby_redo01.log
/u01/app/oracle/oradata/hr/stby_redo02.log
/u01/app/oracle/oradata/hr/stby_redo03.log
/u01/app/oracle/oradata/hr/stby_redo04.log
primary files location :
db files: /u01/app/oracle/oradata/hr/
redo log files : /u01/app/oracle/oradata/hr/
standby files locations :
db files: /u01/app/oracle/oradata/hrsty/
redo log files : /u01/app/oracle/oradata/hrsty/
SQL> alter system set DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/hr/','/u01/app/oracle/oradata/hrsty/' scope=spfile;
System altered.
SQL> alter system set LOG_FILE_NAME_CONVERT='/u01/app/oracle/oradata/hr/','/u01/app/oracle/oradata/hrsty/' scope=spfile;
System altered.
SQL> show parameter conve
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert string
log_file_name_convert string
SQL>
SQL> alter system set DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/hr/','/u01/app/oracle/oradata/hrsty/' scope=spfile;
System altered.
SQL> alter system set LOG_FILE_NAME_CONVERT='/u01/app/oracle/oradata/hr/','/u01/app/oracle/oradata/hrsty/' scope=spfile;
System altered.
(Need restart database for reflect parameter)
SQL> show parameter conve
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert string /u01/app/oracle/oradata/hr/, /
u01/app/oracle/oradata/hrsty/
log_file_name_convert string /u01/app/oracle/oradata/hr/, /
u01/app/oracle/oradata/hrsty/
SQL>
2. Ensure that the sql*net connectivity is working fine.
===============================================================================
Insert a static entry for hrsty in the listener.ora file of the standby system.
NOTE : For non default port set the REMOTE_LISTENER
primary network files
[oracle@pri admin]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 27-AUG-2017 11:13:24
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Starting /u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.4.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/pri/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=pri)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=pri)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 27-AUG-2017 11:13:24
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/pri/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=pri)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "hr" has 1 instance(s).
Instance "hr", status UNKNOWN, has 1 handler(s) for this service...
Service "hrsty" has 1 instance(s).
Instance "hrsty", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@pri admin]$
[oracle@pri admin]$
[oracle@pri admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = pri)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME =hr )
)
(SID_DESC =
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME =hrsty )
)
)
ADR_BASE_LISTENER = /u01/app/oracle
[oracle@pri admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
HR =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.12)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = hr)
)
)
HRSTY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.13)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = hrsty)
)
)
[oracle@pri admin]$
standby network files
-----------------------------------
[oracle@stby admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = hrsty)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = hrsty)
)
(SID_DESC =
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME =hr )
)
)
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.13)(PORT = 1521))
)
ADR_BASE_LISTENER = /u01/app/oracle
[oracle@stby admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
HR =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.12)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = hr)
)
)
HRSTY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.13)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = hrsty)
)
)
[oracle@stby admin]$
[oracle@stby admin]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 27-AUG-2017 11:13:38
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Starting /u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.4.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/stby/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.13)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.13)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 27-AUG-2017 11:13:38
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/stby/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.13)(PORT=1521)))
Services Summary...
Service "hr" has 1 instance(s).
Instance "hr", status UNKNOWN, has 1 handler(s) for this service...
Service "hrsty" has 1 instance(s).
Instance "hrsty", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@stby admin]$
Check with the SQL*Net configuration using the following commands on the Primary AND Standby
tnsping hr
tnsping hrsty
from primary
---------------------
[oracle@pri admin]$ tnsping hr
TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 27-AUG-2017 11:15:33
Copyright (c) 1997, 2013, 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.1.12)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = hr)))
OK (0 msec)
[oracle@pri admin]$ tnsping hrsty
TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 27-AUG-2017 11:15:39
Copyright (c) 1997, 2013, 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.1.13)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = hrsty)))
OK (0 msec)
[oracle@pri admin]$
From standby
----------------------------
[oracle@stby admin]$ tnsping hr
TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 27-AUG-2017 11:18:05
Copyright (c) 1997, 2013, 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.1.12)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = hr)))
OK (10 msec)
[oracle@stby admin]$
[oracle@stby admin]$ tnsping hrsty
TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 27-AUG-2017 11:18:08
Copyright (c) 1997, 2013, 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.1.13)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = hrsty)))
OK (0 msec)
[oracle@stby admin]$
3. Create the standby database
=========================================================
a. Copy the password file from the primary $ORACLE_HOME/dbs and rename it to the standby database name.
The username is required to be SYS and the password needs to be the same on the Primary and Standby.
The best practice for this is to copy the passwordfile as suggested.
The password file name must match the instance name/SID used at the standby site, not the DB_NAME.
b. Create a initialization parameter with only one parameter DB_NAME.
DB_NAME=hr
DB_UNIQUE_NAME=hrsty
DB_BLOCK_SIZE=<same as primary>
mkdir oradata
mkdir oradata/hrsty
[oracle@stby admin]$ pwd
/u01/app/oracle/admin
mkdir /u01/app/oracle/admin/hrsty
mkdir /u01/app/oracle/admin/hrsty/adump
mkdir /u01/app/oracle/admin/hrsty/bdump
mkdir /u01/app/oracle/admin/hrsty/dpdump
mkdir /u01/app/oracle/admin/hrsty/pfile
[oracle@stby hrsty]$ pwd
/u01/app/oracle/admin/hrsty
[oracle@stby hrsty]$ ls -lrt
total 16
drwxr-xr-x. 2 oracle oinstall 4096 Aug 27 11:24 adump
drwxr-xr-x. 2 oracle oinstall 4096 Aug 27 11:24 bdump
drwxr-xr-x. 2 oracle oinstall 4096 Aug 27 11:24 dpdump
drwxr-xr-x. 2 oracle oinstall 4096 Aug 27 11:24 pfile
[oracle@stby hrsty]
[oracle@stby hrsty]$ pwd
/u01/app/oracle/fast_recovery_area
[oracle@stby hrsty]$mkdir hrsty
[oracle@stby fast_recovery_area]$ ls -lrt
total 4
drwxr-xr-x. 2 oracle oinstall 4096 Aug 27 11:51 hrsty
[oracle@stby fast_recovery_area]$
oracle@stby oradata]$ mkdir hrsty
[oracle@stby oradata]$ ls -lrt
total 4
drwxr-xr-x. 2 oracle oinstall 4096 Aug 27 11:53 hrsty
[oracle@stby oradata]$ pwd
/u01/app/oracle/oradata
[oracle@stby oradata]$
Add the following line to /etc/oratab on the standby server.
hrsty:/u01/app/oracle/product/11.2.0/dbhome_1:N
[oracle@stby hrsty]$ cat /etc/oratab
#
# This file is used by ORACLE utilities. It is created by root.sh
# and updated by either Database Configuration Assistant while creating
# a database or ASM Configuration Assistant while creating ASM instance.
# A colon, ':', is used as the field terminator. A new line terminates
# the entry. Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
# $ORACLE_SID:$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively. The third filed indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
#
hrsty:/u01/app/oracle/product/11.2.0/dbhome_1:N
[oracle@stby hrsty]$
Create a basic PFILE in ORACLE_HOME/dbs with the following parameters.
u01/app/oracle/product/11.2.0/dbhome_1/dbs/oracle $ orapwd file=orapwhr password=oracle entries=5
orapwd file=orapwhr password=oracle entries=5
scp orapwhr stby:/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwhrsty
[oracle@pri dbs]$ scp orapwhr stby:/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwhrsty
The authenticity of host 'stby (192.168.1.13)' can't be established.
RSA key fingerprint is f5:e6:6d:1a:54:0a:22:3f:64:df:ff:66:d8:b2:df:03.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'stby' (RSA) to the list of known hosts.
oracle@stby's password:
orapwhr 100% 1536 1.5KB/s 00:00
[oracle@pri dbs]$
Create a basic PFILE in ORACLE_HOME/dbs with the following parameters.
DB_NAME=hr
DB_UNIQUE_NAME=hrsty
[oracle@stby dbs]$ cat inithrsty.ora
DB_NAME=hr
DB_UNIQUE_NAME=hrsty
[oracle@stby dbs]$
[oracle@stby dbs]$ . oraenv
ORACLE_SID = [oracle] ? hrsty
The Oracle base remains unchanged with value /u01/app/oracle
[oracle@stby dbs]$
[oracle@stby dbs]$ echo $ORACLE_SID
hrsty
[oracle@stby dbs]$
[oracle@stby dbs]$ sqlplus "/as sysdba"
SQL*Plus: Release 11.2.0.4.0 Production on Sun Aug 27 11:49:25 2017
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 217157632 bytes
Fixed Size 2251816 bytes
Variable Size 159384536 bytes
Database Buffers 50331648 bytes
Redo Buffers 5189632 bytes
SQL>
SQL> show parameter db_na
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name string hr
SQL> show parameter db_uni
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_unique_name string hrsty
SQL>
Below is the RMAN run command to perform the database duplication from and active database along with brief explanations for the options used in the duplicate.
FOR STANDBY – the duplicate is for use as a standby so a DBID change will not be forced.
FROM ACTIVE DATABASE – instructs RMAN to use the active target database instead of disk based backups.
DORECOVER – do recovery bringing the standby database up to the current point in time.
SPFILE – values for parameters specific to the auxiliary instance can be set here.
NOFILENAMECHECK – this option is added because the duplicate database files uses the same name as the source database.
Primary parameter
SQL> col value for a90
col name for a50
select name, value
from v$parameter
where name in ('db_name','db_unique_name','log_archive_config', 'log_archive_dest_1','log_archive_dest_2',
'log_archive_dest_state_1','log_archive_dest_state_2', 'remote_login_passwordfile',
'log_archive_format','log_archive_max_processes','fal_server','fal_client','db_file_name_convert',
'log_file_name_convert', 'standby_file_management','control_files');
NAME VALUE
-------------------------------------------------- ------------------------------------------------------------------------------------------
control_files /u01/app/oracle/oradata/hr/control01.ctl, /u01/app/oracle/fast_recovery_area/hr/control02.ctl
db_file_name_convert /u01/app/oracle/oradata/hr/, /u01/app/oracle/oradata/hrsty/
log_file_name_convert /u01/app/oracle/oradata/hr/, /u01/app/oracle/oradata/hrsty/
log_archive_dest_1 LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=hr
log_archive_dest_2 SERVICE=hrsty LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=hrsty
log_archive_dest_state_1 enable
log_archive_dest_state_2 enable
fal_client HR
fal_server HRSTY
log_archive_config DG_CONFIG=(hr,hrsty)
log_archive_format %t_%s_%r.arc
log_archive_max_processes 4
standby_file_management AUTO
remote_login_passwordfile EXCLUSIVE
db_name hr
db_unique_name hr
16 rows selected.
SQL>
On primary side
rman target /
connect auxiliary sys/oracle@hrsty
orapwd file=orapwhr password=oracle entries=5 ignorecase=Y
There are no spaces permitted around the equal-to (=).
[oracle@pri dbs]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Sun Aug 27 12:19:01 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: HR (DBID=3602606687)
RMAN> connect auxiliary sys/oracle@hrsty
connected to auxiliary database: HR (not mounted)
RMAN>
run {
allocate channel pri1 type disk;
allocate channel pri2 type disk;
allocate channel prmy4 type disk;
allocate auxiliary channel stby type disk;
duplicate target database for standby from active database
spfile
parameter_value_convert 'hr','hrsty'
set db_unique_name='hrsty'
set control_files='/u01/app/oracle/oradata/hrsty/control01.ctl','/u01/app/oracle/fast_recovery_area/hrsty/control02.ctl'
set fal_client='hrsty'
set fal_server='hr'
set log_archive_max_processes='5'
set standby_file_management='AUTO'
set log_archive_config='dg_config=(hr,hrsty)'
set db_file_name_convert='/u01/app/oracle/oradata/hr/','/u01/app/oracle/oradata/hrsty/'
set log_file_name_convert='/u01/app/oracle/oradata/hr/','/u01/app/oracle/oradata/hrsty/'
set log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=hrsty'
set log_archive_dest_2='service=hr ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=hr'
;
}
on standby site
------------------------
SQL> select name,open_mode,DATABASE_ROLE from v$database;
NAME OPEN_MODE DATABASE_ROLE
--------- -------------------- ----------------
HR MOUNTED PHYSICAL STANDBY
SQL> alter database open;
Database altered.
SQL> select name,open_mode,DATABASE_ROLE from v$database;
NAME OPEN_MODE DATABASE_ROLE
--------- -------------------- ----------------
HR READ ONLY PHYSICAL STANDBY
SQL>
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 21
Next log sequence to archive 0
Current log sequence 23
SQL>
SQL> alter database recover managed standby database disconnect from session;
Database altered.
SQL> select name,open_mode,DATABASE_ROLE from v$database;
NAME OPEN_MODE DATABASE_ROLE
--------- -------------------- ----------------
HR READ ONLY WITH APPLY PHYSICAL STANDBY
SQL>
SQL> select protection_mode,protection_level,database_role,name from v$database;
PROTECTION_MODE PROTECTION_LEVEL DATABASE_ROLE NAME
-------------------- -------------------- ---------------- ---------
MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE PHYSICAL STANDBY HR
we can validate that that logs are shipping and applying. On the standby issue the following query.
===========================================================================================================
On standby
SQL> select sequence#, first_time, next_time, applied
from v$archived_log
order by sequence#; 2 3
SEQUENCE# FIRST_TIM NEXT_TIME APPLIED
---------- --------- --------- ---------
19 27-AUG-17 27-AUG-17 YES
20 27-AUG-17 27-AUG-17 YES
21 27-AUG-17 27-AUG-17 YES
22 27-AUG-17 27-AUG-17 YES
23 27-AUG-17 27-AUG-17 YES
24 27-AUG-17 27-AUG-17 YES
25 27-AUG-17 27-AUG-17 YES
26 27-AUG-17 27-AUG-17 YES
27 27-AUG-17 27-AUG-17 YES
28 27-AUG-17 27-AUG-17 YES
29 27-AUG-17 27-AUG-17 YES
30 27-AUG-17 27-AUG-17 YES
31 27-AUG-17 27-AUG-17 YES
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 24
Next log sequence to archive 0
Current log sequence 26
SQL>
SQL> SELECT 'Last Applied : ' Logs,
2 TO_CHAR(next_time,'DD-MON-YY:HH24:MI:SS') TIME,thread#,sequence#
FROM v$archived_log
WHERE sequence# =
(SELECT MAX(sequence#) FROM v$archived_log WHERE applied='YES'
)
UNION
SELECT 'Last Received : ' Logs,
TO_CHAR(next_time,'DD-MON-YY:HH24:MI:SS') TIME,thread#,sequence#
FROM v$archived_log
WHERE sequence# =
(SELECT MAX(sequence#) FROM v$archived_log );
LOGS TIME THREAD# SEQUENCE#
---------------- --------------------------- ---------- ----------
Last Applied : 27-AUG-17:12:52:32 1 31
Last Received : 27-AUG-17:12:52:32 1 31
SQL>
On primary
============================
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 24
Next log sequence to archive 26
Current log sequence 26
SQL>
SQL> SELECT
2 (SELECT name FROM V$DATABASE
) name,
(SELECT MAX (sequence#) FROM v$archived_log WHERE dest_id = 1
) Current_primary_seq,
(SELECT MAX (sequence#)
FROM v$archived_log
WHERE TRUNC(next_time) > SYSDATE - 1
AND dest_id = 2
) max_stby,
(SELECT NVL (
(SELECT MAX (sequence#) - MIN (sequence#)
FROM v$archived_log
WHERE TRUNC(next_time) > SYSDATE - 1
AND dest_id = 2
AND applied = 'NO'
), 0)
FROM DUAL
) "To be applied",
(
(SELECT MAX (sequence#) FROM v$archived_log WHERE dest_id = 1
) -
(SELECT MAX (sequence#) FROM v$archived_log WHERE dest_id = 2
)) "To be Shipped"
FROM DUAL;
NAME CURRENT_PRIMARY_SEQ MAX_STBY To be applied To be Shipped
--------- ------------------- ---------- ------------- -------------
HR 31 31 0 0
SQL>
logs
===============
[oracle@pri dbs]$
[oracle@pri dbs]$
[oracle@pri dbs]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Sun Aug 27 12:19:01 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: HR (DBID=3602606687)
RMAN> connect auxiliary sys/oracle@hrsty
connected to auxiliary database: HR (not mounted)
RMAN> run {
allocate channel pri1 type disk;
allocate channel pri2 type disk;
allocate channel prmy4 type disk;
allocate auxiliary channel stby type disk;
duplicate target database for standby from active database
spfile
parameter_value_convert 'hr','hrsty'
set db_unique_name='hrsty'
set control_files='/u01/app/oracle/oradata/hrsty/control01.ctl','/u01/app/oracle/fast_recovery_area/hrsty/control02.ctl'
2> 3> 4> 5> 6> 7> 8> 9> 10> 11> set fal_client='hrsty'
set fal_server='hr'
set log_archive_max_processes='5'
set standby_file_management='AUTO'
set log_archive_config='dg_config=(hr,hrsty)'
set db_file_name_convert='/u01/app/oracle/oradata/hr/','/u01/app/oracle/oradata/hrsty/'
set log_file_name_convert='/u01/app/oracle/oradata/hr/','/u01/app/oracle/oradata/hrsty/'
set log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=hrsty'
set log_archive_dest_2='service=hr ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=hr'
;
}12> 13> 14> 15> 16> 17> 18> 19> 20> 21>
using target database control file instead of recovery catalog
allocated channel: pri1
channel pri1: SID=41 device type=DISK
allocated channel: pri2
channel pri2: SID=42 device type=DISK
allocated channel: prmy4
channel prmy4: SID=40 device type=DISK
allocated channel: stby
channel stby: SID=19 device type=DISK
Starting Duplicate Db at 27-AUG-17
contents of Memory Script:
{
backup as copy reuse
targetfile '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwhr' auxiliary format
'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwhrsty' targetfile
'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfilehr.ora' auxiliary format
'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfilehrsty.ora' ;
sql clone "alter system set spfile= ''/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfilehrsty.ora''";
}
executing Memory Script
Starting backup at 27-AUG-17
Finished backup at 27-AUG-17
sql statement: alter system set spfile= ''/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfilehrsty.ora''
contents of Memory Script:
{
sql clone "alter system set audit_file_dest =
''/u01/app/oracle/admin/hrsty/adump'' comment=
'''' scope=spfile";
sql clone "alter system set dispatchers =
''(PROTOCOL=TCP) (SERVICE=hrstyXDB)'' comment=
'''' scope=spfile";
sql clone "alter system set db_unique_name =
''hrsty'' comment=
'''' scope=spfile";
sql clone "alter system set control_files =
''/u01/app/oracle/oradata/hrsty/control01.ctl'', ''/u01/app/oracle/fast_recovery_area/hrsty/control02.ctl'' comment=
'''' scope=spfile";
sql clone "alter system set fal_client =
''hrsty'' comment=
'''' scope=spfile";
sql clone "alter system set fal_server =
''hr'' comment=
'''' scope=spfile";
sql clone "alter system set log_archive_max_processes =
5 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=(hr,hrsty)'' comment=
'''' scope=spfile";
sql clone "alter system set db_file_name_convert =
''/u01/app/oracle/oradata/hr/'', ''/u01/app/oracle/oradata/hrsty/'' comment=
'''' scope=spfile";
sql clone "alter system set log_file_name_convert =
''/u01/app/oracle/oradata/hr/'', ''/u01/app/oracle/oradata/hrsty/'' comment=
'''' scope=spfile";
sql clone "alter system set log_archive_dest_1 =
''LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=hrsty'' comment=
'''' scope=spfile";
sql clone "alter system set log_archive_dest_2 =
''service=hr ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=hr'' comment=
'''' scope=spfile";
shutdown clone immediate;
startup clone nomount;
}
executing Memory Script
sql statement: alter system set audit_file_dest = ''/u01/app/oracle/admin/hrsty/adump'' comment= '''' scope=spfile
sql statement: alter system set dispatchers = ''(PROTOCOL=TCP) (SERVICE=hrstyXDB)'' comment= '''' scope=spfile
sql statement: alter system set db_unique_name = ''hrsty'' comment= '''' scope=spfile
sql statement: alter system set control_files = ''/u01/app/oracle/oradata/hrsty/control01.ctl'', ''/u01/app/oracle/fast_recovery_area/hrsty/control02.ctl'' comment= '''' scope=spfile
sql statement: alter system set fal_client = ''hrsty'' comment= '''' scope=spfile
sql statement: alter system set fal_server = ''hr'' comment= '''' scope=spfile
sql statement: alter system set log_archive_max_processes = 5 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=(hr,hrsty)'' comment= '''' scope=spfile
sql statement: alter system set db_file_name_convert = ''/u01/app/oracle/oradata/hr/'', ''/u01/app/oracle/oradata/hrsty/'' comment= '''' scope=spfile
sql statement: alter system set log_file_name_convert = ''/u01/app/oracle/oradata/hr/'', ''/u01/app/oracle/oradata/hrsty/'' comment= '''' scope=spfile
sql statement: alter system set log_archive_dest_1 = ''LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=hrsty'' comment= '''' scope=spfile
sql statement: alter system set log_archive_dest_2 = ''service=hr ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=hr'' comment= '''' scope=spfile
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 1252663296 bytes
Fixed Size 2252824 bytes
Variable Size 788533224 bytes
Database Buffers 452984832 bytes
Redo Buffers 8892416 bytes
allocated channel: stby
channel stby: SID=18 device type=DISK
contents of Memory Script:
{
backup as copy current controlfile for standby auxiliary format '/u01/app/oracle/oradata/hrsty/control01.ctl';
restore clone controlfile to '/u01/app/oracle/fast_recovery_area/hrsty/control02.ctl' from
'/u01/app/oracle/oradata/hrsty/control01.ctl';
}
executing Memory Script
Starting backup at 27-AUG-17
channel pri1: starting datafile copy
copying standby control file
output file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_hr.f tag=TAG20170827T122351 RECID=2 STAMP=953123032
channel pri1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 27-AUG-17
Starting restore at 27-AUG-17
channel stby: copied control file copy
Finished restore at 27-AUG-17
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
"/u01/app/oracle/oradata/hrsty/temp01.dbf";
switch clone tempfile all;
set newname for datafile 1 to
"/u01/app/oracle/oradata/hrsty/system01.dbf";
set newname for datafile 2 to
"/u01/app/oracle/oradata/hrsty/sysaux01.dbf";
set newname for datafile 3 to
"/u01/app/oracle/oradata/hrsty/undotbs01.dbf";
set newname for datafile 4 to
"/u01/app/oracle/oradata/hrsty/users01.dbf";
set newname for datafile 5 to
"/u01/app/oracle/oradata/hrsty/example01.dbf";
set newname for datafile 6 to
"/u01/app/oracle/oradata/hrsty/test01.dbf";
backup as copy reuse
datafile 1 auxiliary format
"/u01/app/oracle/oradata/hrsty/system01.dbf" datafile
2 auxiliary format
"/u01/app/oracle/oradata/hrsty/sysaux01.dbf" datafile
3 auxiliary format
"/u01/app/oracle/oradata/hrsty/undotbs01.dbf" datafile
4 auxiliary format
"/u01/app/oracle/oradata/hrsty/users01.dbf" datafile
5 auxiliary format
"/u01/app/oracle/oradata/hrsty/example01.dbf" datafile
6 auxiliary format
"/u01/app/oracle/oradata/hrsty/test01.dbf" ;
sql 'alter system archive log current';
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /u01/app/oracle/oradata/hrsty/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
executing command: SET NEWNAME
Starting backup at 27-AUG-17
channel pri1: starting datafile copy
input datafile file number=00006 name=/u01/app/oracle/oradata/hr/test01.dbf
channel pri2: starting datafile copy
input datafile file number=00001 name=/u01/app/oracle/oradata/hr/system01.dbf
channel prmy4: starting datafile copy
input datafile file number=00002 name=/u01/app/oracle/oradata/hr/sysaux01.dbf
output file name=/u01/app/oracle/oradata/hrsty/sysaux01.dbf tag=TAG20170827T122402
channel prmy4: datafile copy complete, elapsed time: 00:08:58
channel prmy4: starting datafile copy
input datafile file number=00005 name=/u01/app/oracle/oradata/hr/example01.dbf
output file name=/u01/app/oracle/oradata/hrsty/system01.dbf tag=TAG20170827T122402
channel pri2: datafile copy complete, elapsed time: 00:09:34
channel pri2: starting datafile copy
input datafile file number=00003 name=/u01/app/oracle/oradata/hr/undotbs01.dbf
output file name=/u01/app/oracle/oradata/hrsty/undotbs01.dbf tag=TAG20170827T122402
channel pri2: datafile copy complete, elapsed time: 00:00:25
channel pri2: starting datafile copy
input datafile file number=00004 name=/u01/app/oracle/oradata/hr/users01.dbf
output file name=/u01/app/oracle/oradata/hrsty/users01.dbf tag=TAG20170827T122402
channel pri2: datafile copy complete, elapsed time: 00:00:03
output file name=/u01/app/oracle/oradata/hrsty/test01.dbf tag=TAG20170827T122402
channel pri1: datafile copy complete, elapsed time: 00:10:25
output file name=/u01/app/oracle/oradata/hrsty/example01.dbf tag=TAG20170827T122402
channel prmy4: datafile copy complete, elapsed time: 00:01:26
Finished backup at 27-AUG-17
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=2 STAMP=953123668 file name=/u01/app/oracle/oradata/hrsty/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=3 STAMP=953123668 file name=/u01/app/oracle/oradata/hrsty/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=4 STAMP=953123668 file name=/u01/app/oracle/oradata/hrsty/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=5 STAMP=953123668 file name=/u01/app/oracle/oradata/hrsty/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=6 STAMP=953123668 file name=/u01/app/oracle/oradata/hrsty/example01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=7 STAMP=953123668 file name=/u01/app/oracle/oradata/hrsty/test01.dbf
Finished Duplicate Db at 27-AUG-17
released channel: pri1
released channel: pri2
released channel: prmy4
released channel: stby
RMAN>
RMAN>
RMAN>
RMAN>
Step by Step Guide on Creating Physical Standby Using RMAN DUPLICATE...FROM ACTIVE DATABASE (Doc ID 1075908.1)
=======================================================================
Database Name :- hr
Primary db_unique_name :- hr
standby db_unique_name :- hrsty
#########################################################################
Primary database information
Host: pri.localdomain
IP Address : 192.168.1.12
Database name = hr
Standby database information
Host: stby.localdomain
IP Address : 192.168.1.13
Database name = hrsty
1. Make the necessary changes to the primary database.
a. Enable force logging.
b. Creating the password file if one does not exist.
c. Create standby redologs.
d. Modify the parameter file suitable for Dataguard.
2. Ensure that the sql*net connectivity is working fine.
3. Create the standby database over the network using the active(primary) database files.
a. Create the password file
b. Create the initialization parameter file for the standby database (auxiliary database)
c. Create the necessary mount points or the folders for the database files
d. Run the standby creation ON STANDBY by connecting to primary as target database.
1. Prepare the production database to be the primary database
a. Ensure that the database is in archivelog mode .
SQL> select log_mode from v$database;
LOG_MODE
------------
ARCHIVELOG
SQL>
b. Enable force logging
SQL> select force_logging from v$database;
FOR
---
NO
SQL> alter database force logging;
Database altered.
SQL> select force_logging from v$database;
FOR
---
YES
c. Create standby redologs (redologs+1)
SQL> select group#, thread#, bytes/1024/1024
from v$log; 2
GROUP# THREAD# BYTES/1024/1024
---------- ---------- ---------------
1 1 50
2 1 50
3 1 50
SQL>
SQL> select * from v$logfile;
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- -------------------------------------------------------------------------------- ---
3 ONLINE /u01/app/oracle/oradata/hr/redo03.log NO
2 ONLINE /u01/app/oracle/oradata/hr/redo02.log NO
1 ONLINE /u01/app/oracle/oradata/hr/redo01.log NO
SQL> alter database add standby logfile '/u01/app/oracle/oradata/hr/stby_redo01.log' size 50M;
Database altered.
SQL> alter database add standby logfile '/u01/app/oracle/oradata/hr/stby_redo02.log' size 50M;
Database altered.
SQL> alter database add standby logfile '/u01/app/oracle/oradata/hr/stby_redo03.log' size 50M;
Database altered.
SQL> alter database add standby logfile '/u01/app/oracle/oradata/hr/stby_redo04.log' size 50M;
Database altered.
SQL>
SQL> select * from v$logfile;
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- -------------------------------------------------------------------------------- ---
3 ONLINE /u01/app/oracle/oradata/hr/redo03.log NO
2 ONLINE /u01/app/oracle/oradata/hr/redo02.log NO
1 ONLINE /u01/app/oracle/oradata/hr/redo01.log NO
4 STANDBY /u01/app/oracle/oradata/hr/stby_redo01.log NO
5 STANDBY /u01/app/oracle/oradata/hr/stby_redo02.log NO
6 STANDBY /u01/app/oracle/oradata/hr/stby_redo03.log NO
7 STANDBY /u01/app/oracle/oradata/hr/stby_redo04.log NO
d. Modify the primary initialization parameter for dataguard on primary.
SQL> show parameter db_name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name string hr
SQL>
SQL> show parameter db_unique_name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_unique_name string hr
SQL>
The DB_NAME parameter will be hr for the both the primary database and the standby database.
The DB_UNIQUE_NAME will be hr for the primary database and hrsty for the standby.
The DB_UNIQUE_NAME will be used in the LOG_ARCHIVE_CONFIG parameter to enable the sending and receiving of redo logs to remote destinations.
SQL> alter system set log_archive_config='DG_CONFIG=(hr,hrsty)';
System altered.
SQL>
SQL> show parameter LOG_ARCHIVE_CONFIG
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_config string DG_CONFIG=(hr,hrsty)
SQL>
Set value for LOG_ARCHIVE_DEST_1 and LOG_ARCHIVE_DEST_2
SQL> show parameter log_archive_dest_1
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_1 string
log_archive_dest_10 string
log_archive_dest_11 string
log_archive_dest_12 string
log_archive_dest_13 string
log_archive_dest_14 string
log_archive_dest_15 string
log_archive_dest_16 string
log_archive_dest_17 string
log_archive_dest_18 string
log_archive_dest_19 string
SQL> alter system set log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=hr';
System altered.
SQL> show parameter log_archive_dest_1
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_1 string LOCATION=USE_DB_RECOVERY_FILE_
DEST VALID_FOR=(ALL_LOGFILES,A
LL_ROLES) DB_UNIQUE_NAME=hr
log_archive_dest_10 string
log_archive_dest_11 string
log_archive_dest_12 string
log_archive_dest_13 string
The redo transport mode is set in the parameter LOG_ARCHIVE_DEST_2. Below we configure redo transport mode for Maximum performance by setting ASYNC NOAFFIRM.
Instead of a location a service name is provided to send the archive logs.
SQL> show parameter log_archive_dest_2
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_2 string
log_archive_dest_20 string
log_archive_dest_21 string
log_archive_dest_22 string
log_archive_dest_23 string
log_archive_dest_24 string
log_archive_dest_25 string
log_archive_dest_26 string
log_archive_dest_27 string
log_archive_dest_28 string
log_archive_dest_29 string
SQL>
SQL> alter system set log_archive_dest_2='SERVICE=hrsty LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=hrsty';
System altered.
SQL> show parameter log_archive_dest_2
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_2 string SERVICE=hrsty LGWR ASYNC VALID
_FOR=(ONLINE_LOGFILES,PRIMARY_
ROLE) DB_UNIQUE_NAME=hrsty
log_archive_dest_20 string
log_archive_dest_21 string
log_archive_dest_22 string
log_archive_dest_23 string
log_archive_dest_24 string
log_archive_dest_25 string
log_archive_dest_26 string
log_archive_dest_27 string
SQL> show parameter LOG_ARCHIVE_DEST_STATE
log_archive_dest_state_1 string enable
log_archive_dest_state_2 string enable
The FAL_SERVER specifies the fetch archive log (FAL) server for the standby database.
The FAL_CLIENT specifies the FAL client name. Both are used by the FAL service. The FAL_SERVER is the primary and FAL_CLIENT is the standby.
In Primary site:
FAL_SERVER=STANDBY
FAL_CLIENT=PRIMARY
In Standby site:
FAL_SERVER=PRIMARY
FAL_CLIENT=STANDB
SQL> alter system set FAL_SERVER=hrsty;
System altered.
SQL> alter system set FAL_CLIENT=hr;
System altered.
SQL>
SQL> show parameter fal
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
fal_client string HR
fal_server string HRSTY
SQL>
Operating system file additions and deletions can be replicated to the physical standby database setting STANDBY_FILE_MANAGEMENT to auto.
SQL> show parameter standby_file_management
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
standby_file_management string MANUAL
SQL>
SQL>
SQL>
SQL> alter system set standby_file_management=auto;
System altered.
SQL> show parameter standby_file_management
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
standby_file_management string AUTO
SQL>
SQL> show parameter remote_login_passwordfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
remote_login_passwordfile string EXCLUSIVE
SQL>
SQL> select name from v$datafile;
NAME
----------------------------------------------------------------------
/u01/app/oracle/oradata/hr/system01.dbf
/u01/app/oracle/oradata/hr/sysaux01.dbf
/u01/app/oracle/oradata/hr/undotbs01.dbf
/u01/app/oracle/oradata/hr/users01.dbf
/u01/app/oracle/oradata/hr/example01.dbf
/u01/app/oracle/oradata/hr/test01.dbf
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/hr/redo03.log
/u01/app/oracle/oradata/hr/redo02.log
/u01/app/oracle/oradata/hr/redo01.log
/u01/app/oracle/oradata/hr/stby_redo01.log
/u01/app/oracle/oradata/hr/stby_redo02.log
/u01/app/oracle/oradata/hr/stby_redo03.log
/u01/app/oracle/oradata/hr/stby_redo04.log
primary files location :
db files: /u01/app/oracle/oradata/hr/
redo log files : /u01/app/oracle/oradata/hr/
standby files locations :
db files: /u01/app/oracle/oradata/hrsty/
redo log files : /u01/app/oracle/oradata/hrsty/
SQL> alter system set DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/hr/','/u01/app/oracle/oradata/hrsty/' scope=spfile;
System altered.
SQL> alter system set LOG_FILE_NAME_CONVERT='/u01/app/oracle/oradata/hr/','/u01/app/oracle/oradata/hrsty/' scope=spfile;
System altered.
SQL> show parameter conve
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert string
log_file_name_convert string
SQL>
SQL> alter system set DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/hr/','/u01/app/oracle/oradata/hrsty/' scope=spfile;
System altered.
SQL> alter system set LOG_FILE_NAME_CONVERT='/u01/app/oracle/oradata/hr/','/u01/app/oracle/oradata/hrsty/' scope=spfile;
System altered.
(Need restart database for reflect parameter)
SQL> show parameter conve
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert string /u01/app/oracle/oradata/hr/, /
u01/app/oracle/oradata/hrsty/
log_file_name_convert string /u01/app/oracle/oradata/hr/, /
u01/app/oracle/oradata/hrsty/
SQL>
2. Ensure that the sql*net connectivity is working fine.
===============================================================================
Insert a static entry for hrsty in the listener.ora file of the standby system.
NOTE : For non default port set the REMOTE_LISTENER
primary network files
[oracle@pri admin]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 27-AUG-2017 11:13:24
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Starting /u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.4.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/pri/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=pri)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=pri)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 27-AUG-2017 11:13:24
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/pri/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=pri)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "hr" has 1 instance(s).
Instance "hr", status UNKNOWN, has 1 handler(s) for this service...
Service "hrsty" has 1 instance(s).
Instance "hrsty", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@pri admin]$
[oracle@pri admin]$
[oracle@pri admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = pri)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME =hr )
)
(SID_DESC =
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME =hrsty )
)
)
ADR_BASE_LISTENER = /u01/app/oracle
[oracle@pri admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
HR =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.12)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = hr)
)
)
HRSTY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.13)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = hrsty)
)
)
[oracle@pri admin]$
standby network files
-----------------------------------
[oracle@stby admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = hrsty)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = hrsty)
)
(SID_DESC =
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME =hr )
)
)
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.13)(PORT = 1521))
)
ADR_BASE_LISTENER = /u01/app/oracle
[oracle@stby admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
HR =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.12)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = hr)
)
)
HRSTY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.13)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = hrsty)
)
)
[oracle@stby admin]$
[oracle@stby admin]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 27-AUG-2017 11:13:38
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Starting /u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.4.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/stby/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.13)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.13)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 27-AUG-2017 11:13:38
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/stby/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.13)(PORT=1521)))
Services Summary...
Service "hr" has 1 instance(s).
Instance "hr", status UNKNOWN, has 1 handler(s) for this service...
Service "hrsty" has 1 instance(s).
Instance "hrsty", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@stby admin]$
Check with the SQL*Net configuration using the following commands on the Primary AND Standby
tnsping hr
tnsping hrsty
from primary
---------------------
[oracle@pri admin]$ tnsping hr
TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 27-AUG-2017 11:15:33
Copyright (c) 1997, 2013, 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.1.12)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = hr)))
OK (0 msec)
[oracle@pri admin]$ tnsping hrsty
TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 27-AUG-2017 11:15:39
Copyright (c) 1997, 2013, 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.1.13)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = hrsty)))
OK (0 msec)
[oracle@pri admin]$
From standby
----------------------------
[oracle@stby admin]$ tnsping hr
TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 27-AUG-2017 11:18:05
Copyright (c) 1997, 2013, 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.1.12)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = hr)))
OK (10 msec)
[oracle@stby admin]$
[oracle@stby admin]$ tnsping hrsty
TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 27-AUG-2017 11:18:08
Copyright (c) 1997, 2013, 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.1.13)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = hrsty)))
OK (0 msec)
[oracle@stby admin]$
3. Create the standby database
=========================================================
a. Copy the password file from the primary $ORACLE_HOME/dbs and rename it to the standby database name.
The username is required to be SYS and the password needs to be the same on the Primary and Standby.
The best practice for this is to copy the passwordfile as suggested.
The password file name must match the instance name/SID used at the standby site, not the DB_NAME.
b. Create a initialization parameter with only one parameter DB_NAME.
DB_NAME=hr
DB_UNIQUE_NAME=hrsty
DB_BLOCK_SIZE=<same as primary>
mkdir oradata
mkdir oradata/hrsty
[oracle@stby admin]$ pwd
/u01/app/oracle/admin
mkdir /u01/app/oracle/admin/hrsty
mkdir /u01/app/oracle/admin/hrsty/adump
mkdir /u01/app/oracle/admin/hrsty/bdump
mkdir /u01/app/oracle/admin/hrsty/dpdump
mkdir /u01/app/oracle/admin/hrsty/pfile
[oracle@stby hrsty]$ pwd
/u01/app/oracle/admin/hrsty
[oracle@stby hrsty]$ ls -lrt
total 16
drwxr-xr-x. 2 oracle oinstall 4096 Aug 27 11:24 adump
drwxr-xr-x. 2 oracle oinstall 4096 Aug 27 11:24 bdump
drwxr-xr-x. 2 oracle oinstall 4096 Aug 27 11:24 dpdump
drwxr-xr-x. 2 oracle oinstall 4096 Aug 27 11:24 pfile
[oracle@stby hrsty]
[oracle@stby hrsty]$ pwd
/u01/app/oracle/fast_recovery_area
[oracle@stby hrsty]$mkdir hrsty
[oracle@stby fast_recovery_area]$ ls -lrt
total 4
drwxr-xr-x. 2 oracle oinstall 4096 Aug 27 11:51 hrsty
[oracle@stby fast_recovery_area]$
oracle@stby oradata]$ mkdir hrsty
[oracle@stby oradata]$ ls -lrt
total 4
drwxr-xr-x. 2 oracle oinstall 4096 Aug 27 11:53 hrsty
[oracle@stby oradata]$ pwd
/u01/app/oracle/oradata
[oracle@stby oradata]$
Add the following line to /etc/oratab on the standby server.
hrsty:/u01/app/oracle/product/11.2.0/dbhome_1:N
[oracle@stby hrsty]$ cat /etc/oratab
#
# This file is used by ORACLE utilities. It is created by root.sh
# and updated by either Database Configuration Assistant while creating
# a database or ASM Configuration Assistant while creating ASM instance.
# A colon, ':', is used as the field terminator. A new line terminates
# the entry. Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
# $ORACLE_SID:$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively. The third filed indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
#
hrsty:/u01/app/oracle/product/11.2.0/dbhome_1:N
[oracle@stby hrsty]$
Create a basic PFILE in ORACLE_HOME/dbs with the following parameters.
u01/app/oracle/product/11.2.0/dbhome_1/dbs/oracle $ orapwd file=orapwhr password=oracle entries=5
orapwd file=orapwhr password=oracle entries=5
scp orapwhr stby:/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwhrsty
[oracle@pri dbs]$ scp orapwhr stby:/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwhrsty
The authenticity of host 'stby (192.168.1.13)' can't be established.
RSA key fingerprint is f5:e6:6d:1a:54:0a:22:3f:64:df:ff:66:d8:b2:df:03.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'stby' (RSA) to the list of known hosts.
oracle@stby's password:
orapwhr 100% 1536 1.5KB/s 00:00
[oracle@pri dbs]$
Create a basic PFILE in ORACLE_HOME/dbs with the following parameters.
DB_NAME=hr
DB_UNIQUE_NAME=hrsty
[oracle@stby dbs]$ cat inithrsty.ora
DB_NAME=hr
DB_UNIQUE_NAME=hrsty
[oracle@stby dbs]$
[oracle@stby dbs]$ . oraenv
ORACLE_SID = [oracle] ? hrsty
The Oracle base remains unchanged with value /u01/app/oracle
[oracle@stby dbs]$
[oracle@stby dbs]$ echo $ORACLE_SID
hrsty
[oracle@stby dbs]$
[oracle@stby dbs]$ sqlplus "/as sysdba"
SQL*Plus: Release 11.2.0.4.0 Production on Sun Aug 27 11:49:25 2017
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 217157632 bytes
Fixed Size 2251816 bytes
Variable Size 159384536 bytes
Database Buffers 50331648 bytes
Redo Buffers 5189632 bytes
SQL>
SQL> show parameter db_na
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name string hr
SQL> show parameter db_uni
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_unique_name string hrsty
SQL>
Below is the RMAN run command to perform the database duplication from and active database along with brief explanations for the options used in the duplicate.
FOR STANDBY – the duplicate is for use as a standby so a DBID change will not be forced.
FROM ACTIVE DATABASE – instructs RMAN to use the active target database instead of disk based backups.
DORECOVER – do recovery bringing the standby database up to the current point in time.
SPFILE – values for parameters specific to the auxiliary instance can be set here.
NOFILENAMECHECK – this option is added because the duplicate database files uses the same name as the source database.
Primary parameter
SQL> col value for a90
col name for a50
select name, value
from v$parameter
where name in ('db_name','db_unique_name','log_archive_config', 'log_archive_dest_1','log_archive_dest_2',
'log_archive_dest_state_1','log_archive_dest_state_2', 'remote_login_passwordfile',
'log_archive_format','log_archive_max_processes','fal_server','fal_client','db_file_name_convert',
'log_file_name_convert', 'standby_file_management','control_files');
NAME VALUE
-------------------------------------------------- ------------------------------------------------------------------------------------------
control_files /u01/app/oracle/oradata/hr/control01.ctl, /u01/app/oracle/fast_recovery_area/hr/control02.ctl
db_file_name_convert /u01/app/oracle/oradata/hr/, /u01/app/oracle/oradata/hrsty/
log_file_name_convert /u01/app/oracle/oradata/hr/, /u01/app/oracle/oradata/hrsty/
log_archive_dest_1 LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=hr
log_archive_dest_2 SERVICE=hrsty LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=hrsty
log_archive_dest_state_1 enable
log_archive_dest_state_2 enable
fal_client HR
fal_server HRSTY
log_archive_config DG_CONFIG=(hr,hrsty)
log_archive_format %t_%s_%r.arc
log_archive_max_processes 4
standby_file_management AUTO
remote_login_passwordfile EXCLUSIVE
db_name hr
db_unique_name hr
16 rows selected.
SQL>
On primary side
rman target /
connect auxiliary sys/oracle@hrsty
orapwd file=orapwhr password=oracle entries=5 ignorecase=Y
There are no spaces permitted around the equal-to (=).
[oracle@pri dbs]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Sun Aug 27 12:19:01 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: HR (DBID=3602606687)
RMAN> connect auxiliary sys/oracle@hrsty
connected to auxiliary database: HR (not mounted)
RMAN>
run {
allocate channel pri1 type disk;
allocate channel pri2 type disk;
allocate channel prmy4 type disk;
allocate auxiliary channel stby type disk;
duplicate target database for standby from active database
spfile
parameter_value_convert 'hr','hrsty'
set db_unique_name='hrsty'
set control_files='/u01/app/oracle/oradata/hrsty/control01.ctl','/u01/app/oracle/fast_recovery_area/hrsty/control02.ctl'
set fal_client='hrsty'
set fal_server='hr'
set log_archive_max_processes='5'
set standby_file_management='AUTO'
set log_archive_config='dg_config=(hr,hrsty)'
set db_file_name_convert='/u01/app/oracle/oradata/hr/','/u01/app/oracle/oradata/hrsty/'
set log_file_name_convert='/u01/app/oracle/oradata/hr/','/u01/app/oracle/oradata/hrsty/'
set log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=hrsty'
set log_archive_dest_2='service=hr ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=hr'
;
}
on standby site
------------------------
SQL> select name,open_mode,DATABASE_ROLE from v$database;
NAME OPEN_MODE DATABASE_ROLE
--------- -------------------- ----------------
HR MOUNTED PHYSICAL STANDBY
SQL> alter database open;
Database altered.
SQL> select name,open_mode,DATABASE_ROLE from v$database;
NAME OPEN_MODE DATABASE_ROLE
--------- -------------------- ----------------
HR READ ONLY PHYSICAL STANDBY
SQL>
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 21
Next log sequence to archive 0
Current log sequence 23
SQL>
SQL> alter database recover managed standby database disconnect from session;
Database altered.
SQL> select name,open_mode,DATABASE_ROLE from v$database;
NAME OPEN_MODE DATABASE_ROLE
--------- -------------------- ----------------
HR READ ONLY WITH APPLY PHYSICAL STANDBY
SQL>
SQL> select protection_mode,protection_level,database_role,name from v$database;
PROTECTION_MODE PROTECTION_LEVEL DATABASE_ROLE NAME
-------------------- -------------------- ---------------- ---------
MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE PHYSICAL STANDBY HR
we can validate that that logs are shipping and applying. On the standby issue the following query.
===========================================================================================================
On standby
SQL> select sequence#, first_time, next_time, applied
from v$archived_log
order by sequence#; 2 3
SEQUENCE# FIRST_TIM NEXT_TIME APPLIED
---------- --------- --------- ---------
19 27-AUG-17 27-AUG-17 YES
20 27-AUG-17 27-AUG-17 YES
21 27-AUG-17 27-AUG-17 YES
22 27-AUG-17 27-AUG-17 YES
23 27-AUG-17 27-AUG-17 YES
24 27-AUG-17 27-AUG-17 YES
25 27-AUG-17 27-AUG-17 YES
26 27-AUG-17 27-AUG-17 YES
27 27-AUG-17 27-AUG-17 YES
28 27-AUG-17 27-AUG-17 YES
29 27-AUG-17 27-AUG-17 YES
30 27-AUG-17 27-AUG-17 YES
31 27-AUG-17 27-AUG-17 YES
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 24
Next log sequence to archive 0
Current log sequence 26
SQL>
SQL> SELECT 'Last Applied : ' Logs,
2 TO_CHAR(next_time,'DD-MON-YY:HH24:MI:SS') TIME,thread#,sequence#
FROM v$archived_log
WHERE sequence# =
(SELECT MAX(sequence#) FROM v$archived_log WHERE applied='YES'
)
UNION
SELECT 'Last Received : ' Logs,
TO_CHAR(next_time,'DD-MON-YY:HH24:MI:SS') TIME,thread#,sequence#
FROM v$archived_log
WHERE sequence# =
(SELECT MAX(sequence#) FROM v$archived_log );
LOGS TIME THREAD# SEQUENCE#
---------------- --------------------------- ---------- ----------
Last Applied : 27-AUG-17:12:52:32 1 31
Last Received : 27-AUG-17:12:52:32 1 31
SQL>
On primary
============================
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 24
Next log sequence to archive 26
Current log sequence 26
SQL>
SQL> SELECT
2 (SELECT name FROM V$DATABASE
) name,
(SELECT MAX (sequence#) FROM v$archived_log WHERE dest_id = 1
) Current_primary_seq,
(SELECT MAX (sequence#)
FROM v$archived_log
WHERE TRUNC(next_time) > SYSDATE - 1
AND dest_id = 2
) max_stby,
(SELECT NVL (
(SELECT MAX (sequence#) - MIN (sequence#)
FROM v$archived_log
WHERE TRUNC(next_time) > SYSDATE - 1
AND dest_id = 2
AND applied = 'NO'
), 0)
FROM DUAL
) "To be applied",
(
(SELECT MAX (sequence#) FROM v$archived_log WHERE dest_id = 1
) -
(SELECT MAX (sequence#) FROM v$archived_log WHERE dest_id = 2
)) "To be Shipped"
FROM DUAL;
NAME CURRENT_PRIMARY_SEQ MAX_STBY To be applied To be Shipped
--------- ------------------- ---------- ------------- -------------
HR 31 31 0 0
SQL>
logs
===============
[oracle@pri dbs]$
[oracle@pri dbs]$
[oracle@pri dbs]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Sun Aug 27 12:19:01 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: HR (DBID=3602606687)
RMAN> connect auxiliary sys/oracle@hrsty
connected to auxiliary database: HR (not mounted)
RMAN> run {
allocate channel pri1 type disk;
allocate channel pri2 type disk;
allocate channel prmy4 type disk;
allocate auxiliary channel stby type disk;
duplicate target database for standby from active database
spfile
parameter_value_convert 'hr','hrsty'
set db_unique_name='hrsty'
set control_files='/u01/app/oracle/oradata/hrsty/control01.ctl','/u01/app/oracle/fast_recovery_area/hrsty/control02.ctl'
2> 3> 4> 5> 6> 7> 8> 9> 10> 11> set fal_client='hrsty'
set fal_server='hr'
set log_archive_max_processes='5'
set standby_file_management='AUTO'
set log_archive_config='dg_config=(hr,hrsty)'
set db_file_name_convert='/u01/app/oracle/oradata/hr/','/u01/app/oracle/oradata/hrsty/'
set log_file_name_convert='/u01/app/oracle/oradata/hr/','/u01/app/oracle/oradata/hrsty/'
set log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=hrsty'
set log_archive_dest_2='service=hr ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=hr'
;
}12> 13> 14> 15> 16> 17> 18> 19> 20> 21>
using target database control file instead of recovery catalog
allocated channel: pri1
channel pri1: SID=41 device type=DISK
allocated channel: pri2
channel pri2: SID=42 device type=DISK
allocated channel: prmy4
channel prmy4: SID=40 device type=DISK
allocated channel: stby
channel stby: SID=19 device type=DISK
Starting Duplicate Db at 27-AUG-17
contents of Memory Script:
{
backup as copy reuse
targetfile '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwhr' auxiliary format
'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwhrsty' targetfile
'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfilehr.ora' auxiliary format
'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfilehrsty.ora' ;
sql clone "alter system set spfile= ''/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfilehrsty.ora''";
}
executing Memory Script
Starting backup at 27-AUG-17
Finished backup at 27-AUG-17
sql statement: alter system set spfile= ''/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfilehrsty.ora''
contents of Memory Script:
{
sql clone "alter system set audit_file_dest =
''/u01/app/oracle/admin/hrsty/adump'' comment=
'''' scope=spfile";
sql clone "alter system set dispatchers =
''(PROTOCOL=TCP) (SERVICE=hrstyXDB)'' comment=
'''' scope=spfile";
sql clone "alter system set db_unique_name =
''hrsty'' comment=
'''' scope=spfile";
sql clone "alter system set control_files =
''/u01/app/oracle/oradata/hrsty/control01.ctl'', ''/u01/app/oracle/fast_recovery_area/hrsty/control02.ctl'' comment=
'''' scope=spfile";
sql clone "alter system set fal_client =
''hrsty'' comment=
'''' scope=spfile";
sql clone "alter system set fal_server =
''hr'' comment=
'''' scope=spfile";
sql clone "alter system set log_archive_max_processes =
5 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=(hr,hrsty)'' comment=
'''' scope=spfile";
sql clone "alter system set db_file_name_convert =
''/u01/app/oracle/oradata/hr/'', ''/u01/app/oracle/oradata/hrsty/'' comment=
'''' scope=spfile";
sql clone "alter system set log_file_name_convert =
''/u01/app/oracle/oradata/hr/'', ''/u01/app/oracle/oradata/hrsty/'' comment=
'''' scope=spfile";
sql clone "alter system set log_archive_dest_1 =
''LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=hrsty'' comment=
'''' scope=spfile";
sql clone "alter system set log_archive_dest_2 =
''service=hr ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=hr'' comment=
'''' scope=spfile";
shutdown clone immediate;
startup clone nomount;
}
executing Memory Script
sql statement: alter system set audit_file_dest = ''/u01/app/oracle/admin/hrsty/adump'' comment= '''' scope=spfile
sql statement: alter system set dispatchers = ''(PROTOCOL=TCP) (SERVICE=hrstyXDB)'' comment= '''' scope=spfile
sql statement: alter system set db_unique_name = ''hrsty'' comment= '''' scope=spfile
sql statement: alter system set control_files = ''/u01/app/oracle/oradata/hrsty/control01.ctl'', ''/u01/app/oracle/fast_recovery_area/hrsty/control02.ctl'' comment= '''' scope=spfile
sql statement: alter system set fal_client = ''hrsty'' comment= '''' scope=spfile
sql statement: alter system set fal_server = ''hr'' comment= '''' scope=spfile
sql statement: alter system set log_archive_max_processes = 5 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=(hr,hrsty)'' comment= '''' scope=spfile
sql statement: alter system set db_file_name_convert = ''/u01/app/oracle/oradata/hr/'', ''/u01/app/oracle/oradata/hrsty/'' comment= '''' scope=spfile
sql statement: alter system set log_file_name_convert = ''/u01/app/oracle/oradata/hr/'', ''/u01/app/oracle/oradata/hrsty/'' comment= '''' scope=spfile
sql statement: alter system set log_archive_dest_1 = ''LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=hrsty'' comment= '''' scope=spfile
sql statement: alter system set log_archive_dest_2 = ''service=hr ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=hr'' comment= '''' scope=spfile
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 1252663296 bytes
Fixed Size 2252824 bytes
Variable Size 788533224 bytes
Database Buffers 452984832 bytes
Redo Buffers 8892416 bytes
allocated channel: stby
channel stby: SID=18 device type=DISK
contents of Memory Script:
{
backup as copy current controlfile for standby auxiliary format '/u01/app/oracle/oradata/hrsty/control01.ctl';
restore clone controlfile to '/u01/app/oracle/fast_recovery_area/hrsty/control02.ctl' from
'/u01/app/oracle/oradata/hrsty/control01.ctl';
}
executing Memory Script
Starting backup at 27-AUG-17
channel pri1: starting datafile copy
copying standby control file
output file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_hr.f tag=TAG20170827T122351 RECID=2 STAMP=953123032
channel pri1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 27-AUG-17
Starting restore at 27-AUG-17
channel stby: copied control file copy
Finished restore at 27-AUG-17
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
"/u01/app/oracle/oradata/hrsty/temp01.dbf";
switch clone tempfile all;
set newname for datafile 1 to
"/u01/app/oracle/oradata/hrsty/system01.dbf";
set newname for datafile 2 to
"/u01/app/oracle/oradata/hrsty/sysaux01.dbf";
set newname for datafile 3 to
"/u01/app/oracle/oradata/hrsty/undotbs01.dbf";
set newname for datafile 4 to
"/u01/app/oracle/oradata/hrsty/users01.dbf";
set newname for datafile 5 to
"/u01/app/oracle/oradata/hrsty/example01.dbf";
set newname for datafile 6 to
"/u01/app/oracle/oradata/hrsty/test01.dbf";
backup as copy reuse
datafile 1 auxiliary format
"/u01/app/oracle/oradata/hrsty/system01.dbf" datafile
2 auxiliary format
"/u01/app/oracle/oradata/hrsty/sysaux01.dbf" datafile
3 auxiliary format
"/u01/app/oracle/oradata/hrsty/undotbs01.dbf" datafile
4 auxiliary format
"/u01/app/oracle/oradata/hrsty/users01.dbf" datafile
5 auxiliary format
"/u01/app/oracle/oradata/hrsty/example01.dbf" datafile
6 auxiliary format
"/u01/app/oracle/oradata/hrsty/test01.dbf" ;
sql 'alter system archive log current';
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /u01/app/oracle/oradata/hrsty/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
executing command: SET NEWNAME
Starting backup at 27-AUG-17
channel pri1: starting datafile copy
input datafile file number=00006 name=/u01/app/oracle/oradata/hr/test01.dbf
channel pri2: starting datafile copy
input datafile file number=00001 name=/u01/app/oracle/oradata/hr/system01.dbf
channel prmy4: starting datafile copy
input datafile file number=00002 name=/u01/app/oracle/oradata/hr/sysaux01.dbf
output file name=/u01/app/oracle/oradata/hrsty/sysaux01.dbf tag=TAG20170827T122402
channel prmy4: datafile copy complete, elapsed time: 00:08:58
channel prmy4: starting datafile copy
input datafile file number=00005 name=/u01/app/oracle/oradata/hr/example01.dbf
output file name=/u01/app/oracle/oradata/hrsty/system01.dbf tag=TAG20170827T122402
channel pri2: datafile copy complete, elapsed time: 00:09:34
channel pri2: starting datafile copy
input datafile file number=00003 name=/u01/app/oracle/oradata/hr/undotbs01.dbf
output file name=/u01/app/oracle/oradata/hrsty/undotbs01.dbf tag=TAG20170827T122402
channel pri2: datafile copy complete, elapsed time: 00:00:25
channel pri2: starting datafile copy
input datafile file number=00004 name=/u01/app/oracle/oradata/hr/users01.dbf
output file name=/u01/app/oracle/oradata/hrsty/users01.dbf tag=TAG20170827T122402
channel pri2: datafile copy complete, elapsed time: 00:00:03
output file name=/u01/app/oracle/oradata/hrsty/test01.dbf tag=TAG20170827T122402
channel pri1: datafile copy complete, elapsed time: 00:10:25
output file name=/u01/app/oracle/oradata/hrsty/example01.dbf tag=TAG20170827T122402
channel prmy4: datafile copy complete, elapsed time: 00:01:26
Finished backup at 27-AUG-17
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=2 STAMP=953123668 file name=/u01/app/oracle/oradata/hrsty/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=3 STAMP=953123668 file name=/u01/app/oracle/oradata/hrsty/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=4 STAMP=953123668 file name=/u01/app/oracle/oradata/hrsty/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=5 STAMP=953123668 file name=/u01/app/oracle/oradata/hrsty/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=6 STAMP=953123668 file name=/u01/app/oracle/oradata/hrsty/example01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=7 STAMP=953123668 file name=/u01/app/oracle/oradata/hrsty/test01.dbf
Finished Duplicate Db at 27-AUG-17
released channel: pri1
released channel: pri2
released channel: prmy4
released channel: stby
RMAN>
RMAN>
RMAN>
RMAN>
Step by Step Guide on Creating Physical Standby Using RMAN DUPLICATE...FROM ACTIVE DATABASE (Doc ID 1075908.1)
No comments:
Post a Comment