11G single primary switchover RAC standby

主库准备工作

SQL> select inst_id,database_role,OPEN_MODE from  gv$database;
   INST_ID DATABASE_ROLE    OPEN_MODE
---------- ---------------- --------------------
         1 PRIMARY        READ WRITE

SQL>  CREATE RESTORE POINT SWITCHOVER_START_GRP GUARANTEE FLASHBACK DATABASE;
Restore point created.

备库准备工作

SQL> select inst_id,database_role,OPEN_MODE from  gv$database;
   INST_ID DATABASE_ROLE    OPEN_MODE
---------- ---------------- --------------------
         1 PHYSICAL STANDBY READ ONLY WITH APPLY
         2 PHYSICAL STANDBY READ ONLY WITH APPLY

[oracle@hpadb2-prod admin]$  srvctl stop instance -d hpadb -i hpadb2
SQL> select inst_id,database_role,OPEN_MODE from  gv$database;
   INST_ID DATABASE_ROLE    OPEN_MODE
---------- ---------------- --------------------
         1 PHYSICAL STANDBY READ ONLY WITH APPLY

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
Database altered.

SQL> CREATE RESTORE POINT SWITCHOVER_START_GRP GUARANTEE FLASHBACK DATABASE;
Restore point created.

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;
Database altered.

主库切换工作

SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS
--------------------
SESSIONS ACTIVE

SQL>  ALTER DATABASE COMMIT TO SWITCHOVER TO STANDBY WITH SESSION SHUTDOWN;
Database altered.

备库切换

SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS
--------------------
TO PRIMARY

SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN;
Database altered.

SQL> ALTER DATABASE OPEN;
Database altered.

老主库处理

SQL> shutdown immediate;
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory

[oracle@hpaydg:/home/oracle]$ps -ef |grep pmon
oracle   45444 57941  0 06:59 pts/0    00:00:00 grep pmon

SQL> startup mount
ORACLE instance started.
Total System Global Area 4.0486E+10 bytes
Fixed Size              2261968 bytes
Variable Size              5368712240 bytes
Database Buffers    3.5031E+10 bytes
Redo Buffers               84606976 bytes
Database mounted.

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;
Database altered.

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE cancel;
Database altered.

SQL> alter database open;
Database altered.

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;
Database altered.

新主库处理

SQL> DROP RESTORE POINT SWITCHOVER_START_GRP;
Restore point dropped.

新备库处理

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
Database altered.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup mount;
ORACLE instance started.
Total System Global Area 4.0486E+10 bytes
Fixed Size              2261968 bytes
Variable Size              5771365424 bytes
Database Buffers    3.4628E+10 bytes
Redo Buffers                84606976 bytes
Database mounted.

SQL> DROP RESTORE POINT SWITCHOVER_START_GRP;
Restore point dropped.

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;
Database altered.

SQL>  ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
Database altered.

SQL> alter database open;
Database altered.

SQL>  ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;
Database altered.

新主库操作

srvctl start instance -d hpadb -i hpadb2

11gR2下DATAGUARD备库增量恢复

 

1、在备库上取消日志应用

alter database recover managed standby database cancel;

2、查看备库scn

select to_char(current_scn) from v$database;
     CURRENT_SCN
---------------
  3056655162

3、根据scn,在主库上进行rman增量备份

backup incremental from scn 3056655162 database format '/u02/rman/riskdb/ForStandby_%U.bka' tag 'forstandby';
或者
backup as compressed backupset incremental from scn 3056655162 database format '/u02/rman/riskdb/ForStandby_%U.bka' tag 'forstandby';

–备份控制文件

backup current controlfile for standby format '/u02/rman/riskdb/ForStandbyCTRL.bkc';


4、将备库关闭后重新启动到mount阶段

SQL>  shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.

SQL> startup nomount;
ORACLE instance started.
Total System Global Area 8551575552 bytes
Fixed Size              2270360 bytes
Variable Size              4227861352 bytes
Database Buffers    4311744512 bytes
Redo Buffers                 9699328 bytes

SQL> alter database mount standby database;
Database altered.

5、注册从主库传过来的增量备份

[oracle@hpdbpre3:/home/oracle]$rman target / nocatalog
Recovery Manager: Release 11.2.0.4.0 - Production on Wed Jan 3 13:09:42 2018
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
connected to target database: RISKDB (DBID=2017870605, not open)
using target database control file instead of recovery catalog

RMAN> catalog start with '/u02/rman/riskdb1';
searching for all files that match the pattern /u02/rman/riskdb1
List of Files Unknown to the Database
=====================================
File Name: /u02/rman/riskdb1/ForStandby_mosnlfhk_1_1.bka
File Name: /u02/rman/riskdb1/ForStandbyCTRL.bkc
File Name: /u02/rman/riskdb1/ForStandby_mpsnll4t_1_1.bka
Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /u02/rman/riskdb1/ForStandby_mosnlfhk_1_1.bka
File Name: /u02/rman/riskdb1/ForStandbyCTRL.bkc
File Name: /u02/rman/riskdb1/ForStandby_mpsnll4t_1_1.bka

6、进行数据库recover恢复

