[20140420]使用dgmgrl管理dataguard(10)

简介: [20140420]使用dgmgrl管理dataguard(10).txt 参考链接: http://blog.itpub.net/267265/viewspace-1142649/ http://blog.

[20140420]使用dgmgrl管理dataguard(10).txt

参考链接:
http://blog.itpub.net/267265/viewspace-1142649/
http://blog.itpub.net/267265/viewspace-1143027/
http://blog.itpub.net/267265/viewspace-1143058/
http://blog.itpub.net/267265/viewspace-1143126/
http://blog.itpub.net/267265/viewspace-1143480/
http://blog.itpub.net/267265/viewspace-1144742/
http://blog.itpub.net/267265/viewspace-1145573/
http://blog.itpub.net/267265/viewspace-1145697/

http://blog.itpub.net/267265/viewspace-1145727/

-- 我的测试环境:primary的tnsnames别名test,standby主机的tnsnames别名testdg。数据库版本:
-- 前面提到了failover,需要手工操作,如果在出现问题时,做这些动作有一些慢.
-- 摘要: Apress.Expert.Consolidation.in.Oracle.Database.12c.Nov.2013.pdf
-- P366:
In the case of Data Guard this software is called the Observer. The observer process, which should ideally be in a third
site, has the task to monitor the primary database. Under certain conditions the failover operation can be initiated by
the Observer, without human intervention at all. Refer back to Figure 10-1 for a description of the architecture. The
Observer in this case is located in data center C, and the database configuration consists of the primary database in
data center A and a single standby database in data center B. For this Broker configuration there is no third database,
although it is possible to have many standby databases, even a mix of physical and logical.

--这个叫Fast Start Failover =>FSFO

Fast-start failover P43

This property of automatng the failover operaton can only be used in Data Guard broker
enabled confguraton. The observer process which runs on a diferent server from the
primary and standby databases, contnuously monitors the accessibility of the primary
database. If both the observer and the standby database cannot reach the primary database
for a predefned length of time, a fully-automated failover process is started. With 11g
Release 2, we call it fully automated, because this process includes changing the role
of the standby as primary, startng the database services on the new primary database,
disconnectng the client from the failed primary database, and redirectng them to the 
new primary database.

If the observer establishes the connecton with the original primary database again afer the
failover, it informs the database that the failover was performed and it will automatcally
reinstate the database using fashback. In order to confgure fast-start failover, we need to
specify the fast recovery area and enable fashback on the primary and standby databases.

Keep in mind that in Version 11g, Data Guard must be on Maximum Availability or Maximum
Performance mode in order to use fast-start failover. In 10g Release 2, only Maximum
Availability mode is supported for fast-start failover.


$ rldgmgrl
DGMGRL for Linux: Version 11.2.0.3.0 - 64bit Production

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

Welcome to DGMGRL, type "help" for information.
Connected.
DGMGRL> show configuration

Configuration - study

  Protection Mode: MaxPerformance
  Databases:
    test   - Primary database
    testdg - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS

-- 可以发现Fast-Start Failover: DISABLED. 是处在禁止状态.

DGMGRL> ENABLE FAST_START FAILOVER;
Error: ORA-16651: requirements not met for enabling fast-start failover

Failed.

$ oerr ORA 16651
16651, 0000, "requirements not met for enabling fast-start failover"
// *Cause:  The attempt to enable fast-start failover could not be completed
//          because one or more requirements were not met:
//          - The Data Guard configuration must be in either MaxAvailability
//            or MaxPerformance protection mode.
//          - The LogXptMode property for both the primary database and
//            the fast-start failover target standby database must be
//            set to SYNC if the configuration protection mode is set to
//            MaxAvailability mode.
//          - The LogXptMode property for both the primary database and
//            the fast-start failover target standby database must be
//            set to ASYNC if the configuration protection mode is set to
//            MaxPerformance mode.
//          - The primary database and the fast-start failover target standby
//            database must both have flashback enabled.
//          - No valid target standby database was specified in the primary
//            database FastStartFailoverTarget property prior to the attempt
//            to enable fast-start failover, and more than one standby
//            database exists in the Data Guard configuration.
// *Action: Retry the command after correcting the issue:
//          - Set the Data Guard configuration to either MaxAvailability
//            or MaxPerformance protection mode.
//          - Ensure that the LogXptMode property for both the primary
//            database and the fast-start failover target standby database
//            are set to SYNC if the configuration protection mode is set to
//            MaxAvailability.
//          - Ensure that the LogXptMode property for both the primary
//            database and the fast-start failover target standby database
//            are set to ASYNC if the configuration protection mode is set to
//            MaxPerformance.
//          - Ensure that both the primary database and the fast-start failover
//            target standby database have flashback enabled.
//          - Set the primary database FastStartFailoverTarget property to
//            the DB_UNIQUE_NAME value of the desired target standby database
//            and the desired target standby database FastStartFailoverTarget
//            property to the DB_UNIQUE_NAME value of the primary database.

