sampe 1:
1.prepar
--/ogg11gdb/ogg--/hdbuatdb/ogg--ogg version:11.2.1.0.23 18709404 OGGCORE_11.2.1.0.0OGGBP_PLATFORMS_140519.1509cd $HOME/utility/setup##instance 1
cp hdb11g.env hdbuat.envecho "export OGG_BIN=/hdbuatdb/ogg" > hdbuat.envecho "export GGS_HOME=/hdbuatdb/ogg" >> hdbuat.envecho "export OGG_SYS_HOST_NAME=192.168.27.195" >> hdbuat.envecho "alias data='cd \$OGG_BIN'" >> hdbuat.env# User defined variablesecho "alias ogg='cd \$OGG_BIN'" >> hdbuat.env##instance 2
cp hdb11g.env ogg11g.envecho "export OGG_BIN=/ogg11gdb/ogg" > ogg11g.env
echo "export GGS_HOME=/ogg11gdb/ogg" >> ogg11g.envecho "export OGG_SYS_HOST_NAME=192.168.27.190" >> ogg11g.envecho "alias data='cd \$OGG_BIN'" >> ogg11g.env# User defined variablesecho "alias ogg='cd \$OGG_BIN'" >> ogg11g.env##instance 1 2
--在None的前一行 打印新行。awk '/None/{print " \"ogg11g\") echo \n export ORACLE_SID=ogg11g \n . $OGG_DIR/ogg11g.env \n export OGG_BIN=/ogg11gdb/ogg \n break; break;; "}1' setogg.sh > 1awk '/None/{print " \"hdbuat\") echo \n export ORACLE_SID=hdbuat \n . $OGG_DIR/hdbuat.env \n export OGG_BIN=/hdbuatdb/ogg \n break; break;; "}1' 1 > setogg.sh##instance 2
sqlplus / as sysdba << eofalter database add supplemental log data ;ALTER SYSTEM SET ENABLE_GOLDENGATE_REPLICATION=TRUE SCOPE=BOTH;create tablespace TS_OGG datafile '/ogg11gdb/data/ts_ogg01.dbf' size 50M ;create user ggusr identified by ggusr_12 default tablespace TS_OGG;grant resource, connect, select any table,select any dictionary,ALTER ANY TABLE,dba to ggusr;eof##instance 1
sqlplus / as sysdba << eofalter database add supplemental log data ;ALTER SYSTEM SET ENABLE_GOLDENGATE_REPLICATION = TRUE SCOPE=BOTH;create tablespace TS_OGG datafile '/hdbuatdb/data/ts_ogg01.dbf' size 50M ;create user ggusr identified by ggusr_12 default tablespace TS_OGG;grant resource, connect, select any table,select any dictionary,ALTER ANY TABLE to ggusr;eof ###instance 2 sqlplus / as sysdba << eofcreate user hr identified by hrdata_12 default tablespace TS_OGG;grant resource, connect, select_catalog_role to hr;create table hr.t1 as select * from dba_objects where 1=2; alter table hr.t1 add constraint pk_t1 primary key(object_id); eof
cp $OGG_BIN/dirprm/mgr.prm $OGG_BIN/dirprm/mgr.prm.bak
echo "port 12100" > $OGG_BIN/dirprm/mgr.prmogg(mkdir dirrptmkdir dirpcsmkdir dirchkmkdir dirtmpmkdir dirdat)ggsci << eofcreate subdirsstart mgrinfo allinfo mgreof
### instance 1
sqlplus / as sysdba << eofcreate user hr identified by hrdata_12 default tablespace TS_OGG;grant resource, connect, select_catalog_role,select any dictionary,select any table to hr;create table hr.t1 as select * from dba_objects;alter table hr.t1 add constraint pk_t1 primary key(object_id); eof cp $OGG_BIN/dirprm/mgr.prm $OGG_BIN/dirprm/mgr.prm.bakecho "port 7810" > $OGG_BIN/dirprm/mgr.prm
echo "extract e_test" > $OGG_BIN/dirprm/e_test.prm
echo "setenv (ORACLE_SID=hdbuat)" >> $OGG_BIN/dirprm/e_test.prmecho "setenv (ORACLE_HOME=/opt/oracle11g/product/11.2)" >> $OGG_BIN/dirprm/e_test.prmecho "setenv (NLS_LANG=AMERICAN_AMERICA.UTF8)" >> $OGG_BIN/dirprm/e_test.prmecho "userid ggusr,password ggusr_12" >> $OGG_BIN/dirprm/e_test.prmecho "exttrail ./dirdat/mc" >> $OGG_BIN/dirprm/e_test.prmecho "table hr.t1; " >> $OGG_BIN/dirprm/e_test.prm
echo "extract p_test" > $OGG_BIN/dirprm/p_test.prm
echo "setenv (ORACLE_SID=hdbuat)" >> $OGG_BIN/dirprm/p_test.prmecho "setenv (ORACLE_HOME=/opt/oracle11g/product/11.2)" >> $OGG_BIN/dirprm/p_test.prmecho "setenv (NLS_LANG=AMERICAN_AMERICA.UTF8)" >> $OGG_BIN/dirprm/p_test.prmecho "passthru" >> $OGG_BIN/dirprm/p_test.prmecho "rmthost 192.168.27.195,mgrport 12100" >> $OGG_BIN/dirprm/p_test.prmecho "rmttrail ./dirdat/pa" >> $OGG_BIN/dirprm/p_test.prmecho "table hr.t1; " >> $OGG_BIN/dirprm/p_test.prm oggggsci << eofcreate subdirsstart mgrinfo allinfo mgrdblogin userid ggusr, password ggusr_12add trandata hr.*add extract e_test,tranlog,begin now add exttrail ./dirdat/mc,extract e_test,megabytes 100 start extract e_testeofogg
ggsci << eofadd extract p_test,exttrailsource ./dirdat/mc add rmttrail ./dirdat/pa,extract p_test,megabytes 100 start extract p_testeof #### instance 2ogg
cp ./GLOBALS ./GLOBALS.bak echo "GGSCHEMA GGUSR" > ./GLOBALSecho "checkpointtable CHECKPOINTTABLE" >> ./GLOBALS echo "replicat r_test" > $OGG_BIN/dirprm/r_test.prmecho "setenv (ORACLE_SID=ogg11g)" >> $OGG_BIN/dirprm/r_test.prmecho "setenv (ORACLE_HOME=/opt/oracle11g/product/11.2)" >> $OGG_BIN/dirprm/r_test.prmecho "setenv (NLS_LANG=AMERICAN_AMERICA.UTF8)" >> $OGG_BIN/dirprm/r_test.prmecho "userid ggusr,password ggusr_12" >> $OGG_BIN/dirprm/r_test.prmecho "handlecollisions" >> $OGG_BIN/dirprm/r_test.prmecho "assumetargetdefs" >> $OGG_BIN/dirprm/r_test.prmecho "discardfile ./dirrpt/r_test.dsc,purge" >> $OGG_BIN/dirprm/r_test.prmecho "map hr.*,target hr.*; " >> $OGG_BIN/dirprm/r_test.prm ggsci << eofdblogin userid ggusr, password ggusr_12add checkpointtable GGUSR.CHECKPOINTTABLEadd replicat r_test,exttrail ./dirdat/pastart R_TEST eof
测试1:
###begin sync data firstly use exp/imp and filter### instance 2oggggsci << eofstop R_TEST eof ### instance 1###add config extract:table hr.t1;pump:table hr.t1; oggggsci << eofstop E_TESTstop P_TESTdblogin userid ggusr, password ggusr_12add trandata hr.t1start E_TESTstart P_TESTeofsqlplus / as sysdba << eof
select count(*) from hr.t1;select current_scn from v\$database;create or replace directory datapump as '/tmp'; grant read,write on directory datapump to public;eof expdp system/oracle123 directory=datapump dumpfile=test.dmp schemas=hr flashback_scn=93919213
### instance 2
impdp system/ngn12_system directory=datapump dumpfile=test.dmp table_exists_action=replacesqlplus / as sysdba << eof
select count(*) from hr.t1;select owner,table_name,TRIGGER_NAME from dba_triggers where table_name ='T1';eof ###add config map hr.t1, target hr.t1, filter ( @getenv("TRANSACTION", "CSN") > 93919213);ogg
ggsci << eofstart R_TEST STATS * latest,totalsonly *.*eof ### instance 1##add a valuessqlplus / as sysdba << eofinsert into hr.t1(object_id) values ( 20000);commit;select * from hr.t1 where object_id=20000;eof##delete values
sqlplus / as sysdba << eofdelete from hr.t1 where object_id=20000;commit;select * from hr.t1 where object_id=20000;eof 测试2:#######simualate ORA-00001##instance 2
oggggsci << eofstop R_TEST eof ###modify config nohandlecollisions###instance 1: add two same values
sqlplus / as sysdba << eofselect owner,table_name,CONSTRAINT_NAME from dba_constraints where table_name ='T1';
alter table hr.t1 disable constraint PK_T1;insert into hr.t1(object_id) values ( 20000);insert into hr.t1(object_id) values ( 20000);select * from hr.t1 where object_id=20000;commit;eof###instance 2 will report ORA-00001
workaourd:
step 1:
######modify config from nohandlecollisions to handlecollisionshandlecollisions ###instance 2 , it will show one row insert ok, one row insert ignoresqlplus / as sysdba << eofselect owner,table_name,CONSTRAINT_NAME from dba_constraints where table_name ='T1';select count(*) from hr.t1 where object_id=20000;commit;eofstep 2:
instance 2######modify config from handlecollisions to nohandlecollisionsoggggsci << eofstop R_TESTstart R_TEST STATS * latest,totalsonly *.*eof