This document describes the steps to create a physical standby database including:
1. Configuring the primary and standby databases with the same Oracle version and opening the primary in archive log mode.
2. Setting up Oracle Net components and testing connectivity between the databases.
3. Enabling archive logging and log shipping on the primary and duplicating or copying the primary database to the standby.
4. Recovering the standby database and opening it in read-only mode to synchronize the data.
1. Creating a Physical Standby Database
Cách thực hiện:
1. Tạo 2 máy ảo ping thông mạng và phải có môi trường giống nhau.
2. Cấu hình tnsname, listener, sql và kiểm tra kết nối.
3. Cấu hình Initialization Parameter File cho primary và standby
4. Add redolog file
5. Tạo controlfile cho standby từ primary.
6. Copy source primary đến standby
7. Kiểm tra
Chuẩn bị:
- OS Names: "prime" for the Primary database and "standby" for the Standby database.
Network:
Trên Prime:
2. Trên Standby:
Next:
+ The primary and standby databases must be using the same version of Oracle Database 11g.
+ The primary database must be opened in ARCHIVELOG mode.
+Install the database, Enterprise edition. (using DBCA)
+Set up Oracle net components (using NETCA)
3. +Test sql net connectivity.
PRIME:
SQL> Alter system set db_recovery_file_dest_size=2G scope=both;
System altered.
Alter system set db_recovery_file_dest=’C:BKFRA’
Select * from v$recovery_file_dest
Oracle Net Services network files must be set up on the primary database and on the standby
database.
SQLNET.ORA file of the Primary:
8. Create standby redo logs(On Prime):
SELECT * from v$logfile;
Alter database add standby logfile group 4 (‘C:apporacleoradataoraprimestandbyredo01.LOG’)
size 50M;
Alter database add standby logfile group 5 (‘C:apporacleoradataoraprimestandbyredo03.LOG’)
size 50M;
Alter database add standby logfile group 6 (‘C:apporacleoradataoraprimestandbyredo03.LOG’)
size 50M;
Alter database add standby logfile group 7 (‘C:apporacleoradataoraprimestandbyredo04.LOG’)
size 50M;
Next: Enable force logging (Optional) (On Prime)
Select log_mode from v$database;
Alter database force logging;
10. alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(oraprime,orastandby)';
alter system set LOG_ARCHIVE_DEST_1='LOCATION=+DATA VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=oraprime';
alter system set LOG_ARCHIVE_DEST_2='SERVICE=orastandby LGWR ASYNC
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME= orastandby’;
alter system set LOG_ARCHIVE_DEST_STATE_1=ENABLE;
alter system set FAL_SERVER=orastandby;
alter system set FAL_CLIENT=oraprime;
alter database add standby logfile '+DATA';
alter database add standby logfile '+DATA';
alter database add standby logfile '+DATA';
alter database add standby logfile '+DATA';
On Standby:
Option 1: Create pfile with only one parameter DB_NAME.
Start up no mount the database using the pfile.
11. Using: - Run RMAN Dupplicate database on primary
rman target sys/@oraprime auxiliary sys/oracle@orastandby
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 'oraprime','orastandby'
set db_unique_name='orastandby'
set control_files='+DATA'
set log_archive_max_processes='5'
set fal_client='oraprime'
set fal_server='orastandby'
set standby_file_management='AUTO'
set log_archive_config='dg_config=(oraprime,orastandby)'
set log_archive_dest_2='service=oraprime LGWR ASYNC
valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=prime'
12. ;
}
Start apply service on standby & Open for read-only
recover managed standby database using current logfile disconnect from session;
recover managed standby database cancel;
alter database open;
recover managed standby database using current logfile disconnect from session;
Option 2: On PRIME
Create a Control File for the Standby Database
SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP MOUNT;
SQL>ALTER DATABASE CREATE STANDBY CONTROLFILE AS
'C:tostandbycontrolstd.ctl';
SQL> ALTER DATABASE OPEN;
Create a pFile for the Standby Database: