I. Pre-switch Check
1. Parameter Check ----------------------------主端-------------------------------------------------------Define valid db_unique_name for Dataguard configuration
Sql> Show parameter Log_archive_config
NAME TYPE VALUE
--------------------------------------- --------------------------------------
log_archive_config string dg_config= (PROD,PROD_STD)
--local archive destinations and attributes
Sql> show parameter log_archive_dest_1;
NAME TYPE VALUE
-----------------------------------------------------------------------------
Log_archive_dest_1 string location=+data_dg/arch valid_f
or= (all_logfiles,all_roles) DB
_unique_ Name=prod
--Remote archive destinations and attributes
Sql> Show parameter log_archive_dest_2
NAME TYPE VALUE
--------------------------------------- --------------------------------------
log_archive_dest_2 string service=prod_std lgwr Async va
Lid_for= (Online_logfiles,prima
ry_roles) db_unique_name=prod_
std
--log_archive_dest_state_1
Sql> Show parameter log_archive_dest_state_1
NAME TYPE VALUE
----------------------------- ------------------------------------------------
log_archive_dest_state_1 string ENABLE
--log_archive_dest_state_2
Sql> Show parameter log_archive_dest_state_2
NAME TYPE VALUE
--------------------------------- --------------------------------------------
log_archive_dest_state_2 string ENABLE
--When the main library data file is added or deleted, automatically configures the repository
Sql> Show parameter standby_file_management
NAME TYPE VALUE
--------------------------------- --------------------------------------------
standby_file_management string Auto
--Repository TNS
Sql> Show parameter Fal_server
NAME TYPE VALUE
------------------------------------------- ----------------------------------
fal_server string prod_std
--Main Library TNS
Sql> Show parameter fal_client
NAME TYPE VALUE
----------------------------------------------- ------------------------------
fal_client string prod_pri
--service_names
Sql> show parameter service_names;
NAME TYPE VALUE
-----------------------------------------------------------------------------
service_names string prod, prod_std
--spfile
Sql> Show parameter SPFile
NAME TYPE VALUE
--------------------------------------------------- --------------------------
spfile string +data_dg/prod/parameterfile/sp
file.281.950980793
----------------------------备端-------------------------------------------------------log_archive_config: Consistent with the main end
--log_archive_dest_1
Sql> Show parameter log_archive_dest_1
NAME TYPE VALUE
--------------------------------------- --------------------------------------
log_archive_dest_1 string location=+data_dg/arch valid_f
or= (all_logfiles,all_roles) DB
_unique_name=prod_std
--log_archive_dest_2
Sql> Show parameter log_archive_dest_2
NAME TYPE VALUE
------------------------------------ -----------------------------------------
log_archive_dest_2 string service=prod_pri lgwr Async VA
lid_for= (Online_logfiles,prima
ry_roles) Db_unique_name=prod
--log_archive_dest_state_1: Consistent with the main end
--log_archive_dest_state_2: Consistent with the main end
--standby_file_management: Consistent with the main end
--fal_server
Sql> Show parameter Fal_server
NAME TYPE VALUE
----------------------------------------------- ------------------------------
fal_server string prod_pri
--fal_client
Sql> Show parameter fal_client
NAME TYPE VALUE
---------------------------------------------- -------------------------------
fal_client string prod_pri
--db_unique_name
Sql> Show parameter Db_unique_name
name TYPE VALUE
------------------------------------------- ----------------------------------
db_unique_name string prod_std
--spfile
Sql> Show parameter SPFile
NAME TYPE VALUE
-------------------------------------------------- ---------------------------
spfile string +data_dg/prod/parameterfile/sp
Fileprod.ora
2. Confirm Primary Standby network connectivityMain end: According to log_archive_dest_2 configuration
[Oracle@oracle-node1 ~]$ tnsping prod_std
TNS Ping Utility for linux:version 12.1.0.2.0-production on 03-aug-2017 1 7:58:10
Copyright (c) 1997, 2014, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES Adapter To resolve the alias attempting to contacts description_list
= (load_b Alance = off) (FAILOVER = in) (DESCRIPTION = (Address_list = (load_balance = off) (FAILOVER = on) (address = (PROTOCOL = T CP) (HOST = 172.18.19.108) (PORT = 1521)) (Connect_data = (service_name = prod) (instance_name = prod1) (Failover_mode = (T ype = Session) (method = Basic) (retries = 4) (DELAY = 1))) (DESCRIPTION = (Address_list = (load_balance = off) (FAILOVER = ON) (address = (PROTOCOL = TCP) (HOST = 172.18.19.109) (PORT = 1521)) (Connect_data = (service_name = prod) (instance_na me = prod2) (Failover_mode = (TYPE = Session) (method = Basic) (retries = 4) (DELAY = 1)))
OK (msec)
Spare side:
[Oracle@oracle-node3 ~]$ tnsping prod_pri
TNS Ping Utility for linux:version 12.1.0.2.0-production on 03-aug-2017 1 7:59:20
Copyright (c) 1997, 2014, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES Adapter To resolve the alias attempting to contacts description_list
= (load_b Alance = off) (FAILOVER = in) (DESCRIPTION = (Address_list = (load_balance = off) (FAILOVER = on) (address = (PROTOCOL = T CP) (HOST = 172.18.19.106) (PORT = 1521)) (Connect_data = (service_name = prod) (instance_name = prod1) (Failover_mode = (T ype = Session) (method = Basic) (retries = 4) (DELAY = 1))) (DESCRIPTION = (Address_list = (load_balance = off) (FAILOVER = ON) (address = (PROTOCOL = TCP) (HOST = 172.18.19.107) (PORT = 1521)) (Connect_data = (service_name = prod) (instance_na me = prod2) (Failover_mode = (TYPE = Session) (method = Basic) (retries = 4) (DELAY = 1)))
OK (0 msec)
3. Main standby standby logfile view, ensure log real-time application
Sql> SELECT * from V$logfile where type= ' STANDBY ';
4. Primary Standby database status check---The main end
Sql> Select Dbid,name,open_mode,current_scn,protection_mode,database_role,force_logging,
2 Open_mode, Switchover_status from Gv$database;
DBID NAME open_mode current_scn protection_mode database_role force_logging Open_mode Switchover_status
--------------------------------------------------------------------------------------- ------------------------------------------------------------------------------
362818713 PROD READ Write 2262262 MAXIMUM performance PRIMARY YES READ WRITE to STANDBY
362818713 Read Write 2262262 MAXIMUM performance PRIMARY YES Read write to STANDBY
--Spare side
Sql> Select Dbid,name,open_mode,current_scn,protection_mode,database_role,force_logging,
2 Open_mode, Switchover_status from Gv$database;
DBID NAME open_mode current_scn protection_mode database_role force_logging Open_mode Switchover_status
---------------------------------------------------------------------------------------- -----------------------------------------------------------------------------
362818713 PROD READ only With APPLY 2263439 MAXIMUM performance physical STANDBY YES READ only with Applynot allowed
362818713 PROD Read only with APPLY 2263439 MAXIMUM Performance physical STANDBY YES READ only with A Pply not allowed
5. Check disaster-tolerant end application node and application situation
Sql> Select Inst_id,value
2 from gv$dataguard_stats
3 where value =
4 (select min (value) From gv$dataguard_stats WHERE name = ' Apply lag ')
5 and name = ' Apply lag '
6 ;
inst_id VALUE
--------------------------------------------------------------------------
1 +00 00:00:00
two. switch over disaster-tolerant switching----------------------------The main end-----------------------------------------------------
1. Turn off the main end, node 2nd.---Stop all two-node monitoring (turn off dual-node all listening, real-time application without lack of archiving, production monitoring does not affect log applications)
[Root@oracle-node2 bin]# su-grid
login:thu Aug 3 17:29:08 CST 2017 on PTS/1
[Grid@oracle-node2 ~]$ Srvctl Stop Listener
--Kill external connections
[Oracle@oracle-node2 ~]$ ps-ef|grep Local=no|awk ' {print $} ' |xargs
--Close the database
[Oracle@oracle-node2 ~]$ sqlplus/as sysdba
alter system switch logfile;
alter system switch logfile;
alter system switch logfile;
alter system switch logfile;
alter system switch logfile;
alter system switch logfile;
alter system switch logfile;
alter system switch logfile;
alter system checkpoint;
sql> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
2.1th number of nodes for disaster-tolerant switching--Kill external connections
[Root@oracle-node1 ~]# ps-ef|grep Local=no|awk ' {print $} ' |xargs kill-9
--
sql> alter system switch LOGFIL e;
System altered.
sql>/
System altered.
sql>/
System altered.
Sql> alter system checkpoint;
System altered.
Sql> ALTER DATABASE commit to switchover to physical standby with session shutdown, (perform primary preparation)
database altered.
--
sql> Startup
--Check Master library status
Sql> Select Dbid,name,open_mode,current_scn,protection_mode,database_role,force_logging,
2 Open_mode, Switchover_status from Gv$database;
DBID NAME open_mode current_scn protection_mode database_role force_logging Open_mode Switchover_status
---------------------------------------------------------------------------------------- -----------------------------------------------------------------------------
362818713 PROD READ only 2366359 MAXIMUM Performance Physical STANDBY YES
READ only to PRIMARY
--Open log application
sql> ALTER DATABASE recover managed standby database using current logfile disconnect from session;
3. Start number 2nd node
Sql> Startup
--Check the main library state, should be physical standby
Sql> Select Dbid,name,open_mode,current_scn,protection_mode,database_role,force_logging,
2 Open_mode, Switchover_status from Gv$database;
DBID NAME open_mode current_scn protection_mode database_role force_logging Open_mode Switchover_status
---------------------------------------------------------------------------------------- -----------------------------------------------------------------------------
362818713 PROD READ only 2366359 MAXIMUM Performance Physical STANDBY YES READ only to PRIMARY
362818713 PROD READ only 2366359 Performance physical STANDBY YES READ only to PRIMARY
--Open two-node monitoring
[Grid@oracle-node2 ~]$ srvctl Start listener
----------------------------备端-----------------------------------------------------Take the log application in the 1th number node as an example
1. Stop capacity Disaster end 2nd node--Stop listening
[Grid@oracle-node4 ~]$ srvctl Stop Listener-n oracle-node4
--Kill external connections
[Root@oracle-node4 ~]# ps-ef|grep Local=no|awk ' {print $} ' |xargs
--Close the database
sql> shutdown abort;
2. At the disaster-tolerant end of the 1th node to prepare the main--Stop listening
[Grid@oracle-node3 ~]$ srvctl Stop Listener-n oracle-node3
--Kill external connections
[Root@oracle-node3 ~]# ps-ef|grep Local=no|awk ' {print $} ' |xargs
--Check Database status
Sql> Select Dbid,name,open_mode,current_scn,protection_mode,database_role,
2 force_logging,switchover _status from V$database;
DBID NAME open_mode current_scn protection_mode database_role force_logging switchover_ STATUS
---------------------------------------------------------------------------------------------------- ---------------------------------------------
362818713 PROD READ only with APPLY 2366359 MAXIMUM Performance physical STANDBY YES to PRIMARY
--Cancel Log application
sql> ALTER DATABASE recover managed standby database cancel;
Database altered.
--Prepare the master, the conversion process includes automatic restart operation
Sql> ALTER DATABASE commit to switchover to primary with the session shutdown;
Database altered.
--Check the state of the database, which is now started to mount
Sql> Select Dbid,name,open_mode,current_scn,protection_mode,database_role,
2 force_logging,switchover _status from V$database;
DBID NAME open_mode current_scn protection_mode database_role force_logging switchover_ STATUS
---------------------------------------------------------------------------------------------------- ---------------------------------------------
362818713 PROD mounted 0 MAXIMUM performance PRIMARY YES not allowed
3. Start number 2nd node--From the library
Sql> Startup
--Open the monitor
[Grid@oracle-node4 ~]$ srvctl Start listener
At this point, switch over completes