RMAN> RECOVER DATABASE NOREDO;
Starting recover at 03-JAN-18
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=351 device type=DISK
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: /u02/oradata/riskrp1/riskrp1/system01.dbf
destination for restore of datafile 00002: /u02/oradata/riskrp1/riskrp1/sysaux01.dbf
destination for restore of datafile 00003: /u02/oradata/riskrp1/riskrp1/undotbs01.dbf
destination for restore of datafile 00004: /u02/oradata/riskrp1/riskrp1/users01.dbf
destination for restore of datafile 00005: /u02/oradata/riskrp1/riskrp1/hprisk01.dbf
destination for restore of datafile 00006: /u02/oradata/riskrp1/riskrp1/hpriskidx01.dbf
destination for restore of datafile 00007: /u02/oradata/riskrp1/riskrp1/hpriskbase01.dbf
destination for restore of datafile 00008: /u02/oradata/riskrp1/riskrp1/hpriskbaseidx01.dbf
destination for restore of datafile 00009: /u02/oradata/riskrp1/riskrp1/hprisk02.dbf
destination for restore of datafile 00010: /u02/oradata/riskrp1/riskrp1/hprisk03.dbf
destination for restore of datafile 00011: /u02/oradata/riskrp1/riskrp1/hprisk04.dbf
destination for restore of datafile 00012: /u02/oradata/riskrp1/riskrp1/credit.dbf
destination for restore of datafile 00013: /u02/oradata/riskrp1/riskrp1/geedun01.dbf
destination for restore of datafile 00014: /u02/oradata/riskrp1/riskrp1/geedunidx01.dbf
destination for restore of datafile 00015: /u02/oradata/riskrp1/riskrp1/hprisk05.dbf
destination for restore of datafile 00016: /u02/oradata/riskrp1/riskrp1/hprisk06.dbf
destination for restore of datafile 00017: /u02/oradata/riskrp1/hprisk07.dbf
destination for restore of datafile 00018: /u02/oradata/riskrp1/hprisk08.dbf
destination for restore of datafile 00019: /u02/oradata/riskrp1/hprisk09.dbf
destination for restore of datafile 00020: /u02/oradata/riskrp1/hprisk10.dbf
destination for restore of datafile 00021: /u02/oradata/riskrp1/hprisk11.dbf
destination for restore of datafile 00022: /u02/oradata/riskrp1/hprisk12.dbf
destination for restore of datafile 00023: /u02/oradata/riskrp1/hprisk13.dbf
destination for restore of datafile 00024: /u02/oradata/riskrp1/hprisk14.dbf
destination for restore of datafile 00025: /u02/oradata/riskrp1/hprisk15.dbf
destination for restore of datafile 00026: /u02/oradata/riskrp1/riskrp1/hprisk16
destination for restore of datafile 00027: /u02/oradata/riskrp1/riskrp1/hprisk17
destination for restore of datafile 00028: /u02/oradata/riskrp1/riskrp1/hprisk18.dbf
destination for restore of datafile 00029: /u02/oradata/riskrp1/riskrp1/hprisk16.dbf
destination for restore of datafile 00030: /u02/oradata/riskrp1/riskrp1/hprisk19.dbf
destination for restore of datafile 00031: /u02/oradata/riskrp1/riskrp1/hprisk20.dbf
destination for restore of datafile 00032: /u02/oradata/riskrp1/riskrp1/hprisk21.dbf
destination for restore of datafile 00033: /u02/oradata/riskrp1/hpay01.dbf
destination for restore of datafile 00034: /u02/oradata/riskrp1/hpayidx01.dbf
destination for restore of datafile 00035: /u02/oradata/riskrp1/smhpay01.dbf
destination for restore of datafile 00036: /u02/oradata/riskrp1/smhpayidx01.dbf
destination for restore of datafile 00037: /u02/oradata/riskrp1/CHALIDX01.dbf
destination for restore of datafile 00038: /u02/oradata/riskrp1/CHANNEL01.dbf
destination for restore of datafile 00039: /u02/oradata/riskrp1/AHPAY01.dbf
destination for restore of datafile 00040: /u02/oradata/riskrp1/AHPAYIDX01.dbf
destination for restore of datafile 00041: /u02/oradata/riskrp1/RCTL01.dbf
destination for restore of datafile 00042: /u02/oradata/riskrp1/RCTLIDX01.dbf
destination for restore of datafile 00043: /u02/oradata/riskrp1/HIST01.dbf
destination for restore of datafile 00044: /u02/oradata/riskrp1/HISTIDX01.dbf
destination for restore of datafile 00045: /u02/oradata/riskrp1/riskrp1/hprisk22.dbf
destination for restore of datafile 00046: /u02/oradata/riskrp1/riskdb/hprisk23.dbf
destination for restore of datafile 00047: /u02/oradata/riskrp1/riskdb/hprisk24.dbf
destination for restore of datafile 00048: /u02/oradata/riskrp1/riskdb/hprisk25.dbf
destination for restore of datafile 00049: /u02/oradata/riskrp1/riskdb/hprisk26.dbf
destination for restore of datafile 00050: /u02/oradata/riskrp1/riskdb/hprisk27.dbf
destination for restore of datafile 00051: /u02/oradata/riskrp1/riskdb/hprisk28.dbf
destination for restore of datafile 00052: /u02/oradata/riskrp1/riskdb/hprisk29.dbf
destination for restore of datafile 00053: /u02/oradata/riskrp1/riskdb/hprisk30.dbf
destination for restore of datafile 00054: /u02/oradata/riskrp1/riskdb/hprisk31.dbf
destination for restore of datafile 00055: /u02/oradata/riskrp1/riskdb/hprisk32.dbf
destination for restore of datafile 00056: /u02/oradata/riskpre1/riskdb/geedun02.dbf
destination for restore of datafile 00057: /u02/oradata/riskpre1/riskdb/hprisk33.dbf
destination for restore of datafile 00058: /u02/oradata/riskpre1/riskdb/hprisk34.dbf
destination for restore of datafile 00059: /u02/oradata/riskpre1/riskdb/hprisk35.dbf
destination for restore of datafile 00060: /u02/oradata/riskpre1/riskdb/hprisk36.dbf
destination for restore of datafile 00061: /u02/oradata/riskpre1/riskdb/hprisk37.dbf
destination for restore of datafile 00062: /u02/oradata/riskpre1/riskdb/hprisk38.dbf
channel ORA_DISK_1: reading from backup piece /u02/rman/riskdb1/ForStandby_mosnlfhk_1_1.bka
channel ORA_DISK_1: piece handle=/u02/rman/riskdb1/ForStandby_mosnlfhk_1_1.bka tag=FORSTANDBY
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 05:14:17
Finished recover at 03-JAN-18

