SQL> show parameter log_archive_config
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_config string dg_config=(prod,prod_std)
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
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
SQL> show parameter log_archive_dest_state_1
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_state_1 string ENABLE
SQL> show parameter log_archive_dest_state_2
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_state_2 string ENABLE
SQL> show parameter standby_file_management
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
standby_file_management string auto
SQL> show parameter fal_server
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
fal_server string PROD_STD
SQL> show parameter fal_client
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
fal_client string PROD_PRI
SQL> show parameter service_names;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
service_names string prod, prod_std
SQL> show parameter spfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string +DATA_DG/PROD/PARAMETERFILE/sp
file.281.950980793
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
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
SQL> show parameter fal_server
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
fal_server string PROD_PRI
SQL> show parameter fal_client
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
fal_client string PROD_PRI
SQL> show parameter db_unique_name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_unique_name string prod_std
SQL> show parameter spfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string +DATA_DG/PROD/PARAMETERFILE/sp
fileprod.ora
[oracle@oracle-node1 ~]$ tnsping prod_std
TNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 03-AUG-2017 17:58:10
Copyright (c) 1997, 2014, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION_LIST = (LOAD_BALANCE = off) (FAILOVER = on) (DESCRIPTION = (ADDRESS_LIST = (LOAD_BALANCE = OFF) (FAILOVER = ON) (ADDRESS = (PROTOCOL = TCP)(HOST = 172.18.19.108)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = prod) (Instance_name = prod1) (FAILOVER_MODE = (TYPE = 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_name = prod2) (FAILOVER_MODE = (TYPE = session) (METHOD = basic) (RETRIES = 4) (DELAY = 1)))))
OK (10 msec)
[oracle@oracle-node3 ~]$ tnsping prod_pri
TNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 03-AUG-2017 17:59:20
Copyright (c) 1997, 2014, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION_LIST = (LOAD_BALANCE = off) (FAILOVER = on) (DESCRIPTION = (ADDRESS_LIST = (LOAD_BALANCE = OFF) (FAILOVER = ON) (ADDRESS = (PROTOCOL = TCP)(HOST = 172.18.19.106)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = prod) (Instance_name = prod1) (FAILOVER_MODE = (TYPE = 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_name = prod2) (FAILOVER_MODE = (TYPE = session) (METHOD = basic) (RETRIES = 4) (DELAY = 1)))))
OK (0 msec)
SQL> select * from v$logfile where type='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 WRITE 2262262 MAXIMUM PERFORMANCE PRIMARY YES READ WRITE TO STANDBY
362818713 PROD READ WRITE 2262262 MAXIMUM PERFORMANCE PRIMARY YES READ WRITE TO 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 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 APPLY NOT ALLOWED
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
[root@oracle-node2 bin]# su - grid
Last login: Thu Aug 3 17:29:08 CST 2017 on pts/1
[grid@oracle-node2 ~]$ srvctl stop listener
--杀外部连接
[oracle@oracle-node2 ~]$ ps -ef|grep LOCAL=NO|awk '{print $2}'|xargs kill -9
[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.
[root@oracle-node1 ~]# ps -ef|grep LOCAL=NO|awk '{print $2}'|xargs kill -9
--
SQL> alter system switch logfile;
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;(执行主切备)
Database altered.
--
SQL> startup
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
SQL> alter database recover managed standby database using current logfile disconnect from session;
Database altered.
SQL> startup
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 MAXIMUM PERFORMANCE PHYSICAL STANDBY YES READ ONLY TO PRIMARY
[grid@oracle-node2 ~]$ srvctl start listener
[grid@oracle-node4 ~]$ srvctl stop listener -n oracle-node4
[root@oracle-node4 ~]# ps -ef|grep LOCAL=NO|awk '{print $2}'|xargs kill -9
SQL> shutdown abort;
[grid@oracle-node3 ~]$ srvctl stop listener -n oracle-node3
[root@oracle-node3 ~]# ps -ef|grep LOCAL=NO|awk '{print $2}'|xargs kill -9
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
SQL> alter database recover managed standby database cancel;
Database altered.
SQL> alter database commit to switchover to primary with session shutdown;
Database altered.
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
SQL> startup
[grid@oracle-node4 ~]$ srvctl start listener