1. 程式人生 > >oracle ogg 單機環境單向復制搭建

oracle ogg 單機環境單向復制搭建

oracle ogg

OGG安裝

fbo_ggs_Linux_x64_shiphome.zip---------------------同時支持11g12c

添加用戶

useradd -u 1003 -g oinstall -G dba ogg

配置環境變量

export ORACLE_BASE=/u01/app/oracle;

export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1;

export ORACLE_SID=racdb1;

export OGG_HOME=$ORACLE_BASE/ogg

export PATH=$ORACLE_HOME/bin:$PATH:/home/oracle/bin:$OGG_HOME/;

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/u01/app/oracle/ogg/:/lib:/usr/lib;

export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib;

安裝時註意目錄

2、找不到ggMessage

Cannot load ICU resource bundle‘ggMessage‘, error code 2 - No such file or directory

Aborted (core dumped)

解決方法:oracle goldengateHOME目錄下執行

GGSCI (oggtarget) 2> help

GGSCI Command Summary:

Object: Command:

SUBDIRS CREATE

DATASTORE ALTER, CREATE, DELETE, INFO, REPAIR

ER INFO, KILL, LAG, SEND, STATUS,START, STATS, STOP

EXTRACT ADD, ALTER, CLEANUP, DELETE, INFO,KILL,

LAG, REGISTER, SEND, START,STATS, STATUS, STOP

UNREGISTER

EXTTRAIL ADD, ALTER, DELETE, INFO

GGSEVT VIEW

JAGENT INFO, START, STATUS, STOP

MANAGER INFO, SEND, START, STOP, STATUS

MARKER INFO

PARAMETERS EDIT, VIEW, SET EDITOR, INFO,GETPARAMINFO

REPLICAT ADD, ALTER, CLEANUP, DELETE, INFO,KILL, LAG, REGISTER, SEND,

START, STATS, STATUS, STOP,SYNCHRONIZE, UNREGISTER

REPORT VIEW

RMTTRAIL ADD, ALTER, DELETE, INFO

TRACETABLE ADD, DELETE, INFO

TRANDATA ADD, DELETE, INFO

SCHEMATRANDATA ADD, DELETE, INFO

CHECKPOINTTABLE ADD, DELETE, CLEANUP, INFO, UPGRADE

WALLET CREATE, OPEN, PURGE

MASTERKEY ADD, INFO, RENEW, DELETE, UNDELETE

CREDENTIALSTORE ADD, ALTER, INFO, DELETE

HEARTBEATTABLE ADD, DELETE, ALTER, INFO

HEARTBEATENTRY DELETE

Commands without an object:

(Database) DBLOGIN, LIST TABLES, ENCRYPT PASSWORD,FLUSH SEQUENCE

MININGDBLOGIN, SET NAMECCSID

(DDL) DUMPDDL

(Miscellaneous) ! ,ALLOWNESTED | NOALLOWNESTED, CREATESUBDIRS,

DEFAULTJOURNAL, FC, HELP,HISTORY, INFO ALL, OBEY, SHELL,

SHOW, VERSIONS, VIEW GGSEVT,VIEW REPORT

