# Active Physical Standby Database Duplication - Oracle 11g

RMAN network-based duplication is one of the key new Oracle Database 11g features; with it, you can clone a database without a backup of the primary database server. This section will provide simple steps for creating a physical standby from an active database using RMAN. Some preparation steps are required prior to initiating an active physical standby database duplication over the network. First, create a blank initialization file with just one parameter in the file, specifically, DB_NAME=PRIMARY_DATABASE{DR} in the $ORACLE_HOME/dbs directory. Second, the password file for sys must be the same on both the primary and Data Guard servers. You must use sftp/scp to transfer the files from the primary$ORACLE_HOME/dbs directory to the disaster recovery database server. You also need to create the required Oracle Database 11g Optimal Flexible Architecture (OFA)–related directories:

• $ORACLE_BASE/admin/$ORACLE_SID/adump
• $ORACLE_BASE/admin/$ORACLE_SID/pfile
• $ORACLE_BASE/admin/$ORACLE_SID/wallet

Now, it’s time to create the listener.ora and tnsnames.ora file entries on both the primary and disaster recovery nodes. You need to make sure the appropriate entries are on both of the tnsnames.ora files. If you are planning to use the broker, you need to pay particular attention to the LISTENER file’s global_dbname parameter. The name of global_dbname must include the _dgmgrl parameter to it. For example, the following listener.ora entry is provided with the appropriate global_dbname parameter:

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /apps/oracle/product/11.1.0/DB)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = DBA11gDR_DGMGRL.dbaexpert.com)
(ORACLE_HOME = /apps/oracle/product/11.1.0/DB)
(SID_NAME = DBA11gDR)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = bpo40.dbaexpert.com)(PORT = 1521))
)
)

After the appropriate changes are made, the database instance and the listeners need to be restarted on both the primary and physical standby database servers.

Lastly, the standby redo logs should be added on the primary standby database so that they will be duplicated as part of the active network–based physical standby duplication.

Mike Smith, a principal member of the technical staff in the High Availability group at Oracle, has provided a script to build a standby database. This RMAN script can single-handedly create a physical standby database over the network. This single integrated RMAN script will duplicate the source database over the network, copy the spfile, copy the controlfile, and duplicate the database. During the process, both the primary and standby initialization parameters will be updated to accommodate the Data Guard configuration.

You can use the following script to create a physical standby database from the remote node:

rman <EOF>
connect target sys/oracle123@DBA11g;
connect auxiliary sys/oracle123@DBA11gDR; run {
allocate channel prmy1 type disk;
allocate channel prmy2 type disk;
allocate channel prmy3 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 'DBA11g','DBA11gDR'
set 'db_unique_name'='DBA11gDR'
set 'db_file_name_convert'='/DBA11g/','/DBA11gDR/'
set log_file_name_convert='/DBA11g/','/DBA11gDR/'
set log_archive_max_processes='5'
set fal_client='DBA11gDR'
set fal_server='DBA11g'
set standby_file_management='AUTO'
set log_archive_config='dg_config=(DBA11g,DBA11gDR)'
set log_archive_dest_1='service=DBA11g LGWR ASYNC
valid_for=(ONLINE_LOGFILES,PRIMARY_ROLE)
db_unique_name=DBA11g'
;
sql channel prmy1 "alter system set log_archive_config=''dg_
config=(DBA11g,DBA11gDR)''";
sql channel prmy1 "alter system set log_archive_dest_1=
''service=DBA11gDR LGWR ASYNC valid_for=(online_logfiles,primary_role)
db_unique_name=DBA11gDR''";
sql channel prmy1 "alter system set log_archive_max_processes=5";
sql channel prmy1 "alter system set fal_client=DBA11g";
sql channel prmy1 "alter system set fal_server=DBA11gDR";
sql channel prmy1 "alter system set standby_file_management=auto";
sql channel prmy1 "alter system set log_archive_dest_state_1=enable";
sql channel prmy1 "alter system archive log current";
allocate auxiliary channel stby type disk;
sql channel stby "alter database recover managed standby database
using current logfile disconnect";
}
EOF

Once the script successfully creates a standby database, you will be able to configure the additional options discussed in this chapter.

Note:We recommend that the DR database db_unique_name parameter should be named $ORACLE_ SID{DR}. The db_unique_name parameter of the primary database can be retrieved on the standby database by querying the PRIMARY_DB_UNIQUE_NAME column in the V$DATABASE view.

The db_unique_name parameter is treated differently in Oracle Database 11g. Databases with the same db_unique_name parameter will not be able to participate in a Data Guard configuration. If the primary and Data Guard standby database db_unique_name parameter is the same, these databases will not be able to communicate with each other after the upgrade.