当前位置: 首页 > DG > 正文

11GR2 datagruad 环境搭建BORKER

公司所有的DG环境都用到了BROKER这个东西,今天我也在VM来测试一下这个玩意。不过听说在生产中用得比较少,不知道我们公司为什么全部上的这个东西。
 
测试环境:OS REDHAT 5.6 X86_64 ,DB 11.2.0.2
DG的测试参考之前写的BLOG:
11GR2 搭建活动的物理DG/DATAGRUAD (READ ONLY模式)
 
1,修改dg_broker_config_file参数。如果是在RAC环境中,这个把这个文件把到共享的存储上面,如果有ASM可以放到ASM中。
主库:
  1. #这里跟官方给的名字有一点不一样htz1.dat这里官方要求是drc<db_uniqun_name>.dat,但是我这里也没有报错。
  2. SQL> alter system set dg_broker_config_file1='/u01/app/oracle/oradata/htz/htz1.dat';
  3.  
  4. System altered.
  5.  
  6. SQL> 
  7. SQL> alter system set dg_broker_config_file2='/u01/app/oracle/oradata/htz/htz2.dat';
  8.  
  9. System altered.
备库:
  1. SQL> alter system set dg_broker_config_file1='/u01/app/oracle/oradata/htz/htz1.dat';
  2.  
  3. System altered.
  4.  
  5. SQL> alter system set dg_broker_config_file2='/u01/app/oracle/oradata/htz/htz2.dat';
  6.  
  7. System altered.
启用BROKER:
在两个数据库上面都执行:
 
  1. SQL> alter system set dg_broker_start=true scope=both;
  2.  
  3. System altered.
 