(note: type the word COMMANDafter the ! to display the

! help topic, for example:GGSCI (sys1)> help ! command

OGG配置

實驗規劃

項目



操作系統



主機名



數據庫版本



數據庫字符集



Oracle版本



Ogg版本



Oracle sid

dbdream

stream

主庫進行全備

$ rman target /

run {

allocate channel d0 type disk;

allocate channel d1 type disk;

backup format‘/u01/backup/full_t%t_s%s_p%p‘ database;

sql ‘alter system archive log current‘;

backup format ‘/u01/backup/arc_t%t_s%s_p%p‘archivelog all;

release channel d0;

release channel d1;

}

2.3.1 主庫備份

主庫進行全備

$ rman target /

run {

allocate channel d0 type disk;

allocate channel d1 type disk;

backup format‘/u01/backup/full_t%t_s%s_p%p‘ database;

sql ‘alter system archive log current‘;

backup format ‘/u01/backup/arc_t%t_s%s_p%p‘archivelog all;

release channel d0;

release channel d1;

}

創建備用控制文件

RMAN> backup current controlfile forstandby format ‘/u01/backup/control01.ctl‘;

scp * 192.168.120.203:/u01/backup

恢復

[[email protected] ~]$ export ORACLE_SID=stream

[[email protected] ~]$ rman target /

Recovery Manager: Release 11.2.0.4.0 -Production on Sun Aug 27 09:54:43 2017

Copyright (c) 1982, 2011, Oracle and/or itsaffiliates. All rights reserved.

connected to target database (not started)

RMAN> set dbid=2496948349

RMAN> startup nomount

startup failed: ORA-01078: failure inprocessing system parameters

LRM-00109: could not open parameter file‘/u01/app/oracle/product/11.2.0/db_1/dbs/initstream.ora‘

starting Oracle instance without parameterfile for retrieval of spfile

Oracle instance started

Total System Global Area 1068937216 bytes

Fixed Size 2260088 bytes

Variable Size 281019272 bytes

Database Buffers 780140544 bytes

Redo Buffers 5517312 bytes

註意:在rman下即使沒有參數文件,默認也會啟動一個DUMMY實例,以便能夠恢復參數文件。

1、恢復spfile

RMAN> restore spfile from‘/u01/backup/full_t953113531_s4_p1‘;

RMAN> sql "create pfile from spfile"

修改pfile參數

dbdream.__java_pool_size=4194304

dbdream.__large_pool_size=8388608

dbdream.__oracle_base=‘/u01/app/oracle‘#ORACLE_BASEset from environment

dbdream.__pga_aggregate_target=314572800

dbdream.__sga_target=465567744

dbdream.__shared_io_pool_size=0

dbdream.__shared_pool_size=117440512

dbdream.__streams_pool_size=0

*.audit_file_dest=‘/u01/app/oracle/admin/stream/adump‘-----------------------修改創建目錄

*.audit_trail=‘db‘

*.compatible=‘11.2.0.4.0‘

*.control_files=‘/u01/app/oracle/oradata/stream/control01.ctl‘,‘/u01/app/oracle/fast_recovery_area/stream/control02.ctl‘----修改

*.db_block_size=8192

*.db_domain=‘‘

*.db_name=‘stream‘-----修改

*.db_recovery_file_dest=‘/u01/app/oracle/fast_recovery_area‘

*.db_recovery_file_dest_size=4385144832

*.diagnostic_dest=‘/u01/app/oracle‘

*.dispatchers=‘(PROTOCOL=TCP)(SERVICE=streamXDB)‘

*.log_archive_format=‘%t_%s_%r.dbf‘

*.memory_target=780140544

*.open_cursors=300

*.processes=150

*.remote_login_passwordfile=‘EXCLUSIVE‘

*.undo_tablespace=‘UNDOTBS1‘

~

RMAN> shutdown abort

用新修改的文件啟動 nomount

RMAN> startup nomount pfile=‘/u01/app/oracle/product/11.2.0/db_1/dbs/initstream.ora‘

創建pfile

RMAN> sql "create spfile from pfile";

spfile啟動

RMAN> startup nomount;

RMAN> startup force nomount;

2、恢復控制文件

RMAN> restore controlfile from ‘/u01/backup/full_t953113527_s3_p1‘;

Starting restore at 27-AUG-17

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=19 device type=DISK

channel ORA_DISK_1: restoring control file

channel ORA_DISK_1: restore complete,elapsed time: 00:00:01

output filename=/u01/app/oracle/oradata/stream/control01.ctl

output filename=/u01/app/oracle/fast_recovery_area/stream/control02.ctl

Finished restore at 27-AUG-17

3、啟動數據庫到加載狀態

RMAN> alter database mount;

RMAN> catalog start with ‘/backup/‘;

RMAN> restore database;

RMAN> recover database;

RMAN>alter database open resetlogs 打開數據庫

nid target=/as sysdba dbname=stream

[[email protected] dbs]$ nid target=/assysdba dbname=stream

DBNEWID: Release 11.2.0.4.0 - Production onSun Aug 27 12:31:08 2017

Copyright (c) 1982, 2011, Oracle and/or itsaffiliates. All rights reserved.

Password:

Connected to database DBDREAM (DBID=2496948349)

Connected to server version 11.2.0

Control Files in database:

/u01/app/oracle/oradata/stream/control01.ctl

/u01/app/oracle/fast_recovery_area/stream/control02.ctl

Change database ID and database nameDBDREAM to STREAM? (Y/[N]) => y

Proceeding with operation

Changing database ID from 2496948349 to1719130576

Changing database name from DBDREAM toSTREAM

Control File /u01/app/oracle/oradata/stream/control01.ctl - modified

Control File /u01/app/oracle/fast_recovery_area/stream/control02.ctl -modified

Datafile /u01/app/oracle/oradata/dbdream/system01.db - dbid changed,wrote new name

Datafile /u01/app/oracle/oradata/dbdream/sysaux01.db - dbid changed,wrote new name

Datafile /u01/app/oracle/oradata/dbdream/undotbs01.db - dbid changed,wrote new name

Datafile /u01/app/oracle/oradata/dbdream/users01.db - dbid changed,wrote new name

Datafile /u01/app/oracle/oradata/dbdream/temp01.db - dbid changed, wrotenew name

Control File /u01/app/oracle/oradata/stream/control01.ctl - dbidchanged, wrote new name

Control File /u01/app/oracle/fast_recovery_area/stream/control02.ctl -dbid changed, wrote new name

Instance shut down

Database name changed to STREAM.

Modify parameter file and generate a newpassword file before restarting.

Database ID for database STREAM changed to1719130576.

All previous backups and archived redo logsfor this database are unusable.

Database is not aware of previous backupsand archived logs in Recovery Area.

Database has been shutdown, open databasewith RESETLOGS option.

Succesfully changed database name and ID.

DBNEWID - Completed succesfully.

如果沒有修改參數文件中的DB_NAME參數,那麽在MOUNT的時候,會報ORA-01103錯誤。

修改DB_NAME參數,嘗試直接打開數據庫。

提示必須使用RESETLOGS的方式才能打開數據庫。

默認情況下,db_unique_name service_names都會伴隨著DB NAME一起改變,此時由於service_names發生了變化,正常情況下應用是無法連接數據庫的(SID連接方式除外)

Oracle goldengate搭建ogg

主庫

設置環境變量(oracle用戶)

PATH=$ORACLE_HOME/bin:$PATH:$HOME/bin:/ggs

export LD_LIBRARY_PATH=/ggs:$ORACLE_HOME/lib

1.檢查是否開啟歸檔

SQL> select log_mode fromgv$database;

SQL> archive log list; ----註意歸檔路徑需要是共享路徑

2.檢查是否開啟force logging及補充日誌

selectforce_logging,supplemental_log_data_min,supplemental_log_data_all,flashback_onfrom v$database;

開啟:

alter database force logging;

alter database add supplemental logdata;

alter system archive log current;

3.對主庫檢查,ogg不允許:唯一索引的索引列的列定義允許為null

select dic.table_owner,

dic.table_name,

dic.index_name,

di.uniqueness,

dic.column_name

from dba_ind_columns dic, dba_indexes di, dba_tab_columns dtc

where dic.table_owner = ‘自行添加用戶‘ -----修改用戶名

and dtc.OWNER = ‘自行添加用戶‘ -----修改用戶名

AND dic.table_owner = di.table_owner

and dic.TABLE_NAME = di.table_name

and dic.index_name = di.index_name

and di.uniqueness = ‘UNIQUE‘

and dtc.owner = di.table_owner

and dtc.TABLE_NAME = di.table_name

and dic.column_name = dtc.COLUMN_NAME

and dtc.nullable = ‘ Y ‘

anddic.TABLE_NAME = dtc.TABLE_NAME;

不應該返回行,如果返回了,修改:要麽變為非唯一索引,要麽在保留唯一索引的情況下,將列的定義置為 not null

4.創建ogg用戶,並授權

create user ogg identified by ogg default tablespaceusers;

grant dba to ogg;

ALTER SYSTEM SETENABLE_GOLDENGATE_REPLICATION = TRUE SCOPE=BOTH;

5.檢查是否有nologing方式的表(ogg不支持nologing方式創建的表)

select owner,table_name,logging fromdba_tables where logging=‘NO‘ AND owner=‘用戶名‘;

修改為logging的表的語法:alter table 表名 logging;

註意:在ext進程的參數文件裏添加 dboptions allownologging可以讓ext進程繼續運行,但是會導致數據丟失。

6.源端數據庫添加表的補充日誌

進入ogg安裝路徑:

ggsci

dblogin userid ogg password ogg

GGSCI (oggsource) 1> dblogin userid ogg password ogg

Successfully logged into database.

GGSCI (oggsource as [email protected]) 2>create subdirs

Creating subdirectories under current directory/u01/app/oracle/ogg

Parameter files /u01/app/oracle/ogg/dirprm:already exists

Report files /u01/app/oracle/ogg/dirrpt:already exists

Checkpoint files /u01/app/oracle/ogg/dirchk:already exists

Process status files /u01/app/oracle/ogg/dirpcs: alreadyexists

SQL script files /u01/app/oracle/ogg/dirsql:already exists

Database definitions files /u01/app/oracle/ogg/dirdef: already exists

Extract data files /u01/app/oracle/ogg/dirdat:already exists

Temporary files /u01/app/oracle/ogg/dirtmp:already exists

Credential store files /u01/app/oracle/ogg/dircrd: alreadyexists

Masterkey wallet files /u01/app/oracle/ogg/dirwlt: alreadyexists

Dump files /u01/app/oracle/ogg/dirdmp: already exists

GGSCI (oggsource as [email protected]) 2>addtrandata lm.testogg

-------------------為表添加附加日誌,以便goldengate進行redo的抽取以及應用。

7.配置DDL復制

使用ogg作為存儲DDL objects的用戶ogg授權:

SQL> GRANT EXECUTE ON UTL_FILE TO ogg;

8.配置GLOBALS文件

ggsci

edit param ./GLOBALS中加入:

GGSCHEMA goldengate

如果是10g需要停用 recyclebin11g就不需要了

9.數據庫執行:

退出所有的oracle連接後執行:

cd /ggs

sqlplus / as sysdba

@marker_setup.sql

SQL> @marker_setup.sql

Marker setup script

You will be prompted for the name of aschema for the Oracle GoldenGate database objects.

NOTE: The schema must be created prior torunning this script.

NOTE: Stop all DDL replication beforestarting this installation.

Enter Oracle GoldenGate schema name:

Setting schema name to OGG

MARKER TABLE

-------------------------------

OK

MARKER SEQUENCE

-------------------------------

OK

Script complete.

SQL>@ddl_setup.sql

Oracle GoldenGate DDL Replication setupscript

Verifying that current user has privilegesto install DDL Replication...

You will be prompted for the name of aschema for the Oracle GoldenGate database objects.

NOTE: For an Oracle 10g source, the systemrecycle bin must be disabled. For Oracle 11g and later, it can be enabled.

NOTE: The schema must be created prior torunning this script.

NOTE: Stop all DDL replication beforestarting this installation.

Enter Oracle GoldenGate schema name:ogg

Working, please wait ...

Spooling to file ddl_setup_spool.txt

Checking for sessions that are holdinglocks on Oracle Golden Gate metadata tables ...

Check complete.

Using OGG as a Oracle GoldenGate schemaname.

Working, please wait ...

DDL replication setup script complete,running verification script...

Please enter the name of a schema for theGoldenGate database objects:

Setting schema name to OGG

CLEAR_TRACE STATUS:

Line/pos Error

-------------------------------------------------------------------------------------

No errors No errors

CREATE_TRACE STATUS:

Line/pos Error

-------------------------------------------------------------------------------------

No errors No errors

TRACE_PUT_LINE STATUS:

Line/pos Error

-------------------- -----------------------------------------------------------------

No errors No errors

INITIAL_SETUP STATUS:

Line/pos Error

-------------------------------------------------------------------------------------

No errors No errors

DDLVERSIONSPECIFIC PACKAGE STATUS:

Line/pos Error

-------------------------------------------------------------------------------------

No errors No errors

DDLREPLICATION PACKAGE STATUS:

Line/pos Error

-------------------------------------------------------------------------------------

No errors No errors

DDLREPLICATION PACKAGE BODY STATUS:

Line/pos Error

-------------------------------------------------------------------------------------

No errors No errors

DDL IGNORE TABLE

-----------------------------------

OK

DDL IGNORE LOG TABLE

-----------------------------------

OK

DDLAUX PACKAGE STATUS:

Line/pos Error

-------------------------------------------------------------------------------------

No errors No errors

DDLAUX PACKAGE BODY STATUS:

Line/pos Error

-------------------------------------------------------------------------------------

No errors No errors

SYS.DDLCTXINFO PACKAGE STATUS:

Line/pos Error

-------------------------------------------------------------------------------------

No errors No errors

SYS.DDLCTXINFO PACKAGE BODY STATUS:

Line/pos Error

-------------------- -----------------------------------------------------------------

No errors No errors

DDL HISTORY TABLE

-----------------------------------

OK

DDL HISTORY TABLE(1)

-----------------------------------

OK

DDL DUMP TABLES

-----------------------------------

OK

DDL DUMP COLUMNS

-----------------------------------

OK

DDL DUMP LOG GROUPS

-----------------------------------

OK

DDL DUMP PARTITIONS

-----------------------------------

OK

DDL DUMP PRIMARY KEYS

-----------------------------------

OK

DDL SEQUENCE

-----------------------------------

OK

GGS_TEMP_COLS

-----------------------------------

OK

GGS_TEMP_UK

-----------------------------------

OK

DDL TRIGGER CODE STATUS:

Line/pos Error

-------------------- -----------------------------------------------------------------

No errors No errors

DDL TRIGGER INSTALL STATUS

-----------------------------------

OK

DDL TRIGGER RUNNING STATUS

----------------------------------------------------------------------

ENABLED

STAYMETADATA IN TRIGGER

----------------------------------------------------------------------

OFF

DDL TRIGGER SQL TRACING

----------------------------------------------------------------------

0

DDL TRIGGER TRACE LEVEL

----------------------------------------------------------------------

NONE

LOCATION OF DDL TRACE FILE

------------------------------------------------------------------------------------------------------------------------

/u01/app/oracle/diag/rdbms/dbdream/dbdream/trace/ggs_ddl_trace.log

Analyzing installation status...

VERSION OF DDL REPLICATION

------------------------------------------------------------------------------------------------------------------------

OGGCORE_12.2.0.1.0_PLATFORMS_151211.1401

STATUS OF DDL REPLICATION

------------------------------------------------------------------------------------------------------------------------

SUCCESSFUL installation of DDL Replicationsoftware components

Script complete.

SQL>

SQL> @role_setup.sql

GGS Role setup script

This script will drop and recreate the roleGGS_GGSUSER_ROLE

To use a different role name, quit thisscript and then edit the params.sql script to change the gg_role parameter tothe preferred name. (Do not run the script.)

You will be prompted for the name of aschema for the GoldenGate database objects.

NOTE: The schema must be created prior torunning this script.

NOTE: Stop all DDL replication beforestarting this installation.

Enter GoldenGate schema name:ogg

SP2-0606: Cannot create SPOOL file"role_setup_spool.txt"

SP2-0606: Cannot create STORE file"role_setup_set.txt"

PL/SQL procedure successfully completed.

Role setup script complete

Grant this role to each user assigned tothe Extract, GGSCI, and Manager processes, by using the following SQL command:

GRANT GGS_GGSUSER_ROLE TO<loggedUser>

where <loggedUser> is the userassigned to the GoldenGate processes.

SQL> grantggs_ggsuser_role to ogg;

SQL> @ddl_enable.sql

如果是有災備演練的需求,需要配置sequence同步

cd /ggs --ogg安裝目錄

sqlplus / as sysdba

@sequence.sql

GRANT EXECUTE on goldengate.updateSequenceTO goldengate;

10.源端配置參數文件

su - grid

vi$ORACLE_HOME/network/admin/listener.ora

SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(GLOBAL_DBNAME = +ASM)

(ORACLE_HOME=/u01/app/11.2.0/grid)

(SID_NAME = +ASM1)

. )

