https://community.oracle.com/docs/DOC-1007327

本文主要包括以下内容:

1.  配置dg broker,需要完成以下几个工作:

  • 在主备库配置静态监听注册,注册的服务名为db_unique_name_DGMGRL;
  • 在主备库修改tnsnames.ora文件,配置别名;
  • 主备库都开启dg_broker_start参数;
  • 在主库注册broker;
  • 在主库添加备库的broker并开启。

2. Data Guard switchover;

3.   Data Guard failover;

4.   Snapshot Standby。

环境:

  主库:ora12c       数据库:db12g   db_unique_name:db12g

  备库:ora12c-dg  数据库:db12g   db_unique_name:db12g_s

配置dg broker:

  1. 主库配置静态监听:

[oracle@ora12c admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/12.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools. LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ora12c)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
) SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = db12g_dgmgrl)
(ORACLE_HOME = /u01/app/oracle/product/12.2.0/db_1)
(SID_NAME = db12g)
)
)

    重新加载监听:

[oracle@ora12c admin]$ lsnrctl reload

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 23-MAY-2017 19:42:33

Copyright (c) 1991, 2016, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ora12c)(PORT=1521)))
The command completed successfully

    查看监听

[oracle@ora12c admin]$ lsnrctl status

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 23-MAY-2017 20:27:43

Copyright (c) 1991, 2016, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ora12c)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date 23-MAY-2017 10:12:47
Uptime 0 days 10 hr. 14 min. 56 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/12.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/ora12c/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ora12c)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=ora12c)(PORT=5500))(Security=(my_wallet_directory=/u01/app/oracle/admin/db12g/xdb_wallet))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "4d852a2714024610e0537838a8c07c53" has 1 instance(s).
Instance "db12g", status READY, has 1 handler(s) for this service...
Service "db12g" has 1 instance(s).
Instance "db12g", status READY, has 1 handler(s) for this service...
Service "db12gXDB" has 1 instance(s).
Instance "db12g", status READY, has 1 handler(s) for this service...
Service "db12g_CFG" has 1 instance(s).
Instance "db12g", status READY, has 1 handler(s) for this service...
Service "db12g_DGB" has 1 instance(s).
Instance "db12g", status READY, has 1 handler(s) for this service...
Service "db12g_dgmgrl" has 1 instance(s).
Instance "db12g", status UNKNOWN, has 1 handler(s) for this service...
Service "pdb01" has 1 instance(s).
Instance "db12g", status READY, has 1 handler(s) for this service...
The command completed successfully

  2. 配置备库静态:

[oracle@ora12c-dg admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/12.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools. LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ora12c-dg)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
) SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = db12g_s_dgmgrl)
(ORACLE_HOME = /u01/app/oracle/product/12.2.0/db_1)
(SID_NAME = db12g)
)
)

    重建加载,与主库相同 

  3. 配置主库tnsnames.ora:

[oracle@ora12c admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools. LISTENER_DB12G =
(ADDRESS = (PROTOCOL = TCP)(HOST = ora12c)(PORT = 1521)) DB12G =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ora12c)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = db12g)
)
) DB12G_S =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ora12c-dg)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = db12g)
)
)

  4. 备库配置tnsnames.ora:

[oracle@ora12c-dg admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools. LISTENER_DB12G =
(ADDRESS = (PROTOCOL = TCP)(HOST = ora12c-dg)(PORT = 1521)) DB12G =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ora12c)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = db12g)
)
) DB12G_S =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ora12c-dg)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = db12g)
)
)

  5. 在主备库同时开启dg_broker_start参数:

[oracle@ora12c admin]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Tue May 23 15:35:20 2017

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production SQL> alter system set dg_broker_start=true scope=both; System altered.

  6. 在主节点,创建配置及注册broker:

[oracle@ora12c admin]$ dgmgrl sys/oracle@db12g
DGMGRL for Linux: Release 12.2.0.1.0 - Production on Tue May 23 15:37:02 2017 Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved. Welcome to DGMGRL, type "help" for information.
Connected to "db12g"
Connected as SYSDBA.
DGMGRL> create configuration my_dg_config as primary database is db12g connect identifier is db12g;
Configuration "my_dg_config" created with primary database "db12g"
DGMGRL>

  7. 在配置中添加备库:

