Oracle Standby database

Shutting Down a Physical Standby Database

Issue the following query to find out if the standby database is performing Redo Apply or real-time apply. 

If the MRP0 or MRP process exists, then the standby database is applying redo.

SQL> SELECT PROCESS, STATUS FROM V$MANAGED_STANDBY;

If Redo Apply is running, cancel it as shown in the following example:

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

Shut down the standby database.

SQL> SHUTDOWN IMMEDIATE;


Start and mount the physical standby database:


SQL> STARTUP MOUNT;
Start Redo Apply or real-time apply:

To start Redo Apply, issue the following statement:

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE  DISCONNECT FROM SESSION;
To start real-time apply, issue the following statement:

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE  USING CURRENT LOGFILE;




ALTER SESSION SET nls_date_format=’DD-MON-YYYY HH24:MI:SS’;
select status,instance_name,database_role from v$database,v$instance;
SELECT   name, db_unique_name, log_mode,   protection_mode, database_role FROM v$database;
SELECT sequence#, first_time, next_time, applied FROM v$archived_log ORDER BY sequence#;
select dest_name,status,error from v$archive_dest where dest_name='LOG_ARCHIVE_DEST_2';
SELECT name, value, datum_time, time_computed FROM V$DATAGUARD_STATS;
SELECT client_process, process, thread#, sequence#, status FROM v$managed_standby  WHERE client_process='LGWR' or process='MRP0' ORDER BY process;

Before getting into the real action, validate the following to avoid any failures during the course of role transition:

Ensure log_archive_dest_2 is configured on PRIMARY and STANDBY databases
Media Recovery Process (MRP) is active on STANDBY and in sync with PRIMARY database

Create STANDBY REDO logs on PRIMARY, if not exists
FAL_CLIENT & FAL_SERVER parameters set on both databases

In Primary site:

FAL_SERVER=STANDBY
FAL_CLIENT=PRIMARY

In Standby site:

FAL_SERVER=PRIMARY
FAL_CLIENT=STANDBY

ALTER SYSTEM SET FAL_SERVER=TSTSB SCOPE=BOTH SID='*';
ALTER SYSTEM SET FAL_CLIENT=TSTSBY SCOPE=BOTH SID='*';
ALTER SYSTEM SET LOG_ARCHIVE_CONFIG='DG_CONFIG=(TSTDB,TSTSBY)' SCOPE=BOTH SID='*';
alter system set log_archive_config='dg_config=(TSTDB,TSTSBY)' scope=both

FAL_SERVER specifies the FAL (fetch archive log) server for a standby database.The value is an Oracle Net service name, which is assumed to be configured properly on the standby database system to point to the desired FAL server.
FAL_CLIENT specifies the FAL (fetch archive log) client name that is used by the FAL service, configured through the FAL_SERVER parameter, to refer to the FAL client. 


Verify TEMP tablespaces on STANDBY, add them if required, as TEMPFFILES created after STANDBY creation won’t be propagated to STANDBY site.

select status,instance_name,database_role from v$database,v$instance;

SQL> -- query on standby database
SQL> select sequence#, first_time, next_time, archived, applied from v$archived_log order by sequence#;

SQL> -- query on physical database
SQL> select sequence#, first_time, next_time, archived, applied from v$archived_log order by sequence#;

select status , error from v$archive_dest where dest_id=2;
alter database switchover to TSTSBY verify; 
alter system set log_archive_dest_state_2=enable scope=both;



start apply
alter database recover managed standby database disconnect from session;

  alter system switch logfile;
 select dest_id,error,status from v$archive_dest where dest_id=2;
 select max(sequence#),thread# from v$log_history group by thread#;
 select max(sequence#)  from v$archived_log where applied='YES' and dest_id=2


select group#, thread#, bytes/1024/1024 "Size in MB" from v$Log;
select group#, type from v$logfile;




ALTER SYSTEM SET log_archive_dest_2='service="tstsby"','ASYNC NOAFFIRM delay=0 optional compression=disable max_failure=0 max_connections=1 reopen=300 db_unique_name="TSTSBY" net_timeout=30','valid_for=(online_logfile,all_roles)' SCOPE=BOTH;

ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=TSTSBY ASYNC NOAFFIRM VALID_FOR=(online_logfile,all_roles) DB_UNIQUE_NAME=TSTSBY' scope=both;

alter system set log_archive_config='dg_config=(TSTDB,TSTSBY)' scope=both

SWITCHOVER VERIFY: Send VERIFY request to switchover target GGSTBY
SWITCHOVER VERIFY WARNING: switchover target has no standby database defined in LOG_ARCHIVE_DEST_n parameter. If the switchover target is converted to a primary database, the new primary database will not be protected.
ORA-16475 signalled during: ALTER DATABASE SWITCHOVER TO GGSTBY VERIFY…
2017-09-03T08:16:47.465995-04:00

# this fixed the warning by doing this on the PRIMARY -TSTSB

alter system set log_archive_dest_2='service="TSTSBY"','ASYNC NOAFFIRM delay=0 optional compression=disable max_failure=0 max_connections=1 reopen=300 db_unique_name="TSTSBY" net_timeout=30','valid_for=(online_logfile,all_roles)';

# for reference the standby must be defined as a DEST_2 as follows: -standby

alter system set log_archive_dest_2='service="TSTSB"','ASYNC NOAFFIRM delay=0 optional compression=disable max_failure=0 max_connections=1 reopen=300 db_unique_name="TSTSB" net_timeout=30','valid_for=(online_logfile,all_roles)';

Comments

Popular posts from this blog

QUERY DATAGUARD AND STANDBY STATUS

Blocking session on RAC database

Finding object size in Oracle database