Вы находитесь на странице: 1из 3

Standby Database creation

Choose two instance names as abc01 and xyz01, db_name will remain same.
create a database make a cold backup, copy the pfile and edit as below.
the primary database should be archive log mode.
password file to be create
$ orapwd=$ORACLE_HOME/dbs/orapwxyz01 passwd=sys entries=5 and
$ orapwd=$ORACLE_HOME/dbs/orapwabc01 passwd=sys entries=5
parameter for Standby database xyz01
1. log_archive_dest_state_2='ENABLE'
2. log_archive_dest_1='LOCATION=/app/orcl/xyz01/arch01/'
3. standby_archive_dest='/app/orcl/xyz01/abcarch'
4. standby_file_management=auto
5. db_file_name_convert='/app/orcl/abc01/','/app/orcl/xyz01/'
6. log_file_name_convert='/app/orcl/abc01/','/app/orcl/xyz01/'
7. db_unique_name=xyz01
Parameter in Primary database abc01
log_archive_dest_2='service=xyz01'
At the primary database abc01:
1) Configure listener and tnsnames with 'xyz01' as connect string
2) # alter database set standby database to maximize performance; (default)
2) startup the Primary database abc01 to open.
3) create standby controlfile “ alter database create standby controlfile as '/app/orcl/xyz01/control01.ctl';
At the standby database xyz01:
1. sql> startup nomunt;
2. startup the standby database xyz01 to nomount.
sql> alter database mount standby database;
3. sql> alter database recover managed standby database disconnect from session;
Find if the standby database is performing managed recovery.
(If the MRP process exists it means the standby database is performing managed recovey.)
sql> select process, status from v$managed_standby;
Monitoring the process activityes:
sql> select process, client_process, sequence#, status from v$managed_standby;
PROCESS STATUS
------------- -------------------
ARCH CONNECTED
MRP0 WAIT_FOR_LOG / WAIT_FOR_GAP
RFS IDLE / ATTACHED / RECEIVING
#RECEIVING - process is receiving network communication
#ATTACHED - process is actively attached and communicating to a primary database client
# WAIT_FOR_LOG - process is waiting for the archived redolog to be completed
# WAIT_FOR_GAP - process is waiting for the archive gap to be resolved
OTHER QUERIES:
SQL> select max(sequence#) from v$log_history;
SQL> select sequence#, applied, registrar from v$archived_log;
SQL> select protection_mode from v$database;
SQL> select * from v$archive_gap;
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

SWITCH OVER
xyz01 becomes PRIMARY and abc01becomes STANDBY

Steps in primary (abc01): set standby parameter


1. log_archive_dest_state_2='ENABLE'
2. log_archive_dest_1='LOCATION=/app/orcl/abc01/arch01'
3. standby_archive_dest='/app/orcl/abc01/xyzarch'
4. standby_file_management=auto
5. db_file_name_convert='/app/orcl/xyz01/','/app/orcl/abc01/'
6. log_file_name_convert='/app/orcl/xyz01/','/app/orcl/abc01/'
7. db_unique_name=abc01
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

steps in standby (xyz01) : set primary parameter


1. log_archive_dest_2='service=abc01'
check the status on standby (xyz01):
SQL> select database_role, switchover_status, open_mode from v$database;
DATABASE_ROLE SWITCHOVER_STATUS OPEN_MODE
PHYSICAL STANDBY NOT ALLOWED MOUNTED

SQL> select sequence#, applied, registrar from v$archived_log;


Note down the current sequence number on standby

check the status using on primary (abc01):


SQL> select database_role, switchover_status, open_mode from v$database;
DATABASE_ROLE SWITCHOVER_STATUS OPEN_MODE
PRIMARY SESSIONS ACTIVE READ WRITE

On the primary database for switch over (abc01):


SQL> alter database commit to switchover to standby; or
SQL> alter database commit to switchover to standby with session shutdown;

check the status on standby (xyz01):


Note down the current sequence number on standby using below query:
SQL> select sequence#, applied, registrar from v$archived_log;
SQL> select process, status, sequence# from v$managed_standby;
PROCESS STATUS SEQUENCE#
ARCH CONNECTED 0
ARCH CONNECTED 0

SQL> select database_role, switchover_status, open_mode from v$database;


DATABASE_ROLE SWITCHOVER_STATUS OPEN_MODE
PHYSICAL STANDBY TO PRIMARY MOUNTED

Description:
primary after giving the command “alter database commit to switchover to standby;” it converts its controlfile to standby
controlfile and closes. dismount the database and now its at nomount stage.
Now the results on primary would be
SQL> select database_role, switchover_status, open_mode from v$database;
select database_role, switchover_status, open_mode from v$database
ERROR at line 1:
ORA-01507: database not mounted
which is switching over to standby.
Note: At this stage both the servers are in standby

On xyz01 to switch from standby to primary: give the command to


SQL> alter database commit to switchover to primary;
Database altered.
After converting standby to primary check the role of the database again.
SQL> select database_role, switchover_status, open_mode from v$database;
DATABASE_ROLE SWITCHOVER_STATUS OPEN_MODE
PRIMARY NOT ALLOWED MOUNTED

Note: Now the xyz01 is the primary and abc01 is the standby

on new primary xyz01


1)shutdown the database
2) uncomment the parameters or set the parameter
log_archive_dest_2='service=abc01'
3) in the tns set the above connect string.
4) startup

On new standby abc01


1) Shutdown (which is now in nomount stage)
2) Set the parameters to

1. log_archive_dest_state_2='ENABLE'
2. log_archive_dest_1='LOCATION=/app/orcl/abc01/arch01/'
3. standby_archive_dest='/app/orcl/xyz01/xyzarch'
4. standby_file_management=auto
5. db_file_name_convert='/app/orcl/xyz01/','/app/orcl/abc01/'
6. log_file_name_convert='/app/orcl/xyz01/','/app/orcl/abc01/'
7. db_unique_name=abc01

3) set the listener and tnsnames with connect string as “abc01”


4) startup nomount
5) alter database mount standby database;
6) recover managed standby database disconnect from session;

select sequence#, applied, registrar from v$archived_log;

Вам также может понравиться