.)

.

.

.su - oracle

.cd $ORACLE_HOME/network/admin

.vi tnsnames.ora

.ASM =

. (DESCRIPTION =

. (ADDRESS = (PROTOCOL = TCP)(HOST = 186.168.100.3)(PORT = 1521))

. (CONNECT_DATA =

. (SERVER = DEDICATED)

. (SERVICE_NAME = +ASM)

. (SID_NAME = +ASM1)

. )

. )

.

11、配置管理進程mgr

GGSCI(NDSCDB1) 1> edit param mgr

port 7809

-- DYNAMICPORTLIST 7830-7835

autostart extract *

autorestart extract *, waitminutes 1,retries 60, RESETMINUTES 60

PURGEOLDEXTRACTS /ggs/dirdat/sd*,USECHECKPOINTS, MINKEEPHOURS 2

~ MANAGER進程參數配置說明:

PORT:指定服務監聽端口;這裏以7839為例,默認端口為7809

DYNAMICPORTLIST:動態端口:可以制定最大256個可用端口的動態列表,當指定的端口不可用時,管理進程將會從列表中選擇一個可用的端口,源端和目標段的CollectorReplicatGGSCI進程通信也會使用這些端口;

COMMENT:註釋行,也可以用--來代替;

AUTOSTART:指定在管理進程啟動時自動啟動哪些進程;