在其中任意一台做下面的操作就可以了,另它安装了client的客户端也是可以的.
 
  1. [oracle@11g admin]$ dgmgrl
  2. DGMGRL for Linux: Version 11.2.0.2.0 - 64bit Production
  3.  
  4. Copyright (c) 2000, 2009, Oracle. All rights reserved.
  5.  
  6. Welcome to DGMGRL, type "help" for information.
  7. #连接数据库
  8. DGMGRL> connect sys/oracle@htz
  9. Connected.
  10. #help是帮忙命令,这点做得很好,不像sqlplus中。
  11. DGMGRL> help create 
  12.  
  13. Creates a broker configuration
  14.  
  15. Syntax:
  16.  
  17.   CREATE CONFIGURATION <configuration name> AS 
  18.     PRIMARY DATABASE IS <database name>
  19.     CONNECT IDENTIFIER IS <connect identifier>;
  20. #创建一个配置文件,这里一定要记得是连接到当前的主数据库
  21. DGMGRL> create configuration htz as primary database is htz connect identifier is htz;
  22. Configuration "htz" created with primary database "htz" 
  23. #启用配置文件
  24. DGMGRL> enable configuration;
  25. Enabled.
  26. #增加备库到配置文件中
  27. DGMGRL> help add 
  28.  
  29. Adds a standby database to the broker configuration
  30.  
  31. Syntax:
  32.  
  33.   ADD DATABASE <database name>
  34.     [AS CONNECT IDENTIFIER IS <connect identifier>]
  35.     [MAINTAINED AS {PHYSICAL|LOGICAL}];
  36.  
  37. DGMGRL> add database htzb as connect identifier is htzb;
  38. Database "htzb" added
  39. #启用备库
  40. DGMGRL> enable database htzb;
  41. Enabled.
  42. #查看配置文件
  43. DGMGRL> show configuration
  44.  
  45. Configuration - htz
  46.  
  47.   Protection Mode: MaxAvailability
  48.   Databases:
  49.     htz  - Primary database 
  50.     htzb - Physical standby database 
  51.  
  52. Fast-Start Failover: DISABLED
  53.  
  54. Configuration Status:
  55. SUCCESS
  56. #查看某个数据库的配置消息,其中很多参数我们都可以在sqlplus修改的。
  57. DGMGRL> show database verbose htz;
  58.  
  59. Database - htz
  60.  
  61.   Role:            PRIMARY 
  62.   Intended State:  TRANSPORT-ON 
  63.   Instance(s):
  64.     htz
  65.  
  66.   Properties:
  67.     DGConnectIdentifier             = 'htz' 
  68.     ObserverConnectIdentifier       = '' 
  69.     LogXptMode                      = 'SYNC' 
  70.     DelayMins                       = '0' 
  71.     Binding                         = 'optional' 
  72.     MaxFailure                      = '0' 
  73.     MaxConnections                  = '1' 
  74.     ReopenSecs                      = '300' 
  75.     NetTimeout                      = '30' 
  76.     RedoCompression                 = 'DISABLE' 
  77.     LogShipping                     = 'ON' 
  78.     PreferredApplyInstance          = '' 
  79.     ApplyInstanceTimeout            = '0' 
  80.     ApplyParallel                   = 'AUTO' 
  81.     StandbyFileManagement           = 'MANUAL' 
  82.     ArchiveLagTarget                = '0' 
  83.     LogArchiveMaxProcesses          = '4' 
  84.     LogArchiveMinSucceedDest        = '1' 
  85.     DbFileNameConvert               = '/u01/app/oracle/oradata/htz/, /u01/app/oracle/oradata/htz/' 
  86.     LogFileNameConvert              = '/u01/app/oracle/oradata/htz/, /u01/app/oracle/oradata/htz/' 
  87.     FastStartFailoverTarget         = '' 
  88.     InconsistentProperties          = '(monitor)' 
  89.     InconsistentLogXptProps         = '(monitor)' 
  90.     SendQEntries                    = '(monitor)' 
  91.     LogXptStatus                    = '(monitor)' 
  92.     RecvQEntries                    = '(monitor)' 
  93.     SidName                         = 'htz' 
  94. #这里要注意了。broker里面的连接的service_name是<db_unique_name>_DGMGRL,因为我们
  95. #静态监听中的GLOBAL_NAME是DB_UNIQUE_NAME,所以这里我们要修改
    StaticConnectIdentifier #不然在切换的时候会报错的。
  96.     StaticConnectIdentifier         = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=11g)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=HTZ_DGMGRL)(INSTANCE_NAME=htz)(SERVER=DEDICATED)))' 
  97.     StandbyArchiveLocation          = '/u01/app/oracle/arch/htz/' 
  98.     AlternateLocation               = '' 
  99.     LogArchiveTrace                 = '0' 
  100.     LogArchiveFormat                = '%t_%s_%r.dbf' 
  101.     TopWaitEvents                   = '(monitor)' 
  102.  
  103. Database Status:
  104. SUCCESS
  105.  
  106. DGMGRL> show database verbose htzb;
  107.  
  108. Database - htzb
  109.  
  110.   Role:            PHYSICAL STANDBY
  111.   Intended State:  APPLY-ON 
  112.   Transport Lag:   0 seconds
  113.   Apply Lag:       0 seconds
  114.   Real Time Query: ON 
  115.   Instance(s):
  116.     htz
  117.  
  118.   Properties:
  119.     DGConnectIdentifier             = 'htzb' 
  120.     ObserverConnectIdentifier       = '' 
  121.     LogXptMode                      = 'SYNC' 
  122.     DelayMins                       = '0' 
  123.     Binding                         = 'OPTIONAL' 
  124.     MaxFailure                      = '0' 
  125.     MaxConnections                  = '1' 
  126.     ReopenSecs                      = '300' 
  127.     NetTimeout                      = '30' 
  128.     RedoCompression                 = 'DISABLE' 
  129.     LogShipping                     = 'ON' 
  130.     PreferredApplyInstance          = '' 
  131.     ApplyInstanceTimeout            = '0' 
  132.     ApplyParallel                   = 'AUTO' 
  133.     StandbyFileManagement           = 'MANUAL' 
  134.     ArchiveLagTarget                = '0' 
  135.     LogArchiveMaxProcesses          = '4' 
  136.     LogArchiveMinSucceedDest        = '1' 
  137.     DbFileNameConvert               = '/u01/app/oracle/oradata/htz/, /u01/app/oracle/oradata/htz/' 
  138.     LogFileNameConvert              = '/u01/app/oracle/oradata/htz/, /u01/app/oracle/oradata/htz/' 
  139.     FastStartFailoverTarget         = '' 
  140.     InconsistentProperties          = '(monitor)' 
  141.     InconsistentLogXptProps         = '(monitor)' 
  142.     SendQEntries                    = '(monitor)' 
  143.     LogXptStatus                    = '(monitor)' 
  144.     RecvQEntries                    = '(monitor)' 
  145.     SidName                         = 'htz' 
  146.     StaticConnectIdentifier         = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=11gdg)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=HTZB_DGMGRL)(INSTANCE_NAME=htz)(SERVER=DEDICATED)))' 
  147.     StandbyArchiveLocation          = '/u01/app/oracle/arch/htz/' 
  148.     AlternateLocation               = '' 
  149.     LogArchiveTrace                 = '0' 
  150.     LogArchiveFormat                = '%t_%s_%r.dbf' 
  151.     TopWaitEvents                   = '(monitor)' 
  152.  
  153. Database Status:
  154. SUCCESS
