You are on page 1of 9

The current status is

Primary001 – primary server

Standby001 – Standby server, but no database running.

Primary Server Details

Pre-Requisites:

Archive log should be enabled

Flashback should be on

Server name: Primary001

LOG_MODE     FORCE_LOGGING

———— ————-

ARCHIVELOG   YES

SELECT DBID, NAME, DB_UNIQUE_NAME, LOG_MODE, OPEN_MODE, PROTECTION_MODE,


PROTECTION_LEVEL, DATABASE_ROLE, FLASHBACK_ON, CURRENT_SCN FROM V$DATABASE;

DBID NAME      DB_UNIQUE_NAME                 LOG_MODE     OPEN_MODE  PROTECTION_MODE     


PROTECTION_LEVEL     DATABASE_ROLE

———- ——— —————————— ———— ———- ——————– ——————– —————-

FLASHBACK_ON       CURRENT_SCN

—————— ———–

224883408 REPLICA    REPLICA_fc                      ARCHIVELOG   READ WRITE MAXIMUM PERFORMANCE 


MAXIMUM PERFORMANCE  PRIMARY

YES                 2.6969E+10

SELECT COUNT(*) TOTAL_DATAFILES FROM  V$DATAFILE;

SELECT COUNT(*) TOTAL_LOGFILES_AND_STBY_FILES FROM  V$LOGFILE;

SELECT COUNT(*) TOTAL_CONTROLFILES FROM  V$CONTROLFILE;

SELECT SUM(BYTES)/(1024*1024*1024) DF_SIZE_IN_GB FROM V$DATAFILE;

SELECT SUM(BYTES)/(1024*1024*1024) LOGFILE_SIZE_IN_GB FROM V$LOGFILE A, V$LOG B WHERE


A.GROUP#=B.GROUP#;

SELECT SUM(BYTES)/(1024*1024*1024) TEMPFILE_IN_GB FROM V$TEMPFILE WHERE STATUS=’ONLINE’;

— SHOW THE DATAFILES WHICH ARE OFFLINE

select name,status,checkpoint_change# from v$datafile where status not in (‘ONLINE’,’SYSTEM’);

no rows selected.

SQL> show parameter spfile

NAME                                 TYPE        VALUE

———————————— ———– ——————————

spfile                               string      /u01/oracle/product/10.2/db_1/dbs/spfileREPLICA.ora


Select * from v$tempfile;

FILE# CREATION_CHANGE# CREATION_TIME        TS#     RFILE# STATUS  ENABLED         BYTES     BLOCKS


CREATE_BYTES BLOCK_SIZE

———- —————- ————- ———- ———- ——- ———- ———- ———- ———— ———-

NAME

——————————————————————————————————————————————–

1         78931268 06-AUG-08              3          1 ONLINE  READ WRITE 1.4840E+10    1811584  


1.4840E+10       8192

/u02/oradata/REPLICA/temp01.dbf

Select * from dba_temp_files;

Select count(*) from dba_data_files;

SELECT NAME “Read only” FROM V$DATAFILE WHERE ENABLED=’READ ONLY’;

 Standby Server Details

 Server name: standby001

 OPERATIONS

 Shutdown the PRIMARY Database, Listeners and Standby

 Login to primary001

 SQL> shutdown immediate

lsnrctl stop REPLICA_public

lsnrctl stop REPLICA_fc_dg

Login to standby server – standby001 and stop the Listener if any running

 Copy / scp the datafiles to DR Server – standby001

Do a cleanup on the DR Server if required – check the relevant directories