SQL> shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.

SQL> startup nomount;
ORACLE instance started.
Total System Global Area 8551575552 bytes
Fixed Size              2270360 bytes
Variable Size              4227861352 bytes
Database Buffers    4311744512 bytes
Redo Buffers                 9699328 bytes

7、还原控制文件

RMAN> restore standby controlfile from '/u02/rman/riskdb1/ForStandbyCTRL.bkc';
Starting restore at 04-JAN-18
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=816 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
output file name=/u02/oradata/riskpre1/control01.dbf
output file name=/u02/oradata/riskpre1/control02.dbf
output file name=/u02/oradata/riskpre1/control03.dbf
Finished restore at 04-JAN-18

8.启动备库到mount状态

SQL> startup nomount;
ORACLE instance started.

Total System Global Area 8551575552 bytes
Fixed Size              2270360 bytes
Variable Size              4227861352 bytes
Database Buffers    4311744512 bytes
Redo Buffers                 9699328 bytes

SQL> alter database mount standby database;
Database altered.


9、由于恢复了控制文件,可能需要重新添加新的standby redo log file(可选)

alter database add standby logfile group 8 ('/u02/oradata/riskrp1/riskrp1/standby08.log') size 500M reuse;
alter database add standby logfile group 9 ('/u02/oradata/riskrp1/riskrp1/standby09.log') size 500M reuse;
alter database add standby logfile group 10 ('/u02/oradata/riskrp1/riskrp1/standby10.log') size 500M reuse;
alter database add standby logfile group 11 ('/u02/oradata/riskrp1/riskrp1/standby11.log') size 500M reuse;
alter database add standby logfile group 12 ('/u02/oradata/riskrp1/riskrp1/standby12.log') size 500M reuse;

10、启动mrp进程

SQL> alter database recover managed standby database disconnect from session using current logfile;
Database altered.

10.启动备库同步

SQL> alter database open read only;
Database altered.

Thu Jan 04 09:09:11 2018
Errors in file /u01/app/oracle/diag/rdbms/riskpre1/riskpre1/trace/riskpre1_dbw0_16368.trc:
ORA-01157: cannot identify/lock data file 56 - see DBWR trace file
ORA-01110: data file 56: '/u02/oradata/riskrp1/riskdb/geedun02.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Errors in file /u01/app/oracle/diag/rdbms/riskpre1/riskpre1/trace/riskpre1_dbw0_16368.trc:
ORA-01157: cannot identify/lock data file 57 - see DBWR trace file
ORA-01110: data file 57: '/u02/oradata/riskrp1/riskdb/hprisk33.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Errors in file /u01/app/oracle/diag/rdbms/riskpre1/riskpre1/trace/riskpre1_dbw0_16368.trc:
ORA-01157: cannot identify/lock data file 58 - see DBWR trace file
ORA-01110: data file 58: '/u02/oradata/riskrp1/riskdb/hprisk34.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Errors in file /u01/app/oracle/diag/rdbms/riskpre1/riskpre1/trace/riskpre1_dbw0_16368.trc:
ORA-01157: cannot identify/lock data file 59 - see DBWR trace file
ORA-01110: data file 59: '/u02/oradata/riskrp1/riskdb/hprisk35.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Errors in file /u01/app/oracle/diag/rdbms/riskpre1/riskpre1/trace/riskpre1_dbw0_16368.trc:
ORA-01157: cannot identify/lock data file 60 - see DBWR trace file
ORA-01110: data file 60: '/u02/oradata/riskrp1/riskdb/hprisk36.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Errors in file /u01/app/oracle/diag/rdbms/riskpre1/riskpre1/trace/riskpre1_dbw0_16368.trc:
ORA-01157: cannot identify/lock data file 61 - see DBWR trace file
ORA-01110: data file 61: '/u02/oradata/riskrp1/riskdb/hprisk37.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Errors in file /u01/app/oracle/diag/rdbms/riskpre1/riskpre1/trace/riskpre1_dbw0_16368.trc:
ORA-01157: cannot identify/lock data file 62 - see DBWR trace file
ORA-01110: data file 62: '/u02/oradata/riskrp1/riskdb/hprisk38.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Errors in file /u01/app/oracle/diag/rdbms/riskpre1/riskpre1/trace/riskpre1_dbw0_16368.trc:
ORA-01157: cannot identify/lock data file 63 - see DBWR trace file
ORA-01110: data file 63: '/u02/oradata/riskrp1/riskdb/users02.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
MRP0: Background Media Recovery terminated with error 1110