DGMGRL> add database db12g_s as connect identifier is db12g_s maintained as physical;
Database "db12g_s" added
DGMGRL>

  8. enable 配置:

DGMGRL> enable configuration
Enabled.
DGMGRL>

  9.  通过broker查看配置情况及数据库情况:

DGMGRL> show configuration

Configuration - my_dg_config Protection Mode: MaxPerformance
Members:
db12g - Primary database
db12g_s - Physical standby database Fast-Start Failover: DISABLED Configuration Status:
SUCCESS (status updated 34 seconds ago)
DGMGRL> SHOW DATABASE db12g;

Database - db12g

  Role:               PRIMARY
Intended State: TRANSPORT-ON
Instance(s):
cdb1 Database Status:
SUCCESS
DGMGRL> SHOW DATABASE db12g_s;

Database - db12g_s

  Role:               PHYSICAL STANDBY
Intended State: APPLY-ON
Transport Lag: 0 seconds (computed 1 second ago)
Apply Lag: 0 seconds (computed 1 second ago)
Average Apply Rate: 11.00 KByte/s
Real Time Query: OFF
Instance(s):
db12g Database Status:
SUCCESS

  10. switchover演练,这里的切换无数据丢失,连接到主库,切换到备库:

[oracle@ora12c admin]$ dgmgrl sys/oracle@db12g
DGMGRL for Linux: Release 12.2.0.1.0 - Production on Tue May 23 16:47:58 2017 Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved. Welcome to DGMGRL, type "help" for information.
Connected to "db12g"
Connected as SYSDBA. DGMGRL> switchover to db12g_s
Performing switchover NOW, please wait...
Operation requires a connection to database "db12g_s"
Connecting ...
Connected to "db12g_s"
Connected as SYSDBA.
New primary database "db12g_s" is opening...
Operation requires start up of instance "db12g" on database "db12g"
Starting instance "db12g"...
ORACLE instance started.
Database mounted.
Database opened.
Connected to "db12g"
Switchover succeeded, new primary is "db12g_s" SQL> select database_role from v$database; DATABASE_ROLE
----------------
PHYSICAL STANDBY SQL> select process,status,sequence# from v$managed_standby; PROCESS   STATUS        SEQUENCE#
--------- ------------ ----------
ARCH      CONNECTED             0
ARCH      CONNECTED             0
ARCH      CLOSING               1
ARCH      CLOSING               2
ARCH      CONNECTED             0
ARCH      CONNECTED             0
ARCH      CONNECTED             0
ARCH      CONNECTED             0
DGRD      ALLOCATED             0
DGRD      ALLOCATED             0
RFS       IDLE                  0 PROCESS   STATUS        SEQUENCE#
--------- ------------ ----------
MRP0      APPLYING_LOG          3
RFS       IDLE                  0
RFS       IDLE                  3 14 rows selected.

  11. failover演练,如果主库发生故障,无法连接到主库,可以用下面命令进行切换。连接到备库,并切换到备库:

[oracle@ora12c admin]$ dgmgrl sys/oracle@db12g_s
DGMGRL for Linux: Release 12.2.0.1.0 - Production on Tue May 23 17:48:32 2017 Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved. Welcome to DGMGRL, type "help" for information.
Connected to "db12g_s"
Connected as SYSDBA.
DGMGRL> failover to db12g_s
Performing failover NOW, please wait...
Failover succeeded, new primary is "db12g_s"
DGMGRL>

  12. 当源主库开启了闪回功能,这时将源主库修复之后,可以不用重新搭建DG,而是用一命令,可将源主库变为备库。但是如果源主库未开启闪回,将需要重建:

DGMGRL> reinstate database db12g
Reinstating database "db12g", please wait...
Operation requires shut down of instance "db12g" on database "db12g"
Shutting down instance "db12g"...
Connected to "db12g"
ORACLE instance shut down.
Operation requires start up of instance "db12g" on database "db12g"
Starting instance "db12g"...
ORACLE instance started.
Database mounted.
Connected to "db12g"
Continuing to reinstate database "db12g" ...
Reinstatement of database "db12g" succeeded
DGMGRL>

  13. 开启快照备库,这是11g的新功能,开启之后备库可以进行读写,但是当重新更改会备库的模式之后,所有的更改都是丢失,备库将继续同步主库的数据:

