通過Oracle 11g 邏輯standby實現BI的需求
想到可以試試邏輯standby去實現,同步生產庫的基礎資料使用者,並在邏輯standby上建BI相關的使用者,用做資料統計.這樣可以避免直接通過dblink或物化檢視抓取資料對生
產庫的效能影響,又比利用goldengate實現同步在維護性上方便.
一.建立邏輯standby官方文件及註釋:
Applies to:
Oracle Database - Enterprise Edition - Version 10.2.0.1 to 12.1.0.2 [Release 10.2 to 12.1]Information in this document applies to any platform.
***Checked for relevance on 21-Sep-2012***
*** Reviewed for Relevance 16-Jul-2015 ***
Goal
Step by Step Guide on How to Create Logical Standby
Solution
Prerequisite
--必要條件
1 : Before setting up a logical standby database, ensure the logical
standby database can maintain the data types and tables in your primary
database. See Appendix C of the dataguard documentation for a complete
list of data type and storage type considerations.
--確定資料庫中的資料型別和儲存型別支援
2 : Ensure Table Rows in the Primary Database Can Be Uniquely Identified.
--確定表中各行的唯一性,儘量有主鍵或唯一索引
2.1 : Find Tables Without Unique Logical Identifier in the Primary Database.
Use following query to display a list of tables that SQL Apply may not be able to uniquely identify:
2.2 : If your application ensures the rows in a
table are unique, you can create a disabled primary key RELY constraint
on the table. Use ALTER TABLE command to add a disabled primary-key
RELY constraint.
The following example creates a disabled RELY
constraint on a table named mytab, for which rows can be uniquely
identified using the id and name columns:
Creating a Logical Standby Database:
--建立邏輯standby
Step 1 Create a Physical Standby Database
--建邏輯standby,要先建一個物理standby,然後再進行轉換
Create a Physical Standby Database and make sure that there is no error in remote archiving to Standby from Primary Database.
Please refer following documentations for creating physical standby database:
For 10.2:
Oracle? Data Guard Concepts and Administration 10g Release 2 (10.2)
http://download.oracle.com/docs/cd/B19306_01/server.102/b14239/create_ps.htm#i63561
For 11.1:
Oracle? Data Guard Concepts and Administration 11g Release 1 (11.1)
http://download.oracle.com/docs/cd/B28359_01/server.111/b28294/create_ps.htm#i63561
Step 2 Make Sure that Physical Standby is in Sync with Primary Database
--在物理standby上執行,檢視跟主庫的同步情況
Use following query on Standby to check:
FROM
(SELECT THREAD# ,SEQUENCE# FROM V$ARCHIVED_LOG WHERE (THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST_TIME) FROM V$ARCHIVED_LOG GROUP BY THREAD#)) ARCH,
(SELECT THREAD# ,SEQUENCE# FROM V$LOG_HISTORY WHERE (THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST_TIME) FROM V$LOG_HISTORY GROUP BY THREAD#)) APPL
WHERE
ARCH.THREAD# = APPL.THREAD#
ORDER BY 1;
/*
Thread Last Sequence Received Last Sequence Applied
1 60 60
*/
There should not be any difference in Last Seq Received and Last Seq Applied on Physical Standby.
Step 3 Stop Redo Apply on the Physical Standby Database
--停止物理standby的redo應用
Step 4 Set Parameters for Logical Standby in Primary
--設定主庫的日誌歸檔目錄,LOG_ARCHIVE_DEST_3的設定是為了主庫切換後使用
4.1. Change VALID_FOR in LOG_ARCHIVE_DEST_1 on Primary to (ONLINE_LOGFILES,ALL_ROLES)
4.2. Set LOG_ARCHIVE_DEST_3 for logs which will received on Standby from Primary
LOG_ARCHIVE_DEST_STATE_3=ENABLE
Note: LOG_ARCHIVE_DEST_3 only takes effect when the primary database is transitioned to the logical standby role.
Step 5 Build a Dictionary in the Redo Data on Primary Database
--在主庫上生成logminer字典資訊
The DBMS_LOGSTDBY.BUILD procedure waits for all existing
transactions to complete. Long-running transactions executed on the
primary database will affect the timeliness of this command.
Step 6 Convert to a Logical Standby Database
--轉換物理standby到邏輯standby,db_name是要指定一個新的邏輯standby 的db_name
For db_name, specify a database name to identify the new logical
standby database. If you are using a spfile for standby, then command
will update the db_name parameter otherwise it will issues a message
reminding you to set the name of the DB_NAME parameter after shutting
down the database.
Step 7 Create a New Password File for Logical Standby Database
--新建密碼檔案,這個在10g需要執行,11g原有的就可以
This step is required in 10.2 only and should not be performed in 11g.
Step 8 Shutdown and Startup Logical Standby Database in Mount Stage
--關閉邏輯standby並開戶到mount狀態
SQL> STARTUP MOUNT;
Step 9 Adjust Initialization Parameter on Logical Standby Database
--轉換為邏輯standby後,修改原有的日誌歸檔目錄
LOG_ARCHIVE_DEST_2= 'SERVICE=prim1 LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=prim1'
LOG_ARCHIVE_DEST_3= 'LOCATION=/u01/arch/standby/ VALID_FOR=(STANDBY_LOGFILES,STANDBY_ROLE) DB_UNIQUE_NAME=logstd1'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
LOG_ARCHIVE_DEST_STATE_3=ENABLE
Step 10 Open the Logical Standby Database
--以resetlogs方式開啟資料庫
Step 11 Start Logical Apply on Standby
--開啟sql apply,這裡的immediate是要實時應用,需要有standby redo log支援,如果不需要實時應用,可不加immediate.
二.邏輯standby建立完成後的一些設定
--在邏輯standby上將guard設定為standby,實現能在邏輯standby建立BI相關的使用者
SQL>alter database guard standby;
--在邏輯standby上使用dbms_logstdby.skip跳過不需要同步的使用者的表
SQL>alter database stop logical standby apply;
SQL>exec dbms_logstdby.skip(stmt=>'SCHEMA_DDL',SCHEMA_NAME=>'HR',OBJECT_NAME=>'%');
SQL>exec dbms_logstdby.skip(stmt=>'DML',SCHEMA_NAME=>'HR',OBJECT_NAME=>'%');
SQL>alter database start logical standby apply;
如果將來需要將跳過的表重新新增回來
SQL>alter database stop logical standby apply;
通過exec dbms_logstdby.unskip新增回來
通過dbms_logstdby.instantiate_table同步,這裡需要建dblink
SQL>alter database start logical standby apply;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28539951/viewspace-1776691/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- oracle邏輯讀過程Oracle
- 邏輯STANDBY建立中碰到ORA-16146: standby destination control file enqueue unavailableENQAI
- 4 Creating a Logical Standby Database 建立邏輯備庫Database
- 通過ORACLE VM virtualbox環境安裝oracle 11G RAC(ASM)OracleASM
- 邏輯STANDBY負載高,應用緩慢的解決負載
- 邏輯STANDBY上的ORA-00600: internal error code, arguments: [krvtadc], [], [], [], [], []Error
- 解析jwt實現邏輯JWT
- PostgreSQL,SQLServer邏輯增量(通過邏輯標記update,delete)同步到Greenplum,PostgreSQLSQLServerdelete
- oracle 邏輯結構Oracle
- Oracle的快照standbyOracle
- 通過實驗理解PG邏輯結構:1 使用者(角色)
- redis實現文章投票邏輯Redis
- 實現拼團業務邏輯
- Oracle OCP(41):邏輯結構Oracle
- Java通過Mybatis實現批量插入資料到Oracle中JavaMyBatisOracle
- MyBatis-Plus之邏輯刪除的實現MyBatis
- 圖解MySQL邏輯備份的實現流程圖解MySql
- 聊聊支付流程的設計與實現邏輯
- 原生 JS 實現 HTML 轉 Markdown,以及其實現邏輯JSHTML
- 聊聊訊息中心的設計與實現邏輯
- 通過佇列實現棧OR通過棧實現佇列佇列
- Flutter 的渲染邏輯及和 Native 通訊Flutter
- 通過三款遊戲,淺談遊戲BOSS戰的邏輯設計遊戲
- 簡單的幾條Insert語句引起的邏輯Standby應用延遲的診斷
- Verilog 邏輯綜合過程
- oracle邏輯備份之--資料泵Oracle
- SAP CRM 裡 Attachment 搜尋的實現邏輯介紹
- Vue主要原理最簡實現與邏輯梳理Vue
- 邏輯迴歸演算法推理與實現邏輯迴歸演算法
- oracle中通過decode實現行變列的二維表統計展示Oracle
- LRU 實現 通過 LinkedHashMapHashMap
- 通過模板實現POI
- 《Spring Boot 實戰紀實》缺失的邏輯Spring Boot
- 【ASK_ORACLE】Oracle Data Guard(三)邏輯備庫的概念和優勢Oracle
- 3:Oracle體系結構(邏輯結構)Oracle
- Oracle DG Standby Database型別OracleDatabase型別
- Oracle DG建立Physical Standby DatabaseOracleDatabase
- Oracle DG建立Logical Standby DatabaseOracleDatabase
- Java程式呼叫expdp資料泵實現自動邏輯備份Oracle資料庫的方案設計JavaOracle資料庫