DGMGRL> show database verbose test LogXptMode
  LogXptMode = 'SYNC'
DGMGRL> show database verbose testdg LogXptMode
  LogXptMode = 'SYNC'

SYS@test> select database_role,open_mode,protection_mode,force_logging,FLASHBACK_ON from v$database;

DATABASE_ROLE    OPEN_MODE            PROTECTION_MODE      FOR FLASHBACK_ON
---------------- -------------------- -------------------- --- ------------------
PRIMARY          READ WRITE           MAXIMUM PERFORMANCE  YES YES

SYS@testdg> select database_role,open_mode,protection_mode,force_logging,FLASHBACK_ON from v$database;

DATABASE_ROLE    OPEN_MODE            PROTECTION_MODE      FOR FLASHBACK_ON
---------------- -------------------- -------------------- --- ------------------
PHYSICAL STANDBY READ ONLY WITH APPLY MAXIMUM PERFORMANCE  YES YES

//          - Set the primary database FastStartFailoverTarget property to
//            the DB_UNIQUE_NAME value of the desired target standby database
//            and the desired target standby database FastStartFailoverTarget
//            property to the DB_UNIQUE_NAME value of the primary database.
--仅仅这个不满足要求.


DGMGRL> show database test FastStartFailoverTarget
  FastStartFailoverTarget = ''
DGMGRL> show database testdg FastStartFailoverTarget
  FastStartFailoverTarget = ''

DGMGRL> edit database test set PROPERTY FastStartFailoverTarget='testdg';
Property "faststartfailovertarget" updated
DGMGRL> edit database testdg set PROPERTY FastStartFailoverTarget='test';
Property "faststartfailovertarget" updated

DGMGRL> ENABLE FAST_START FAILOVER;
Error: ORA-16651: requirements not met for enabling fast-start failover

Failed.
--依旧不行.

DGMGRL> edit configuration  SET PROTECTION MODE AS MaxAvailability;
Succeeded.

DGMGRL> ENABLE FAST_START FAILOVER;
Enabled.

DGMGRL> show configuration

Configuration - study

  Protection Mode: MaxAvailability
  Databases:
    test   - Primary database
      Warning: ORA-16819: fast-start failover observer not started

    testdg - (*) Physical standby database
      Warning: ORA-16819: fast-start failover observer not started

Fast-Start Failover: ENABLED

Configuration Status:
WARNING

--没有启动observer.
--适用另外的机器,启动observer.
DGMGRL> start observer
Error: ORA-16556: observer version mismatch

Failed.

--我的client是12c的,版本与数据库不匹配.更换机器继续测试.

DGMGRL> connect sys/btbtms@test
Connected.
DGMGRL> start observer
Observer started


--可以发现并不退出,一直监测....也可以放在后台.
--dgmgrl -logfile /tmp/obsvr.log sys/btbtms@test "start observer" &

DGMGRL> show configuration

Configuration - study

  Protection Mode: MaxAvailability
  Databases:
    test   - Primary database
    testdg - (*) Physical standby database

Fast-Start Failover: ENABLED

Configuration Status:
SUCCESS
-- OK ,现在成功启动.

DGMGRL> enable configuration
Enabled.

--现在先dml一些数据,然后关闭test数据库,注意我的测试发现必须执行shutdown abort才会触发切换,其他正常关闭不会,浪费许多时间.
SYS@test> select * from scott.dept1 where deptno=60;
    DEPTNO DNAME          LOC
---------- -------------- -------------
        60 MMMM           BBBBBB

SYS@test> update scott.dept1 set loc='CCCCCC' where deptno=60;
1 row updated.

SYS@test> commit;
Commit complete.

SYS@test> shutdown abort
ORACLE instance shut down.


--等一段时间看看(30秒缺省时间).....检查发现
[W000 04/22 08:33:35.45] Observer started.

08:37:59.49  Tuesday, April 22, 2014
Initiating Fast-Start Failover to database "testdg"...
Performing failover NOW, please wait...
Failover succeeded, new primary is "testdg"
08:38:07.14  Tuesday, April 22, 2014

--可以发现已经完成了切换.

SYS@testdg> select database_role,open_mode,protection_mode,force_logging,FLASHBACK_ON from v$database;

DATABASE_ROLE    OPEN_MODE            PROTECTION_MODE      FOR FLASHBACK_ON
---------------- -------------------- -------------------- --- ------------------
PRIMARY          READ WRITE           MAXIMUM AVAILABILITY YES YES

DGMGRL> show  configuration

Configuration - study

  Protection Mode: MaxAvailability
  Databases:
    testdg - Primary database
      Warning: ORA-16817: unsynchronized fast-start failover configuration

    test   - (*) Physical standby database (disabled)
      ORA-16661: the standby database needs to be reinstated

