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 String对象的经典问题(转)

    public class StringTest { public static void main(String[] args) { String strA = "abc"; St ...

  2. sqlserver中的存储过程 函数 事物 索引及视图

                                           存储过程和函数具体的区别: 核心提示:本质上没区别.只是函数有限制只能返回一个标量,而存储过程可以返回多个.并且函数是可以 ...

  3. maven hadoop 3.x HADOOP_HOME and hadoop.home.dir are unset Not implemented by the WebHdfsFileSystem FileSystem implementation

    具体异常如下: 解决方案: 删除pom文件中的hadoop-core的依赖,原因:hadoop-core是1.x的产物,在2.x之后已经被hadoop-common取代,我配置的时候同时使用了这两个依 ...

  4. ANDROID L——RecyclerView,CardView进口和使用(Demo)

    转载请注明本文出自大苞米的博客(http://blog.csdn.net/a396901990),谢谢支持! 简单介绍: 这篇文章是ANDROID L--Material Design具体解释(UI控 ...

  5. 美国是一个"愚蠢而落后的国度"--大家千万别去

    看到一篇文章,写的很诙谐风趣,已经被转载无数遍但却不知道原出处.读过之后又值得我们深思.和大家一起分享: 来美国已多时了.我后悔当初的选择.一直都被西方媒体所蒙蔽欺骗,让我错误地以为美国是一个现代化国 ...

  6. 树莓派挂载移动硬盘开启samba

    本文参考 [https://blog.csdn.net/u010906068/article/details/38455363],原文部分步骤在我的树莓派上,可能是版本不同吧,进行了修改后部署成功 一 ...

  7. Android的PVPlayer介绍

    1 Player的组成 OpenCore的Player的编译文件是pvplayer/Android.mk,将生成动态库文件 libopencoreplayer.so.这个库包括了双方面的内容:一方是P ...

  8. 远程主机关闭了连接。错误代码是 0x80070057,与远程主机通信时发生错误。错误代码是 0x80070057

    远程主机关闭了连接.错误代码是 0x80070057,与远程主机通信时发生错误.错误代码是 0x80070057突然在异常错误日志中看到这个错误,虽然在测试中发现不影响流的传输,但是不代表没错误,解决 ...

  9. 给 Web 开发人员推荐的通用独立 UI 组件(一)(按钮很不错)

    现代 Web 开发在将体验和功能做到极致的同时,对于美观的追求也越来越高.在推荐完图形库之后,再来推荐一些精品的独立 UI 组件.这些组件可组合在一起,形成美观而交互强大的 Web UI . 给 We ...

  10. XamlReader 动态加载XAML

    原文:XamlReader 动态加载XAML XAML: <Grid xmlns:x="http://schemas.microsoft.com/client/2006" x ...