Wednesday, March 16, 2011

DataGuard switchover



Summary
1. stop/suspend schedule jobs
2. Switchover Primary database role
3. Switchover Standby database role
4. Check Primary and Standby are in sync

     
-- ON PRIMARY

    -- clear blocking parameters and jobs

    > alter system set job_queue_processes=0 scope=both sid='*';
    > select owner,job_name, start_date, end_date, enabled
             from dba_scheduler_jobs
             where enabled='TRUE' and owner <> 'SYS';
    > execute dbms_scheduler.disable(job_name);
    > disable cron jobs
    
-- TURN ON DATA TRACING ON PRIMARY AND STANDBY

    > show parameter log_archive_trace
    > alter system set log_archive_trace=8191;
    >  tail alert.log file on primary
    > tail alert.log file on standby
       
-- ON PRIMARY
     
   > select switchover_status from v$database;
   > alter database commit to switchover to standby with session shutdown;
   > select open_mode,protection_mode,database_role from v$database;
   > select switchover_status from v$database;
       
-- ON STANDBY  AFTER PRIMARY SWITCHOVER
  
   > select switchover_status from v$database;
   > alter database commit to switchover to primary;
   > select open_mode,protection_mode,database_role from v$database;
   > alter database open;
   > select open_mode,protection_mode,database_role from v$database;
   > select switchover_status from v$database;
       
-- ON PRIMARY (original)
    
   > shutdown immediate
   > startup mount
  
 # for redo apply
   > alter database recover managed standby database disconnect from session;

 # for real-time apply
   > alter database recover managed standby database using current logfile disconnect;  

-- CHECK THAT BOTH DATBASES ARE IN SYNC
   > archive log list
   > col host_name for a10
   > col db_unique_name for a10
   > col name for a10
   > select name, db_unqiue_name, host_name, open_mode,protection_mode,database_role
from v$database, v$instance;
  > select switchover_status from v$database;
  > select sequence#,applied from v$archived_log order by sequence#;


Hope this helps! Rupam