Chinaunix首页 | 论坛 | 博客
  • 博客访问: 245229
  • 博文数量: 50
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 533
  • 用 户 组: 普通用户
  • 注册时间: 2015-07-28 21:56
个人简介

活着,寻找生存。

文章分类

全部博文(50)

文章存档

2017年(1)

2016年(20)

2015年(29)

我的朋友

分类: Oracle

2016-09-19 17:42:44

   最近一直在学习Oracle 12C 数据库,所以进行了一些文档梳理。 这里我主要介绍如何在Oracle 12c far sync active dataguard 架构上配置DG Broker

一:查看数据库版本:

点击(此处)折叠或打开

  1. SQL> col BANNER for a90
  2. SQL> select * from v$version;
  3.    
  4. BANNER CON_ID
  5. ------------------------------------------------------------------------------------------ ----------
  6. Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production 0
  7. PL/SQL Release 12.1.0.2.0 - Production 0
  8. CORE 12.1.0.2.0 Production 0
  9. TNS for Linux: Version 12.1.0.2.0 - Production 0
  10. NLSRTL Version 12.1.0.2.0 - Production 0

二:去除DG redo log 同步参数设置:

点击(此处)折叠或打开

  1. primary:
  2. alter system set log_archive_dest_2='';
  3.    
  4. alter system set log_archive_dest_3='';
  5.    
  6. fay sync:
  7. alter system set log_archive_dest_2='';
  8.     
  9. standby:
  10. alter system set log_archive_dest_2='';
  11. alter system set log_archive_dest_3='';

注:在12cR1以前版本中,配置dg broker是不需要去除。但是在12cR1以上版本中,如果不去除已配置了dg redo log同步参数,那么在创建dg broker的时候会出现如下错误:

点击(此处)折叠或打开

  1. DGMGRL> create configuration dg12c_broker as primary database is dg12cpy connect identifier is xxxx;
  2. Error: ORA-16698: LOG_ARCHIVE_DEST_n parameter set for object to be added
  3. Failed.
  4.  
  5. 错误说明:
  6.  
  7. dg12c@dgpy /home/oracle$ oerr ora 16649
  8. 16649, 0000, "possible failover to another database prevents this database from being opened"
  9. // *Cause: An attempt to open the primary database was made either after
  10. // a failover occurred, or when it was likely to have occurred as
  11. // the result of the primary being isolated from the fast-start
  12. // failover target standby database and from the fast-start failover
  13. // observer.
  14. // *Action: Check if a failover did occur. If fast-start failover is enabled,
  15. // and a failover did not occur, ensure that connectivity exists
  16. // between the primary database and either the observer or the
  17. // target standby database. Then, try opening the database again.

三:修改dg broker初始化参数:
分别在主库,far sync实例和备库上执行:

点击(此处)折叠或打开

  1. SQL> alter system set dg_broker_start=true scope=both;

四:配置dg broker:
 
primary:
 
创建broker配置:

点击(此处)折叠或打开

  1. DGMGRL> create configuration dg12c_broker as primary database is dg12cpy connect identifier is dg12cpy;
  2. Configuration "dg12c_broker" created with primary database "dg12cpy"

添加备用数据库到配置中:

点击(此处)折叠或打开

  1. DGMGRL> add database dg12csd as connect identifier is dg12csd maintained as physical;
  2. Database "dg12csd" added

启动配置:

点击(此处)折叠或打开

  1. DGMGRL> enable configuration
  2. Enabled.

查看配置:

点击(此处)折叠或打开

  1. DGMGRL> show configuration
  2. Configuration - dg12c_broker
  3.   Protection Mode: MaxPerformance
  4.   Members:
  5.   dg12cpy - Primary database
  6.     dg12csd - Physical standby database
  7. Fast-Start Failover: DISABLED
  8. Configuration Status:
  9. SUCCESS (status updated 20 seconds ago)
  10.    
  11. DGMGRL> show database verbose 'dg12csd'
  12. Database - dg12csd
  13.   Role: PHYSICAL STANDBY
  14.   Intended State: APPLY-ON
  15.   Transport Lag: 0 seconds (computed 1 second ago)
  16.   Apply Lag: 0 seconds (computed 1 second ago)
  17.   Average Apply Rate: 20.00 KByte/s
  18.   Active Apply Rate: 1.05 MByte/s
  19.   Maximum Apply Rate: 3.18 MByte/s
  20.   Real Time Query: ON
  21.   Instance(s):
  22.     dg12c
  23.   Properties:
  24.     DGConnectIdentifier = 'dg12csd'
  25.     ObserverConnectIdentifier = ''
  26.     LogXptMode = 'ASYNC'
  27.     RedoRoutes = ''
  28.     DelayMins = '0'
  29.     Binding = 'optional'
  30.     MaxFailure = '0'
  31.     MaxConnections = '1'
  32.     ReopenSecs = '300'
  33.     NetTimeout = '30'
  34.     RedoCompression = 'DISABLE'
  35.     LogShipping = 'ON'
  36.     PreferredApplyInstance = ''
  37.     ApplyInstanceTimeout = '0'
  38.     ApplyLagThreshold = '0'
  39.     TransportLagThreshold = '0'
  40.     TransportDisconnectedThreshold = '30'
  41.     ApplyParallel = 'AUTO'
  42.     StandbyFileManagement = 'AUTO'
  43.     ArchiveLagTarget = '0'
  44.     LogArchiveMaxProcesses = '4'
  45.     LogArchiveMinSucceedDest = '1'
  46.     DbFileNameConvert = ''
  47.     LogFileNameConvert = ''
  48.     FastStartFailoverTarget = ''
  49.     InconsistentProperties = '(monitor)'
  50.     InconsistentLogXptProps = '(monitor)'
  51.     SendQEntries = '(monitor)'
  52.     LogXptStatus = '(monitor)'
  53.     RecvQEntries = '(monitor)'
  54.     StaticConnectIdentifier = '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dgsd)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=dg12csd_DGMGRL)(INSTANCE_NAME=dg12c)(SERVER=DEDICATED)))'
  55.     StandbyArchiveLocation = '/opt/oracle/oradata/dg12c/archive'
  56.     AlternateLocation = ''
  57.     LogArchiveTrace = '0'
  58.     LogArchiveFormat = 'arch_%r_%t_%s.dbf'
  59.     TopWaitEvents = '(monitor)'
  60. Database Status:
  61. SUCCESS

