Oracle 面試寶典-DG篇
一: 請描述Oracle Data Guard優點有哪些; 二: 請描述DG備庫型別和特點; 三: 請描述如何將物理備用資料庫轉換為快照備用資料庫; 四: 請描述如何將快照備用資料庫轉換為物理備用資料庫; 五: 請描述DG環境需要配置哪些引數; 六: 請描述如果DG備庫伺服器要回收,如何關閉DG同步關係; 七: 請描述在DG執行SWITCHOVER前需要注意什麼; 八: 請描述在DG主、備庫都是二節點RAC的場景下,執行SWITCHOVER的過程; 九: 請描述Oracle DG FAILOVER過程; 十: 請描述Oracle DG GAP問題處理方法; 十一:請描述Oracle DG有哪些程式; 十二:請描述Oracle DG常用命令。
一:請描述Oracle Data Guard優點有哪些
Summary of Oracle Data Guard Benefits
Oracle Data Guard提供了一個高效、全面的災難恢復和高可用性解決方案。
Oracle Data Guard provides an efficient and comprehensive disaster recovery and high availability solution.
Oracle Data Guard提供以下好處:
Oracle Data Guard offers these benefits:
1.高可用性
High availability Oracle Data Guard易於管理的switchover和failover功能允許在主資料庫和備用資料庫之間進行角色轉換,從而最大限度地減少主資料庫在計劃內和計劃外停機時的停機時間。 Oracle Data Guard’s easy-to-manage switchover and failover capabilities allow role reversals between primary and standby databases, minimizing the downtime of the primary database for planned and unplanned outages.
2.完整的資料保護
Complete data protection Oracle Data Guard可以確保零資料丟失,即使在遇到意外情況時也是如此。 Oracle Data Guard can ensure zero data loss, even in the face of unforeseendisasters. 備用資料庫可防止所有型別的計劃外停機,包括資料損壞和管理錯誤。 A standby database provides a safeguard against unplanned outages of all types, including data corruption and administrative error. 因為從主資料庫接收的重做資料在備用資料庫中進行驗證,所以主資料庫中可能發生的物理損壞不會傳播到備用資料庫。 Because the redo data received from a primary database is validated at a standby database, physical corruptions that can occur at a primary database are not propagated to the standby database. 在備用資料庫上執行的附加驗證還可以防止邏輯塊內損壞和丟失寫入損壞傳播到備用資料庫。 Additional validation performed at a standby database also prevents logical intra-block corruptions and lost-write corruptions from propagating to the standby. 類似地,管理錯誤(如儲存管理員意外刪除檔案)不會傳播到備用資料庫。 Similarly, administrative errors such as accidental file deletions by a storage administrator are not propagated to a standby database. 物理備用資料庫也可用於防止使用者錯誤,方法是延遲重做應用,或使用閃回資料庫倒回備用資料庫並提取資料的良好副本。 A physical standby database can also be used to protect against user errors either by delaying the redo apply or by using Flashback Database to rewind the standby and extract a good copy of the data.
3.有效利用系統資源
Efficient use of system resources 使用從主資料庫接收的重做資料更新的備用資料庫表可用於其他任務,如備份、報告、彙總和查詢,從而減少執行這些任務所需的主資料庫工作負載,節省寶貴的CPU和I/O週期。 The standby database tables that are updated with redo data received from the primary database can be used for other tasks such as backups, reporting,summations, and queries, thereby reducing the primary database workloadnecessary to perform these tasks, saving valuable CPU and I/O cycles.
4.資料保護的靈活性,以平衡可用性和效能要求
Flexibility in data protection to balance availability against performance requirements Oracle Data Guard提供了最大保護、最大可用性和最大效能模式,幫助企業平衡資料可用性和系統效能需求。 Oracle Data Guard offers maximum protection, maximum availability, and maximum performance modes to help enterprises balance data availability against system performance requirements.
5.自動gap檢測和解決
Automatic gap detection and resolution 如果主資料庫和一個或多個備用資料庫之間的連線丟失(例如,由於網路問題), If connectivity is lost between the primary and one or more standby databases (for example, due to network problems), 這樣,在主資料庫上生成的重做資料就不能傳送到那些備用資料庫。 then redo data being generated on the primary database cannot be sent to those standby databases. 重新建立連線後,Oracle Data Guard會自動檢測到丟失的存檔重做日誌檔案(稱為gap),然後將丟失的存檔重做日誌檔案自動傳輸到備用資料庫。 After a connection is reestablished, the missing archived redo log files (referred to as a gap) are automatically detected by Oracle Data Guard, which then automatically transmits the missing archived redo log files to the standby databases. 備用資料庫與主資料庫同步,無需DBA手動干預。 The standby databases are synchronized with the primary database, without manual intervention by the DBA.
6.集中化、簡單化管理
Centralized and simple management Oracle Data Guard broker提供了圖形使用者介面和命令列介面,用於在DG配置中跨多個資料庫自動化管理和操作任務。 代理還監視單個Oracle Data Guard配置中的所有系統。 The Oracle Data Guard broker provides a graphical user interface and a command-line interface to automate management and operational tasks across multiple databases in an Oracle Data Guard configuration. The broker also monitors all of the systems within a single Oracle Data Guard configuration.
7.與Oracle資料庫整合
Integration with Oracle Database Oracle Data Guard是Oracle Database Enterprise Edition的一項功能,不需要單獨安裝。 Oracle Data Guard is a feature of Oracle Database Enterprise Edition and does not require separate installation.
8.自動角色轉換
Automatic role transitions 啟用快速啟動故障切換後,如果主站點發生災難,Oracle Data Guard broker將自動故障切換到同步備用站點,而無需DBA干預。此外,應用程式會自動通知角色轉換。 When fast-start failover is enabled, the Oracle Data Guard broker automatically fails over to a synchronized standby site in the event of a disaster at the primary site, requiring no intervention by the DBA. In addition, applications are automatically notified of the role transition.
二:請描述DG備庫型別和特點
Standby Database Types 備用資料庫是Oracle生產資料庫的事務一致性副本,它最初是從主資料庫的備份副本建立的。 A standby database is a transactionally consistent copy of an Oracle production database that is initially created from a backup copy of the primary database. 一旦建立並配置了備用資料庫,Oracle Data Guard就會透過將主資料庫redo資料傳輸到備用系統來自動維護備用資料庫,並將redo資料應用到備用資料庫。 Once the standby database is created and configured, Oracle Data Guard automatically maintains the standby database by transmitting primary database redo data to the standby system, where the redo data is applied to the standby database. 備用資料庫可以是以下型別之一:物理備用資料庫、邏輯備用資料庫或快照備用資料庫。 A standby database can be one of these types: a physical standby database, a logical standby database, or a snapshot standby database. 如果需要,物理或邏輯備用資料庫都可以充當主資料庫的角色並接管生產處理。 If needed, either a physical or a logical standby database can assume the role of the primary database and take over production processing. Oracle Data Guard配置可以包括這些型別的備用資料庫的任意組合。 An Oracle Data Guard configuration can include any combination of these types of standby databases.
2.1 Physical Standby Databases
物理備用資料庫是主資料庫的精確逐塊副本。 A physical standby database is an exact, block-for-block copy of a primary database. 物理備份透過一個稱為Redo Apply的過程作為精確副本進行維護,在這個過程中,使用資料庫恢復機制將從主資料庫接收的Redo資料連續應用到物理備份資料庫。 A physical standby is maintained as an exact copy through a process called Redo Apply, in which redo data received from a primary database is continuously applied to a physical standby database using the database recovery mechanisms. 可以開啟物理備用資料庫進行只讀訪問,並用於從主資料庫解除安裝查詢。 A physical standby database can be opened for read-only access and used to offload queries from a primary database. 如果購買了Oracle Active Data Guard選項的許可證,那麼Redo Apply可以在物理備用資料庫開啟時處於活動狀態,從而允許查詢返回與從主資料庫返回的結果相同的結果。 If a license for the Oracle Active Data Guard option has been purchased, Redo Apply can be active while the physical standby database is open, thus allowing queries to return results that are identical to what would be returned from the primary database. 此功能稱為實時查詢功能。 This capability is known as the real-time query feature.
Physical Standby Database優點
Benefits of a Physical Standby Database
A physical standby database provides the following benefits:
災難恢復和高可用性
Disaster recovery and high availability 物理備用資料庫是一種健壯、高效的災難恢復和高可用性解決方案。 A physical standby database is a robust and efficient disaster recovery and high availability solution. 易於管理的切換和故障切換功能允許在主資料庫和物理備用資料庫之間輕鬆進行角色轉換,從而最大限度地減少主資料庫因計劃內和計劃外停機而導致的停機時間。 Easy-to-manage switchover and failover capabilities allow easy role reversals between primary and physical standby databases, minimizing the downtime of the primary database for planned and unplanned outages.
資料保護
Data protection 物理備用資料庫可以防止資料丟失,即使是在遇到不可預見的災難時。 A physical standby database can prevent data loss, even in the face of unforeseen disasters. 物理備用資料庫支援所有資料型別,以及主資料庫可以支援的所有DDL和DML操作。 A physical standby database supports all datatypes, and all DDL and DML operations that the primary database can support. 它還提供了防止資料損壞和使用者錯誤的保護措施。 It also provides a safeguard against data corruptions and user errors. 主資料庫上的儲存級物理損壞不會傳播到備用資料庫。 Storage level physical corruptions on the primary database are not propagated to a standby database. 類似地,可以很容易地解決邏輯損壞或使用者錯誤,否則會導致資料丟失。 Similarly, logical corruptions or user errors that would otherwise cause data loss can be easily resolved.
減少主資料庫工作負載
Reduction in primary database workload Oracle Recovery Manager(RMAN)可以使用物理備用資料庫從主資料庫解除安裝備份,從而節省寶貴的CPU和I/O週期。 Oracle Recovery Manager (RMAN) can use a physical standby database to offload backups from a primary database, saving valuable CPU and I/O cycles. 當Redo Apply處於活動狀態時,還可以查詢物理備用資料庫,這樣可以將查詢從主資料庫解除安裝到物理備用資料庫,從而進一步減少主資料庫的工作負載。 A physical standby database can also be queried while Redo Apply is active, which allows queries to be offloaded from the primary to a physical standby, further reducing the primary workload.
效能
Performance 物理備用資料庫使用的Redo Apply技術是保持備用資料庫更新為主資料庫所做更改的最有效機制,因為它使用繞過所有SQL級程式碼層的低階恢復機制應用更改。 The Redo Apply technology used by a physical standby database is the most efficient mechanism for keeping a standby database updated with changes being made at a primary database because it applies changes using low-level recovery mechanisms which bypass all SQL level code layers.
2.2 Logical Standby Databases
邏輯備用資料庫最初是作為主資料庫的相同副本建立的,但以後可以更改為具有不同的結構。 A logical standby database is initially created as an identical copy of the primary database, but it later can be altered to have a different structure. 透過執行SQL語句更新邏輯備用資料庫。 The logical standby database is updated by executing SQL statements. 邏輯備用資料庫的靈活性使您可以升級Oracle資料庫軟體(修補程式集和新的Oracle資料庫版本),並以滾動方式執行其他資料庫維護,幾乎沒有停機。 The flexibility of a logical standby database lets you upgrade Oracle Database software (patch sets and new Oracle Database releases) and perform other database maintenance in rolling fashion with almost no downtime. 從Oracle Database 11g開始,臨時邏輯資料庫滾動升級過程也可以用於現有的物理備用資料庫。 From Oracle Database 11g onward, the transient logical database rolling upgrade process can also be used with existing physical standby databases. Oracle Data Guard透過將日誌檔案中的資料轉換為SQL語句,然後在邏輯備用資料庫上執行SQL語句,自動將歸檔的重做日誌檔案或備用重做日誌檔案中的資訊應用到邏輯備用資料庫。 Oracle Data Guard automatically applies information from the archived redo log file or standby redo log file to the logical standby database by transforming the data in the log files into SQL statements and then executing the SQL statements on the logical standby database. 因為邏輯備用資料庫是使用SQL語句更新的,所以它必須保持開啟狀態。 Because the logical standby database is updated using SQL statements, it must remain open. 儘管邏輯備用資料庫是以讀/寫模式開啟的,但其重新生成的SQL的目標表僅可用於只讀操作。 Although the logical standby database is opened in read/write mode, its target tables for the regenerated SQL are available only for read-only operations. 在更新這些表時,它們可以同時用於其他任務,如報告、彙總和查詢。 While those tables are being updated, they can be used simultaneously for other tasks such as reporting,summations, and queries. 邏輯備用資料庫對資料型別、表型別以及DDL和DML操作型別有一些限制。 A logical standby database has some restrictions on data types, types of tables, and types of DDL and DML operations. 有關邏輯備用資料庫上的資料型別和DDL支援的資訊,請參見邏輯備用資料庫上的資料型別和DDL支援。 See Data Type and DDL Support on a Logical Standby Database for information on data type and DDL support on logical standby databases.
邏輯備用資料庫的優點
Benefits of a Logical Standby Database 邏輯備用資料庫是高可用性(HA)的理想選擇,同時還能提供資料恢復(DR)好處。 A logical standby database is ideal for high availability (HA) while still offering data recovery (DR) benefits. 與物理備用資料庫相比,邏輯備用資料庫提供了顯著的附加HA好處: Compared to a physical standby database, a logical standby database provides significant additional HA benefits:
最大限度地減少軟體升級的停機時間
• Minimizing downtime on software upgrades 邏輯備用資料庫是以滾動方式升級Oracle Data Guard配置的理想選擇。 A logical standby database is ideal for upgrading an Oracle Data Guard configuration in a rolling fashion. 邏輯待機可用於大大減少與應用補丁集和新軟體版本相關的停機時間。 Logical standby can be used to greatly reduce downtime associated with applying patchsets and new software releases. 邏輯備用可以升級到新版本,然後切換為活動主版本。 A logical standby can be upgraded to the new release and then switched over to become the active primary. 這允許在舊的主裝置轉換為邏輯備用裝置並應用補丁集時實現完全可用性。 This allows full availability while the old primary is converted to a logical standby and the patchset is applied. 邏輯備用程式為DBMS\u ROLLING PL/SQL包提供了底層平臺,它提供的功能允許您在滾動升級和其他儲存重組的上下文中使您的Oracle Data Guard配置高度可用。 Logical standbys provide the underlying platform for the DBMS_ROLLING PL/SQL package, which provides functionality that allows you to make your Oracle Data Guard configuration highly available in the context of rolling upgrades and other storage reorganization.
最大限度地減少軟體升級的停機時間
• Support for reporting and decision support requirements 邏輯備用的一個關鍵好處是可以建立重要的輔助結構來最佳化報告工作量; A key benefit of logical standby is that significant auxiliary structures can be created to optimize the reporting workload; 可能對主伺服器的事務響應時間產生禁止性影響的結構。 structures that could have a prohibitive impact on the primary's transactional response time. 邏輯備用可以將其資料物理地重新組織為具有不同分割槽的不同儲存型別,具有許多不同的索引,建立和維護按需重新整理物化檢視,並且可以用於驅動資料多維資料集和其他OLAP資料檢視的建立。 A logical standby can have its data physically reorganized into a different storage type with different partitioning, have many different indexes, have on-demand refresh materialized views created and maintained, and can be used to drive the creation of data cubes and other OLAP data views. 但是,邏輯備用資料庫不允許對資料進行任何轉換(例如僅複製列的子集或允許在使用者表上新增列)。 However, a logical standby database does not allow for any transformation of your data (such as replicating only a subset of columns or allowing additional columns on user tables). 對於這些型別的報告活動,Oracle GoldenGate是Oracle的首選解決方案。 For those types of reporting activities, Oracle GoldenGate is Oracle's preferred solution.
2.3 Snapshot Standby Databases
快照備用資料庫是一種可更新的備用資料庫,為主資料庫提供完整的資料保護。 A snapshot standby database is a type of updatable standby database that provides full data protection for a primary database. 快照備用資料庫從其主資料庫接收並存檔(但不應用)重做資料。 A snapshot standby database receives and archives, but does not apply, redo data from its primary database. 在放棄對快照備用資料庫的所有本地更新後,當快照備用資料庫轉換回物理備用資料庫時,將應用從主資料庫接收的重做資料。 Redo data received from the primary database is applied when a snapshot standby database is converted back into a physical standby database, after discarding all local updates to the snapshot standby database. 快照備用資料庫隨著時間的推移會與其主資料庫分離,因為主資料庫中的重做資料在接收時不會應用。 A snapshot standby database diverges from its primary database over time because redo data from the primary database is not applied as it is received. 對快照備用資料庫的本地更新會導致其他分歧。 Local updates to the snapshot standby database cause additional divergence. 但是,主資料庫中的資料是完全受保護的,因為可以隨時將快照備用資料庫轉換回物理備用資料庫,然後應用從主資料庫接收的重做資料。 The data in the primary database is fully protected however, because a snapshot standby can be converted back into a physical standby database at any time, and the redo data received from the primary is then applied.
快照備用資料庫的好處
Benefits of a Snapshot Standby Database 快照備用資料庫是完全可更新的備用資料庫,它提供了與物理備用資料庫類似的災難恢復和資料保護好處。 A snapshot standby database is a fully updatable standby database that provides disaster recovery and data protection benefits that are similar to those of a physical standby database. 快照備用資料庫最好用在這樣的場景中:主資料庫有一個臨時的、可更新的快照,這樣可以增加從主資料庫故障中恢復的時間。 Snapshot standby databases are best used in scenarios where the benefit of having a temporary, updatable snapshot of the primary database justifies the increased time to recover from primary database failures.
使用快照備用資料庫的好處包括: The benefits of using a snapshot standby database include the following: •它為開發和測試的提供生產資料庫的精確副本,同時始終保持資料保護。 • It provides an exact replica of a production database for development and testing purposes, while maintaining data protection at all times. 您可以使用Oracle Real Application Testing選項捕獲主資料庫工作負載,然後在snapshot備用伺服器上重放它以進行測試。 You can use the Oracle Real Application Testing option to capture primary database workload and then replay it for test purposes on the snapshot standby. •透過轉換為物理備用並重新同步,可以輕鬆重新整理以包含當前生產資料。 • It can be easily refreshed to contain current production data by converting to a physical standby and resynchronizing. 建立快照備用、測試、與生產重新同步,然後再次建立快照備用和測試的能力是一個可以根據需要重複的週期。 The ability to create a snapshot standby, test, resynchronize with production, and then again create a snapshot standby and test, is a cycle that can be repeated as often as desired. 在需要對資料進行讀/寫訪問的情況下,可以使用相同的過程輕鬆建立和定期更新備用快照,以便進行報告。 The same process can be used to easily create and regularly update a snapshot standby for reporting purposes where read/write access to data is required.
三:請描述如何將物理備用資料庫轉換為快照備用資料庫。
Converting a Physical Standby Database into a Snapshot Standby Database These steps describe how to convert a physical standby database into a snapshot standby database. 1. Stop Redo Apply, if it is active. 2. Ensure that the database is mounted, but not open. 3. Ensure that a fast recovery area has been configured. It is not necessary for flashback database to be enabled. 4. Issue the following SQL statement to perform the conversion: SQL> ALTER DATABASE CONVERT TO SNAPSHOT STANDBY; 5. Open the snapshot standby in read/write mode by issuing the following SQL statement: SQL> ALTER DATABASE OPEN READ WRITE;
四:請描述如何將快照備用資料庫轉換為物理備用資料庫
Converting a Snapshot Standby Database into a Physical Standby Database These steps describe how to convert a snapshot standby database into a physical standby database. 1. On an Oracle Real Applications Cluster (Oracle RAC) database, shut down all but one instance. 2. Ensure that the database is mounted, but not open. 3. Issue the following SQL statement to perform the conversion: SQL> ALTER DATABASE CONVERT TO PHYSICAL STANDBY; Redo data received while the database was a snapshot standby database is automatically applied when Redo Apply is started.
五:請描述DG環境需要配置哪些引數?
設定主資料庫初始化引數
Set Primary Database Initialization Parameters
1.DB_NAME
示例: DB_NAME=chicago 說明: 在主資料庫上,指定建立資料庫時使用的名稱。 On a primary database, specify the name used when the database was created. 在物理備用資料庫上,使用主資料庫的DB_NAME名稱。 On a physical standby database, use the DB_NAME of the primary database.
2.DB_UNIQUE_NAME
示例: DB_UNIQUE_NAME=chicago 說明: 為每個資料庫指定唯一的名稱。 Specify a unique name for each database. 此名稱將保留在資料庫中,並且不會更改,即使主資料庫和備用資料庫反轉角色也是如此。 This name stays with the database and does not change, even if the primary and standby databases reverse roles.
3.LOG_ARCHIVE_CONFIG
示例: LOG_ARCHIVE_CONFIG='DG_CONFIG=(chicago,boston)' 說明: 必須在Oracle Data Guard配置中的每個資料庫上顯式設定此引數的DG_CONFIG屬性,以啟用完整的Oracle Data Guard功能。 The DG_CONFIG attribute of this parameter must be explicitly set on each database in an Oracle Data Guard configuration to enable full Oracle Data Guard functionality. 將DG_CONFIG設定為包含配置中每個資料庫的DB_UNIQUE_NAME的文字字串,該列表中的每個名稱用逗號分隔。 Set DG_CONFIG to a text string that contains the DB_UNIQUE_NAME of each database in the configuration, with each name in this list separated by a comma.
4.CONTROL_FILES
示例: CONTROL_FILES='/arch1/chicago/control1.ctl', '/arch2/chicago/control2.ctl' 說明: 指定主資料庫上控制檔案的路徑名。 Specify the path name for the control files on the primary database. 建議提供控制檔案的第二個副本,以便在將好的控制檔案複製到壞的控制檔案位置後,可以輕鬆地重新啟動例項。 It is recommended that a second copy of the control file is available so an instance can be easily restarted after copying the good control file to the location of the bad control file.
5.LOG_ARCHIVE_DEST_1
示例: LOG_ARCHIVE_DEST_1= 'LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=chicago'
6.LOG_ARCHIVE_DEST_2
示例: LOG_ARCHIVE_DEST_2= 'SERVICE=boston ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=boston' 說明: LOG_ARCHIVE_DEST_n 指定重做資料在主系統和備用系統上的存檔位置。 Specify where the redo data is to be archived on the primary and standby systems. • LOG_ARCHIVE_DEST_1 將主資料庫生成的重做資料從本地聯機重做日誌檔案存檔到/arch1/chicago/中的本地存檔重做日誌檔案。 archives redo data generated by the primary database from the local online redo log files to the local archived redo log files in /arch1/chicago/. • LOG_ARCHIVE_DEST_2 僅對主角色有效。 is valid only for the primary role. 此目的地將重做資料傳輸到遠端物理備用目的地。 This destination transmits redo data to the remote physical standby destination boston. Note: 如果已配置快速恢復區域(使用DB_RECOVERY_FILE_DEST引數),但您尚未使用local屬性顯式配置本地存檔目標, If a fast recovery area was configured (with the DB_RECOVERY_FILE_DEST initialization parameter) and you have not explicitly configured a local archiving destination with the LOCATION attribute, Oracle Data Guard會自動使用LOG_ARCHIVE_DEST_1初始化引數(如果尚未設定)作為本地存檔的預設目標。 Oracle Data Guard automatically uses the LOG_ARCHIVE_DEST_1 initialization parameter (if it has not already been set) as the default destination for local archiving. 另外,有關完整的日誌存檔目標資訊,請參閱日誌存檔目標引數屬性。 Also,see LOG_ARCHIVE_DEST_n Parameter Attributes for complete LOG_ARCHIVE_DEST_n information.
7.REMOTE_LOGIN_PASSWORDFILE
示例: REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE 說明: 如果遠端登入密碼檔案用於驗證管理使用者或重做傳輸會話,則必須將此引數設定為EXCLUSIVE或SHARED。 This parameter must be set to EXCLUSIVE or SHARED if a remote login password file is used to authenticate administrative users or redo transport sessions.
8.LOG_ARCHIVE_FORMAT
示例: LOG_ARCHIVE_FORMAT=%t_%s_%r.arc 說明: 使用執行緒(%t)、序列號(%s)和resetlogs ID(%r)指定已存檔重做日誌檔案的格式。 Specify the format for the archived redo log files using a thread (%t), sequence number (%s), and resetlogs ID (%r).
下面顯示了主資料庫上的其他備用角色初始化引數。
The following shows the additional standby role initialization parameters on the primary database.
這些引數在主資料庫轉換為備用角色時生效。
These parameters take effect when the primary database is transitioned to the standby role.
1.FAL_SERVER
示例: FAL_SERVER=boston 說明: 指定FAL伺服器的Oracle Net服務名稱(通常這是以主角色執行的資料庫)。 Specify the Oracle Net service name of the FAL server (typically this is the database running in the primary role). 當Chicago資料庫以備用角色執行時,如果Boston無法自動傳送丟失的日誌檔案,它將使用Boston資料庫作為FAL伺服器,從中獲取(請求)丟失的存檔重做日誌檔案。 When the Chicago database is running in the standby role, it uses the Boston database as the FAL server from which to fetch (request) missing archived redo log files if Boston is unable to automatically send the missing log files.
2.DB_FILE_NAME_CONVERT
示例: DB_FILE_NAME_CONVERT='/boston/','/chicago/' 說明: 指定備用資料庫資料檔案的路徑名和檔名位置,後跟主位置。 Specify the path name and filename location of the standby database data files followed by the primary location. 此引數將主資料庫資料檔案的路徑名轉換為備用資料檔案路徑名。 This parameter converts the path names of the primary database data files to the standby data file path names. 此引數僅用於轉換物理備用資料庫的路徑名。 This parameter is used only to convert path names for physical standby databases. 此引數可以指定多對路徑。 Multiple pairs of paths may be specified by this parameter.
3.LOG_FILE_NAME_CONVERT
示例: LOG_FILE_NAME_CONVERT='/boston/','/chicago/' 說明: 指定備用資料庫聯機重做日誌檔案的位置,後跟主位置。 Specify the location of the standby database online redo log files followed by the primary location. 此引數將主資料庫日誌檔案的路徑名轉換為備用資料庫上的路徑名。 This parameter converts the path names of the primary database log files to the path names on the standby database. 此引數可以指定多對路徑。 Multiple pairs of paths may be specified by this parameter.
4.STANDBY_FILE_MANAGEMENT
示例: STANDBY_FILE_MANAGEMENT=AUTO 說明: 設定為AUTO,這樣當資料檔案新增到主資料庫或從主資料庫中刪除時,將自動對備用資料庫進行相應的更改。 Set to AUTO so when data files are added to or dropped from the primary database, corresponding changes are made automatically to the standby database.
六:請描述如果DG備庫伺服器要回收,如何關閉DG同步關係。
1.主庫:檢查當前引數值log_archive_dest_state_2、log_archive_dest_2、log_archive_config。
su - oracle sqlplus / as sysdba col name for a30 col value for a100 set line 200 select name,value from v$parameter where name in('log_archive_dest_state_2', 'log_archive_dest_2', 'log_archive_config'); NAME VALUE ------------------------------ ---------------------------------------------------------------------------------------------------- log_archive_dest_2 service=HCJCDB valid_for=(online_logfiles,primary_roles) db_unique_name=CJCDB compression=enable log_archive_dest_state_2 ENABLE log_archive_config dg_config=(XXCJCDB,CJCDB)
2.主庫:修改DG引數,停止DG同步關係
alter system set log_archive_dest_state_2=defer; alter system set log_archive_dest_2=''; alter system set log_archive_config='';
3.檢查修改後引數值
select name,value from v$parameter where name in('log_archive_dest_state_2', 'log_archive_dest_2', 'log_archive_config');
4.停止備庫
export ORACLE_SID=CJCDB1 sqlplus / as sysdba 檢查會話確認無業務會話 select username,status,count(*) from gv$session group by username,status; 關閉資料庫例項 shutdown immediate
七:請描述在DG執行SWITCHOVER前需要注意什麼。
1.資料庫版本、補丁版本。 2.DG相關引數配置是否正確。 檢查DB_UNIQUE_NAME、LOG_ARCHIVE_CONFIG、LOG_ARCHIVE_DEST_1、LOG_ARCHIVE_DEST_2、DB_FILE_NAME_CONVERT、LOG_FILE_NAME_CONVERT等引數。 3.檢查最近半年監聽連線資訊,避免漏掉某個連線資料庫的系統。 4.申請停機視窗。 5.作業系統相關配置 因為DG切換後,不僅僅是資料庫的切換,同時也是作業系統,伺服器,網路的切換,至少需要檢查如下內容: (1)資料庫伺服器上作業系統使用者是否一致。 (2)資料庫伺服器上作業系統crontab等計劃任務是否一致。 (3)tnsnames是否一致。 (4)如有directory,檢查是否一致。 (5)如有NAS掛載,檢查是否一致。
八:請描述在DG主、備庫都是二節點RAC的場景下,執行SWITCHOVER的過程。
###1 查詢主庫狀態
ssh 192.168.1.100 su - oracle export ORACLE_SID=cjcdb1 sqlplus / as sysdba SELECT DATABASE_ROLE,SWITCHOVER_STATUS FROM v$DATABASE; /* NOT ALLOWED 當前的資料庫不是帶有備用資料庫的主資料庫 PREPARING DICTIONARY 該邏輯備用資料庫正在向一個主資料庫和其他備用資料庫傳送它的重做資料,以便為切換做準備 PREPARING SWITCHOVER 接受用於切換的重做資料時,邏輯備用配置會使用它 RECOVERY NEEDED 備用資料庫還沒有接收到切換請求 SESSIONS ACTIVE 在主資料庫中存在活動的SQL會話;在繼續執行之前必須斷開這些會話 SWITCHOVER PENDING 適用於那些已收到主資料庫切換請求但是還沒有處理該請求的備用資料庫 SWITCHOVER LATENT 切換沒有完成並返回到主資料庫 TO LOGICAL STANDBY 主資料庫已經收到了來自邏輯備用資料庫的完整的字典 TO PRIMARY 該備用資料庫可以轉換為主資料庫 TO STANDBY 該主資料庫可以轉換為備用資料庫 */
###2 停用備庫2節點
ssh 10.10.10.200 su - oracle sqlplus / as sysdba show parameter instance_name shutdown immediate
###3 停用主庫2節點
ssh 192.168.1.200 export ORACLE_SID=trnt2 sqlplus / as sysdba shutdown immediate
###4 主庫驗證GAP(不能大於3)
ssh 192.168.1.100 export ORACLE_SID=cjcdb1 sqlplus / as sysdba SELECT LOG_ARCHIVED - LOG_APPLIED + 1 LOGGAP FROM (SELECT MAX(SEQUENCE#) LOG_ARCHIVED FROM V$ARCHIVED_LOG WHERE DEST_ID = 1 AND ARCHIVED = 'YES' AND RESETLOGS_CHANGE# = (SELECT MAX(RESETLOGS_CHANGE#) FROM V$ARCHIVED_LOG)), (SELECT MAX(SEQUENCE#) LOG_APPLIED FROM V$ARCHIVED_LOG WHERE DEST_ID = 2 AND APPLIED = 'YES' AND RESETLOGS_CHANGE# = (SELECT MAX(RESETLOGS_CHANGE#) FROM V$ARCHIVED_LOG));
###5 主切備
ssh 192.168.1.100 export ORACLE_SID=cjcdb1 sqlplus / as sysdba SELECT trim(DATABASE_ROLE) DBROLE FROM v$DATABASE; alter system switch logfile; alter system flush SHARED_POOL; ---啟動trace,方便問題排查 ALTER SYSTEM SET log_archive_trace=8191 sid='*'; ---執行命令後,原主庫自動關閉例項 alter database commit to switchover to physical standby with session shutdown; startup mount
###6 備切主
ssh 10.10.10.100 su - oracle sqlplus / as sysdba show parameter instance_name SELECT trim(DATABASE_ROLE) DBROLE FROM v$DATABASE; ALTER SYSTEM SET log_archive_trace=8191 sid='*'; ---執行命令後,原備庫自動啟動到mount alter database commit to switchover to primary with session shutdown; shutdown immediate; startup; set lin 200 pages 100 set lin 200 pages 100 col FLASHBACK_ON for a10 col current_scn for 99999999999999 col open_mode for a10 col SWITCHOVER_STATUS for a20 col PROTECTION_MODE for a20 select current_scn,protection_mode,database_role,force_logging,FLASHBACK_ON,open_mode,switchover_status from v$database; ---關閉trace ALTER SYSTEM SET log_archive_trace=0 sid='*';
###7 新備庫啟動mrp
ssh 192.168.1.100 export ORACLE_SID=cjcdb1 sqlplus / as sysdba alter database open; ALTER SYSTEM SET log_archive_trace=0 sid='*'; recover managed standby database using current logfile disconnect from session;
###8 新備庫啟動節點2
ssh 192.168.1.200 export ORACLE_SID=cjcdb1 startup
###9 新主庫啟動節點2
ssh 10.116.7.88 export ORACLE_SID=trnt2 sqlplus / as sysdba show parameter instance_name startup
###10 新備庫檢查
ssh 192.168.1.100 export ORACLE_SID=cjcdb1 sqlplus / as sysdba SELECT status from v$instance; set lin 200 pages 200 select process,status,thread#,sequence#,block#,blocks from v$managed_standby; set lin 200 pages 100 col FLASHBACK_ON for a10 col current_scn for 99999999999999 col open_mode for a10 col SWITCHOVER_STATUS for a20 col PROTECTION_MODE for a20 select current_scn, protection_mode, database_role, force_logging, FLASHBACK_ON, open_mode, switchover_status from v$database;
###11 新主庫檢查
ssh 10.10.10.100 export ORACLE_SID=cjcdb1 sqlplus / as sysdba SELECT status from v$instance;
九:請描述Oracle DG FAILOVER過程
set lin 200 pages 100 set lin 200 pages 100 col FLASHBACK_ON for a10 col current_scn for 99999999999999 col open_mode for a10 col SWITCHOVER_STATUS for a20 col PROTECTION_MODE for a20 select current_scn,protection_mode,database_role,force_logging,FLASHBACK_ON,open_mode,switchover_status from v$database; alter database recover managed standby database cancel; alter database recover managed standby database finish; select current_scn,protection_mode,database_role,force_logging,FLASHBACK_ON,open_mode,switchover_status from v$database; alter database commit to switchover to primary with session shutdown; select current_scn,protection_mode,database_role,force_logging,FLASHBACK_ON,open_mode,switchover_status from v$database; ###mount alter database open;
十:請描述Oracle DG GAP問題處理方法。
檢查備庫缺失的歸檔 SELECT * FROM V$ARCHIVE_GAP; SELECT NAME FROM V$ARCHIVED_LOG WHERE THREAD#=1 AND DEST_ID=1 AND SEQUENCE# BETWEEN 43968 AND 50948;
場景1:檢查主庫是否還有這些歸檔
如果有日誌檔案未被傳輸或未被註冊到備庫,那麼可以使用如下命令手工註冊到備庫。 下面的SQL語句可以生成物理和邏輯DG註冊的SQL語句,日誌號從1980到2000: 如果還有通常情況下會自動解決,也可以手動傳輸到備庫,執行註冊操作。 SELECT 'alter database register or replace logical logfile ''/arch/log_1_' || A || ' _666200636.arc'';' LOGICAL_DG, 'alter database register or replace logfile ''/arch/log_1_' || A || ' _666200636.arc'';' PHYSICAL_DG FROM (SELECT LEVEL A FROM DUAL CONNECT BY LEVEL <= 2000) WHERE A >= 1980; alter database register logfile 'XXXXX';
場景2:檢查主庫和備庫沒有這些歸檔
但是備份檔案中有這些歸檔,可以透過備份恢復歸檔檔案。 http://blog.itpub.net/29785807/viewspace-2729496/ 檢視備庫節點1本地歸檔日誌,顯示已經沒有thread 1 sequence 99924-99925了。 rman target / list archivelog all; 檢視控制檔案記錄的備份中是存在thread 1 sequence 99924-99925歸檔 list backup of archivelog all; 手動將缺失的歸檔restore restore archivelog sequence between 99924 and 99925 thread 1;
場景3:主備庫、備份中都沒有這些歸檔
http://blog.itpub.net/29785807/viewspace-2147373/ (1)如果資料量很小,可以考慮重建備庫; (2)如果資料量很大,可以使用Rman基於SCN的增量備份來修復GAP問題; 確定增量恢復的起始SCN號 select file#,checkpoint_change# from v$datafile order by checkpoint_change#; 主庫:使用Rman基於SCN的增量備份,並將備份檔案傳輸到備庫 run { allocate channel c3 device type disk; backup as compressed backupset incremental from scn 1879904814 database format '/home/oracle/rman1116/%U'; release channel c3; } 備庫:恢復控制檔案 RMAN> restore standby controlfile from '/home/oracle/rman1116/12sjnabm_1_1'; SQL> alter database mount standby database; 恢復備庫 RMAN> catalog start with '/home/oracle/rman1116'; RMAN> recover database; 驗證備庫,並啟動mrp SQL> alter database open;
十一:請描述Oracle DG有哪些程式?
1.LNSn(LGWR Network Server process)程式 DG可以使用ARCn、LGWR來傳送日誌,但它們都是把日誌傳送給本地的LNSn(如果有多個目標備庫,那麼會啟動相應數量的LNSn程式,同時傳送資料)程式,然後備庫的RFS程式接收資料,接收到的資料可以儲存在備庫的備用Redo日誌檔案中或備庫的歸檔日誌中,然後再應用到備庫中。
2.RFS(Remote File Server)程式 RFS(Remote File Server)程式主要用來接受從主庫傳送過來的日誌資訊。 對於物理備庫而言,RFS程式可以直接將日誌寫進Standby Redo logs,也可以直接將日誌資訊寫到歸檔日誌中。
3.NSA,NSS 需要注意的是,若在Oracle 10g中採用LGWR傳輸日誌的時候,則程式表現為LNSn。 但在Oracle 11g中,若採用LGWR ASYNC(非同步方式)來傳輸日誌的時候,則程式表現為nsa。 若採用LGWR SYNC(同步方式)來傳輸日誌的時候,則程式表現為nss。 且透過檢視GV$MANAGED_STANDBY查詢的結果不盡相同。
4.MRP(Managed Recovery Process)程式 該程式只針對物理備庫,作用為應用從主庫傳遞過來的Redo日誌到物理備庫,稱為Redo Apply。 如果使用SQL語句“ALTER DATABASE RECOVER MANAGED STANDBY DATABASE”啟用該程式,那麼前臺程式將會做恢復。 如果加上DISCONNECT語句,那麼恢復過程將在後臺程式,發出該語句的程式可以繼續做其它的事情。
5.LSP(logical standby process)程式 只有邏輯備庫才會有該程式。 LSP程式控應用Redo日誌到邏輯備庫。
十二:請描述Oracle DG常用命令。
1.檢查備庫是否是real time apply模式
set lines 200 col dest_name for a30 select DEST_ID,DEST_NAME,RECOVERY_MODE from v$archive_dest_status where RECOVERY_MODE <>'IDLE'; #RECOVERY_MODE=MANAGED REAL TIME APPLY 為 real time apply,否則不是
2.啟動和關閉mrp
實時應用 ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL; ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION; 非實時應用 ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL; ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
3.檢視DG程式狀態
set lin 200 pages 200 select process,status,thread#,sequence#,block#,blocks from v$managed_standby;
4.主庫傳輸狀態檢查
col dest_name for a30 col error for a50 set lin 200 pages 100 select dest_id,error,status,log_sequence,applied_scn,MAX_CONNECTIONS,NET_TIMEOUT,COMPRESSION from v$archive_dest where dest_id<5; 如有必要重新啟用傳輸 ###alter system set log_archive_dest_state_2=defer; ###alter system set log_archive_dest_state_2=enable;
5.檢視資料庫資訊
set lin 200 pages 100 col FLASHBACK_ON for a10 col current_scn for 99999999999999 col open_mode for a10 col SWITCHOVER_STATUS for a20 col PROTECTION_MODE for a20 select current_scn,protection_mode,database_role,force_logging,FLASHBACK_ON,open_mode,switchover_status from v$database;
#####chenjuchao 202100725 15:15#####
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29785807/viewspace-2783162/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle面試寶典-鎖篇Oracle面試
- Oracle 面試寶典-RAC篇Oracle面試
- Oracle 面試寶典-UNDO篇Oracle面試
- Oracle面試寶典-等待事件篇Oracle面試事件
- Oracle面試寶典-引數篇Oracle面試
- Oracle面試寶典-事務篇Oracle面試
- Oracle面試寶典-程式結構篇Oracle面試
- Oracle面試寶典-記憶體結構篇Oracle面試記憶體
- Redis面試寶典-持久化篇Redis面試持久化
- MySQL面試寶典-檔案篇MySql面試
- 面試寶典面試
- MySQL面試寶典-主從複製篇MySql面試
- Python面試寶典之基礎篇-05Python面試
- iOS跳槽寶典-面試技術基礎篇iOS面試
- Java 面試寶典Java面試
- PHP面試寶典PHP面試
- iOS 面試寶典iOS面試
- C++面試寶典C++面試
- Java面試葵花寶典Java面試
- 大資料面試寶典五大資料面試
- Java面試寶典-2017Java面試
- Web前端面試寶典(最新)Web前端面試
- 新書出版 |《Oracle程式設計師面試筆試寶典》新書Oracle程式設計師面試筆試
- 好程式設計師Java教程之Java面試寶典Java IO篇程式設計師Java面試
- Java面試寶典之開源框架!Java面試框架
- Oracle 資料庫應急寶典(二)_引數檔案篇Oracle資料庫
- android程式設計師面試寶典Android程式設計師面試
- Java面試寶典2010版Java面試
- 2019最新前端面試寶典前端面試
- Java面試寶典之—-java基礎(含答案)Java面試
- Netbackup For Oracle client安裝寶典Oracleclient
- 面試寶典:15道MyBatis 常見面試題彙總及答案MyBatis面試題
- 【JAVA面試資料】程式設計師面試之葵花寶典1Java面試程式設計師
- 【JAVA面試資料】程式設計師面試之葵花寶典2Java面試程式設計師
- Java初中級程式設計師面試題寶典Java程式設計師面試題
- Kubernetes面試題寶典,建議收藏哦!面試題
- 12個程式設計師筆試面試寶典程式設計師筆試面試
- Java面試寶典2010(一.51—83)Java面試