scp -pr /u04/oradata/REPLICA/* oracle@standby001:/u04/oradata/REPLICA

scp -pr /u02/oradata/REPLICA/* oracle@standby001:/u02/oradata/REPLICA

Note:- scp by default is binary copy, so no worries

Create STANDBY Controlfile in Primary Server / Database

Login to primary001 Primary Server

SQL> startup

SQL> Alter database create standby controfile as ‘/u01/oracle/control01.ctl’;

Do few Log switches on Primary Server

SQL> alter system switch logfile;

/
Copy / sftp this file to /u02/oradata/REPLICA

sftp  oracle@standby001

pwd: *****

cd /u02/oradata/REPLICA

lcd /u01/oracle

Also Copy / sftp the Archive logs to DR Server – standby001

Startup the Standby Database in DR Server

Login to standby001 and recheck the initREPLICA.ora parameters if needed for stby parameters

Ensure the controlfile is pointing to the just copied standby controlfile under “/u02/oradata/REPLICA” directory.

Sqlplus / as sysdba

Startup nomount pfile=initREPLICA.ora

Alter database mount standby database;

Create Standby Log files and temp file

CREATE TEMPORARY TABLESPACE TEMP TEMPFILE

‘/u02/oradata/REPLICA/temp01.dbf’ SIZE 14153M AUTOEXTEND ON NEXT 1M MAXSIZE UNLIMITED

TABLESPACE GROUP ”

EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M;

alter system set standby_file_management=manual;

alter database add standby logfile ‘/u03/oradata/REPLICA/stdby_redo_09.log’ SIZE 2G reuse;

alter database add standby logfile ‘/u03/oradata/REPLICA/stdby_redo_10.log’ SIZE 2G reuse;

alter database add standby logfile ‘/u03/oradata/REPLICA/stdby_redo_11.log’ SIZE 2G reuse;

alter database add standby logfile ‘/u03/oradata/REPLICA/stdby_redo_12.log’ SIZE 2G reuse;

alter database add standby logfile ‘/u03/oradata/REPLICA/stdby_redo_13.log’ SIZE 2G reuse;

alter system set standby_file_management=auto;

Enable Block Change Tracking in standby server

SQL> alter database enable block change tracking using file


‘/u01/oracle/product/10.2.0/db_1/dbs/REPLICA_bct.dbf’ reuse;

Stop the job_queue_processes  STANDBY database by setting them to 0

SQL> alter system set job_queue_processes=0 scope=memory;

SQL> alter database recover managed standby database disconnect from session

 
IF needed , do check in Primary Server / database

– CHECK THE STATUS IF VALID FOR STBY

select dest_id, status from v$archive_dest;

show parameter dest_state_2

— TO disable log shipping to stby site

alter system set log_archive_dest_state_2=defer scope=memory;

— TO disable log shipping to stby site

alter system set log_archive_dest_state_2=enable scope=memory;

Check the open_mode, protection_mode, database_role, Flashback Status in the STANDBY Server

SQL> select NAME,OPEN_MODE,PROTECTION_MODE,DATABASE_ROLE,FLASHBACK_ON from v$database;

NAME      OPEN_MODE  PROTECTION_MODE      DATABASE_ROLE    FLASHBACK_ON

——— ———- ——————– —————- ——————

REPLICA    MOUNTED    MAXIMUM AVAILABILITY PHYSICAL STANDBY YES

SQL> select * from v$archive_gap;

Check the open_mode, protection_mode, database_role, Flashback Status in the PRIMARY Server

SQL> select NAME,OPEN_MODE,PROTECTION_MODE,DATABASE_ROLE,FLASHBACK_ON from v$database;

NAME      OPEN_MODE  PROTECTION_MODE      DATABASE_ROLE    FLASHBACK_ON

——— ———- ——————– —————- ——————

REPLICA    READ WRITE MAXIMUM AVAILABILITY PRIMARY          YES

 
 

Also run the ControlM Job and verify if the standby database is in sync with Primary

Run the Script from the PRIMARY Database

oracle@primary001 logs>cat REPLICA.stby_check.20101220_1134.log

SQL*Plus: Release 10.2.0.4.0 – Production on Mon Dec 20 11:34:58 2010

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 – 64bit Production

With the Partitioning, Data Mining and Real Application Testing options

PERFORMING – DATAGUARD STATUS CHECK FOR LOG_GAP <= 2 AND SYNCHRONIZATION_STATUS = OK

INST_NAME HOST_NAME  PROTECTION_MODE      SYNCHRONIZATION_STATUS LOG_ARCHIVED LOG_APPLIED


TIME_APPLIED   LOG_GAP

——— ———- ——————– ———————- ———— ———– ————– ——-

REPLICA    primary001 MAXIMUM AVAILABILITY                     OK         1855        1855 20/12 11:30:57       0

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 – 64bit Production

With the Partitioning, Data Mining and Real Application Testing options

Making initREPLICA.ora changes permanent in Standby

Alter system job_queue_processes=0 scope=spfile

….

 
Create spfile from pfile;

Shutdown immediate

Startup nomount

Alter database mount standby database

alter database recover managed standby database disconnect from session

TEST THE STANDBY IN READ ONLY MODE

In Primary – primary001

Login as db user

Bb15908

Create table test as select * from dba_users;

Alter system switch logfile;

Login to standby server – standby001

Note:- if you have enable DB Auditing , then the following is required to open the database in read only mode.

SQL> Recover managed standby database cancel;

Media recovery complete.

SQL> alter database open readonly;

alter database open readonly


*

ERROR at line 1:

ORA-02288: invalid OPEN mode

SQL> alter database open read only;

alter database open read only

ERROR at line 1:

ORA-16006: audit_trail destination incompatible with database open mode

SQL> show parameter audit_trail

NAME                                 TYPE        VALUE

———————————— ———– ——————————

audit_trail                          string      DB

SQL> alter system set audit_trail=OS scope=spfile;

System altered.

Shutdown immediate

ORA-01109: database not open

Database dismounted.

ORACLE instance shut down.

SQL>

SQL>
SQL> startup nomount

ORACLE instance started.

Total System Global Area 3321888768 bytes

Fixed Size                  2087680 bytes

Variable Size            1828717824 bytes

Database Buffers         1476395008 bytes

Redo Buffers               14688256 bytes

SQL> alter database mount standby database;

Database altered.

SQL> show parameter audit_trail

NAME                                 TYPE        VALUE

———————————— ———– ——————————

audit_trail                          string      OS

SQL> alter database open read only;

SQL> select * from bb15908.test;

Make sure you set back the audit_trail=DB after this

Shutdown immediate

Startup nomount

Alter database mount standby database

SQL> alter system set audit_trail=DB scope=spfile;


 

System altered.

Shutdown immediate

Startup nomount

Alter database mount standby database;

alter database recover managed standby database disconnect from session;

You might also like