AUTORESTART:自動重啟參數設置:本處設置表示每3分鐘嘗試重新啟動所有EXTRACT進程,共嘗試5次;

PURGEOLDEXTRACTS:定期清理trail文件設置:本處設置表示對於超過3天的trail文件進行刪除。

LAGREPORTLAGINFOLAGCRITICAL

定義數據延遲的預警機制:本處設置表示MGR進程每隔1小時檢查EXTRACT的延遲情況,如果超過了30分鐘就把延遲作為信息記錄到錯誤日誌中,如果延遲超過了45分鐘,則把它作為警告寫到錯誤日誌中。

12、配置extfull

add extract extfull, tranlog,begin now

edit param extfull

extract extfull

setenv ( NLS_LANG = " AMERICAN_AMERICA.ZHS16GBK " )------添加報錯

TRANLOGOPTIONS [email protected], ASMPASSWORD oracle

THREADOPTIONS MAXCOMMITPROPAGATIONDELAY80000 IOLATENCY 160000

DBOPTIONS ALLOWUNUSEDCOLUMN

userid goldengate, password goldengate

ddl include mapped

ddloptions addtrandata RETRYOP MAXRETRIES1000 RETRYDELAY 10, REPORT

WARNLONGTRANS 1h, CHECKINTERVAL 5m