,58,59,60,61,62,63
backup datafile 61,62,63 format '/u02/rman/riskdb/datafile3.bkp';

restore datafile 61,62,63

 

11G DataGuard  ORA-01111,ORA-01110 – Recover standby  rename to dbs/UNNAMEDxxxxx

11G DataGuard  ORA-01111,ORA-01110 – Recover standby  rename to dbs/UNNAMEDxxxxx

    Today,check log file of dg.I find the mrp0 process was termial.
Because the disk is not enough space and create the new file on the primary ,that not rebuild on the standy database.
OS version:RHEL 6.5
DB version:11.2.0.4

1.the standby's alert log file

Successfully added datafile 129 to media recovery
Datafile #129: '/u02/oradata/hpaypre3/hpay36.dbf'
Mon Jan 23 09:10:53 2017
RFS[222]: Assigned to RFS process 27211
RFS[222]: Possible network disconnect with primary database
Mon Jan 23 09:12:12 2017
Archived Log entry 19108 added for thread 1 sequence 9737 ID 0x44f2486d dest 1:
Mon Jan 23 09:15:35 2017
Errors in file /u01/app/oracle/diag/rdbms/hpaypre3/hpaypre3/trace/hpaypre3_pr00_19866.trc:
ORA-19502: write error on file "/u02/oradata/hpaypre3/users06.dbf", block number 3325952 (block size=8192)
ORA-27061: waiting for async I/Os failed
Linux-x86_64 Error: 28: No space left on device
Additional information: -1
Additional information: 1048576
File #130 added to control file as 'UNNAMED00130'.
Originally created as:
'+DATA/hpaydb/users06.dbf'
Recovery was unable to create the file as:
'/u02/oradata/hpaypre3/users06.dbf'
Errors with log /u02/arch/hpaypre3/2_8462_909679324.dbf
MRP0: Background Media Recovery terminated with error 1274
Errors in file /u01/app/oracle/diag/rdbms/hpaypre3/hpaypre3/trace/hpaypre3_pr00_19866.trc:
ORA-01274: cannot add datafile '+DATA/hpaydb/users06.dbf' - file could not be created
Recovery interrupted!
Mon Jan 23 09:15:49 2017
Recovery stopped due to failure in applying recovery marker (opcode 17.30).
Datafiles are recovered to a consistent state at change 19186758978 but controlfile could be ahead of datafiles.
Mon Jan 23 09:15:49 2017
MRP0: Background Media Recovery process shutdown (hpaypre3)
Mon Jan 23 09:17:43 2017

......................

solution

SQL*Plus: Release 11.2.0.4.0 Production on Tue Jan 24 01:53:06 2017
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> alter system set standby_file_management=manual;
System altered.

SQL> alter database create datafile '/u01/app/oracle/product/11.2.0/db_1/dbs/UNNAMED00130' as '/u02/oradata/hpaypre3/users06.dbf';
Database altered.

SQL> alter system set standby_file_management=auto;
System altered.

SQL>  alter database recover managed standby database disconnect from session;
Database altered.

we will found mrp process sucessful.

alter database recover managed standby database disconnect from session
Attempt to start background Managed Standby Recovery process (hpaypre3)
Tue Jan 24 02:10:54 2017
MRP0 started with pid=21, OS id=31885 
MRP0: Background Managed Standby Recovery process started (hpaypre3)
 started logmerger process
Tue Jan 24 02:11:00 2017
Managed Standby Recovery not using Real Time Apply
Tue Jan 24 02:11:08 2017
Parallel Media Recovery started with 8 slaves
Waiting for all non-current ORLs to be archived...
All non-current ORLs have been archived.
Tue Jan 24 02:11:08 2017
Completed:  alter database recover managed standby database disconnect from session
Media Recovery Log /u02/arch/hpaypre3/1_9645_909679324.dbf
Media Recovery Log /u02/arch/hpaypre3/2_8462_909679324.dbf

11gR2 RAC+ADG+RAC Actual Operation

11gR2 RAC+ADG+RAC Actual Operation

一、Environment configuration information
PRIMARY:
1.OS information

[oracle@trsenpr1:/home/oracle]$uname -a
Linux trsenpr1.zr.trsen 3.8.13-16.2.1.el6uek.x86_64 #1 SMP Thu Nov 7 17:01:44 PST 2013 x86_64 x86_64 x86_64 GNU/Linux
[oracle@trsenpr1:/home/oracle]$more /etc/redhat-release 
Red Hat Enterprise Linux Server release 6.5 (Santiago)

2.IP informations

[oracle@trsenpr1:/home/oracle]$more /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
#::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
#public IP
10.88.100.40  trsenpr1  trsenpr1.zr.trsen
10.88.100.41  trsenpr2  trsenpr2.zr.trsen
#virtual IP
10.88.100.42  trsenpr1-vip  trsenpr1-vip.zr.trsen
10.88.100.43  trsenpr2-vip  trsenpr2-vip.zr.trsen

3.Database version

SQL> select version,comments from registry$history;
VERSION                COMMENTS
------------------------------ --------------------------------------------------
11.2.0.4               Patchset 11.2.0.2.0集群版本:

4.path information
./opatch  lsinventory
Not opatch for the database and cluster.

STANDBY.
1.OS information