启动standby 配置:

点击(此处)折叠或打开

  1. DGMGRL> ENABLE DATABASE 'dg12csd'
  2. Enabled.
  3.    
  4. DGMGRL> show database 'dg12csd'
  5. Database - dg12csd
  6.   Role: PHYSICAL STANDBY
  7.   Intended State: APPLY-ON
  8.   Transport Lag: 0 seconds (computed 0 seconds ago)
  9.   Apply Lag: 0 seconds (computed 0 seconds ago)
  10.   Average Apply Rate: 20.00 KByte/s
  11.   Real Time Query: ON
  12.   Instance(s):
  13.     dg12c
  14. Database Status:
  15. SUCCESS

添加far sync 配置:

点击(此处)折叠或打开

  1. DGMGRL> ENABLE FAR_SYNC dg12cfy;
  2. Enabled.
  3.  
  4. DGMGRL> show configuration;
  5. Configuration - dg12c_broker
  6.   Protection Mode: MaxPerformance
  7.   Members:
  8.   dg12cpy - Primary database
  9.     dg12csd - Physical standby database
  10.     dg12cfy - Far sync instance
  11. Fast-Start Failover: DISABLED
  12. Configuration Status:
  13. SUCCESS (status updated 7 seconds ago)

在 Broker 中设置 Redo 传输:

点击(此处)折叠或打开

  1. DGMGRL> EDIT DATABASE 'dg12cpy' SET PROPERTY 'RedoRoutes'='(LOCAL : dg12cfy SYNC)';
  2. Property "RedoRoutes" updated
  3.    
  4. DGMGRL> EDIT FAR_SYNC 'dg12cfy' SET PROPERTY 'RedoRoutes'='(dg12cpy : dg12csd ASYNC )';
  5. Property "RedoRoutes" updated
查看配置:

点击(此处)折叠或打开

  1. DGMGRL> SHOW CONFIGURATION;
  2. Configuration - dg12c_broker
  3.   Protection Mode: MaxPerformance
  4.   Members:
  5.   dg12cpy - Primary database
  6.     dg12cfy - Far sync instance
  7.       dg12csd - Physical standby database
  8. Fast-Start Failover: DISABLED
  9. Configuration Status:
  10. SUCCESS (status updated 23 seconds ago)

修改高可用模式:

点击(此处)折叠或打开

  1. DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MaxAvailability;
  2. Succeeded.
  3.    
  4. DGMGRL> SHOW CONFIGURATION;
  5. Configuration - dg12c_broker
  6.   Protection Mode: MaxAvailability
  7.   Members:
  8.   dg12cpy - Primary database
  9.     dg12cfy - Far sync instance
  10.       dg12csd - Physical standby database
  11. Fast-Start Failover: DISABLED
  12. Configuration Status:
  13. SUCCESS (status updated 30 seconds ago)
  14.     
  15. DGMGRL> show configuration when primary is 'dg12cpy';
  16. Configuration when dg12cpy is primary - dg12c_broker
  17.   Members:
  18.   dg12cpy - Primary database
  19.     dg12cfy - Far sync instance
  20.       dg12csd - Physical standby database

五:验证同步:

PRIMARY:

点击(此处)折叠或打开

  1. SQL> alter session set container=pdb1;
  2. Session altered.
  3.    
  4. SQL> create table t2 as select * from t1 where 1=0;
  5. Table created.
  6.    
  7. SQL> insert into t2(id,name) values (1,'dfrt');
  8. 1 row created.
  9.    
  10. SQL> commit;
  11. Commit complete.
  12.    
  13. SQL> select * from t2;
  14.     ID NAME
  15. ---------- ------------------------------------------------------------
  16.      1 dfrt

STANDBY:

点击(此处)折叠或打开

  1. SQL> alter session set container=pdb1;
  2. Session altered.
  3.    
  4. SQL> select * from t2;
  5. no rows selected
  6.    
  7. SQL> select * from t2;
  8.     ID NAME
  9. ---------- ------------------------------------------------------------
  10.      1 dfrt








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