Oracle 11g introduces the "duplicate from active database database to stand by". This feature allows the creation of a stand by database without need a previous backup. The primary database need to be in archive mode.
This is possible by using one RMAN script. It will copy the server parameter file to the standby host, start the auxiliary instance using the server parameter file and will copy control, redologs and datafiles over the network to the stand by host.
1- Create a single instance database (for this case, our primary database will be tst).
Primary server : 10.1.0.1
Secondary server : 10.1.0.2
TNS alias for Primary – TST_PR
TNS alias for standby – TST_DRP
Primary DB_NAME Parameter=tst Primary DB_UNIQUE_NAME Parameter=tst_pri
Standby DB_NAME Parameter=tst Standby DB_UNIQUE_NAME Parameter=tst_drp
ALTER SYSTEM SET LOG_ARCHIVE_CONFIG='DG_CONFIG=(ep0_pri,tst_drp)';
alter system set db_unique_name='tst_pri' SCOPE=SPFILE; (On primary server)
alter system set db_unique_name='tst_drp' SCOPE=SPFILE; (On stand by server)
Check che changes :
select db_unique_name from v$database;
select name from v$database;
1.1- Enable the force logging on primary server
SELECT force_logging FROM v$database;
ALTER DATABASE FORCE LOGGING;
SELECT force_logging FROM v$database;
1.2 The primary databse must be in archive mode log, in case not do the following :
shutdown immediate
startup mount;
alter database archivelog;
alter database open;
1.3 You'll need a password file under $ORACLE_HOME/dbs (if is not already there) in primary server.
orapwd file=orapwTST password=***** entries=30
Copy this password file from $ORACLE_HOME/dbs from primary server to stand-by server under same location.
4- Check entries in tnsnames.ora in both servers :
tnsnames.ora entries on primary server :
TST_PR =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.0.1)(PORT = 1529))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = tst)
)
)
TST_DRP =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.0.2)(PORT = 1529))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = tst)
)
)
tnsnames.ora entries on secondary server :
TST_PR =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.0.1)(PORT = 1529))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = tst)
)
)
TST_DRP =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.0.2)(PORT = 1529))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = tst)
)
)
5- Important : For this example, primary and stand-by database will have same structure.
Both databases must be in archivelog mode.
On stand by server must be created all same directories than primary server (datafiles, control files, tempfiles and redologs files directories)
On stand by server on parameter file set this : *.log_file_name_convert=('/data5/oracle11/tst','/data5/oracle11/tst'), after duplicate, delete this entry from parameter file.
In this case, redo log directories are same on both servers.
6- On the stand by server under $ORACLE_HOME/dbs create pfile/spfile entry
7 - Connect to the stand by server and perform a startup nomount
export ORACLE_SID=tst
sqlplus / as sysdba
startup nomount
7.1 On primary database enable flash back database.
7.1.1 Ensure db_recovery_file_dest is set.
alter system set db_recovery_file_dest='/archive/tst/oraflash' SCOPE=spfile;
7.1.2 Ensure db_recovery_file_dest_size is set
alter system set db_recovery_file_dest_size=1G SCOPE=spfile;
7.1.3 Enable flashback database
alter database flashback on;
7.1.3 Stop and start database in order the parameter takes change :
sqlplus / as sysdba
shutdown immediate
startup
show parameter db_recovery_file_dest
show parameter db_recovery_file_dest_size
select flashback_on from v$database;
8- Modify some parameter un primary servers :
alter system set LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=tst_pri' scope=both;
alter system set LOG_ARCHIVE_DEST_STATE_1=enable scope=both;
alter system set log_archive_config='dg_config=(tst_pri,tst_drp)' scope=both;
alter system set log_archive_dest_2='service=tst_drp LGWR ASYNC valid_for=(online_logfile,primary_role) db_unique_name=tst_drp' scope=both;
In order the changes takes effect do the following :
shutdown immediate
startup
9- On primary server perform the following command :
export ORACLE_SID=tst
rman target sys/******@TST_PR auxiliary sys/******@TST_DRP (The auxiliary is the stand-by entry)
10- After you connect succesfully in both databases, perform the following rman command :
run {
allocate channel prmy1 type disk;
allocate channel prmy2 type disk;
allocate channel prmy3 type disk;
allocate auxiliary channel stby type disk;
duplicate target database for standby from active database dorecover NOFILENAMECHECK;
release channel prmy1;
release channel prmy2;
release channel prmy3;
release channel stby;
}
This is possible by using one RMAN script. It will copy the server parameter file to the standby host, start the auxiliary instance using the server parameter file and will copy control, redologs and datafiles over the network to the stand by host.
1- Create a single instance database (for this case, our primary database will be tst).
Primary server : 10.1.0.1
Secondary server : 10.1.0.2
TNS alias for Primary – TST_PR
TNS alias for standby – TST_DRP
Primary DB_NAME Parameter=tst Primary DB_UNIQUE_NAME Parameter=tst_pri
Standby DB_NAME Parameter=tst Standby DB_UNIQUE_NAME Parameter=tst_drp
ALTER SYSTEM SET LOG_ARCHIVE_CONFIG='DG_CONFIG=(ep0_pri,tst_drp)';
alter system set db_unique_name='tst_pri' SCOPE=SPFILE; (On primary server)
alter system set db_unique_name='tst_drp' SCOPE=SPFILE; (On stand by server)
Check che changes :
select db_unique_name from v$database;
select name from v$database;
1.1- Enable the force logging on primary server
SELECT force_logging FROM v$database;
ALTER DATABASE FORCE LOGGING;
SELECT force_logging FROM v$database;
1.2 The primary databse must be in archive mode log, in case not do the following :
shutdown immediate
startup mount;
alter database archivelog;
alter database open;
1.3 You'll need a password file under $ORACLE_HOME/dbs (if is not already there) in primary server.
orapwd file=orapwTST password=***** entries=30
Copy this password file from $ORACLE_HOME/dbs from primary server to stand-by server under same location.
4- Check entries in tnsnames.ora in both servers :
tnsnames.ora entries on primary server :
TST_PR =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.0.1)(PORT = 1529))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = tst)
)
)
TST_DRP =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.0.2)(PORT = 1529))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = tst)
)
)
tnsnames.ora entries on secondary server :
TST_PR =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.0.1)(PORT = 1529))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = tst)
)
)
TST_DRP =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.0.2)(PORT = 1529))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = tst)
)
)
5- Important : For this example, primary and stand-by database will have same structure.
Both databases must be in archivelog mode.
On stand by server must be created all same directories than primary server (datafiles, control files, tempfiles and redologs files directories)
On stand by server on parameter file set this : *.log_file_name_convert=('/data5/oracle11/tst','/data5/oracle11/tst'), after duplicate, delete this entry from parameter file.
In this case, redo log directories are same on both servers.
6- On the stand by server under $ORACLE_HOME/dbs create pfile/spfile entry
7 - Connect to the stand by server and perform a startup nomount
export ORACLE_SID=tst
sqlplus / as sysdba
startup nomount
7.1 On primary database enable flash back database.
7.1.1 Ensure db_recovery_file_dest is set.
alter system set db_recovery_file_dest='/archive/tst/oraflash' SCOPE=spfile;
7.1.2 Ensure db_recovery_file_dest_size is set
alter system set db_recovery_file_dest_size=1G SCOPE=spfile;
7.1.3 Enable flashback database
alter database flashback on;
7.1.3 Stop and start database in order the parameter takes change :
sqlplus / as sysdba
shutdown immediate
startup
show parameter db_recovery_file_dest
show parameter db_recovery_file_dest_size
select flashback_on from v$database;
8- Modify some parameter un primary servers :
alter system set LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=tst_pri' scope=both;
alter system set LOG_ARCHIVE_DEST_STATE_1=enable scope=both;
alter system set log_archive_config='dg_config=(tst_pri,tst_drp)' scope=both;
alter system set log_archive_dest_2='service=tst_drp LGWR ASYNC valid_for=(online_logfile,primary_role) db_unique_name=tst_drp' scope=both;
In order the changes takes effect do the following :
shutdown immediate
startup
9- On primary server perform the following command :
export ORACLE_SID=tst
rman target sys/******@TST_PR auxiliary sys/******@TST_DRP (The auxiliary is the stand-by entry)
10- After you connect succesfully in both databases, perform the following rman command :
run {
allocate channel prmy1 type disk;
allocate channel prmy2 type disk;
allocate channel prmy3 type disk;
allocate auxiliary channel stby type disk;
duplicate target database for standby from active database dorecover NOFILENAMECHECK;
release channel prmy1;
release channel prmy2;
release channel prmy3;
release channel stby;
}
Comments