[oracle@trsendb1:/home/oracle]$uname -a
Linux trsendb1.zr.trsen 3.8.13-16.2.1.el6uek.x86_64 #1 SMP Thu Nov 7 17:01:44 PST 2013 x86_64 x86_64 x86_64 GNU/Linux
[oracle@trsendb1:/home/oracle]$more /etc/redhat-release 
Red Hat Enterprise Linux Server release 6.5 (Santiago)

2.IP informations

[oracle@trsendb1:/home/oracle]$more /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
#public ip
10.88.100.50  trsendb1  trsendb1.zr.trsen
10.88.100.51  trsendb2  trsendb2.zr.trsen
#virtual IP
10.88.100.52  trsendb1-vip  trsendb1-vip.zr.trsen
10.88.100.53  trsendb2-vip  trsendb2-vip.zr.trsen

3.Database version

SQL> select version,comments from registry$history;
VERSION                COMMENTS
------------------------------ --------------------------------------------------
11.2.0.4               Patchset 11.2.0.2.0

4.path information
./opatch  lsinventory
Not opatch for the database and cluster.

二、Prerequisites / Preparation
1.We will switchover 100.50/51 to primary database and 100.40/41 to standby database.
2.We will Data Guard Physical Standby Switchover using SQL*Plus
3.Review Primary Database Initialization Parameters
Ensure that the LOG_ARCHIVE_CONFIG & DG_CONFIG initialization parameters are established at the primary database and 'compatible' is set correctly and to the same Value on the Primary and Standby Site.
4.Verify the Physical Standby Database Is Performing Properly
a.on the standby database, query the V$ARCHIVED_LOG view to identify existing files in the archived redo log.

SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

b.On the primary database, issue the ALTER SYSTEM SWITCH LOGFILE statement to force a log switch and archive the current online redo log file group

ALTER SYSTEM SWITCH LOGFILE;

c.On the standby database, query the V$ARCHIVED_LOG view to verify the redo data was received and archived on the standby database

SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

d.On the standby database, query the V$ARCHIVED_LOG view to verify that received redo has been applied

SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

5.Verify Managed Recovery is running on the standby
The following query at the standby verifies that managed recovery is running

SELECT PROCESS FROM V$MANAGED_STANDBY WHERE PROCESS LIKE 'MRP%';

6.The following query at the Primary verifies that recovery is running with “REAL TIME APPLY” option. 
In the example below, LOG_ARCHIVE_DEST_5 is established to ship redo to the target standby (dest_id=5):

SQL> SELECT RECOVERY_MODE FROM V$ARCHIVE_DEST_STATUS WHERE DEST_ID=5;
RECOVERY_MODE
-----------------------
MANAGED REAL TIME APPLY

If managed standby recovery is not running or not started with real-time apply, restart managed recovery with real-time apply enabled:

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

Note: If you previously defined a delay for this standby the delay is ignored when you start real time apply

7.Verify Sufficient Number of Archiver Processes
Make sure LOG_ARCHIVE_MAX_PROCESSES is set to 4 or higher on every primary and standby database in the Data Guard configuration. 
Take care not to set it too high as the additional archivers can increase the time to shutdown the database. 
This parameter can be set dynamically via ALTER SYSTEM.
Ensure Online Redo Log Files on the Target Physical Standby have been cleared.
Online redo logs on the target physical standby need to be cleared before that standby database can become a primary database.
Although this will automatically happen as part of the SWITCHOVER TO PRIMARY command, it is recommended that the logs are cleared prior to the switchover. 
If your databases are using Oracle Managed Files (OMF) or you have already set the parameter LOG_FILE_NAME_CONVERT you can skip this step as the online log files will always be cleared automatically.

8.Verify there are no large Gaps
Identify the current sequence number for each thread on the primary database

SQL> SELECT THREAD#, SEQUENCE# FROM V$THREAD;

Verify the target physical standby database has applied up to, but not including the logs from the primary query. On the standby the following query should be within 1 or 2 of the primary query result.

SELECT THREAD#, MAX(SEQUENCE#) FROM V$ARCHIVED_LOG
WHERE APPLIED = 'YES'
AND RESETLOGS_CHANGE# = (SELECT RESETLOGS_CHANGE#
FROM V$DATABASE_INCARNATION WHERE STATUS = ‘CURRENT’)
GROUP BY THREAD#;

9.Verify Primary and Standby tempfiles match and all datafiles are ONLINE

10.If The Primary is a RAC or Standby is a RAC, then shutdown all secondary primary instances
A normal or immediate shutdown can be done, but to expedite the shutdown issue a SHUTDOWN ABORT on secondary RAC instances on the primary cluster only leaving one  instance up.
Wait until the remaining instance has completed cluster reconfiguration (and performed recovery if you chose to abort the secondary instances) before continuing.
NOTE:it's very very important.

11.Verify that the primary database can be switched to the standby role
Query the SWITCHOVER_STATUS column of the V$DATABASE view on the primary database:

SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS
-----------------
TO STANDBY

三.Switchover
NOTE:These steps are completed as part of the switchover process on the day of the planned outage.
1.Cancel any apply delay for the target standby
Remove any delay in applying redo that may be in effect on the standby database that will become the new primary database.
If there is a delay then on the target standby database execute the following command.

ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE NODELAY DISCONNECT FROM SESSION;

Clear Potential Blocking Parameters & Jobs and Capture current job state on the primary

SELECT * FROM DBA_JOBS_RUNNING;

Depending on what the running job is, be ready to terminate the job if necessary.

