在一般環境中很常看到 RAC+ Active Data Guard 或者 RAC + Golden Gate 的配置
以下介紹 ADG + OGG 配置, 不從主庫這次從備庫同步到OGG的DB
*.RAC + ADG + OGG 跟這次所說的配置其實大同小異 , 這一篇看完 RAC + ADG + OGG 應該也就會建立了
環境說明
10.10.17.27 主庫
10.10.17.28 備庫(Active Data Guard)
10.10.17.30 備庫(Golden Gate)
安裝 Active Data Guard 就不再說明,這邊就直接配置 Active Data Guard (10.10.17.28)+ Golden gate (10.10.17.30) 同步操作
10.10.17.27 28 tnsnames.ora 內容
[oracle@ora28 admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /ORA/11.2.4/db/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
ora27 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.17.27)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SID = orcl)
)
)
ora28 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.17.28)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SID = orcl)
)
)
1.(10.10.17.28) ADG 配置 mgr
設定 mgr
GGSCI (ora28) 1> edit param mgr
PORT 7809
dynamicportlist 7501-7505
autorestart extract *,waitminutes 2,retries 5
GGSCI (ora28) 3> start mgr
Manager started.
2.(10.10.17.28) ADG 配置 Extract
GGSCI (ora28) 4> dblogin userid ogg,password ogg
Successfully logged into database.
GGSCI (ora28 as ogg@LG) 5>
GGSCI (ora28 as ogg@LG) 5> add extract ext1, tranlog,begin now
EXTRACT added.
GGSCI (ora28 as ogg@LG) 6> edit params ext1
#因為 28 是備庫 read only , 所以這邊這邊登入27 主庫,且只讀取 archivedlog
所以說必須等到主庫switch logfile , extract 才會擷取資料丟過去 30
userid ogg@ora27,password ogg
tranlogoptions archivedlogonly
tranlogoptions altarchivelogdest /ORA/ARCH
exttrail /ORA/ogg/dirdat/ex
discardfile /ORA/ogg/dirrpt/exta.dsc,append, megabytes 500
table VJ.*;
GGSCI (ora28 as ogg@LG) 7> ADD EXTTRAIL /ORA/ogg/dirdat/ex, EXTRACT ext1
EXTTRAIL added.
GGSCI (ora28 as ogg@LG) 8>
3.(10.10.17.28) ADG 配置 第二個 extract (data dump)
GGSCI (ora28 as ogg@LG) 8> edit params pump1
EXTRACT dump1
RMTHOST 10.10.17.30, MGRPORT 7809 TCPBUFSIZE 5000000
PASSTHRU
RMTTRAIL /ORA/ogg/dirdat/pt
NUMFILES 3000
TABLE VJ.*;
*rmthost :為目的端的IP及Port
*rmttrail :為目的端的接收資料檔的位置
#.這邊配置 要從哪裡取資料
GGSCI (ora28 as ogg@LG) 9> add extract dump1, exttrailsource /ORA/ogg/dirdat/ex
EXTRACT added.
GGSCI (ora28 as ogg@LG) 10>
#.這邊配置要把檔案傳去Target 哪一個位置
GGSCI (ora28 as ogg@LG) 10> add rmttrail /ORA/ogg/dirdat/pt, extract dump1, megabytes 10
RMTTRAIL added.
啟動 dump 跟 ext
GGSCI (ora28 as ogg@LG) 17> start dump1
Sending START request to MANAGER ...
EXTRACT DUMP1 starting
Sending START request to MANAGER ...
EXTRACT EXT1 starting
GGSCI (ora28 as ogg@LG) 25> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
EXTRACT RUNNING DUMP1 00:00:00 00:00:08
EXTRACT RUNNING EXT1 01:52:30 00:00:01
GGSCI (ora28 as ogg@LG) 26>
4.(10.10.17.30) OGG 配置 checkpoing table
GGSCI (datagu) 1> dblogin userid ogg,password ogg
Successfully logged into database.
GGSCI (datagu as ogg_tar@orclogg) 2> add checkpointtable ogg.ogg_chk
Successfully created checkpoint table ogg.ogg_chk
將 checkpoint table 設定在 golden gate 裡頭
edit params ./GLOBALS
GGSCHEMA OGG
CHECKPOINTTABLE OGG.OGG_CHK
5.(10.10.17.30) OGG 配置 Peplicat
新增Peplicat
GGSCI (ora30 as ogg@LG) 2> add replicat rep01,exttrail /ORA/ogg/dirdat/pt,checkpointtable OGG.OGG_CHK
REPLICAT added.
*.這邊設定要從哪裡讀取從target丟過來的檔案
設定參數
GGSCI (ora30 as ogg@LG) 3> edit params rep01
replicat rep01
setenv (ORACLE_SID=orcl)
userid ogg,password ogg
assumetargetdefs
reperror default,discard
discardfile /ORA/ogg/dirdat/repl.dsc,append,megabytes 50
dynamicresolution
DDL INCLUDE ALL
DDLERROR DEFAULT IGNORE RETRYOP MAXRETRIES 3 RETRYDELAY 5
map VJ.*, target VJ.*;
6.啟動 (10.10.17.30) Peplicat
GGSCI (ora30 as ogg@LG) 4> start rep01
Sending START request to MANAGER ...
REPLICAT REP01 starting
GGSCI (ora30 as ogg@LG) 5> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
REPLICAT RUNNING REP01 00:00:00 00:00:01
GGSCI (ora30 as ogg@LG) 6>
看一下有無錯誤
GGSCI (ora30 as ogg@LG) 7> view report rep01
.
.
.
.
.
Database Language and Character Set:
NLS_LANGUAGE = "AMERICAN"
NLS_TERRITORY = "AMERICA"
NLS_CHARACTERSET = "AL32UTF8"
***********************************************************************
** Run Time Messages **
***********************************************************************
2017-07-12 13:45:53 INFO OGG-02243 Opened trail file /ORA/ogg/dirdat/pt000000000 at 2017-07-12 13:45:53.977593.
看來有正常讀取到
7.主庫27進行操作 並且執行 alter system switch logfile; 再去看看備庫30有無資料
-----------
在RAC 環境時 ext1 還需要設定
TRANLOGOPTIONS altarchivelogdest primary instance orcl1 /u02/Archive/ORCL/, altarchivelogdest instance orcl2 /u03/Archive/ORCL/
來配置 rac1 及 rac2 的位置