In the past, as a better-than-nothing backup and disaster recovery strategy, I export it every night and ship the export dump file to a remote server. Now I decide to create a physical standby database at the same remote server for it.
The transaction volumn of this application is typically very low as at any given time there could be just two or three DBAs logged into it to update some info. So it is ideal to use RMAN active database duplication technique to create the physical standby. In this method, RMAN duplicate process copies the active data files of the primary database directly to the remote host through network. RMAN supports two basic types of duplication: active database duplication and backup-based duplication. Oracle online documentation has a section about the considerations to choose duplication technique.
I describe the steps involved in the following:
1. Prepare the production database to be the primary database
a. Ensure that the database is in archivelog mode
b. Enable force logging
SQL> ALTER DATABASE FORCE LOGGING;
c. Create standby redologs
SQL> alter database add standby logfile '/db2st2/u01/oradata/etsdb/stby_redo01.rdo' size 100M;
d. Modify the primary initialization parameter for dataguard on primary,
alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(etsdb,ettdb)';
alter system set LOG_ARCHIVE_DEST_1='LOCATION=/db2st2/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=etsdalter system set LOG_ARCHIVE_DEST_2='SERVICE=ettdb LGWR ASYNC VALID_FOR=(online_LOGFILES, PRIMARY_ROLE) DB_UNIQUE_NAME=ettdb';
alter system set LOG_ARCHIVE_DEST_STATE_1=ENABLE;
alter system set FAL_SERVER=ettdb;
alter system set FAL_CLIENT=etsdb;
alter system set DB_FILE_NAME_CONVERT='/db2st2/u01/oradata/etsdb','/db2/u01/oradata/ettdb' scope=spfile;
alter system set LOG_FILE_NAME_CONVERT='/db2st2/u01/oradata/etsdb','/db2/u01/oradata/ettdb', '/db2st2/u02/oradata/etsdb','/db2/u02/oradata/ettdb' scope=spfile;
2. Ensure that the sql*net connectivity is working fine.
Configure the listener in standby and put the following tns entries in tnsnames.ora:
ettdb = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = standby_server)(PORT = 1523)) ) (CONNECT_DATA = (SERVICE_NAME = ettdb ) ) ) etsdb = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = primary_server)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = etsdb ) ) )Confirm that tnsping ettdb and tnsping etsdb work on both primary and standby sites
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.
orapwetsdb ----> orapwettdb
b. Create a initialization parameter with only one parameter DB_NAME.
-- initettdb.ora DB_NAME=etsdb DB_UNIQUE_NAME=ettdb DB_BLOCK_SIZE=8192
c. Create the necessary directories in the standby location to place the datafiles and the trace files in the $ADR_HOME.
d. Set the environment variable ORACLE_SID to the standby service and start the standby-instance.
% export ORACLE_SID=ettdb % sqlplus "/ as sysdba" SQL> startup nomount pfile=$ORACLE_HOME/dbs/initettdb.ora
e. Verify if the connection 'AS SYSDBA' is working
sqlplus sys@ettdb as sysdba
sqlplus sys@etsdb as sysdba
f. On the primary system invoke the RMAN executable and connect to the primary and the auxiliary database ( i.e., the standby)
$ rman target sys/xxx@etsdb auxiliary sys/xxx@ettdb cmdfile=dup.rmn
content of dup.rmn :
duplicate target database for standby from active database spfile parameter_value_convert 'etsdb','ettdb' set db_unique_name='ettdb' set db_file_name_convert='/db2st2/u01/oradata/etsdb','/db2/u01/oradata/ettdb','/db2st2','/db2' set log_file_name_convert='/db2st2/u01/oradata/etsdb','/db2/u01/oradata/ettdb', '/db2st2/u02/oradata/etsdb','/db2/u02/oradata/ettdb' set control_files='/db2/u01/oradata/ettdb/control01.ctl' set log_archive_dest_1 = 'LOCATION=/db2/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=ettdb' set log_archive_max_processes='5' set fal_client='ettdb' set fal_server='etsdb' set standby_file_management='AUTO' set log_archive_config='dg_config=(etsdb,ettdb)' set log_archive_dest_2='service=etsdb ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=etsdb' ;
4. Connect to standby using SQL*Plus and start the MRP ( Managed Recovery Process)
-- mount db first if required
alter database recover managed standby database disconnect from session;
5. If licensed and want to use Active Dataguard (ADG), than open the Standby Database in READ ONLY and start the revoer
Enable Active Data Guard using SQL Plus :
SQL> alter database recover managed standby database cancel; SQL> alter database open read only; SQL> alter database recover managed standby database disconnect using current logfile; -- verify SQL> select name, db_unique_name, database_role, open_mode from v$database; NAME DB_UNIQUE_NAME DATABASE_ROLE OPEN_MODE --------- ------------------------------ ---------------- -------------------- ETSDB ettdb PHYSICAL STANDBY READ ONLY WITH APPLYtesting to confirm that standby db can be read and meanwhile redo logs are being applied:
in standby create table dbaets.t as select * from all_objects * ERROR at line 1: ORA-00604: error occurred at recursive SQL level 1 ORA-16000: database open for read-only access in primary 1* select thread#, max(sequence#) from v$log_history group by thread# SQL> / THREAD# MAX(SEQUENCE#) ---------- -------------- 1 1057 SQL> create table dbaets.t as select * from all_objects; Table created. SQL> alter system archive log current; System altered. SQL> select thread#, max(sequence#) from v$log_history group by thread# 2 ; THREAD# MAX(SEQUENCE#) ---------- -------------- 1 1058 in standby: SQL> select thread#, max(sequence#) from v$log_history group by thread#; THREAD# MAX(SEQUENCE#) ---------- -------------- 1 1058 SQL> select count(*) from dbaets.t; COUNT(*) ---------- 17855References:
Step by Step Guide on Creating Physical Standby Using RMAN DUPLICATE...FROM ACTIVE DATABASE (Doc ID 1075908.1)
RMAN duplicate: http://docs.oracle.com/cd/E11882_01/backup.112/e10642/rcmdupdb.htm#BRADV298
1 comment:
Note: LOCAL_LISTNER parameter in standby db need to change to reflect standby site env.
Post a Comment