程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> Oracle數據庫 >> Oracle教程 >> OracleDataGuard_備庫以只讀或讀寫方式打開訪問

OracleDataGuard_備庫以只讀或讀寫方式打開訪問

編輯:Oracle教程

8.2 Opening a Standby Database for Read-Only or Read/Write Access

8.2以只讀或者可讀寫方式打開備庫來訪問

When a standby database is open for read-only access, users can query the standby database but cannot update it. Thus, you can reduce the load on the primary database by using the standby database for reporting purposes. You can periodically open the standby database for read-only access and perform ad hoc queries to verify Redo Apply is updating the standby database correctly. (Note that for distributed queries, you must first issue theALTER DATABASE SET TRANSACTION READ ONLY statement before you can issue a query on the read-only database.)

當備庫是以只讀方式打開時,用戶只能在備庫上查詢而不能更新它。那麼你可以為主庫減輕負載而在備庫上出報表,你可以定期的以只讀方式打開備庫,查詢驗證重做應用是否正確的更新到備庫。針對分布式查詢,你必須在只讀數據庫查詢之前發出ALTER DATABASE SET TRANSACTION READ ONLY語句。

Figure 8-1 shows a standby database open for read-only access.

Figure 8-1 Standby Database Open for Read-Only Access

\

Description of "Figure 8-1 Standby Database Open for Read-Only Access"

See Also:

Assessing Whether or Not to Open a Standby Database

Opening a Physical Standby Database for Read-Only Access

A physical standby database can be opened temporarily in read/write mode for development, reporting, or testing purposes, and then flashed back to a point in the past to be reverted back to a physical standby database. When the database is flashed back, Data Guard automatically synchronizes the standby database with the primary database, without the need to re-create the physical standby database from a backup copy of the primary database.

物理備庫可以暫時打開以讀/寫模式用來開發,報告或測試的目的,然後閃回到過去一個點來恢復到一個物理備用數據庫。當數據庫閃回以後,Data Guard自動同步主庫與備庫之間的數據,而不需要從主數據庫的備份副本重新創建物理備用數據庫。

See Also:

Section 12.6 for a scenario that describes activating a physical standby database as a read/write reporting database, and then resynchronizing the database with the primary database 第12.6節的場景,描述活動的物理備用數據庫為讀/寫報告數據庫,然後與主數據庫重新同步數據庫。

8.2.1 Assessing Whether or Not to Open a Standby Database

8.2.1 評估是否要打開備庫

As you decide whether or not to open a physical standby database for read-only or read/write access, consider the following:

決定是否要以只讀方式或者讀寫方式打開物理備庫,可以考慮如下:

Opening the physical standby database read-only may lengthen the time it takes to recover from a failure or outage, because the database must be restarted after a failover.

以只讀方式打開物理備庫可以延長失敗或中斷恢復的時間,因為數據庫必須在故障切換後重新啟動。

As long as the physical standby database has not been opened read-only since the last time it was started, a restart is unnecessary after failover, thus increasing system availability.

只要物理備庫自從上次啟動沒有以只讀方式打開,在故障切換後,重啟是必須的,那麼就會增加系統的可用性。

While a standby database is open for read-only or read/write access, it does not apply redo data received from the primary database, thus it is not kept transactionally consistent with the primary database.

當備庫是以只讀方式打開或者讀寫方式打開,就不會應用來自主庫的重做數據,那麼就不能與主庫保持一致性的事務。

When a physical standby database is open, redo data from the primary database is received by the standby database, but the log files are not applied. At some point, you need to resume Redo Apply on the standby database, and apply the archived redo log files to resynchronize the standby database with the primary database. Because of the additional time required to apply any accumulated archived redo log files, having a standby database open for read-only access can increase the time required to complete failovers or switchovers.

當物理備庫是打開時,來自主庫的重做數據被備庫接收,但是不會被應用。在有點傷,你需要在備庫上重新應用重做數據,應用歸檔日志來同步備庫和主庫之間的數據。因為應用任何所需的額外時間累積的歸檔重做日志文件,因為需要申請任何累計歸檔重做日志文件,有一個備用數據庫只讀訪問打開會增加完成故障切換或換藥所需的額外時間。

