系统版本:redhat 6.5
数据库版本:11.2.0.4
OGG软件链接: https://pan.baidu.com/s/1kWuhBsN 密码: h5q1
创建OGG表空间
create tablespace ogg datafile '/u01/app/oracle/oradata/ogg.dbf' size 2G autoextend off;
创建OGG用户
create user ogg identified by ogg default tablespace ogg;
添加权限
grant connect,resource,create session,alter session,
select any dictionary,select any table,flashback any table,
alter any table,insert any table,update any table,
delete any table,select any transaction,
execute on DBMS_CAPTURE_ADM to ogg;
开启归档
shutdown immediate
startup mount
alter database archivelog;
alter database open;
开启强制日志
ALTER DATABASE FORCE LOGGING;
开启附加日志
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
修改参数
ALTER SYSTEM SET ENABLE_GOLDENGATE_REPLICATION=TRUE;
创建OGG表空间
create tablespace ogg datafile '/u01/app/oracle/oradata/ogg.dbf' size 2G autoextend off;
创建OGG用户
create user ogg identified by ogg default tablespace ogg;
添加权限
grant connect,resource,create session,alter session,
select any dictionary,select any table,flashback any table,
alter any table,insert any table,update any table,
delete any table,select any transaction,
execute on DBMS_CAPTURE_ADM to ogg;
修改参数
ALTER SYSTEM SET ENABLE_GOLDENGATE_REPLICATION=TRUE;
源库MGR进程
GGSCI>edit params mgr
port 7809
DYNAMICPORTLIST 7840-7850
PURGEOLDEXTRACTS /oracle/ogg/testogg/dirdat/*,usecheckpoints,minkeepdays 7
源库抽取进程
a.创建trail文件目录
mkdir -p /u01/ogg/dirdat/EXTEST01
b.添加抽取进程
GGSCI>add extract extest01,tranlog,threads 1,begin now
GGSCI>add exttrail /u01/ogg/dirdat/EXTEST01/EX,extract extest01,megabytes 200
GGSCI>edit param extest01
extract extest01
SETENV(NLS_LANG="AMERICAN_AMERICA.AL32UTF8")
SETENV(ORACLE_SID="source")
USERID ogg,PASSWORD ogg
TRANLOGOPTIONS DBLOGREADER
TRANLOGOPTIONS DBLOGREADER LOGRETENTION ENABLED
warnlongtrans 4h,checkinterval 10m
EXTTRAIL /oracle/ogg/testogg/dirdat/extest01/ex
GETTRUNCATES
TABLE TEST.*;
源库投递进程
GGSCI >add extract putest01,EXTTRAILSOURCE /u01/ogg/dirdat/EXTEST01/EX
GGSCI >add rmttrail /u01/ogg/dirdat/RETEST01/RE,ext putest01,megabytes 200
GGSCI >edit params putest01
extract putest01
passthru
USERID ogg,PASSWORD ogg
SETENV(NLS_LANG="AMERICAN_AMERICA.AL32UTF8")
SETENV(ORACLE_SID="source")
rmthost 192.168.88.129,mgrport 7809
rmttrail /oracle/ogg/testogg/dirdat/retest01/re
USERID ogg,PASSWORD ogg
TABLE TEST.*;
目标库MGR进程
GGSCI >edit params mgr
port 7809
DYNAMICPORTLIST 7840-7850
autorestart er *, retries 5, waitminutes 3
purgeoldextracts /oracle/ogg/testogg/dirdat/*,usecheckpoints, minkeepdays 7
目标库复制进程
a.建trail存放目录
mkdir -p /u01/ogg/dirdat/RETEST01
b.创建checkpoint表
GGSCI >dblogin USERID ogg,PASSWORD ogg
GGSCI >add checkpointtable ogg.ckpttest01
c.添加复制进程
GGSCI >add replicat retest01,exttrail /oracle/ogg/testogg/dirdat/retest01/re,checkpointtable ogg.ckpttest01
GGSCI >edit params retest01
replicat retest01
batchsql
SETENV(NLS_LANG="AMERICAN_AMERICA.AL32UTF8")
SETENV(ORACLE_SID="target")
ASSUMETARGETDEFS
USERID ogg,PASSWORD ogg
discardfile /oracle/ogg/testogg/dirrpt/retest01.dsc,append,megabytes 100
MAP TEST.*,TARGET TEST.*````
a.添加附加日志
dblogin userid ogg,password ogg
add trandata TEST.*
b.启动抽取进程和投递进程
GGSCI>start extrac t *
c.查看当前数据库SCN
col scn for 9999999999999999
select dbms_flashback.get_system_change_number scn from dual;
d.通过数据泵导出相关对象
expdp '\sys/luhengxing as sysdba'\ DIRECTORY =DMP_DIR DUMPFILE=OGG.DMP LOGFILE=OGG.LOG
CLUSTER=N EXCLUDE=STARTISTICS
FLASHBACK_SCN=100000
SCHEMAS=TEST
e.TARGET端导入数据
impdp '\sys/luhengxing as sysdba'\ DIRECTORY=DMP_DIR
DUMPFILE=OGG.DMP LOGFILE=OGG.LOG
CLUSTER=N TABLE_EXISTS_ACTION=append SCHEMAS=TEST
f.启动复制进程
GGSCI>start retest01,
fterscn 10000
OGG用户密码加密
a.获取key值
OGG_HOME >./keygen 128 1 -----128位算法,生成一个key值
b.创建密钥
vi ENCKEYS
kasaur_key 0x00268557C534302D9702CB1B16958365
c.生成加密值
GGSCI (source) 1> encrypt password ogg encryptkey kasaur_key
Encrypted password: AADAAAAAAAAAAADAYGGHJDTDVFRICBLJGJQFDEEDRCOEDBEAWFSDCGYENGBGSEVEDAEHTFHFLDAGJHKJ
Algorithm used: AES128
GGSCI (source) 4> dblogin userid ogg,password AADAAAAAAAAAAADAYGGHJDTDVFRICBLJGJQFDEEDRCOEDBEAWFSDCGYENGBGSEVEDAEHTFHFLDAGJHKJ ,encryptkey kasaur_key
Successfully logged into database.