[oracle@ora12c admin]$ dgmgrl sys/oracle@db12g
DGMGRL for Linux: Release 12.2.0.1.0 - Production on Tue May 23 17:44:43 2017 Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved. Welcome to DGMGRL, type "help" for information.
Connected to "db12g"
Connected as SYSDBA.
DGMGRL> CONVERT DATABASE db12g_s TO SNAPSHOT STANDBY;
Converting database "db12g_s" to a Snapshot Standby database, please wait...
Database "db12g_s" converted successfully
DGMGRL>

  14. 当结束快照数据之后,可以将其切换到物理备库:

[oracle@ora12c admin]$ dgmgrl sys/oracle@db12g
DGMGRL for Linux: Release 12.2.0.1.0 - Production on Tue May 23 17:45:55 2017 Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved. Welcome to DGMGRL, type "help" for information.
Connected to "db12g"
Connected as SYSDBA.
DGMGRL> CONVERT DATABASE db12g_s TO PHYSICAL STANDBY;
Converting database "db12g_s" to a Physical Standby database, please wait...
Operation requires shut down of instance "db12g" on database "db12g_s"
Shutting down instance "db12g"...
Database closed.
Database dismounted.
ORACLE instance shut down.
Operation requires start up of instance "db12g" on database "db12g_s"
Starting instance "db12g"...
ORACLE instance started.
Database mounted.
Continuing to convert database "db12g_s" ...
Database "db12g_s" converted successfully
DGMGRL>

  此时,物理备库再次同步主库数据。

遇到的坑:

1. 配置完broker之后,查看配置的时候报错:

DGMGRL> show configuraton
show configuraton
^
Syntax error before or at "configuraton"
DGMGRL> show configuration Configuration - my_dg_config Protection Mode: MaxPerformance
Members:
db12g - Primary database
db12g_s - Physical standby database
Error: ORA-16664: unable to receive the result from a member Fast-Start Failover: DISABLED Configuration Status:
ERROR (status updated 59 seconds ago)

  经过检查,是由于备库的tnsnames.ora文件中的配置错误导致无法连接到主库,其次查看备库的配置,发现很多警告,重新进行修改并重启数据库之后OK:

DGMGRL> show database verbose db12g_s

Database - db12g_s

  Role:               PHYSICAL STANDBY
