安装环境:
source: OS:redhat 6.3 DB:11.2.0.4 rac OGG:11.2.1.0.1 target: OS:redhat 6.3 DB:11.2.0.4 OGG:11.2.1.0.1
rac到单机的一个传输配置,这里测试ogg没有放入到共享存储中。建议生产环境将ogg放入共享存储,以免单点故障。
Prepare(Source And Target DB):
useradd ogg -g oinstall Add Environment Varible vi /home/oracle/.bash_profile export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/ogg Configure Database alter database archivelog; alter database force logging; alter database add supplemental log data; For Oracle DB versions 11.2.0.4 and 12.1.0.2 there will be a new init.ora parameter called ENABLE_GOLDENGATE_REPLICATION. In order for some of the Oracle GoldenGate functionality to work, this parameter must be set to true. ALTER SYSTEM SET ENABLE_GOLDENGATE_REPLICATION = TRUE SCOPE=BOTH; Create OGG User: sqlplus / as sysdba create user ogg identified by ogg; grant dba to ogg; GGSCI (zbdba1) 1> edit params ./GLOBAL GGSCHEMA ogg CHECKPOINTTABLE ogg.checkpoint Installing the DDL objects: 1、Run the @marker_setup.sql script. This script installs support for the Oracle GoldenGate marker system, which is required for DDL support. You will be prompted for the name of the Oracle GoldenGate schema. 2、Run the @ddl_setup.sql script Script that installs the Oracle GoldenGate DDL extraction and replication objects. (Oracle installations) 3、Run the @role_setup.sql script. This script drops and creates the role needed for DDL synchronization. It grants DML permissions on the Oracle GoldenGate DDL objects 4、Grant the role to all Oracle GoldenGate Extract users. You may need to make multiple grants if the processes have different user names. Run the @ddl_enable.sql script to enable the DDL trigger. 5、To improve the performance of the DDL trigger, make the ddl_pin script part of the database startup. It must be invoked with the Oracle GoldenGate DDL user name, as in: @?/rdbms/admin/dbmspool.sql SQL> @ddl_pin ogg To improve the performance of the DDL trigger This script pins the PL/SQL package that is used by the trigger into memory. If executing this script from SQL*Plus, connect as SYSDBA from the Oracle GoldenGate home directory. This script relies on the Oracle dmbs_shared_pool system package, so install that package before using ddl_pin.
Source DB:
MANAGER GGSCI (zbdba1) 1> create subdirs GGSCI (zbdba1) 22> view param mgr port 7839 DYNAMICPORTLIST 7840-7914 USERID OGG,PASSWORD ogg AUTORESTART EXTRACT *, RETRIES 5, WAITMINUTES 3 PURGEOLDEXTRACTS ./DIRDAT/*,MINKEEPDAYS 3 PURGEDDLHISTORY MINKEEPDAYS 7,MAXKEEPDAYS 10,FREQUENCYMINUTES 30 PURGEMARKERHISTORY MINKEEPDAYS 7,MAXKEEPDAYS 10 LAGREPORTHOURS 1 LAGINFOMINUTES 30 LAGCRITICALMINUTES 45 EXTRACT add extract ext1,tranlog, threads 2, begin now add exttrail /ogg/dirdat/sa extract ext1 add rmttrail ./dirdat/sa,extract ext1
这里使用asm时候,需要强调一下, Oracle 10.2.0.5、Oracle 11.2.0.2 版本和后续版本的数据库中,Oracle 提供了一个新的 ASM API接口 ,可以让 extract 进程直接利用数据库服务器来访问 redo 和 archive log。使用该 API 后,extract 将获得一个最大不超过 4 mb 的read buffer。read buffer 越大,对于 redo 量较高的 环境越容易提高 Extract 的进程。可以通过使用 TRANLOGOPTIONS
的 DBLOGREADERBUFSIZE 选项来指定read buffer 的大小。
这种方案只需要在抽取进程的参数中加:
TRANLOGOPTIONS DBLOGREADER
其他版本的方案:
指明asm用户密码和归档路径
TRANLOGOPTIONS ASMUSER [email protected], ASMPASSWORD oracle TRANLOGOPTIONS ALTARCHIVELOGDEST primary instance test1 /opt/oracle/arch, ALTARCHIVELOGDEST primary instance test2 /opt/oracle/arch
配置tnsnames.ora
ASM1 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.52)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = +ASM) (INSTANCE_NAME= +ASM1) ) )
并且两个节点的归档需要用nfs映射。
这里数据库版本是11.2.0.4,所以采用方案一
EXTRACT EXT1 setenv ( NLS_LANG = AMERICAN_AMERICA.ZHS16GBK ) setenv (ORACLE_SID= "test1") USERID ogg,PASSWORD ogg TRANLOGOPTIONS DBLOGREADER DDL & INCLUDE MAPPED OBJTYPE 'TABLE' & INCLUDE MAPPED OBJTYPE 'IDNEX' & INCLUDE MAPPED OBJTYPE 'SEQUENCE' & INCLUDE MAPPED OBJTYPE 'VIEW' & INCLUDE MAPPED OBJTYPE 'PROCEDURE' & INCLUDE MAPPED OBJTYPE 'FUNCTION' & INCLUDE MAPPED OBJTYPE 'PACKAGE' & INCLUDE MAPPED OBJTYPE 'MATERIALIZED VIEW' & EXCLUDE OPTYPE COMMENT DDLOPTIONS ADDTRANDATA NOCROSSRENAME REPORT REPORTCOUNT EVERY 1 MINUTES,RATE DISCARDFILE ./dirrpt/EXTSA.DSC,APPEND,MEGABYTES 1024 THREADOPTIONS MAXCOMMITPROPAGATIONDELAY 60000 IOLATENCY 60000 DBOPTIONS ALLOWUNUSEDCOLUMN WARNLONGTRANS 2H,CHECKINTERVAL 3M exttrail ./dirdat/sa FETCHOPTIONS NOUSESNAPSHOT,FETCHPKUPDATECOLS,MISSINGROW REPORT table zbdba.*;
datapump GGSCI (zbdba1) 4>> add extract ext2,exttrailsource /ogg/dirdat/sa EXTRACT added. ADD EXTTRAIL ./dirdat/sa, EXTRACT EXT2 GGGSCI (zbdba1) 4> add rmttrail /ogg/dirdat/sa, extract ext2 RMTTRAIL added. GGSCI (zbdba1) 2> view param ext2 EXTRACT EXT2 passthru RMTHOST 192.168.56.61,MGRPORT 7839,COMPRESS RMTTRAIL ./dirdat/sa table zbdba.*;
Target DB:
GGSCI (zbdba2) 1> create subdirs GGSCI (zbdba2) 42> view param mgr port 7839 DYNAMICPORTLIST 7840-7914 USERID OGG,PASSWORD ogg AUTORESTART REPLICAT *, RETRIES 5, WAITMINUTES 3 PURGEOLDEXTRACTS ./dirdat/*,MINKEEPDAYS 3 PURGEDDLHISTORY MINKEEPDAYS 7,MAXKEEPDAYS 10,FREQUENCYMINUTES 30 PURGEMARKERHISTORY MINKEEPDAYS 7,MAXKEEPDAYS 10 LAGREPORTHOURS 1 LAGINFOMINUTES 30 LAGCRITICALMINUTES 45 Create Replicat GGSCI (zbdba2) 1> view param ./GLOBALS GGSCHEMA ogg CHECKPOINTTABLE ogg.checkpoint GGSCI (zbdba2) 1> dblogin userid ogg,password ogg GGSCI (zbdba2) 2> add checkpointtable ogg.checkpoint Successfully created checkpoint table OGG.CHECKPOINT. GGSCI (zbdba2) 2> add replicat rep1,exttrail /ogg/dirdat/sa, checkpointtable ogg.checkpoint REPLICAT added. GGSCI (zbdba2) 19> edit param rep1 REPLICAT rep1 ASSUMETARGETDEFS USERID ogg, PASSWORD ogg discardfile ./dirdat/rep1_discard.txt,append,megabytes 5 DDL INCLUDE MAPPED DDLOPTIONS REPORT BATCHSQL DBOPTIONS DEFERREFCONST DBOPTIONS LOBWRITESIZE 102400 HANDLECOLLISIONS DDLERROR DEFAULT DISCARD RETRYOP MAXRETRIES 5 RETRYDELAY 20 --grouptransops 1 --maxtransops 1 APPLYNOOPUPDATES MAP zbdba.*, TARGET zbdba.*; start manager GGSCI (zbdba2) 23> info all Program Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNING REPLICAT STOPPED REP1 00:00:00 00:00:03
Test Data(Source and Target DB):
create tablepsace zbdab datafile '/opt/oracle/oradata/zbdba.dbf' size 100m; create zbdba identified by oracle default tablespace zbdba; grant dba to zbbda; On Source DB: User data pump: expdp zbdba/oracle DIRECTORY=dumpdir DUMPFILE=zbdba.dmp LOGFILE=zbdba.log SCHEMAS=zbdba JOB_NAME=exp_zbdba_schema scp data to target DB On Target DB: impdp zbdba/oracle DIRECTORY=dumpdir DUMPFILE=zbdba.dmp SCHEMAS=zbdba JOB_NAME=imp_zbdba_schema GGSCI (ogg2) 24> start rep1 Sending START request to MANAGER ... REPLICAT REP1 starting GGSCI (ogg2) 26> info all Program Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNING REPLICAT RUNNING REP1 00:00:00 00:00:07 On Source DB: create table test as select * from dba_objects; Monitor OGG(Source And Target DB): tail -100f ggserr.log
时间: 2024-12-13 09:06:41