Chinaunix首页 | 论坛 | 博客
  • 博客访问: 59558
  • 博文数量: 11
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 65
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-22 14:36
文章分类

全部博文(11)

文章存档

2018年(5)

2017年(6)

我的朋友

分类: Oracle

2017-11-19 18:26:02

DGMGRL> show configuration;

Configuration - DG_CONF

  Protection Mode: MaxAvailability
  Databases:
    primarydb - Primary database
    stbydb - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS

DGMGRL> failover to 'stbydb';
Performing failover NOW, please wait...
Failover succeeded, new primary is "stbydb"
DGMGRL> reinstate database 'primarydb';
Reinstating database "primarydb", please wait...
Operation requires shutdown of instance "primarydb" on database "primarydb"
Shutting down instance "primarydb"...
Database closed.
Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance "primarydb" on database "primarydb"
Starting instance "primarydb"...
ORACLE instance started.
Database mounted.
Continuing to reinstate database "primarydb" ...
Operation requires shutdown of instance "primarydb" on database "primarydb"
Shutting down instance "primarydb"...
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance "primarydb" on database "primarydb"
Starting instance "primarydb"...
ORACLE instance started.
Database mounted.
Continuing to reinstate database "primarydb" ...
Reinstatement of database "primarydb" succeeded
DGMGRL> show configuration;

Configuration - DG_CONF

  Protection Mode: MaxAvailability
  Databases:
    stbydb - Primary database
    primarydb - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS

DGMGRL>


============fast_start failover


situation  -- primary db is down imnormally

--current primary
1)
alter system switch logfile;
shutdown abort;

--current standby
2)

select name,database_role,switchover_status from v$database;

-- switchover status should be "NOT ALLOWED"


3)
alter databae commit to swtichover to primary;   -- will failed .

4) alter database reover managed standby database finsh;


5) check status
select name,database_role,switchover_status from v$database;
select status from v$insance;

6) switchover
alter databae commit to swtichover to primary;
alter database open;

===
startup old primary db and found it's in "failed destination"
old primary dba need to be rebuild as standby db.


==============DG broker  fastfailover

1 need to set the flashback on
alter database flashback on ;   -- in 12c, no need to restart the db

2 dgmgrl check fask_start failover status

show fast_star failover

DGMGRL> show fast_start failover

Fast-Start Failover: DISABLED

  Threshold:          30 seconds
  Target:             (none)
  Observer:           (none)
  Lag Limit:          30 seconds
  Shutdown Primary:   TRUE
  Auto-reinstate:     TRUE
  Observer Reconnect: (none)
  Observer Override:  FALSE

Configurable Failover Conditions
  Health Conditions:
    Corrupted Controlfile          YES
    Corrupted Dictionary           YES
    Inaccessible Logfile            NO
    Stuck Archiver                  NO
    Datafile Offline               YES

  Oracle Error Conditions:
    (none)


3 enable fast_start failover;

4 start observer    -- the command it's better to run on server side, to keep the observer running

5 simulate primary db down

 shutdown abort the  primary db

then the database will automatically failover to standby db



======== use flashback on to rebuild DG after failover


1 set database flashback on

alter database flashback on

select flashback_on from v$database;

select oldest_flashback_scn,oldest_flashback_time from v$flashback_database_log;

SQL> show parameter flashback

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_flashback_retention_target        integer     1440


2 simulate primary db down

 shutdown abort


3  -- on standby

select * from v$archive_gap;


alter database recover managed standby database cancel;
alter database recover managed standby database finish;

select open_mode,database_role from v$database;


==== if no errors show on above commands , means no data will lost.

4 -- on standby  ,failover to primary

alter database commit to swtichover to primary with session shutdown;

select open_mode,database_role from v$database;


----failover done.

5 Rebuild old primary db ,add back to DG

1) old primary db should flashback to the time when standby switchover to primary . can check the time on V$database on old standby db

select standby_became_primary_scn from v$database;

SQL> select standby_became_primary_scn from v$database;

STANDBY_BECAME_PRIMARY_SCN
--------------------------
                  81413952


2) on old standby db ,

--create a test table for testing

create table t as select * from dba_objects where rownum<100;
select count(*) from t;

alter system switch logfile;
alter system switch logfile;

select dbms_flashback.get_system_change_number from dual;

SQL> select dbms_flashback.get_system_change_number from dual;

GET_SYSTEM_CHANGE_NUMBER
------------------------
                81459931


3) startup old primary db  in mount status and flashback db to the scn of "standby_became_primary_scn" of old standby db

startup mount;

flashback database to scn 81413952;


4) alter database convert to physical standby ;


select open_mode, database_role from v$database;

--shutdown immediate;
--startup
-- alter database recover managed standby database using current logfile disconnect from session;

check if the log can sync from prmary and standby..

check the table t
select count(*) from t;use flashback on to rebuild DG after failoveruse flashback on to rebuild DG after failoveruse

阅读(2299) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~