一、 环境说明: 二、 配置broker 1、调整主库与备库的监听文件[oracle@locate admin]$ catlistener.ora # listener.ora NetworkConfiguration File:/u01/app/oracle/product/12.2.0/dbhome_1/network/admin/listener.ora # Generated by Oracleconfiguration tools. LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST =oracledg)(PORT = 1521)) (ADDRESS = (PROTOCOL = IPC)(KEY =EXTPROC1521)) ) ) SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = orcl) (ORACLE_HOME =/u01/app/oracle/product/12.2.0/dbhome_1) (SID_NAME = orcl) ) (SID_DESC = (GLOBAL_DBNAME = orcl_DGMGRL) (ORACLE_HOME =/u01/app/oracle/product/12.2.0/dbhome_1) (SID_NAME = orcl) ) ) [oracle@localhostadmin]$ cat tnsnames.ora # tnsnames.oraNetwork Configuration File:/u01/app/oracle/product/12.2.0/dbhome_1/network/admin/tnsnames.ora # Generated byOracle configuration tools. LISTENER_ORCL = (ADDRESS = (PROTOCOL = TCP)(HOST =oracledg)(PORT = 1521)) ORCL = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST =oracledb)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl) ) ) ORCLDG = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = oracledg)(PORT= 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl) ) ) 2、检查主库与备库的broder参数 SQL> show parameter dg_broker NAME TYPE VALUE ----------------------------------------------- ------------------------------ dg_broker_config_file1 string /u01/app/oracle/product/12.2.0 /dbhome_1/dbs/dr1orcldg.dat dg_broker_config_file2 string /u01/app/oracle/product/12.2.0 /dbhome_1/dbs/dr2orcldg.dat dg_broker_start boolean TRUE 4、设置dataguard broker在主库、备库或者另外一台独立的机器都可以设置。
本次操作是在主库上。 主库创建dg_broker [oracle@oracledb ~]$ dgmgrl DGMGRL for Linux: Release12.2.0.1.0 - Production on Mon Jun 3 01:19:20 2020 Copyright (c) 1982, 2017,Oracle and/or its affiliates. All rightsreserved. Welcome to DGMGRL, type"help" for information. DGMGRL> DGMGRL> connnectsys/oracle@ORCLDG Unrecognized command"connnect", try "help" DGMGRL> connectsys/oracle@ORCLDG Connected as SYSDBA. DGMGRL> help create; Creates a brokerconfiguration Syntax: CREATE CONFIGURATION <configurationname> [AS] PRIMARY DATABASE IS <database name> CONNECT IDENTIFIER IS <connectidentifier>; DGMGRL> createconfiguration dgconfig as primary database is orcl connect identifier is ORCL; Error: ORA-16525: TheOracle Data Guard broker is not yet available. 错误原因:连接是备库,并非主库,所以创建时,失败。 连接切换到主库后,创建成功。 DGMGRL> connectsys/oracle@ORCL Connected to "orcl" Connected as SYSDBA. DGMGRL> createconfiguration dgconfig as primary database is orcl connect identifier is ORCL; Configuration"dgconfig" created with primary database "orcl" 增加备库 DGMGRL> connect sys/oracle Connected to "orcl" Connected as SYSDG. DGMGRL> add databaseorcldg as connect identifier is ORCLDG; Error: ORA-16698: member hasa LOG_ARCHIVE_DEST_n parameter with SERVICE attribute set Failed. 原因是这一块的参数应当是交给DG broker 来管理了,不再需要人为介入设置,故而这里要解决这个问题,只需要将之前人为设置的log_archive_dest_2这个参数重置掉即可 在主库与备库中执行 SQL> alter system setlog_archive_dest_2='' scope=both; System altered. DGMGRL> add databaseorcldg as connect identifier is ORCLDG; Database "orcldg"added 查看broker配置 DGMGRL> show configuration Configuration - dgconfig Protection Mode: MaxPerformance Members: orcl - Primary database orcldg - Physical standby database(disabled) Fast-Start Failover: DISABLED Configuration Status: SUCCESS (status updated 39 seconds ago) DGMGRL> show configuration verbose; Configuration - dgconfig Protection Mode: MaxPerformance Members: orcl - Primary database orcldg - Physical standby database Properties: FastStartFailoverThreshold = '30' OperationTimeout = '30' TraceLevel = 'USER' FastStartFailoverLagLimit = '30' CommunicationTimeout = '180' ObserverReconnect = '0' FastStartFailoverAutoReinstate = 'TRUE' FastStartFailoverPmyShutdown = 'TRUE' BystandersFollowRoleChange = 'ALL' ObserverOverride = 'FALSE' ExternalDestination1 = '' ExternalDestination2 = '' PrimaryLostWriteAction = 'CONTINUE' ConfigurationWideServiceName = 'orcl_CFG' Fast-Start Failover: DISABLED Configuration Status: SUCCESS 查看broker主库配置 DGMGRL> show database verbose ORCL Database - orcl Role: PRIMARY Intended State: TRANSPORT-ON Instance(s): orcl Properties: DGConnectIdentifier = 'orcl' ObserverConnectIdentifier = '' LogXptMode = 'ASYNC' RedoRoutes = '' DelayMins = '0' Binding = 'optional' MaxFailure = '0' MaxConnections = '1' ReopenSecs = '300' NetTimeout = '30' RedoCompression = 'DISABLE' LogShipping = 'ON' PreferredApplyInstance = '' ApplyInstanceTimeout = '0' ApplyLagThreshold = '30' TransportLagThreshold = '30' TransportDisconnectedThreshold = '30' ApplyParallel = 'AUTO' ApplyInstances = '0' StandbyFileManagement = 'AUTO' ArchiveLagTarget = '0' LogArchiveMaxProcesses = '4' LogArchiveMinSucceedDest = '1' DataGuardSyncLatency = '0' DbFileNameConvert = '' LogFileNameConvert = '' FastStartFailoverTarget = '' InconsistentProperties = '(monitor)' InconsistentLogXptProps = '(monitor)' SendQEntries = '(monitor)' LogXptStatus = '(monitor)' RecvQEntries = '(monitor)' PreferredObserverHosts = '' StaticConnectIdentifier ='(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracledb)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=orcl_DGMGRL)(INSTANCE_NAME=orcl)(SERVER=DEDICATED)))' StandbyArchiveLocation = '/u01/app/oracle/archivelog' AlternateLocation = '' LogArchiveTrace = '0' LogArchiveFormat = '%t_%s_%r.dbf' TopWaitEvents = '(monitor)' Log file locations: Alert log :/u01/app/diag/rdbms/orcl/orcl/trace/alert_orcl.log Data Guard Broker log :/u01/app/diag/rdbms/orcl/orcl/trace/drcorcl.log Database Status: SUCCESS 查看broker备库配置 DGMGRL> show database verbose ORCLDG; Database - orcldg 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: 0 Byte/s Active Apply Rate: 1.43 MByte/s Maximum Apply Rate: 1.63 MByte/s Real Time Query: ON Instance(s): orcl Properties: DGConnectIdentifier = 'orcldg' ObserverConnectIdentifier = '' LogXptMode = 'ASYNC' RedoRoutes = '' DelayMins = '0' Binding = 'optional' MaxFailure = '0' MaxConnections = '1' ReopenSecs = '300' NetTimeout = '30' RedoCompression = 'DISABLE' LogShipping = 'ON' PreferredApplyInstance = '' ApplyInstanceTimeout = '0' ApplyLagThreshold = '30' TransportLagThreshold = '30' TransportDisconnectedThreshold = '30' ApplyParallel = 'AUTO' ApplyInstances = '0' StandbyFileManagement = 'AUTO' ArchiveLagTarget = '0' LogArchiveMaxProcesses = '4' LogArchiveMinSucceedDest = '1' DataGuardSyncLatency = '0' DbFileNameConvert = '/u01/app/oradata/orcl/,/u01/app/oradata/orcl/' LogFileNameConvert = '/u01/app/oradata/orcl/,/u01/app/oradata/orcl/' FastStartFailoverTarget = '' InconsistentProperties = '(monitor)' InconsistentLogXptProps = '(monitor)' SendQEntries = '(monitor)' LogXptStatus = '(monitor)' RecvQEntries = '(monitor)' PreferredObserverHosts = '' StaticConnectIdentifier ='(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracledg)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=orcldg_DGMGRL)(INSTANCE_NAME=orcl)(SERVER=DEDICATED)))' StandbyArchiveLocation = '/u01/app/oracle/archivelog' AlternateLocation = '' LogArchiveTrace = '0' LogArchiveFormat = '%t_%s_%r.dbf' TopWaitEvents = '(monitor)' Log file locations: Alert log :/u01/app/diag/rdbms/orcldg/orcl/trace/alert_orcl.log Data Guard Broker log : /u01/app/diag/rdbms/orcldg/orcl/trace/drcorcl.log Database Status: SUCCESS 查看broker配置的log_archive_dest_2的参数 SQL> show parameter log_archive_dest_2 NAME TYPE VALUE ----------------------------------------------- ------------------------------ log_archive_dest_2 string service="orcldg", ASYNC NOAFFI RM delay=0 optional compressio n=disable max_failure=0 max_co nnections=1 reopen=300 db_uniq ue_name="orcldg" net_timeout=3 0, valid_for=(online_logfile,a ll_roles)
|