You can use a physical standby database for reporting purposes or as a clone database while also maintaining the ability to complete a failover or switchover quickly if you configure more than one standby database on the standby system.

如果你的備用系統上配置多個備用數據庫,你可以使用一個物理備用數據庫進行報表用途或克隆一個數據庫,同時還保持了完整的故障切換或正常切換。

For example, based on your business requirements, you might:

例如,基於你的業務需求,你可以:

Configure two physical standby databases with one standby database always performing Redo Apply to be as current as possible with the primary database and the other standby database open in read-only mode during business hours for reporting purposes.

配置兩個物理備庫,其中一個備庫盡可能經常用來執行重做應用主庫的日志,另外一個則以只讀方式打開在業務期間達到出報表的目的。

Configure a physical standby database to maintain a copy of the primary database for disaster recovery purposes and also configure a logical standby database to off-load reporting tasks that require access to the latest data from the primary database.

配置物理備庫來維護主庫的副本來達到災難恢復的目的,配置邏輯備庫來卸載報表任務,這需要訪問到主庫最新的數據。

When configuring more than one standby database on the same system, consider using the DEPENDENCY attribute of the LOG_ARCHIVE_DEST_ninitialization parameter to define one archival destination to receive redo data on behalf of all of the destinations, rather than transmitting redo data to each individual destination. See Section 5.7.5 for more information.

8.2.2 Opening a Physical Standby Database for Read-Only Access

You can alternate between having a physical standby database open for read-only access and performing Redo Apply using the following procedures.

你可以使用以下過程在物理備庫只讀方式打開訪問和執行重做應用來輪流切換。

To open a standby database for read-only access when it is currently shut down:

當備庫是關閉狀態,直接使用STARTUP命令來以只讀方式打開備庫:

Start, mount, and open the database for read-only access using the following statement:

SQL> STARTUP;

To open a standby database for read-only access when it is currently performing Redo Apply:

當目前正在執行重做應用,以只讀方式打開備庫來訪問:(首先取消重做應用,然後再打開數據庫)

Cancel Redo Apply:

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

Open the database for read-only access:

SQL> ALTER DATABASE OPEN;
###################################################################################### SYS@PRODSTD>alter database open;
Database altered.
SYS@PRODSTD>select OPEN_MODE from v$database;
OPEN_MODE ---------- READ ONLY
SYS@PRODSTD> ------------------------------------------------------------------------------------------------------------------ Sat Mar 29 13:22:29 2014 alter database open Sat Mar 29 13:22:29 2014 SMON: enabling cache recovery Sat Mar 29 13:22:30 2014 Database Characterset is AL32UTF8 replication_dependency_tracking turned off (no async multimaster replication found) Physical standby database opened for read only access. Completed: alter database open
########################################################################################

You do not need to shut down the instance to open it for read-only access.

Note:

By default, the ALTER DATABASE OPEN statement opens physical standby databases in read-only mode. The Oracle database determines if this is a physical standby database based on information in the control file. 默認的, ALTER DATABASE OPEN 這條語句是以只讀凡是打開物理備庫。oracle數據庫是以控制文件裡的信息是否是物理備庫來決定的。

To change the standby database from being open for read-only access to performing Redo Apply:

切換備庫從只讀訪問到重做應用:

Terminate all active user sessions on the standby database.

1.終止備庫上所有活躍的用戶會話。

Restart Redo Apply. To start Redo Apply, issue the following statement:

2.重啟重做應用,發出以下語句可以啟用重做應用:

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE 2> DISCONNECT FROM SESSION;

To enable real-time apply, include the USING CURRENT LOGFILE clause:

實時應用,需要包含USING CURRENT LOGFILE子句:

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE 2> USING CURRENT LOGFILE;

You do not need to shut down the instance to start either of these apply modes.

你不需要關閉數據庫然後再啟用這些應用模式。

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved