ITPub博客

首页 > 数据库 > Oracle > [20140418]使用dgmgrl管理dataguard(7).txt

[20140418]使用dgmgrl管理dataguard(7).txt

原创 Oracle 作者:lfree 时间:2014-04-20 13:46:46 0 删除 编辑

[20140418]使用dgmgrl管理dataguard(7).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/

-- 我的测试环境:primary的tnsnames别名test,standby主机的tnsnames别名testdg。数据库版本:
-- 前面提高要完成切换最好要配置_DGMGRL.为静态服务。
-- 实际上也可以修改staticConnectidentifier参数来替换,自己做一个测试看看。

1.修改监听文件,删除_DGMGRL.的静态注册。两边都要修改:
--test
SID_LIST_LISTENER =
   (SID_LIST =
    (SID_DESC =
      (SDU=32767)
      (GLOBAL_DBNAME = test.com)
      (ORACLE_HOME = /u01/app/oracle11g/product/11.2.0/db_2)
      (SID_NAME = test)
      )
   )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = hisdg)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle11g

--testdg
SID_LIST_LISTENER =
   (SID_LIST =
    (SID_DESC =
      (SDU=32767)
      (GLOBAL_DBNAME = test.com)
      (ORACLE_HOME = /u01/app/oracle11g/product/11.2.0/db_2)
      (SID_NAME = testdg)
      )
   )


LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = testdb)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle11g

$ lsnrctl reload

2.修改dgmrgl的参数StaticConnectIdentifier:

DGMGRL> show database verbose test StaticConnectIdentifier
  StaticConnectIdentifier = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hisdg)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=test_DGMGRL.com)(INSTANCE_NAME=test)(SERVER=DEDICATED)))'

DGMGRL> show database verbose testdg StaticConnectIdentifier
  StaticConnectIdentifier = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=testdb)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=testdg_DGMGRL.com)(INSTANCE_NAME=testdg)(SERVER=DEDICATED)))'

DGMGRL> edit database test set PROPERTY StaticConnectIdentifier= '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hisdg)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=test.com)(INSTANCE_NAME=test)(SERVER=DEDICATED)))';
Property "staticconnectidentifier" updated

DGMGRL> edit database testdg set PROPERTY StaticConnectIdentifier= '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=testdb)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=test.com)(INSTANCE_NAME=testdg)(SERVER=DEDICATED)))';
Property "staticconnectidentifier" updated

3.测试切换:
DGMGRL> show configuration
Configuration - study
  Protection Mode: MaxPerformance
  Databases:
    test   - Primary database
    testdg - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS

DGMGRL> connect sys/btbtms@testdg
Connected.

DGMGRL> switchover to testdg;
Performing switchover NOW, please wait...
New primary database "testdg" is opening...
Operation requires shutdown of instance "test" on database "test"
Shutting down instance "test"...
ORACLE instance shut down.
Operation requires startup of instance "test" on database "test"
Starting instance "test"...
ORACLE instance started.
Database mounted.
Switchover succeeded, new primary is "testdg"

DGMGRL> show configuration
Configuration - study
  Protection Mode: MaxPerformance
  Databases:
    testdg - Primary database
    test   - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS

--切换完成。

4.修改dgmrgl的参数StaticConnectIdentifier使用tnsnames.ora中的定义,如何呢?
--tnsnames.ora定义如下:
TEST =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.40)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = test.com)
    )
  )

TESTDG =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.101.115)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = test.com)
    )
  )

DGMGRL> show database verbose test StaticConnectIdentifier
  StaticConnectIdentifier = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hisdg)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=test.com)(INSTANCE_NAME=test)(SERVER=DEDICATED)))'
DGMGRL> show database verbose testdg StaticConnectIdentifier
  StaticConnectIdentifier = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=testdb)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=test.com)(INSTANCE_NAME=testdg)(SERVER=DEDICATED)))'

DGMGRL> edit database test set PROPERTY StaticConnectIdentifier= 'test';
Property "staticconnectidentifier" updated
DGMGRL> edit database testdg set PROPERTY StaticConnectIdentifier= 'testdg';
Property "staticconnectidentifier" updated

5.再次测试切换:
DGMGRL> show configuration
Configuration - study
  Protection Mode: MaxPerformance
  Databases:
    testdg - Primary database
    test   - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS

DGMGRL> connect sys/btbtms@test
Connected.

DGMGRL> connect sys/btbtms@test
Connected.
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.
Switchover succeeded, new primary is "test"

DGMGRL> show configuration

Configuration - study

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

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS

--切换正常。

总结:
说明只要staticconnectidentifier配置正确,切换是没有问题的。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/267265/viewspace-1145573/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
熟悉oracle相关技术,擅长sql优化,rman备份与恢复,熟悉linux shell编程。

注册时间:2008-01-03

  • 博文量
    4006
  • 访问量
    7969588