SELECT OWNER, JOB_NAME, START_DATE, END_DATE, ENABLED FROM  DBA_SCHEDULER_JOBS WHERE ENABLED=’TRUE’ AND OWNER <> ‘SYS”;

Note: Job candidates to be disabled among others: oracle text sync and optimizer, RMAN backups, application garbage collectors, application background agents.
Block further job submission

ALTER SYSTEM SET job_queue_processes=0 SCOPE=BOTH SID=’*’;

Disable any jobs that may interfere.

SQL> EXECUTE DBMS_SCHEDULER.DISABLE( <job_name> );

Tail the alert logs
tail –f <background_dump_dest location>/alert*

check transaction

select xidusn,xidslot,xidsqn,status,start_time from gv$transaction;

Switchover the primary to a standby database

ALTER SYSTEM CHECKPOINT;
ALTER DATABASE COMMIT TO SWITCHOVER TO STANDBY WITH SESSION SHUTDOWN;
alter database recover managed standby database using current logfile disconnect from session;

If an ORA-16139 error is encountered, as long as V$DATABASE.DATABASE_ROLE=’PHYSICAL STANDBY’, then you can proceed.
A common case where this can occur is when there are a large number of data files. 
Once managed recovery is started on the new standby, the database will recover.

If the role was not changed then you need to cancel the switchover and review the alert logs and trace files further.
Verify the standby has received the end-of-redo (EOR) log(s)

In the primary alert log you will see messages like these:

Reconfiguration started (old inc 4, new inc 6)<<<<<<<<======shutdown immedaite second node,reconfiguration.
List of instances:
 1 (myinst: 1) 
 Global Resource Directory frozen
 * dead instance detected - domain 0 invalid = TRUE 
 Communication channels reestablished
 Master broadcasted resource hash value bitmaps
 Non-local Process blocks cleaned out
Tue Nov 22 03:04:31 2016
 LMS 1: 0 GCS shadows cancelled, 0 closed, 0 Xw survived
Tue Nov 22 03:04:31 2016
Tue Nov 22 03:04:31 2016
 LMS 2: 0 GCS shadows cancelled, 0 closed, 0 Xw survived
 LMS 0: 0 GCS shadows cancelled, 0 closed, 0 Xw survived
 Set master node info 
 Submitted all remote-enqueue requests
 Dwn-cvts replayed, VALBLKs dubious
 All grantable enqueues granted
 Post SMON to start 1st pass IR
Tue Nov 22 03:04:32 2016
Instance recovery: looking for dead threads
Instance recovery: lock domain invalid but no dead threads
 Submitted all GCS remote-cache requests
 Post SMON to start 1st pass IR
 Fix write in gcs resources
