Linux下单机OGG同步oracle11g DB测试
一、安装goldengate软件
1.1测试环境
OS: redhat 6 64bit DB: oracle 11.2.0.3 64bit 查看OS和DB版本
[ ~]$ uname -aLinux redhat6 2.6.32-131.0.15.el6.x86_64 #1 SMP Tue May 10 15:42:40 EDT 2011 x86_64 x86_64 x86_64 GNU/LinuxSQL> select * from v$version where rownum=1;?BANNER\--------------------------------------------------------------------------------Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
1.2.安装OGG
[ ~]$ cd /u01/ogg[ ogg]$unzip ogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zip[ ogg]$ tar -xvf fbo_ggs_Linux_x64_ora11g_64bit.tar
1.3.添加环境变量
[ ogg]$ vi /home/oracle/.bash_profileLD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/libexport LD_LIBRARY_PATHexport PATH=/u01/ogg:$PATHexport GGATE=/u01/ogg
1.4.使用ggsci工具创建目录
[ ogg]$ ./ggsci?Oracle GoldenGate Command Interpreter for OracleVersion 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBOLinux, x64, 64bit (optimized), Oracle 11g on Apr 23 2012 08:32:14?Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.?GGSCI (redhat6) 1> create subdirs
以上配置须SOURCE和TARGET端都进行
二、配置源(SOURCE)数据库
Goldengate通过抓取源端数据库重做日志进行分析,将获取的数据应用到目标端,实现数据同步。
2.1 源数据库需要必须处于归档模式,并启用附加 日志和强制日志。
(1)归档模式
SQL> archive log list;Database log mode Archive ModeAutomatic archival EnabledArchive destination /u01/app/oracle/archlogOldest online log sequence 12Next log sequence to archive 14Current log sequence 14SQL> select log_mode,supplemental_log_data_min,force_logging from v$database;?LOG_MODE SUPPLEME FOR------------ -------- ---ARCHIVELOG YES NO
(2)强制日志
SQL> alter database force logging;Database altered.
(3)附加日志
SQL>alter database add supplemental log data;SQL> select log_mode,supplemental_log_data_min,force_logging from v$database;?LOG_MODE SUPPLEME FOR------------ -------- ---ARCHIVELOG YES YES
2.2禁用RecycleBin(oracle10g ogg需要禁用,oracle11g ogg不要求)
SQL> alter system set recyclebin=off scope=spfile;System altered.SQL> shutdown immediate
2.3创建存放DDL信息的用户并授权
SQL> create user ggate identified by ggate default tablespace users temporary tablespace temp;User created.SQL> grant connect,resource to ggate;Grant succeeded.SQL> grant execute on utl_file to ggate;Grant succeeded.[ ~]$ cd $GGATE[ ggate]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.3.0 Production on Mon Dec 9 04:55:44 2013Copyright (c) 1982, 2011, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> @marker_setup.sql; ---输入之前创建的用户ggateSQL> @ddl_setup.sql; ---输入之前创建的用户ggateSQL> @role_setup.sql; ---输入之前创建的用户ggateSQL>grant GGS_GGSUSER_ROLE to ggate;SQL>@ddl_enable.sql;
三、测试OGG
3.1 分别在SOURCE DB和TARGET DB上创建测试用户
SOURCE DB:
SQL> create user source identified by oracle default tablespace users temporary tablespace temp;User created.SQL> grant connect,resource,dba to source;Grant succeeded.
TARGET DB:
SQL> create user targer identified by oracle default tablespace tbs_hjj temporary tablespace temp;User created.SQL> grant connect,resource,dba to targer;Grant succeeded.
3.2 在SOURCE和TARGET分别配置MANAGER
远端和目标端都做同样的操作
GGSCI (redhat6) 1> info all?Program Status Group Lag at Chkpt Time Since Chkpt?MANAGER STOPPED?GGSCI (redhat6) 2> edit params mgr?GGSCI (redhat6) 3> start mgr?Manager started.?GGSCI (redhat6) 4> info all?Program Status Group Lag at Chkpt Time Since Chkpt?MANAGER RUNNING
3.3 配置SOURCE DB的复制队列
连接到数据库,测试连接:
GGSCI (redhat6) 5> dblogin userid [,password](mailto:,password) ggateSuccessfully logged into database.
增加一个抽取extract:
GGSCI (redhat6) 6> add extract ext1,tranlog,begin nowEXTRACT added.GGSCI (redhat6) 7> add exttrail /u01/ogg/dirdat/lt,extract ext1EXTTRAIL added.GGSCI (redhat6) 8> edit params ext1extract ext1userid [,password](mailto:,password) ggatermthost redhat6,mgrport 7809rmttrail /u01/ogg/dirdat/ltddl include mapped objname source.*;table source.*;GGSCI (redhat6) 2> info all?Program Status Group Lag at Chkpt Time Since Chkpt?MANAGER RUNNINGEXTRACT RUNNING EXT1 00:00:00 00:00:10
3.4 配置TARGET DB的同步队列
GGSCI (redhat6) 2> edit params ./GLOBALGGSCHEMA ggateCHECKPOINTTABLE ggate.checkpointGGSCI (redhat6) 3> dblogin userid [,password](mailto:,password) ggateSuccessfully logged into database.GGSCI (redhat6) 4> add checkpointtable ggate.checkpointSuccessfully created checkpoint table ggate.checkpoint.
创建同步队列
GGSCI (redhat6) 1> add replicat rep1,exttrail /u01/ogg/dirdat/lt,checkpointtable ggate.checkpointREPLICAT added.GGSCI (redhat6) 5> edit params rep1replicat rep1ASSUMETARGETDEFSuserid [,password](mailto:,password) ggatediscardfile /u01/ogg/dirdat/rep1_discard.txt,append, megabytes 10DDLmap source.*, target targer.*;
3.5 开启同步
(1)SOURCE端:
GGSCI (redhat6) 10> start extract ext1Sending START request to MANAGER ...EXTRACT EXT1 starting?GGSCI (redhat6) 11> info all?Program Status Group Lag at Chkpt Time Since ChkptMANAGER RUNNINGEXTRACT RUNNING EXT1 00:07:38 00:00:00
(2)TARGET端:
GGSCI (redhat6) 3> start replicat rep1Sending START request to MANAGER ...REPLICAT REP1 starting?GGSCI (redhat6) 4> info allProgram Status Group Lag at Chkpt Time Since Chkpt?MANAGER RUNNINGEXTRACT RUNNING EXT1 00:00:00 00:00:05REPLICAT RUNNING REP1 00:00:00 00:00:01
3.6 测试数据复制
(1)SOURCE DB:
[ora ogg]$ sqlplus source/oracle?SQL*Plus: Release 11.2.0.3.0 Production on Mon Dec 9 20:09:11 2013?Copyright (c) 1982, 2011, Oracle. All rights reserved.??Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options?SQL> create table hjj as select * from sys.all_users;?Table created.
(2)TARGET DB 查看数据同步情况:
[ ogg]$ sqlplus targer/oracle?SQL*Plus: Release 11.2.0.3.0 Production on Mon Dec 9 20:09:26 2013?Copyright (c) 1982, 2011, Oracle. All rights reserved.?Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options?SQL> select count(*) from hjj;? COUNT(*)\---------- 12
在SOURCE端执行:
SQL> insert into hjj select * from sys.all_users;?12 rows created.?SQL> commit;?Commit complete.
在TARGET查看同步情况
SQL> select count(*) from hjj;? COUNT(*)\---------- 24
Oracle到Oracle的单向复制配置完成。
相关推荐
farwang 2020-11-25
星愿心愿 2020-11-24
tianhuak 2020-11-24
zhjn0 2020-11-24
昭君出塞 2020-11-23
bluecarrot 2020-11-23
linuxwcj 2020-10-21
以梦为马不负韶华 2020-10-20
彼岸随笔 2020-10-20
yutou0 2020-10-17
applecarelte 2020-10-16
ourtimes 2020-10-16
waterhorse 2020-09-19
MRFENGG 2020-11-11
rainandtear 2020-10-30
kyssfanhui 2020-10-20
liuhangtiant 2020-10-20