exttrail /ggs/dirdat/sd

gettruncates

dynamicresolution

NOCOMPRESSUPDATES

NOCOMPRESSDELETES

table LM.testogg;

add exttrail /u01/app/oracle/ogg/dirdat/sd, extractextfull, MEGABYTES 50

13.添加傳輸進程

添加傳輸進程

addextract dpfull exttrailsource /ggs/dirdat/sd

創建遠程隊列文件並將其指定給傳輸進程

addrmttrail /u01/app/oracle/ogg/td, extract dpfull, MEGABYTES 50

配置傳輸進程參數

editparam dpfull

==================================

extractdpfull

passthru

rmthost 186.168.100.22, mgrport 7809

rmttrail /ggs/dirdat/td

gettruncates

table LM.testogg;

12、啟動管理進程:

dblogin userid ogg password ogg

GGSCI (oggsource as [email protected]) 11>start mgr

Manager started.

查看進程狀態可發現 MANAGER狀態為 RUNNING

GGSCI(NDSCDB1) 3> info all

/u01/app/oracle/ogg/dirrpt

13、配置抽取進程:

GGSCI (oggsource as [email protected]) 12> addextract extnd,tranlog,begin now

EXTRACT added.

GGSCI (oggsource as [email protected]) 13> addexttrail ./dirdat/nd,extract extnd,megabytes 100