Fast-Start Failover: ENABLED

Configuration Status:
WARNING

SYS@testdg> select * from scott.dept1 where deptno=60;
    DEPTNO DNAME          LOC
---------- -------------- -------------
        60 MMMM           CCCCCC

--可以发现dml的信息并没有丢失.启动test数据库.
SYS@test> startup
ORACLE instance started.
Total System Global Area 1603411968 bytes
Fixed Size                  2228784 bytes
Variable Size            1006636496 bytes
Database Buffers          587202560 bytes
Redo Buffers                7344128 bytes
Database mounted.
ORA-16649: possible failover to another database prevents this database from being opened

SYS@test> select database_role,open_mode,protection_mode,force_logging,FLASHBACK_ON from v$database;
DATABASE_ROLE    OPEN_MODE            PROTECTION_MODE      FOR FLASHBACK_ON
---------------- -------------------- -------------------- --- ------------------
PRIMARY          MOUNTED              MAXIMUM AVAILABILITY YES YES

DGMGRL> show  configuration

Configuration - study

  Protection Mode: MaxAvailability
  Databases:
    testdg - Primary database
    test   - (*) Physical standby database

Fast-Start Failover: ENABLED

Configuration Status:
ORA-16610: command "REINSTATE DATABASE test" in progress
DGM-17017: unable to determine configuration status

DGMGRL> REINSTATE DATABASE test
Reinstating database "test", please wait...
Reinstatement of database "test" succeeded
DGMGRL> show  configuration

Configuration - study

  Protection Mode: MaxAvailability
  Databases:
    testdg - Primary database
    test   - (*) Physical standby database

Fast-Start Failover: ENABLED

Configuration Status:
SUCCESS

--测试完成.还原现场.
DGMGRL> switchover to test;
Performing switchover NOW, please wait...
New primary database "test" is opening...
Operation requires shutdown of instance "testdg" on database "testdg"
Shutting down instance "testdg"...
ORACLE instance shut down.
Operation requires startup of instance "testdg" on database "testdg"
Starting instance "testdg"...
ORACLE instance started.
Database mounted.
Database opened.
Switchover succeeded, new primary is "test"

总结:
实际上使用FSFO还是满简单的,不知道在生产系统是否敢用.
我的测试要设置在MaxAvailability模式,LogXptMode='SYNC',按照前面的介绍在MaxPerformance也可以,再做一个测试看看.

目录
相关文章
|
Oracle 网络协议 关系型数据库
|
数据库 Go 测试技术
[20151109]使用dgmgrl管理dataguard(15)
[20151109]使用dgmgrl管理dataguard(15).txt 参考链接: http://blog.itpub.net/267265/viewspace-1142649/ http://blog.
1031 0
|
SQL 监控 Oracle
11g dataguard使用总结
11g的dataguard相比于10g来说,最优越的特性应该算就是active dataguard了,这一点改进在很大意义上促使用户需要把数据库从10g升级到11g,读写分离在这个时候得到了升华,而且在后台会根据需要进行数据的同步,相比于使用10g,想读数据的时候把数据库启动到read only 阶段,但这个时候不接受日志同步数据,如果需要同步数据还需要把数据库再启动到mount阶段,感觉还是比较繁琐的。
1212 0
dataguard dubugs
alter database open read only;alter database open read only*ERROR at line 1:ORA-10456: cannot open standby database; media recovery session may be in...
709 0
|
Oracle 关系型数据库 数据库
[20140422]使用dgmgrl管理dataguard(12)
[20140422]使用dgmgrl管理dataguard(12).txt 参考链接: http://blog.itpub.net/267265/viewspace-1142649/ http://blog.
927 0
|
SQL Oracle 关系型数据库
[20140422]使用dgmgrl管理dataguard(14)
[20140422]使用dgmgrl管理dataguard(14).txt 参考链接: http://blog.itpub.net/267265/viewspace-1142649/ http://blog.
847 0
|
SQL Oracle 关系型数据库
[20140422]使用dgmgrl管理dataguard(13)
[20140422]使用dgmgrl管理dataguard(13).txt 参考链接: http://blog.itpub.net/267265/viewspace-1142649/ http://blog.
980 0
|
测试技术 数据库 关系型数据库
[20140422]使用dgmgrl管理dataguard(11)
[20140422]使用dgmgrl管理dataguard(11).txt 参考链接: http://blog.itpub.net/267265/viewspace-1142649/ http://blog.
897 0
|
数据库
[20140416]使用dgmgrl管理dataguard(3)
[20140416]使用dgmgrl管理dataguard(3).txt 参考链接: http://blog.itpub.net/267265/viewspace-1142649/ http://blog.itpub.net/267265/viewspace-1143027/ 从前面的测试看配置启用dgmgrl还是非常简单的。
855 0