Reconfiguration complete
Tue Nov 22 03:04:45 2016
Redo thread 2 internally disabled at seq 6493 (CKPT)
Tue Nov 22 03:04:45 2016
ARC3: Archiving disabled thread 2 sequence 6493
Archived Log entry 43702 added for thread 2 sequence 6493 ID 0x43f83f07 dest 1:
Tue Nov 22 03:05:37 2016
Decreasing number of real time LMS from 3 to 0
Tue Nov 22 03:06:41 2016
ALTER SYSTEM SET log_archive_dest_state_3='DEFER' SCOPE=BOTH;
Tue Nov 22 03:06:51 2016
ALTER SYSTEM SET log_archive_dest_state_5='DEFER' SCOPE=BOTH;
Tue Nov 22 03:08:06 2016
alter database commit to switchover to physical standby WITH SESSION SHUTDOWN<<<<<<<<=======staring switchover primary to standby.
ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY [Process Id: 144279] (trsenpr1)
Waiting for all non-current ORLs to be archived...
All non-current ORLs have been archived.
Waiting for all FAL entries to be archived...
All FAL entries have been archived.
Waiting for potential Physical Standby switchover target to become synchronized...
Active, synchronized Physical Standby switchover target has been identified
Switchover End-Of-Redo Log thread 1 sequence 7911 has been fixed
Switchover: Primary highest seen SCN set to 0x4.0x2f9d035c
ARCH: Noswitch archival of thread 1, sequence 7911
ARCH: End-Of-Redo Branch archival of thread 1 sequence 7911
ARCH: LGWR is actively archiving destination LOG_ARCHIVE_DEST_2
ARCH: Standby redo logfile selected for thread 1 sequence 7911 for destination LOG_ARCHIVE_DEST_2
Archived Log entry 43706 added for thread 1 sequence 7911 ID 0x43f83f07 dest 1:
ARCH: Archiving is disabled due to current logfile archival
Primary will check for some target standby to have received alls redo
Final check for a synchronized target standby. Check will be made once.
LOG_ARCHIVE_DEST_2 is a potential Physical Standby switchover target
Active, synchronized target has been identified
Target has also received all redo
Backup controlfile written to trace file /u01/app/oracle/diag/rdbms/trsenpr/trsenpr1/trace/trsenpr1_ora_144279.trc
Clearing standby activation ID 1140342535 (0x43f83f07)
The primary database controlfile was created using the
'MAXLOGFILES 192' clause.
There is space for up to 182 standby redo logfiles
Use the following SQL commands on the standby database to create
standby redo logfiles that match the primary database:
ALTER DATABASE ADD STANDBY LOGFILE 'srl1.f' SIZE 1073741824;
ALTER DATABASE ADD STANDBY LOGFILE 'srl2.f' SIZE 1073741824;
ALTER DATABASE ADD STANDBY LOGFILE 'srl3.f' SIZE 1073741824;
ALTER DATABASE ADD STANDBY LOGFILE 'srl4.f' SIZE 1073741824;
ALTER DATABASE ADD STANDBY LOGFILE 'srl5.f' SIZE 1073741824;
ALTER DATABASE ADD STANDBY LOGFILE 'srl6.f' SIZE 1073741824;
ALTER DATABASE ADD STANDBY LOGFILE 'srl7.f' SIZE 1073741824;
ALTER DATABASE ADD STANDBY LOGFILE 'srl8.f' SIZE 1073741824;
ALTER DATABASE ADD STANDBY LOGFILE 'srl9.f' SIZE 1073741824;
ALTER DATABASE ADD STANDBY LOGFILE 'srl10.f' SIZE 1073741824;
ALTER DATABASE ADD STANDBY LOGFILE 'srl11.f' SIZE 1073741824;
Archivelog for thread 1 sequence 7911 required for standby recovery
Switchover: Primary controlfile converted to standby controlfile succesfully.
Switchover: Complete - Database shutdown required
......
.....
Tue Nov 22 03:09:23 2016
ALTER DATABASE OPEN
This instance was first to open
Beginning Standby Crash Recovery.
Serial Media Recovery started
Tue Nov 22 03:09:23 2016
Managed Standby Recovery starting Real Time Apply
CHANGE TRACKING change stream 1 is open.
CHANGE TRACKING file is not usable. The above change
stream(s) are open. Change tracking was not closed
cleanly the last time it was shutdown.
CHANGE TRACKING is reinitializing the change tracking file.
Starting background process CTWR
Tue Nov 22 03:09:23 2016
CTWR started with pid=47, OS id=4150 
ARC7: Archival started
ARC0: STARTING ARCH PROCESSES COMPLETE
Block change tracking service is active.
Media Recovery Log +ARCH/trsenpr/1_7911_909679324.dbf
SUCCESS: diskgroup ARCH was mounted
Identified End-Of-Redo (switchover) for thread 1 sequence 7911 at SCN 0x4.2f9d035c
Tue Nov 22 03:09:24 2016
NOTE: dependency between database trsenpr and diskgroup resource ora.ARCH.dg is established
Resetting standby activation ID 0 (0x0)
Incomplete Recovery applied until change 17978688348 time 11/22/2016 03:08:08
Block change tracking service stopping.
Stopping background process CTWR
Completed Standby Crash Recovery.
Picked Lamport scheme to generate SCNs
Tue Nov 22 03:09:25 2016
SMON: enabling cache recovery
Dictionary check beginning
Dictionary check complete
Database Characterset is ZHS16GBK
Opening with Resource Manager plan: trsenPLAN 
Tue Nov 22 03:09:26 2016
Starting background process VKRM
Tue Nov 22 03:09:26 2016
VKRM started with pid=47, OS id=4249 
Starting background process GTX0
Tue Nov 22 03:09:26 2016
GTX0 started with pid=49, OS id=4252 
replication_dependency_tracking turned off (no async multimaster replication found)
Physical standby database opened for read only access.
Completed: ALTER DATABASE OPEN
Tue Nov 22 03:09:26 2016
db_recovery_file_dest_size of 51100 MB is 0.23% used. This is a
user-specified limit on the amount of space that will be used by this
database for recovery-related files, and does not reflect the amount of
space available in the underlying filesystem or ASM diskgroup.
Tue Nov 22 03:09:52 2016
alter database recover managed standby database using current logfile disconnect from session
Attempt to start background Managed Standby Recovery process (trsenpr1)
Tue Nov 22 03:09:52 2016
MRP0 started with pid=53, OS id=4605 
MRP0: Background Managed Standby Recovery process started (trsenpr1)
 started logmerger process
Tue Nov 22 03:09:57 2016
Managed Standby Recovery starting Real Time Apply
Parallel Media Recovery started with 32 slaves
Tue Nov 22 03:09:59 2016
Block change tracking file is current.
Starting background process CTWR
Tue Nov 22 03:09:59 2016
CTWR started with pid=87, OS id=4891 
Block change tracking service is active.
Waiting for all non-current ORLs to be archived...
All non-current ORLs have been archived.
Clearing online redo logfile 1 +DATA/trsenpr/redo1-1.log
Clearing online log 1 of thread 1 sequence number 7908
Completed: alter database recover managed standby database using current logfile disconnect from session

And correspondingly in the standby alert log file you should see messages like these

Tue Nov 22 03:04:46 2016
RFS[28]: Assigned to RFS process 1500
RFS[28]: Opened log for thread 2 sequence 6493 dbid 1097341969 branch 909679324
Archived Log entry 729 added for thread 2 sequence 6493 rlc 909679324 ID 0x43f83f07 dest 2:
Tue Nov 22 03:04:46 2016
Media Recovery Log +ARCH/trsendb/2_6493_909679324.dbf
Tue Nov 22 03:05:31 2016
Decreasing number of real time LMS from 3 to 0
Tue Nov 22 03:08:08 2016
RFS[29]: Assigned to RFS process 3944
RFS[29]: Selected log 11 for thread 1 sequence 7911 dbid 1097341969 branch 909679324
Tue Nov 22 03:08:08 2016
Archived Log entry 730 added for thread 1 sequence 7911 ID 0x43f83f07 dest 1:
Tue Nov 22 03:08:08 2016
Resetting standby activation ID 1140342535 (0x43f83f07)
Media Recovery End-Of-Redo indicator encountered
Media Recovery Continuing
Media Recovery Waiting for thread 1 sequence 7912
Tue Nov 22 03:08:09 2016
RFS[17]: Possible network disconnect with primary database
Tue Nov 22 03:08:09 2016
RFS[30]: Assigned to RFS process 59932
RFS[30]: Possible network disconnect with primary database
Tue Nov 22 03:08:09 2016
RFS[24]: Possible network disconnect with primary database