修改StaticConnectIdentifier参数,记得两个数据库都要修改。
  1. DGMGRL>    edit database htz set property  StaticConnectIdentifier    = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.100.30)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=htz)(INSTANCE_NAME=htz)(SERVER=DEDICATED)))';
  2. Property "staticconnectidentifier" updated
  3. DGMGRL>       edit database htzb set property  StaticConnectIdentifier    = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.100.31)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=htzb)(INSTANCE_NAME=htz)(SERVER=DEDICATED)))';
  4. Property "staticconnectidentifier" updated

开始切换:

  1. DGMGRL> show configuration
  2.  
  3. Configuration - htz
  4.  
  5.   Protection Mode: MaxAvailability
  6.   Databases:
  7. #注意这里hta是主数据库
  8.     htz  - Primary database
  9.     htzb - Physical standby database
  10.  
  11. Fast-Start Failover: DISABLED
  12.  
  13. Configuration Status:
  14. SUCCESS
  15. #开始切换
  16. DGMGRL> switchover to htzb;
  17. Performing switchover NOW, please wait...
  18. New primary database "htzb" is opening...
  19. Operation requires shutdown of instance "htz" on database "htz"
  20. Shutting down instance "htz"...
  21. ORACLE instance shut down.
  22. Operation requires startup of instance "htz" on database "htz"
  23. Starting instance "htz"...
  24. ORACLE instance started.
  25. Database mounted.
  26. Database opened.
  27. Switchover succeeded, new primary is "htzb"
  28. #查看状态
  29. DGMGRL> show configuration;
  30.  
  31. Configuration - htz
  32.  
  33.   Protection Mode: MaxAvailability
  34.   Databases:
  35. #htzb已经切换成主数据库了,切换成功
  36.     htzb - Primary database
  37.     htz  - Physical standby database
  38.  
  39. Fast-Start Failover: DISABLED
  40.  
  41. Configuration Status:
  42. SUCCESS

本文固定链接: http://www.htz.pw/2014/06/18/11gr2-datagruad-%e7%8e%af%e5%a2%83%e6%90%ad%e5%bb%baborker-2.html | 认真就输

该日志由 huangtingzhong 于2014年06月18日发表在 DG 分类下, 你可以发表评论,并在保留原文地址及作者的情况下引用到你的网站或博客。
原创文章转载请注明: 11GR2 datagruad 环境搭建BORKER | 认真就输
关键字: , ,