1. 程式人生 > >Oracle11gr2_ADG管理之在備庫上模擬failover的過程實戰

Oracle11gr2_ADG管理之在備庫上模擬failover的過程實戰

11.2.0.4 erro from databases art gpo als initial ora-1652

技術建議和方案。

 要求failover後不重建備庫,並能夠把failover的數據庫重新切換回備庫 
主庫為newtest,備庫為snewtest
備庫上已經開啟了閃回

得到一個參考的SCN

SQL> select current_scn from v$database;

CURRENT_SCN
-----------
    4491930

查看閃回數據庫特性是打開的。

SQL> select flashback_on from v$database;
FLASHBACK_ON
------------------------------------
YES

然後我們在備庫上開始failover

DGMGRL> failover to snewtest;
Performing failover NOW, please wait...
Failover succeeded, new primary is "snewtest"

操作很快完成,我們查看備庫此時的狀態和角色

SQL> select open_mode,database_role    from v$database;

OPEN_MODE            DATABASE_ROLE
-------------------- ----------------
READ WRITE           PRIMARY

當然這個步驟可以做一些讀寫操作之類的.

然後我們開始計劃切回備庫。

SQL> shutdown immediate

SQL> startup mount

閃回數據庫到指定的SCN,

SQL> flashback database to scn 4491930;            
Flashback complete.

切換這個新主庫為備庫

SQL> alter database convert to physical standby;
Database altered.

需要重啟備庫

SQL> shutdown immediate
SQL> startup mount

最關鍵的步驟,重新配置DG Broker

主庫上刪除DG Broker配置

SQL> alter system set dg_broker_start = false;

System altered.

SQL> !ps -ef |grep dmon                        
oracle   24648 24644  0 00:13 pts/3    00:00:00 /bin/bash -c ps -ef |grep dmon
oracle   24650 24648  0 00:13 pts/3    00:00:00 grep dmon

[oracle@localhost ~]$ cd $ORACLE_HOME/dbs
[oracle@localhost dbs]$ ll
total 10048
-rw-r-----. 1 oracle dba     8192 Mar 30 00:07 dr1newtest.dat
-rw-r-----. 1 oracle dba     8192 Mar 30 00:07 dr2newtest.dat
-rw-rw----. 1 oracle dba     1544 Mar 12 00:02 hc_DBUA1321268.dat
-rw-rw----. 1 oracle dba     1544 Mar 27 21:10 hc_newtest.dat
-rw-r--r--. 1 oracle dba      982 Mar 21 23:12 initnewtest.ora
-rw-r--r--. 1 oracle dba     2851 May 15  2009 init.ora
-rw-r-----. 1 oracle dba       24 Jan 31 20:16 lkNEWTEST
-rw-r-----. 1 oracle dba     1536 Jan 31 20:18 orapwnewtest
-rw-r-----. 1 oracle dba 10240000 Mar 27 23:53 snapcf_newtest.f
-rw-r-----. 1 oracle dba     3584 Mar 30 00:12 spfilenewtest.ora
[oracle@localhost dbs]$ rm -rf dr*newtest.dat
[oracle@localhost dbs]$ ll
total 10032
-rw-rw----. 1 oracle dba     1544 Mar 12 00:02 hc_DBUA1321268.dat
-rw-rw----. 1 oracle dba     1544 Mar 27 21:10 hc_newtest.dat
-rw-r--r--. 1 oracle dba      982 Mar 21 23:12 initnewtest.ora
-rw-r--r--. 1 oracle dba     2851 May 15  2009 init.ora
-rw-r-----. 1 oracle dba       24 Jan 31 20:16 lkNEWTEST
-rw-r-----. 1 oracle dba     1536 Jan 31 20:18 orapwnewtest
-rw-r-----. 1 oracle dba 10240000 Mar 27 23:53 snapcf_newtest.f
-rw-r-----. 1 oracle dba     3584 Mar 30 00:12 spfilenewtest.ora

備庫上刪除DG Broker配置

SQL>  alter system set dg_broker_start = false;

System altered.