EXTTRAIL added.

Megabytes:指定隊列大小,本處設置表示100M

添加傳輸進程,配置參數

GGSCI(NDSCDB1) 15> edit params extnd

EXTRACT extnd

setenv(NLS_LANG ="AMERICAN_AMERICA.ZHS16GBK")

SETENV(ORACLE_HOME ="/u01/app/oracle/product/11.2.0/db_1")

SETENV(ORACLE_SID ="dbdream")

USERID ogg, PASSWORD ogg

--GETTRUNCATES

REPORTCOUNTEVERY 1 MINUTES, RATE

DISCARDFILE./dirrpt/extnd.dsc,APPEND,MEGABYTES1024

--THREADOPTIONS MAXCOMMITPROPAGATIONDELAY 60000 IOLATENS60000

DBOPTIONS ALLOWUNUSEDCOLUMN

WARNLONGTRANS2h,CHECKINTERVAL 3m

EXTTRAIL./dirdat/nd

--TRANLOGOPTIONSEXCLUDEUSER USERNAME

FETCHOPTIONSNOUSESNAPSHOT

TRANLOGOPTIONS CONVERTUCS2CLOBS

TABLE olive.ol$_objects

GGSCI(NDSCDB1) 15>add extract dpend,exttrailsource ./dirdat/nd