Intended State: APPLY-ON
Transport Lag: 0 seconds (computed 0 seconds ago)
Apply Lag: 0 seconds (computed 0 seconds ago)
Average Apply Rate: 1.00 KByte/s
Active Apply Rate: 183.00 KByte/s
Maximum Apply Rate: 183.00 KByte/s
Real Time Query: ON
Instance(s):
db12g
Warning: ORA-16714: the value of property LogArchiveTrace is inconsistent with the member setting
Warning: ORA-16675: database instance restart required for property value modification to take effect
Warning: ORA-16714: the value of property LogArchiveFormat is inconsistent with the member setting Properties:
DGConnectIdentifier = 'db12g_s'
ObserverConnectIdentifier = ''
LogXptMode = 'ASYNC'
RedoRoutes = ''
DelayMins = ''
Binding = 'optional'
MaxFailure = ''
MaxConnections = ''
ReopenSecs = ''
NetTimeout = ''
RedoCompression = 'DISABLE'
LogShipping = 'ON'
PreferredApplyInstance = ''
ApplyInstanceTimeout = ''
ApplyLagThreshold = ''
TransportLagThreshold = ''
TransportDisconnectedThreshold = ''
ApplyParallel = 'AUTO'
ApplyInstances = ''
StandbyFileManagement = 'AUTO'
ArchiveLagTarget = ''
LogArchiveMaxProcesses = ''
LogArchiveMinSucceedDest = ''
DataGuardSyncLatency = ''
DbFileNameConvert = '/u01/app/oradata, /u01/app/oracle/oradata'
LogFileNameConvert = '/u01/app/oradata, /u01/app/oracle/oradata'
FastStartFailoverTarget = ''
InconsistentProperties = '(monitor)'
InconsistentLogXptProps = '(monitor)'
SendQEntries = '(monitor)'
LogXptStatus = '(monitor)'
RecvQEntries = '(monitor)'
PreferredObserverHosts = ''
StaticConnectIdentifier = '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ora12c-dg)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=db12g_s_DGMGRL)(INSTANCE_NAME=db12g)(SERVER=DEDICATED)))'
StandbyArchiveLocation = '/u01/app/oracle/archivelog'
AlternateLocation = ''
LogArchiveTrace = ''
LogArchiveFormat = '%t_%s_%r.arc'
TopWaitEvents = '(monitor)' Log file locations:
Alert log : /u01/app/oracle/diag/rdbms/db12g_s/db12g/trace/alert_db12g.log
Data Guard Broker log : /u01/app/oracle/diag/rdbms/db12g_s/db12g/trace/drcdb12g.log Database Status:
WARNING DGMGRL> edit database db12g_s set property LogArchiveTrace='';
Property "logarchivetrace" updated DGMGRL> edit database db12g_s set property LogArchiveFormat='%t_%s_%r.arc';
Warning: ORA-16675: database instance restart required for property value modification to take effect Property "logarchiveformat" updated
DGMGRL> quit
[oracle@ora12c-dg ~]$
[oracle@ora12c-dg ~]$
[oracle@ora12c-dg ~]$
[oracle@ora12c-dg ~]$ sqlplus / as sysdba SQL*Plus: Release 12.2.0.1.0 Production on Tue May 23 17:18:49 2017 Copyright (c) 1982, 2016, Oracle. All rights reserved. Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started. Total System Global Area 1207959552 bytes
Fixed Size 8792152 bytes
Variable Size 436209576 bytes
Database Buffers 754974720 bytes
Redo Buffers 7983104 bytes
Database mounted.
Database opened.

2. 配置归档参数时报错,无法配置,经过检查发现是log_archive_config参数配置错误,修改之后正常:

SQL> alter system set log_archive_dest_2='service=db12g_s LGWR ASYNC=20480 VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=DB12G_S OPTIONAL REOPEN=15 MAX_FAILURE=10 NET_TIMEOUT=30' scope=both;
alter system set log_archive_dest_2='service=db12g_s LGWR ASYNC=20480 VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=DB12G_S OPTIONAL REOPEN=15 MAX_FAILURE=10 NET_TIMEOUT=30' scope=both
*
ERROR at line 1:
ORA-02097: parameter cannot be modified because specified value is invalid
ORA-16053: DB_UNIQUE_NAME DB12G_S is not in the Data Guard Configuration SQL> show parameter dg_config
SQL> alter system set log_archive_config='dg_config=(db12g,db12g_s)'; System altered. SQL> alter system set log_archive_dest_2='service=db12g_s LGWR ASYNC=20480 VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=DB12G_S OPTIONAL REOPEN=15 MAX_FAILURE=10 NET_TIMEOUT=30' scope=both; System altered.

