標籤:dataguard broker 建立和啟用
DataGuard Broker是一個分布式管理架構用於自動建立、維護和監視dataguard配置。你可以使用OEM(映像化介面)或者DGMGRL(命令列方式)進行以下操作:
1。建立和啟用dataguard配置,包括設定redo transport services and log apply services
2。可以在任何系統管理這個配置中的整個dataguard配置(所有的主庫和備庫)
3。管理和監視組件含RAC primary或standby資料庫的dataguard配置
4。簡化角色切換操作,只要DGMGRL的一條命令或者OEM的一個按鈕就可以進行switchover或failover
5。可以啟用fast-start failover以自動進行fail over當主庫不可用時。當此功能被啟用,Data Guard broker決定failover是否必需,並開始自動failover到指定的目標standby資料庫,不需要DBA幹涉,也不會遺失資料。
下面我們示範一下,Broker如何建立和啟用Broker配置。
一、 啟用DataGuard Broker
在主從資料庫上都需執行如下兩步。
1.1 啟用dg_broker
SQL> ALTER SYSTEM SET dg_broker_start=TRUE SCOPE=BOTH;System altered.
檢查後台進程,你會發現Oracle多啟動了一個進程
11gdg1-> ps -ef | grep ora_dmonoracle 19675 1 0 03:43 ? 00:00:00 ora_dmon_dgtst
1.2 配置靜態監聽器。
註:資料庫上一定要配置listener的靜態監聽,並且GLOBAL_NAME要指定為db_unique_name_DGMGRL.domain
SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = 11gdg1_DGMGRL) (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1) (SID_NAME = dgtst) ) )
二、使用dgmgrl
2.1 查看dgmgrl協助
11gdg1-> dgmgrl DGMGRL for Linux: Version 11.2.0.3.0 - 64bit ProductionCopyright (c) 2000, 2009, Oracle. All rights reserved.Welcome to DGMGRL, type "help" for information.DGMGRL> helpThe following commands are available:add Adds a standby database to the broker configurationconnect Connects to an Oracle database instanceconvert Converts a database from one type to anothercreate Creates a broker configurationdisable Disables a configuration, a database, or fast-start failoveredit Edits a configuration, database, or instanceenable Enables a configuration, a database, or fast-start failoverexit Exits the programfailover Changes a standby database to be the primary databasehelp Displays description and syntax for a commandquit Exits the programreinstate Changes a database marked for reinstatement into a viable standbyrem Comment to be ignored by DGMGRLremove Removes a configuration, database, or instanceshow Displays information about a configuration, database, or instanceshutdown Shuts down a currently running Oracle database instancesql Executes a SQL statementstart Starts the fast-start failover observerstartup Starts an Oracle database instancestop Stops the fast-start failover observerswitchover Switches roles between a primary and standby databaseUse "help <command>" to see syntax for individual commands
2.2 串連到資料庫
使用dgmgrl進行任何資料庫操作時,必須先串連到資料庫。
DGMGRL> help connect Connects to an Oracle database instanceSyntax: CONNECT <username>/<password>[@<connect identifier>]
串連到主庫
DGMGRL> connect sys/[email protected]Connected.
2.3 建立一個broker的設定檔
DGMGRL> help createCreates a broker configurationSyntax: CREATE CONFIGURATION <configuration name> AS PRIMARY DATABASE IS <database name> CONNECT IDENTIFIER IS <connect identifier>;
此步驟一定要在主庫上執行,<database name>指定的是DB_UNIQUE_NAME,而不是DB_NAME
DGMGRL> CREATE CONFIGURATION DR1 AS PRIMARY DATABASE IS 11gdg1 CONNECT IDENTIFIER IS 11GDG1;Configuration "dr1" created with primary database "11gdg1"
此時,我們只是建立了一個配置,該配置儲存在主要資料庫的設定檔中,但是我們既沒有加入standby資料,也沒有使配置生效。我們可以使用SHOW CONFIGURATION 查看配置。
DGMGRL> show configuration;Configuration - dr1 Protection Mode: MaxPerformance Databases: 11gdg1 - Primary databaseFast-Start Failover: DISABLEDConfiguration Status:DISABLED
2.4 將從庫添加到配置中
DGMGRL> ADD DATABASE 11GDG2;Database "11gdg2" added
因為在主庫上已經配置了LOG_ARCHIVE_DEST_2,如下。
SQL> show parameter log_archive_dest_2NAME TYPE VALUE------------------ --------- ------------------------------log_archive_dest_2 string service=11gdg2 ASYNC DB_UNIQUE_NAME=11gdg2 VALID_FOR=(primary_role,online_logfile)
所以添加從庫執行執行
ADD DATABASE 11GDG2;
即可,如果沒有配置的話,需要指定完整的資訊。
ADD DATABASE 11gdg2 AS CONNECT IDENTIFIER IS 11gdg2 MAINTAINED AS PHYSICAL;
查看配置資訊
DGMGRL> show configurationConfiguration - dr1 Protection Mode: MaxPerformance Databases: 11gdg1 - Primary database 11gdg2 - Physical standby databaseFast-Start Failover: DISABLEDConfiguration Status:DISABLED
standby已經被添加到配置中。
2.4 查看資料庫DG配置的詳細資料
DGMGRL> show database verbose 11gdg1;Database - 11gdg1 Role: PRIMARY Intended State: OFFLINE Instance(s): dgtst Properties: DGConnectIdentifier = ‘11gdg1‘ ObserverConnectIdentifier = ‘‘ LogXptMode = ‘ASYNC‘ DelayMins = ‘0‘ Binding = ‘optional‘ MaxFailure = ‘0‘ MaxConnections = ‘1‘ ReopenSecs = ‘300‘ NetTimeout = ‘30‘ RedoCompression = ‘DISABLE‘ LogShipping = ‘ON‘ PreferredApplyInstance = ‘‘ ApplyInstanceTimeout = ‘0‘ ApplyParallel = ‘AUTO‘ StandbyFileManagement = ‘AUTO‘ ArchiveLagTarget = ‘0‘ LogArchiveMaxProcesses = ‘4‘ LogArchiveMinSucceedDest = ‘1‘ DbFileNameConvert = ‘‘ LogFileNameConvert = ‘‘ FastStartFailoverTarget = ‘‘ InconsistentProperties = ‘(monitor)‘ InconsistentLogXptProps = ‘(monitor)‘ SendQEntries = ‘(monitor)‘ LogXptStatus = ‘(monitor)‘ RecvQEntries = ‘(monitor)‘ SidName = ‘dgtst‘ StaticConnectIdentifier = ‘(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=11gdg1.localdomain.com)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=11gdg1_DGMGRL)(INSTANCE_NAME=dgtst)(SERVER=DEDICATED)))‘ StandbyArchiveLocation = ‘USE_DB_RECOVERY_FILE_DEST‘ AlternateLocation = ‘‘ LogArchiveTrace = ‘0‘ LogArchiveFormat = ‘%t_%s_%r.dbf‘ TopWaitEvents = ‘(monitor)‘Database Status:DISABLED
2.5 使CONFIGURATION生效
DGMGRL> ENABLE CONFIGURATION;Enabled.DGMGRL> SHOW CONFIGURATION;Configuration - dr1 Protection Mode: MaxPerformance Databases: 11gdg1 - Primary database 11gdg2 - Physical standby databaseFast-Start Failover: DISABLEDConfiguration Status:SUCCESS
本文出自 “叮咚” 部落格,請務必保留此出處http://lqding.blog.51cto.com/9123978/1681701
Oracle學習之DATAGUARD(六) 建立和啟用Broker配置