EXTRACT added.

GGSCI(NDSCDB1) 15>add rmttrail /u01/app/oracle/ogg/nd, EXTRACT DPEND

RMTTRAIL added.

edit params dpend

EXTRACT dpend

SETENV(NLS_LANG ="AMERICAN_AMERICA.ZHS16GBK")

USERID ogg, PASSWORD ogg

PASSTHRU

RMTHOST10.122.0.113, MGRPORT 7839, compress

RMTTRAILF:/u01/app/oracle/ogg/dirdat/nd

TABLE olive.ol$_objects;

抽取進程和傳輸進程其實都是EXTRACT進程,也可以配置在一個進程完成這兩個功能,但是當網絡傳輸有問題時,這樣抽取也就不能繼續運行了,所以推薦分開配置為兩個進程;

EXTRACT進程參數配置說明:

SETENV:配置系統環境變量

USERID/ PASSWORD:指定OGG連接數據庫的用戶名和密碼,這裏使用3.4部分中創建的數據庫用戶OGG;

COMMENT:註釋行,也可以用--來代替;

TABLE:定義需復制的表,後面需以;結尾

TABLEEXCLUDE:定義需要排除的表,如果在TABLE參數中使用了通配符,可以使用該參數指定排除掉得表。

GETUPDATEAFTERS|IGNOREUPDATEAFTERS

是否在隊列中寫入後影像,缺省復制

GETUPDATEBEFORES| IGNOREUPDATEBEFORES

是否在隊列中寫入前影像,缺省不復制

GETUPDATES|IGNOREUPDATES

是否復制UPDATE操作,缺省復制

GETDELETES|IGNOREDELETES

是否復制DELETE操作,缺省復制

GETINSERTS|IGNOREINSERTS

是否復制INSERT操作,缺省復制

GETTRUNCATES|IGNORETRUNDATES

是否復制TRUNCATE操作,缺省不復制;

RMTHOST:指定目標系統及其GoldengateManager進程的端口號,還用於定義是否使用壓縮進行傳輸,本例中的compress為壓縮傳輸;

RMTTRAIL:指定寫入到目標斷的哪個隊列;

EXTTRAIL:指定寫入到本地的哪個隊列;

SQLEXEC:在extract進程運行時首先運行一個SQL語句;

PASSTHRU:禁止extract進程與數據庫交互,適用於DataPump傳輸進程;

REPORT:定義自動定時報告;

STATOPTIONS:定義每次使用stat時統計數字是否需要重置;

REPORTCOUNT:報告已經處理的記錄條數統計數字;

TLTRACE:打開對於數據庫日誌的跟蹤日誌;

DISCARDFILE:定義discardfile文件位置,如果處理中油記錄出錯會寫入到此文件中;

DBOPTIONS:指定對於某種特定數據庫所需要的特殊參數;

TRANLOGOPTIONS:指定在解析數據庫日誌時所需要的特殊參數,例如:對於裸設備,可能需要加入以下參數 rawdeviceoggset 0

WARNLONGTRANS:指定對於超過一定時間的長交易可以在gsserr.log裏面寫入警告信息,本處配置為每隔3分鐘檢查一次場交易,對於超過2小時的進行警告;~

~

~

目標庫

備庫:

1.創建ogg用戶並授權

create user goldengatet identified bygoldengatet default tablespace tbs_ogg;

grant dba to ogg;

execdbms_streams_auth.grant_admin_privilege(grantee => ‘ogg‘,grant_privileges=> true);

ALTER SYSTEM SETENABLE_GOLDENGATE_REPLICATION = TRUE SCOPE=BOTH;

2.配置環境變量(oracle用戶下)

export LD_LIBRARY_PATH

export PATH=

