3.1,启动switchover --primary上操作 首先将primary 转换为standby 的角色,通过下列语句: alter database commit to switchover to physical standby; SQL> alter database commit to switchover to physical standby;
Database altered.
SQL>
3.2 重启到mount SQL> shutdown immediate ORA-01507: database not mounted
ORACLE instance shut down. SQL> startup mount ORACLE instance started.
Total System Global Area 3373858816 bytes Fixed Size 2218032 bytes Variable Size 1845495760 bytes Database Buffers 1509949440 bytes Redo Buffers 16195584 bytes Database mounted. SQL>
3.3,去查看当前的状态 SQL> select switchover_status from v$database;
SWITCHOVER_STATUS -------------------- TO PRIMARY
SQL> switchover_status为TO PRIMARY。 SQL> select open_mode,database_role from v$database;
5,验证一下新的primary以及新的standby操作 去新的primary上 SQL> show parameter db_unique
NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ db_unique_name string pdunq_dg SQL> SQL> SQL> select max(sequence#) from v$archived_log;
MAX(SEQUENCE#) -------------- 369
SQL>
SQL> alter system switch logfile; System altered.
SQL>
select max(sequence#) from v$archived_log; SQL> select max(sequence#) from v$archived_log;
MAX(SEQUENCE#) -------------- 370
SQL>
去新的standby库查看下 SQL> select max(sequence#) from v$archived_log;
MAX(SEQUENCE#) -------------- 368
SQL>
redo日志没有传送到新的standby上面去,检查下新primary的alert日志,如下报错: Mon Feb 09 16:55:35 2015 Error 12154 received logging on to the standby Errors in file /oracle/app/oracle/diag/rdbms/pdunq_dg/powerdes/trace/powerdes_arc2_23808.trc: ORA-12154: TNS:could not resolve the connect identifier specified PING[ARC2]: Heartbeat failed to connect to standby ‘pdunq_dg‘. Error is 12154. Mon Feb 09 16:56:35 2015 Error 12154 received logging on to the standby Errors in file /oracle/app/oracle/diag/rdbms/pdunq_dg/powerdes/trace/powerdes_arc2_23808.trc: ORA-12154: TNS:could not resolve the connect identifier specified PING[ARC2]: Heartbeat failed to connect to standby ‘pdunq_dg‘. Error is 12154.
6,问题排查 这个报错原因是因为原来的primary和standby的db_unique_name不一样,所以switchover后,原来指向的归档参数的db_unique_name要与新的standby保持一致,也就是要保持成pdunq才行: 去查看下 show parameter log_archive_dest_2参数: SQL> show parameter log_archive_dest_2;
NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ log_archive_dest_2 string SERVICE=pdunq_dg lgwr sync af firm VALID_FOR=(ONLINE_LOGFILE S,PRIMARY_ROLE) DB_UNIQUE_NAME =pdunq log_archive_dest_20 string log_archive_dest_21 string log_archive_dest_22 string log_archive_dest_23 string log_archive_dest_24 string log_archive_dest_25 string log_archive_dest_26 string
NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ log_archive_dest_27 string log_archive_dest_28 string log_archive_dest_29 string SQL> --修改log_archive_dest_2参数 alter system set log_archive_dest_2=‘SERVICE=pdunq_dg lgwr sync affirm VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=pdunq‘; alter system set log_archive_dest_state_2=enable; alter system switch logfile; SQL> alter system set log_archive_dest_2=‘SERVICE=pdunq_dg lgwr sync affirm VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=pdunq‘;
System altered.
SQL> alter system set log_archive_dest_state_2=enable;
System altered.
SQL> alter system switch logfile;
System altered.
SQL> 去新的primary、standby库使用select max(sequence#) from v$archived_log;检查记录 SQL> select max(sequence#) from v$archived_log;