oracle data guard配置dg_broker的更多相关文章

  1. (转)Oracle Data Guard配置

    data guard配置的条件1.在主库和从库的所有机器上必须安装同一个版本的Oracle企业版.2.主库必须运行在归档模式下.3.主库和从库的操作系统必须一样(允许版本不同),从库可以使用与主库不同 ...

  2. Oracle Data Guard配置

    Oracle Data Guard 的配置在网上有很多资料,但是没有一个完整的,配置下来多少有些问题.在踩了各种坑之后,自己终于配置成功,就想把这过程记录下来. 1   测试环境 主数据库:windo ...

  3. Oracle Data Guard的配置

    概述 Oracle Data Guard 是针对企业数据库的最有效和最全面的数据可用性.数据保护和灾难恢复解决方案.它提供管理.监视和自动化软件基础架构来创建和维护一个或多个同步备用数据库,从而保护数 ...

  4. Oracle Data Guard 重要配置参数

    Oracle Data Guard主要是通过为生产数据库提供一个或多个备用数据库(是产生数据库的一个副本),以保证在主库不可用或异常时数据不丢失并通过备用数据库继续提供服务.对于Oracle DG的配 ...

  5. Oracle Data Guard

    DG 是 Oracle Data Guard 的简称.也就是Oracle11g的 数据卫士. 由于在工作中 Oracle和 SQL SERVER2008 同时都需要维护管理.给我的感觉这里的 DG 其 ...

  6. (转)Oracle Data Guard学习

    一.Data Guard提供如下三种数据保护模式: 1)最高保护模式(Maximum Protection) 这里的”最高保护“是指最大限度的保护数据不丢失,也就是至少有一个standby和prima ...

  7. Oracle data guard学习

    Oracle data guard学习:三思笔记 Data guard 1data guard结构: data guard是一个集合,由一个primary数据库(生产数据库)和一个或多个standby ...

  8. Oracle data guard 10g 搭建

    Oracle data guard 10g 搭建 1系统常规参数检查 硬盘 [root@localhost ~]# df -h 内核 [root@localhost ~]# uname -a [roo ...

  9. 一步一步搭建 Oracle Data Guard

    前言 为什么要写前言,因为我要吐槽一下.作为一个Java后端,搭建Oracle Data Guard真的是一件,嗯,既不专业也不擅长的事情,然而,为什么还是要我来弄? 因为DBA出差了,我们这边急着要 ...

随机推荐

  1. java phoenix 连接hbase

    <dependency> <groupId>org.apache.phoenix</groupId> <artifactId>phoenix-core& ...

  2. 记录一次对接XX支付SDK过程中报错问题

    我们支付平台以前我不做对接上游的,偶然间替别人做"对接了XX支付的相关接口的工作".在工作过程中发现SDK和对外提供服务过程中很容易出问题.在此做个记录,为了以后相关工作中作为自己 ...

  3. Cocos2d-x 脚本语言Lua基本语法

    Cocos2d-x 脚本语言Lua基本语法 前面一篇博客对Lua这门小巧的语言进行了简单的介绍.本篇博客来给大家略微讲一下Lua的语法.不会长篇累牍得把Lua的全部语法都讲一遍,这里通过下面几点来讲L ...

  4. flex新的心得

    主要是对于flex: 与width: 的心得,先看代码. <head> <meta charset="UTF-8"> <meta name=" ...

  5. 解决mysql连接异常—-com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception

    DBCP连接池连接MySql数据库时,一奇葩数据库设置为30秒内无请求自动断开.超时后链接无法关闭,活动链接数飞奔,最后挂掉. 网上找了一圈,一般是这三种,方法一pass,方法二测试无效可能设置错了吧 ...

  6. 《深入浅出WPF》笔记——资源篇

    原文:<深入浅出WPF>笔记--资源篇 前面的记录有的地方已经用到了资源,本文就来详细的记录一下WPF中的资源.我们平时的“资源”一词是指“资财之源”,是创造人类社会财富的源泉.在计算机程 ...

  7. CUDA中的常量内存__constant__

    GPU包含数百个数学计算单元,具有强大的处理运算能力,可以强大到计算速率高于输入数据的速率,即充分利用带宽,满负荷向GPU传输数据还不够它计算的.CUDA C除全局内存和共享内存外,还支持常量内存,常 ...

  8. android点击屏幕隐藏小键盘

    原文:android点击屏幕隐藏小键盘 fragment 下隐藏点击空白处隐藏小键盘   view.setOnTouchListener(new OnTouchListener() { @Overri ...

  9. 王立平--GC

    Gabage Collection:垃圾回收 是.net中对内存管理的一种功能. 垃圾回收器跟踪并回收托管内存中分配的对象,定期运行垃圾回收以回收分配给没有有效引用的对象的内存. 当使用可用内存不能满 ...

  10. 2-1 Consul简介

    Consul英文意思是大使馆. Consul主要干3件事情: 1.提供服务到ip地址的注册. 2.提供服务到ip地址列表的查询. 3.对提供服务方的健康检查. Consul官网 :https://ww ...