目標庫創建GoldenGate數據庫用戶並授權:

GGSCI (oggtarget) 1> create subdirs

Creating subdirectories under currentdirectory /u01/app/oracle/ogg

Parameter files /u01/app/oracle/ogg/dirprm:already exists

Report files /u01/app/oracle/ogg/dirrpt:already exists

Checkpoint files /u01/app/oracle/ogg/dirchk:already exists

Process status files /u01/app/oracle/ogg/dirpcs: alreadyexists

SQL script files /u01/app/oracle/ogg/dirsql:already exists

Database definitions files /u01/app/oracle/ogg/dirdef: already exists

Extract data files /u01/app/oracle/ogg/dirdat:already exists

Temporary files /u01/app/oracle/ogg/dirtmp:already exists

Credential store files /u01/app/oracle/ogg/dircrd: alreadyexists

Masterkey wallet files /u01/app/oracle/ogg/dirwlt: alreadyexists

Dump files /u01/app/oracle/ogg/dirdmp: already exists

SQL> create tablespace ogg datafile‘/u01/app/oracle/oradata/dbdream/ogg.dbf‘ size 50M autoextend on;

SQL> create user ogg identified by oggdefault tablespace ogg;

grant connect,resource,unlimited tablespaceto ogg;

grant execute on utl_file to ogg;

grant select any dictionary,select anytable to ogg;

grant alter any table to ogg;

grant flashback any table to ogg;

grant execute on DBMS_FLASHBACK to ogg;

grant insert any table to ogg;

grant delete any table to ogg;

grant update any table to ogg;

庫配置檢查

SQL> select NAME,OPEN_MODE,FORCE_LOGGING,SUPPLEMENTAL_LOG_DATA_MINfrom v$database;

SQL> alter database force logging;

SQL> alter database add SUPPLEMENTAL log data;

配置MGR

配置參數文件

MGR

edit param mgr

PORT 7839

autostart replicat *

autorestart replicat *, waitminutes 1,retries 60, RESETMINUTES 60

PURGEOLDEXTRACTS/u01/app/oracle/ogg/dirdat/td*, USECHECKPOINTS, MINKEEPHOURS 2

添加checkpoint

dblogin userid goldengate,password goldengate

ADD CHECKPOINTTABLE goldengate.ckptfull

配置目標端進程組

add replicat repfull, exttrail/u01/app/oracle/ogg/dirdat/td, CHECKPOINTTABLE ogg.ckptfull

edit params repfull

replicat repfull

setenv ( NLS_LANG = "AMERICAN_AMERICA.ZHS16GBK" )

assumetargetdefs

userid ogg, password ogg

DBOPTIONS DEFERREFCONST, SUPPRESSTRIGGERS

gettruncates

ALLOWNOOPUPDATES

ddl include mapped

discardfile ./dirrpt/repfull.dsc, append,megabytes 4000

map scott.t1, target scott.t1;

GGSCI (oggtarget as [email protected]) 74>start mgr

GGSCI (oggtarget as [email protected]) 75> infoall

Program Status Group Lag at Chkpt Time Since Chkpt

MANAGER RUNNING

REPLICAT RUNNING REPFULL 00:00:00 00:00:02

參數介紹:

REPLICAT RINI_1:說明這是REPLICAT應用進程,名字叫RINI_1

SETENV:語言變量,同捕獲進程EINI_1

ASSUMETARGETDEFS:告訴OGG目標端和源端需要同步的表的結構完全一致,不需要OGG去檢查表的結構,包括表名、字段名、字段類型、字段長度等,如果目標端和源端同步的表的結構不一樣,需要使用SOURCEDEFS參數,詳見OGG官方文檔。

USERIDPASSWORD:同捕獲進程EINI_1參數介紹

DISCARDFILE:錯誤信息存放位置及命名規則

MAP:源端捕獲的表的名字

TARGET:目標端同步的表的名字,可以不在同一SCHEMA

測試檢查

info all---------------------檢查進程

info 進程名,detail

stats REPFULL-----------------------------檢查數據傳輸狀態

view report 進程名

數據庫登錄檢查數據是否有變化

本文出自 “11300506” 博客,請務必保留此出處http://11310506.blog.51cto.com/11300506/1959799

oracle ogg 單機環境單向復制搭建