SQL> !ps -ef |grep dmon
oracle   15200 15198  0 00:15 pts/2    00:00:00 /bin/bash -c ps -ef |grep dmon
oracle   15202 15200  0 00:15 pts/2    00:00:00 grep dmon

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@localhost backup_stage]$ cd $ORACLE_HOME/dbs
[oracle@localhost dbs]$ ll
total 10064
-rw-r-----. 1 oracle dba    20480 Mar 30 00:13 dr1snewtest.dat
-rw-r-----. 1 oracle dba    20480 Mar 30 00:08 dr2snewtest.dat
-rw-rw----. 1 oracle dba     1544 Mar 30 00:12 hc_newtest.dat
-rw-r--r--. 1 oracle dba     1062 Mar 21 23:30 initnewtest.ora
-rw-r-----. 1 oracle dba       24 Mar 21 23:38 lkSNEWTEST
-rw-r-----. 1 oracle dba     1536 Mar 27 23:34 orapwnewtest
-rw-r-----. 1 oracle dba 10240000 Mar 29 06:45 snapcf_newtest.f
-rw-r-----. 1 oracle dba     4608 Mar 30 00:15 spfilenewtest.ora
[oracle@localhost dbs]$ rm -rf dr*snewtest.dat
[oracle@localhost dbs]$ ll
total 10024
-rw-rw----. 1 oracle dba     1544 Mar 30 00:12 hc_newtest.dat
-rw-r--r--. 1 oracle dba     1062 Mar 21 23:30 initnewtest.ora
-rw-r-----. 1 oracle dba       24 Mar 21 23:38 lkSNEWTEST
-rw-r-----. 1 oracle dba     1536 Mar 27 23:34 orapwnewtest
-rw-r-----. 1 oracle dba 10240000 Mar 29 06:45 snapcf_newtest.f
-rw-r-----. 1 oracle dba     4608 Mar 30 00:15 spfilenewtest.ora

主庫上重新配置 DG Broker

SQL> alter system set dg_broker_start =true;

System altered.

[oracle@localhost dbs]$ dgmgrl /
DGMGRL for Linux: Version 11.2.0.4.0 - 64bit Production

Copyright (c) 2000, 2009, Oracle. All rights reserved.

Welcome to DGMGRL, type "help" for information.
Connected.
DGMGRL> create configuration dg_newtest as primary database is newtest connect identifier is newtest;
Configuration "dg_newtest" created with primary database "newtest"
DGMGRL> show configuration;

Configuration - dg_newtest

  Protection Mode: MaxPerformance
  Databases:
    newtest - Primary database

Fast-Start Failover: DISABLED

Configuration Status:
DISABLED

DGMGRL> enable configuration ;
Enabled.
DGMGRL>  show configuration;

Configuration - dg_newtest

  Protection Mode: MaxPerformance
  Databases:
    newtest - Primary database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS

DGMGRL> add database snewtest as connect identifier is snewtest maintained as physical;
Database "snewtest" added
DGMGRL>  enable database snewtest;
Enabled.
DGMGRL>  show configuration;

Configuration - dg_newtest

  Protection Mode: MaxPerformance
  Databases:
    newtest  - Primary database
    snewtest - Physical standby database
      Error: ORA-16525: the Data Guard broker is not yet available

Fast-Start Failover: DISABLED

Configuration Status:
ERROR

此時提示備庫的 Data Guard broker不可用

配置備庫的DG Broker

SQL> alter system set dg_broker_start = true;

System altered.

在主庫上再次查看dg broke 的狀態

DGMGRL> show configuration

Configuration - dg_newtest

  Protection Mode: MaxPerformance
  Databases:
    newtest  - Primary database
    snewtest - Physical standby database
      Error: ORA-16613: initialization in progress for database

Fast-Start Failover: DISABLED

Configuration Status:
ERROR

此時是初始化狀態

open 備庫

SQL> alter database open;

Database altered.

在主庫上再次查看dg broke 的狀態

DGMGRL> show configuration

Configuration - dg_newtest

  Protection Mode: MaxPerformance
  Databases:
    newtest  - Primary database
    snewtest - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS

查看備庫的狀態

 SQL> select open_mode,database_role    from v$database;

OPEN_MODE            DATABASE_ROLE
-------------------- ----------------
READ ONLY WITH APPLY PHYSICAL STANDBY

Oracle11gr2_ADG管理之在備庫上模擬failover的過程實戰