In versions prior to Oracle Database 11g Release 2, the MRP (Redo Apply coordinator) would stop automatically after processing the End-of-Redo marker. 
With Oracle Database 11g Release 2, it no longer stops leaving all bystander standby databases still ready to apply redo from the new primary database without having to be restarted. 
The MRP process will be shut down automatically by the switchover command when executed at the target standby database.

Verify that the standby database can be switched to the primary role
Query the SWITCHOVER_STATUS column of the V$DATABASE view on the standby database:

SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS
-----------------
TO PRIMARY

A value of TO PRIMARY or SESSIONS ACTIVE indicates that the standby database is ready to be switched to the primary role.
If neither of these values is returned, verify that redo apply is active and that redo transport is configured and working properly.
Continue to query this column until the value returned is either TO PRIMARY or SESSIONS ACTIVE.


Switchover the standby database to a primary

ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN;

In the standby alert log file you should see messages like these:


lter database commit to switchover to primary WITH SESSION SHUTDOWN
ALTER DATABASE SWITCHOVER TO PRIMARY (trsendb1)
Maximum wait for role transition is 15 minutes.
Switchover: Media recovery is still active
Role Change: Canceling MRP - no more redo to apply
Tue Nov 22 03:11:38 2016
MRP0: Background Media Recovery cancelled with status 16037
Errors in file /u01/app/oracle/diag/rdbms/trsendb/trsendb1/trace/trsendb1_pr00_71666.trc:
ORA-16037: user requested cancel of managed recovery operation
Tue Nov 22 03:11:38 2016
Managed Standby Recovery not using Real Time Apply
Recovery interrupted!
Tue Nov 22 03:11:45 2016
MRP0: Background Media Recovery process shutdown (trsendb1)
Tue Nov 22 03:11:47 2016
Role Change: Canceled MRP
All dispatchers and shared servers shutdown
CLOSE: killing server sessions.
....
Active process 31997 user 'grid' program 'oracle@trsendb1.zr.trsen'
Active process 121903 user 'grid' program 'oracle@trsendb1.zr.trsen'
Active process 31999 user 'grid' program 'oracle@trsendb1.zr.trsen'
Active process 31002 user 'grid' program 'oracle@trsendb1.zr.trsen'
Active process 4500 user 'grid' program 'oracle@trsendb1.zr.trsen'
Active process 4502 user 'grid' program 'oracle@trsendb1.zr.trsen'
Active process 747 user 'grid' program 'oracle@trsendb1.zr.trsen'
Active process 4504 user 'grid' program 'oracle@trsendb1.zr.trsen'
CLOSE: all sessions shutdown successfully.
Tue Nov 22 03:11:50 2016
SMON: disabling cache recovery
Tue Nov 22 03:12:00 2016
Backup controlfile written to trace file /u01/app/oracle/diag/rdbms/trsendb/trsendb1/trace/trsendb1_ora_196197.trc
SwitchOver after complete recovery through change 17978688348
Online log +DATA/trsendb/redo1-1.log: Thread 1 Group 1 was previously cleared
Online log +DATA/trsendb/redo1-2.log: Thread 1 Group 2 was previously cleared
Online log +DATA/trsendb/redo1-3.log: Thread 1 Group 3 was previously cleared
Online log +DATA/trsendb/redo1-4.log: Thread 1 Group 4 was previously cleared
Online log +DATA/trsendb/redo1-5.log: Thread 1 Group 5 was previously cleared
Online log +DATA/trsendb/redo2-1.log: Thread 2 Group 6 was previously cleared
Online log +DATA/trsendb/redo2-2.log: Thread 2 Group 7 was previously cleared
Online log +DATA/trsendb/redo2-3.log: Thread 2 Group 8 was previously cleared
Online log +DATA/trsendb/redo2-4.log: Thread 2 Group 9 was previously cleared
Online log +DATA/trsendb/redo2-5.log: Thread 2 Group 10 was previously cleared
Standby became primary SCN: 17978688346
Switchover: Complete - Database mounted as primary
Completed: alter database commit to switchover to primary WITH SESSION SHUTDOWN
Tue Nov 22 03:12:08 2016
ARC1: Becoming the 'no SRL' ARCH
Tue Nov 22 03:12:16 2016
Starting ORACLE instance (normal)
Tue Nov 22 03:12:53 2016
alter database open
This instance was first to open

Open the new primary database

ALTER DATABASE OPEN;

Correct any tempfile mismatch
If there was a tempfile that was not corrected during the pre-switchover check, then correct it now on the new primary.

Restart the new standby
If the new standby database (former primary database) was not shutdown since switching it to standby, bring it to the mount state and start managed recovery.
This can be done in parallel to the new primary open.

SHUTDOWN immediate;
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;

The blog reference the 11.2 Data Guard Physical Standby Switchover Best Practices using SQL*Plus (Doc ID 1304939.1)
The blog come from real cases.