Oracle_11G搭建单实例GoldenGate步骤
oracle goldengate使用前的准备事项-概述说明以及解释
oracle goldengate使用前的准备事项-概述说明以及解释1.引言1.1 概述Oracle GoldenGate是一种用于实时数据复制和数据在不同数据库之间的同步的解决方案。
它支持跨数据库平台和操作系统的复制,并且可以用于广泛的业务需求,包括数据库迁移、数据同步和实时分析等。
在开始使用Oracle GoldenGate之前,有一些准备工作是必要的。
首先,需要了解Oracle GoldenGate的基本概念和工作原理。
它通过捕获源数据库的事务日志,将变更数据传输到目标数据库,并应用这些变更以保持两个数据库之间的一致性。
因此,对于Oracle GoldenGate的使用,对于源和目标数据库的理解是非常重要的。
其次,确保满足Oracle GoldenGate的硬件和软件要求。
根据不同的操作系统和数据库平台,Oracle GoldenGate对硬件和软件的要求也有所不同。
在使用Oracle GoldenGate之前,需要确保所使用的硬件和软件环境符合Oracle GoldenGate的要求,以便能够正常运行和实现预期的功能。
最后,准备好源和目标数据库。
在使用Oracle GoldenGate之前,需要确保源数据库和目标数据库已经成功安装和配置,并且能够正常工作。
此外,需要进行一些特定的配置,以便Oracle GoldenGate能够访问并捕获源数据库的事务日志,以及将变更数据应用到目标数据库。
在本文中,我们将深入探讨Oracle GoldenGate使用前的准备事项,包括硬件和软件要求的准备、数据库的准备,以及一些使用Oracle GoldenGate的建议和总结。
通过充分理解和准备这些事项,您将能够更好地使用Oracle GoldenGate,满足您的业务需求。
1.2 文章结构文章结构部分的内容应该包括以下内容:文章结构是指文章在内容组织上的布局和安排。
一个良好的文章结构将有助于读者更好地理解和接受文章的内容。
goldengate如何安装和配置
goldengate如何安装和配置要安装goldengate,第一步当然要先下载软件,您可以到/网站上下载相关软件,注意goldengate是在oracle fusion middleware大类下面,它和操作系统版本,数据库版本都有关系,下载时注意别下错版本。
对于源端数据库,要做以下准备,这里以oracle为例,其它数据库请查找相关手册:a.在源端操作系统上,创建GoldenGate系统用户,设置该用户环境变量(如果是oracle数据库的话,ORACLE_SID,ORACLE_HOME等等),也可以采用oracle 安装用户运行GoldenGate。
建议采用oracle的安装用户安装运行GoldenGate,无需建立新用户,否则还得给新用户授一堆权限,具体请参考安装手册。
b.在数据库中创建GoldenGate数据库用户,名称无所谓,这里以goldengate 为例,用户至少应该有connect,resource,select any dictionary,select any table的权限,当然如果能给dba,一切就都覆盖了:CREATE USER goldengate IDENTIFIED BY goldengate;GRANT dba TO goldengate;c.检查源端数据库是否为归档模式,若为非归档模式,建议将其改为归档模式,其实在非归档模式下也能运行,但以防万一,还是配置归档保险:SQL> alter database archivelog;(需要在数据库mount状态下执行);SQL>archive log list;d.检查源端数据库附加日志是否打开SQL>select supplemental_log_data_min from v$database;将数据库附加日志打开SQL>alter database add supplemental log data;切换日志以使附加日志生效:SQL〉ALTER SYSTEM ARCHIVE LOG CURRENT;在目标数据库上,也需要建立一个goldengate用户,或者利用现有用户也行,该用户应该至少有connect,resource,select any table,select any dictionary以及对应同步表的insert/update/delete权限。
Oracl-11G安装手册
Oracl 11G 64位安装手册1、解压两个压缩包到同一目录,即"database",然后单击解压目录下的"setup.exe"文件,如下图所示:2、.执行安装程序后会出现如下的命令提示行。
3、等待片刻之后就会出现启动画(加载应用程序)4、稍微等待一会,就会出现如下图所示的安装画面,选择第二项:仅安装数据库软件,然后单击"下一步"继续,同时在出现的信息提示框单击"是"继续。
5、之后会出现安装类型对话框,选择:单实例数据库安装6、选择你运行产品使用需要的语言7、选择数据库版本(这里选择企业版)8、选择Oracl的安装路径9、Oracl自动检测本机环境是否符合要求10、检测完成之后,点击完成即可11、Oracl正在安装产品12、1为Sage X3创建用户,赋予权限接下来我们要做的是为windows操作系统创建一个名叫“adonix”的登陆用户,并为用户“adonix”和用户“administrator”赋予权限。
其中,“administrator”是windows操作系统自动创建的用户。
点击“系统工具”>>“本地用户和组”>>“用户”。
密码设置为1位或1位以上,X3才可以正常设置console中的server;如果windows提示密码需满足“8位以上,字母数字并用”等条件,你可以照做,或在“开始”>>“所有程序”>>“管理工具”>>“本地安全策略”>>“账户策略”>>“密码策略”中禁用“密码必须符合复杂性要求”。
现在已经成功地将adonix添加到了ora_dba组中,按相同的方法把adonix也添加进Administrators组中。
给用户adonix赋予权限,点击“开始”>>“所有程序”>>“管理工具”>>“本地安全策略”。
Oracle_GoldenGate安装、配置、管理
Oracle GoldenGate主要由如下一些组件组成● Extract● Data pump● Replicat● Trails or extract files● Checkpoints● Manager● Collector1、Data Pump是一个次级的Extract Group,如果你的GG环境中不使用Data Pump的话,那么Primary Extract Group必须直接将trail通过网络写到Target系统上.参见后面的示例6:配置Data Pump实现一对多拓扑方案.2、默认情况下,Replicat是实时复制的,如果因为某种需要需要延迟复制的话,那么可以通过Replicat Group的如下DEFERAPPLYINTERVAL参数来控制,该参数允许delay的最大时间是7天。
按照Oracle GoldenGate的工作原理和体系结构,在每个复制数据源和目标端都需要安装一套GoldenGate软件,同时需要分别启动一个 GoldenGate实例,一个GoldenGate实例就是一个管理进程(Manager process),这个管理进程也是整个GoldenGate实例运行时最主要的控制进程。
GoldenGate操作系统内存的使用是通过操作系统来控制的,而不是通过GoldenGate程序控制的,GoldenGate进程会根据需要从OS 那里分配相应的virtual memory.●GoldenGate GGSCI命令接口工具对于每个GoldenGate实例可以支持并发300个Extract和Replicat进程。
●每个Extract和Replicat进程需要大约25-55 MB内存,这主要取决于transaction的大小和并发的transaction数量。
所以,根据上面2个条件,GoldenGate对操作系统内存的需求主要取决于Extract和Replicat进程数。
工作目录每个GoldenGate实例的工作目录(working directories and binaries),大约需要40M的空间,如果你要同一台Server安装多个GoldenGate实例到不同的目录/文件系统下话,那么就需要多倍的空间分配,在考虑空间分配的时候,也需要考虑这个因数。
goldengate配置(rac向单实例包含ddl)
goldengate配置(rac向单实例包含ddl)Goldengate配置环境:11204的双节点rac,11204的单实例数据库软件:goldengate 版本:121200_fbo_ggs_Linux_x64_shiphome(中国官网没有)由于之前使用版本ogg112101_fbo_ggs_Linux_x64_ora11g_64bit(中国官网)导致与11204版本不兼容,所以更换最新版。
Rac与单实例不同之处在与rac上的goldengate需要安装在共享存储上,以下为详细步骤:首先在oracle rac上安装goldengate,因为使用的oracle版本比较新,goldengate 版本也比较新,所以很多以前的的配置方法需要一些小的修改,具体为下面红色字体:安装之前,先要在各个节点都创建/opt/app/ogg的安装目录,然后在共享存储上新建一个供各个节点的/opt/app/ogg安装目录使用的分区,此处把该分区格式化为ext3文件系统(ext3文件系统不是支持共享的,所以在安装过程中会有错误):mkfs �Ct ext3/dev/sdf1,然后把各个节点的目录挂载到共享存储的供goldengate使用的分区下:mount /dev/sdf1/opt/app/ogg,之后使用grid用户来进行安装,执行下面的安装: 源端配置步骤:[grid@rac1 ~]$ cd /opt/app/dir/fbo_ggs_Linux_x64_shiphome/ [grid@rac1fbo_ggs_Linux_x64_shiphome]$ ls Disk1[grid@rac1 fbo_ggs_Linux_x64_shiphome]$ cd Disk1/ [grid@rac1Disk1]$ ./runInstaller Starting Oracle Universal Installer...Checking Temp space: must be greater than 120 MB. Actual 8976 MB Passed Checking swap space: must be greater than 150 MB. Actual 29996 MB PassedChecking monitor: must be configured to display at least 256 colors. Actual 16777216 PassedPreparing to launch Oracle Universal Installer from /tmp/OraInstall2021-06-12_11-29-54AM. Please wait ...[grid@rac1 Disk1]$因为使用的数据库版本wei11204,此处选择安装11g的goldengate,点击next此处选择软件的安装路径和是否启动goldengate的mgr,注意:此处的安装目录/opt/app/ogg必须是安装在共享存储上,然后各个节点的/opt/app/ogg都挂在该共享存储分区,点击next因为之前把共享存储分区格式化为了ext3文件系统,但是该系统并是共享文件系统,所以回报这个错误,但是goldengate依旧还是安装在了共享存储上,依旧可以从其他节点启动,只是此处无法识别,虽然可以点击yes,继续安装,把goldengate安装在sdf1分区上。
ORACLE GoldenGate搭建实验
ORACLE GoldenGate搭建实验实验环境说明:操作系统版本:Red hat Enterprise 6.5(Linux系统)Windows Server 2012R2(Windows系统)数据库ORACLE版本:11.2.0.4Goldengate版本:12.1.2.1.0一、GoldenGate搭建前的准备工作1.1Goldengate软件下载建议去ORACLE官网下载,根据需要下载不同版本的GoldenGate软件,本次试验下载的GoldenGate软件版本是12.1.2.1.01.2数据库配置1.2.1创建ORACLE GoldenGate的管理用户--创建管理用户所对应的表空间SQL>create tablespace oggtb datafile '/oradata/ogg01.dbf' size 1000M autoextend on next 5M maxsize unlimited;--创建管理用户ogg,源端用户ogg1,目标端用户ogg2SQL>create user ogg identified by oggtest default tablespace oggtb;SQL>create user ogg1 identified by ogg1 default tablespace oggtb;SQL>create user ogg2 identified by ogg2 default tablespace oggtb;--给用户授权SQL>grant connect,resource,dba to ogg;SQL>grant connect,resource,dba to ogg1;SQL>grant connect,resource,dba to ogg2;1.2.2开启数据库归档--查看当前数据库是否开启归档。
OracleGoldenGate介绍与实施
OracleGoldenGate介绍与实施Oracle GoldenGate是一种高性能、实时数据复制和数据集成软件,可在异构数据库、主机和平台之间实现高效的实时数据复制和同步。
GoldenGate可以在源和目标系统之间进行数据抽取、传输和应用,并提供高可用性、可伸缩性和数据一致性。
1. 高性能:GoldenGate使用轻量级的事务日志挖掘技术,可以在几乎没有对源系统的影响下进行实时数据复制。
2. 实时数据复制:GoldenGate可以在源数据库上监控日志,并将变更应用到目标数据库中,实现实时的数据同步。
3. 异构数据库支持:GoldenGate可以支持多种数据库平台,包括Oracle、Microsoft SQL Server、IBM DB2等。
4. 数据过滤和转换:GoldenGate可以根据用户的需求,在数据复制过程中进行数据过滤和转换,以满足不同系统的数据需求。
5. 可伸缩性和高可用性:GoldenGate可以通过添加副本和增加传输通道来实现灵活的扩展。
同时,GoldenGate还提供了故障转移和冗余配置,确保数据复制的连续性和可用性。
6. 实时监控和管理:GoldenGate提供了一套监控和管理工具,可以用于实时监控数据复制的状态、性能和健康状况,并提供了故障排除和性能优化的功能。
在实施Oracle GoldenGate时,可以按照以下步骤进行:1. 环境准备:在实施GoldenGate之前,需要准备好源和目标数据库的环境。
这包括安装并配置GoldenGate软件、创建必要的用户和权限、设置数据库参数等。
2. 配置和启动GoldenGate:在源和目标数据库上配置GoldenGate的参数文件,并使用GoldenGate提供的管理工具启动GoldenGate进程。
3. 创建抽取进程:通过GoldenGate的管理工具创建抽取进程,用于在源数据库上监控日志,并将变更写入GoldenGate的抽取文件。
goldengate施工文档详解
Goldengate施工文档(生产库部分)按照此文档施工需求:1.镜像库需要安装oracle数据库,字符集为utf82. 施工介质------(ggs_Linux_x64_ora11g_64bit_v11_1_1_0_0_078.tar)需要上传至镜像服务器/u01/app/upload目录下。
并授权给oracle用户第一步:准备工作登录生产服务器:1.检查环境变量[root@localhost ~]# su - oracle[oracle@localhost ~]$ vi .bash_profile -------------------------编辑oracle用户的环境变量配置文件# .bash_profile# Get the aliases and functionsif [ -f ~/.bashrc ]; then. ~/.bashrcfi# User specific environment and startup programsPATH=$PATH:$HOME/binexport PATHexport ORACLE_BASE=/u01/app/oracleexport ORACLE_HOME=$ORACLE_BASE/product/11g/db_1export ORACLE_SID=orclexport NLS_LANG=AMERICAN_AMERICA.al32UTF8export PATH=$PATH:$ORACLE_HOME/binexport LANG=zh_CN.UTF-8export PATH=$PATH:$ORACLE_BASE/goldengateexportLD_LIBRARY_PATH=$ORACLE_BASE/goldengate:$LD_LIBRARY_PATH:$ORACLE_HOME/lib主要查看蓝色字体部分,没有的话添加上!光标用上下键移动至文件末尾,摁i键进入编辑模式,摁Enter键换行,然后输入上面的蓝色字体部分,最后摁Esc键,然后输入:wq!再摁回车键保存退出2.检查数据库是否开启归档[oracle@localhost ~]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.1.0 Production on Mon Mar 19 20:42:59 2012Copyright (c) 1982, 2009, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> archive log list;-----------------------------------------------(查看是否开启归档)Database log mode Archive Mode----------------------------(归档模式)Automatic archival EnabledArchive destination /archive-----------------------------(归档日志路径,牢记,后面会用到)Oldest online log sequence 10Next log sequence to archive 12Current log sequence 12SQL> archive log list;Database log mode No Archive Mode----------------------------(非归档模式)Automatic archival DisabledArchive destination USE_DB_RECOVERY_FILE_DESTOldest online log sequence 7Current log sequence 9若数据库为非归档模式,当联系当地数据库管理员开启归档模式!附(开启归档命令):设置为归档模式SQL> exitDisconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options[oracle@localhost ~]$ exitlogout[root@localhost ~]# mkdir /archive[root@localhost ~]# chown oracle:oinstall /archive[root@localhost ~]# su - oracle[oracle@localhost ~]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.1.0 Production on Tue Mar 20 21:41:19 2012Copyright (c) 1982, 2009, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> show parameter logSQL> alter system set log_archive_dest_1='location=/archive' scope=spfile;SQL> alter system set log_archive_format='%s_%t_%r.arc' scope=spfile;SQL> shutdown immediate----------- 一致性停库(切记联系当地数据库管理员,取得同意方可停库)SQL> startup mountSQL> alter database archivelog ;SQL> alter database open;SQL> alter system switch logfile;第二步:安装goldengate软件1.创建goldengate数据库用户SQL> select name from v$datafile;NAME--------------------------------------------------------------------------------/u01/app/oracle/oradata/orcl/system01.dbf/u01/app/oracle/oradata/orcl/sysaux01.dbf/u01/app/oracle/oradata/orcl/undotbs01.dbf/u01/app/oracle/oradata/orcl/users01.dbf/u01/app/oracle/oradata/orcl/example01.dbf/u01/app/oracle/oradata/orcl/test1.dbf/u01/app/oracle/oradata/orcl/test2.dbfSQL> CREATE SMALLFILE TABLESPACE "GGS" datafile '/u01/app/oracle/oradata/orcl/ggs.dbf' SIZE 200M;---------------------------------------(注意蓝色字体部分的路径必须和上面查出来的保持一致) SQL> create user GGMGR identified by oracle default tablespace GGS;SQL>grant connect to ggmgr;SQL>grant resource to ggmgr;SQL>grant CREATE SESSION, ALTER SESSION to ggmgr;SQL>grant SELECT ANY DICTIONARY to ggmgr;SQL>grant FLASHBACK ANY TABLE to ggmgr;SQL>grant alter any table to ggmgr;SQL>grant SELECT ANY TABLE to ggmgr;SQL>grant EXECUTE on DBMS_FLASHBACK to ggmgr;2.调整归档模式SQL> alter database force logging;SQL> alter database add supplemental log data;3.安装goldengateSQL>exitDisconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options[oracle@localhost ~]$ cd $ORACLE_BASE[oracle@localhost oracle]$ mkdir goldengate[oracle@localhost goldengate]$scp 10.10.40.200:/u01/app/upload/ggs_Linux_x64_ora11g_64bit_v11_1_1_0_0_078.tar .注:蓝色字体部分为镜像机的IP[oracle@localhost goldengate]$ tar -xcf ggs_Linux_x64_ora11g_64bit_v11_1_1_0_0_078.tar 4.配置goldengate相关进程[oracle@localhost goldengate]$ ./ggsciOracle GoldenGate Command Interpreter for OracleVersion 11.1.1.0.0 Build 078Linux, x64, 64bit (optimized), Oracle 11 on Jul 28 2010 13:13:42Copyright (C) 1995, 2010, Oracle and/or its affiliates. All rights reserved.GGSCI (localhost.localdomain) 1> create subdirsCreating subdirectories under current directory /u01/app/oracle/goldengateParameter files /u01/app/oracle/goldengate/dirprm: createdReport files /u01/app/oracle/goldengate/dirrpt: createdCheckpoint files /u01/app/oracle/goldengate/dirchk: createdProcess status files /u01/app/oracle/goldengate/dirpcs: createdSQL script files /u01/app/oracle/goldengate/dirsql: created Database definitions files /u01/app/oracle/goldengate/dirdef: created Extract data files /u01/app/oracle/goldengate/dirdat: created Temporary files /u01/app/oracle/goldengate/dirtmp: created Veridata files /u01/app/oracle/goldengate/dirver: created Veridata Lock files /u01/app/oracle/goldengate/dirver/lock: created Veridata Out-Of-Sync files /u01/app/oracle/goldengate/dirver/oos: created Veridata Out-Of-Sync XML files /u01/app/oracle/goldengate/dirver/oosxml: created Veridata Parameter files /u01/app/oracle/goldengate/dirver/params: created Veridata Report files /u01/app/oracle/goldengate/dirver/report: created Veridata Status files /u01/app/oracle/goldengate/dirver/status: created Veridata Trace files /u01/app/oracle/goldengate/dirver/trace: created Stdout files /u01/app/oracle/goldengate/dirout: created GGSCI (localhost.localdomain) 2> edit params mgr摁i键,输入port 7809然后摁Esc键输入:wq! 最后摁回车,保存退出GGSCI (localhost.localdomain) 3>start mgrGGSCI (localhost.localdomain) 4>info allProgram Status Group Lag Time Since Chkpt MANAGER RUNNINGGGSCI (localhost.localdomain) 5>dblogin userid ggmgr,password oracle Successfully logged into database.GGSCI (localhost.localdomain) 6> add trandata test1.*GGSCI (localhost.localdomain) 7> add trandata test2.*GGSCI (localhost.localdomain) 8> exit[oracle@localhost goldengate]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.1.0 Production on Mon Mar 19 23:44:59 2012Copyright (c) 1982, 2009, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> alter system switch logfile;System altered.SQL> alter system switch logfile;System altered.SQL> alter system switch logfile;System altered.SQL> exitDisconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options[oracle@localhost goldengate]$ ll -t /archive/总计5928-rw-r----- 1 oracle oinstall 1536 03-19 23:45 14_1_778124720.arc-rw-r----- 1 oracle oinstall 1024 03-19 23:45 13_1_778124720.arc-rw-r----- 1 oracle oinstall 2477056 03-19 23:45 12_1_778124720.arc-rw-r----- 1 oracle oinstall 2048 03-19 22:02 11_1_778124720.arc-rw-r----- 1 oracle oinstall 1024 03-19 22:02 10_1_778124720.arc-rw-r----- 1 oracle oinstall 3567104 03-19 22:02 9_1_778124720.arc注意上面蓝色字体部分为日志序列号,记录最大的数![oracle@localhost goldengate]$ ./ggsciOracle GoldenGate Command Interpreter for OracleVersion 11.1.1.0.0 Build 078Linux, x64, 64bit (optimized), Oracle 11 on Jul 28 2010 13:13:42Copyright (C) 1995, 2010, Oracle and/or its affiliates. All rights reserved.GGSCI (localhost.localdomain) 1>add extract exttyfc,tranlog, extseqno 14, extrba 0 EXTRACT added.注意命令中蓝色字体部分跟刚才查看的最大日志序列号保持一致GGSCI (localhost.localdomain) 2> add exttrail ./dirdat/et,extract exttyfc,megabytes 50 EXTTRAIL added.GGSCI (localhost.localdomain) 3> edit params exttyfc摁i进入编辑模式,输入下面的内容,注意的是蓝色字体部分其中/archive是生产库归档路径,如果不能肯定的话回头看第一步操作中的第二小节!TEST1和TEST2分别是两个生产用户,每个生产用户写一行,根据生产库实际情况确定!输入完成后先摁Esc键,再输入:wq!最后摁回车保存退出extract exttyfcsetenv (NLS_LANG=AMERICAN_AMERICA.AL32UTF8)userid ggmgr,password oracleTRANLOGOPTIONS ARCHIVEDLOGONLYTRANLOGOPTIONS altarchivelogdest /archiveGETTRUNCATESREPORTCOUNT EVERY 30 MINUTES, RATEDISCARDFILE ./dirrpt/exttyfc.dsc,APPEND,MEGABYTES 1024exttrail ./dirdat/ettable TEST1.*;table TEST2.*;GGSCI (localhost.localdomain) 4> add extract dpetk exttrailsource ./dirdat/etEXTRACT added.GGSCI (localhost.localdomain) 5> add rmttrail ./dirdat/tk,extract dpetkRMTTRAIL added.GGSCI (localhost.localdomain) 6> edit params dpetk摁i进入编辑模式,输入下面的内容,注意的是蓝色字体部分其中10.10.40.201是镜像库的IP地址,TEST1和TEST2分别是两个生产用户,每个生产用户下的每个表写一行,根据生产库实际情况确定,输入完成后先摁Esc键,再输入:wq!最后摁回车保存退出extract dpetkpassthrurmthost 10.10.40.201,mgrport 7809, compressnumfiles 5000DYNAMICRESOLUTIONrmttrail ./dirdat/tktable TEST1.T1;table TEST1.T2;table TEST2.T3;GGSCI (localhost.localdomain) 7> exitGoldengate施工文档(镜像库部分)登录镜像服务器:第一步:检查环境变量[root@localhost ~]# su - oracle[oracle@localhost ~]$ vi .bash_profile -------------------------编辑oracle用户的环境变量配置文件# .bash_profile# Get the aliases and functionsif [ -f ~/.bashrc ]; then. ~/.bashrcfi# User specific environment and startup programsPATH=$PATH:$HOME/binexport PATHexport ORACLE_BASE=/u01/app/home/oracleexport ORACLE_HOME=$ORACLE_BASE/product/11g/db_1export ORACLE_SID=orclexport NLS_LANG=AMERICAN_AMERICA.al32UTF8export PATH=$PATH:$ORACLE_HOME/binexport LANG=zh_CN.UTF-8export PATH=$PATH:$ORACLE_BASE/goldengateexportLD_LIBRARY_PATH=$ORACLE_BASE/goldengate:$LD_LIBRARY_PATH:$ORACLE_HOME/lib主要查看蓝色字体部分,没有的话添加上!光标用上下键移动至文件末尾,摁i键进入编辑模式,摁Enter键换行,然后输入上面的蓝色字体部分,最后摁Esc键,然后输入:wq!再摁回车键保存退出第二步:建立表空间和用户1.建立表空间[oracle@localhost ~]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.1.0 Production on Tue Mar 20 01:05:48 2012Copyright (c) 1982, 2009, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> select name from v$datafile;NAME--------------------------------------------------------------------------------/u01/app/home/oracle/oradata/orcl/system01.dbf/u01/app/home/oracle/oradata/orcl/sysaux01.dbf/u01/app/home/oracle/oradata/orcl/undotbs01.dbf/u01/app/home/oracle/oradata/orcl/users01.dbf/u01/app/home/oracle/oradata/orcl/example01.dbfSQL> create tablespace ggmgr datafile '/u01/app/home/oracle/oradata/orcl/ggmgr.dbf' size 1024m;Tablespace created.SQL> select name from v$datafile;NAME--------------------------------------------------------------------------------/u01/app/home/oracle/oradata/orcl/system01.dbf/u01/app/home/oracle/oradata/orcl/sysaux01.dbf/u01/app/home/oracle/oradata/orcl/undotbs01.dbf/u01/app/home/oracle/oradata/orcl/users01.dbf/u01/app/home/oracle/oradata/orcl/example01.dbf/u01/app/home/oracle/oradata/orcl/ggmgr.dbf此时用相同命令查看生产库的表空间,对比后创建生产库有而镜像库没有的表空间,路径参考镜像库路径,文件名参考生产库文件名SQL> create bigfile tablespace test1 datafile '/u01/app/home/oracle/oradata/orcl/test1.dbf' size 2G autoextend on;Tablespace created.SQL> create bigfile tablespace test2 datafile '/u01/app/home/oracle/oradata/orcl/test2.dbf' size 2G autoextend on;Tablespace created.2.建立用户SQL> create user test1 identified by "test1" default tablespace test1 temporary tablespace temp;User created.SQL> create user test2 identified by "test2" default tablespace test2 temporary tablespace temp;User created.SQL> create user ggmgr identified by oracle default tablespace ggmgr temporary tablespace temp;User created.SQL> grant resource,connect,DBA to test1,test2;Grant succeeded.SQL> grant create session,connect,resource,dba to ggmgr;Grant succeeded.SQL>exitDisconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options第三步:安装goldengate软件1.安装goldengate软件[oracle@localhost ~]$ cd $ORACLE_BASE[oracle@localhost oracle]$ mkdir goldengate[oracle@localhost goldengate]$cp /u01/app/upload/ggs_Linux_x64_ora11g_64bit_v11_1_1_0_0_078.tar .[oracle@localhost goldengate]$ tar -xcf ggs_Linux_x64_ora11g_64bit_v11_1_1_0_0_078.tar 2.配置goldengate相关进程[oracle@localhost goldengate]$ ./ggsciOracle GoldenGate Command Interpreter for OracleVersion 11.1.1.0.0 Build 078Linux, x64, 64bit (optimized), Oracle 11 on Jul 28 2010 13:13:42Copyright (C) 1995, 2010, Oracle and/or its affiliates. All rights reserved.GGSCI (localhost.localdomain) 1> create subdirsCreating subdirectories under current directory /u01/app/home/oracle/goldengateParameter files /u01/app/home/oracle/goldengate/dirprm: createdReport files /u01/app/home/oracle/goldengate/dirrpt: created Checkpoint files /u01/app/home/oracle/goldengate/dirchk: createdProcess status files /u01/app/home/oracle/goldengate/dirpcs: createdSQL script files /u01/app/home/oracle/goldengate/dirsql: createdDatabase definitions files /u01/app/home/oracle/goldengate/dirdef: createdExtract data files /u01/app/home/oracle/goldengate/dirdat: created Temporary files /u01/app/home/oracle/goldengate/dirtmp: created Veridata files /u01/app/home/oracle/goldengate/dirver: createdVeridata Lock files /u01/app/home/oracle/goldengate/dirver/lock: created Veridata Out-Of-Sync files /u01/app/home/oracle/goldengate/dirver/oos: created Veridata Out-Of-Sync XML files /u01/app/home/oracle/goldengate/dirver/oosxml: created Veridata Parameter files /u01/app/home/oracle/goldengate/dirver/params: created Veridata Report files /u01/app/home/oracle/goldengate/dirver/report: created Veridata Status files /u01/app/home/oracle/goldengate/dirver/status: created Veridata Trace files /u01/app/home/oracle/goldengate/dirver/trace: created Stdout files /u01/app/home/oracle/goldengate/dirout: createdGGSCI (localhost.localdomain) 2> edit params mgr摁i键,输入port 7809然后摁Esc键输入:wq! 最后摁回车,保存退出GGSCI (localhost.localdomain) 3>start mgrGGSCI (localhost.localdomain) 4>info allProgram Status Group Lag Time Since ChkptMANAGER RUNNINGGGSCI (localhost.localdomain) 5>dblogin userid ggmgr,password oracleSuccessfully logged into database.GGSCI (localhost.localdomain) 6> edit params ./GLOBALS摁i键,输入checkpointtable ggmgr.ggs_checkpointtable然后摁Esc键输入:wq! 最后摁回车,保存退出GGSCI (localhost.localdomain) 7>dblogin userid ggmgr,password oracleSuccessfully logged into database.GGSCI (localhost.localdomain) 8> ADD CHECKPOINTTABLE ggmgr.ggs_checkpointtable Successfully created checkpoint table GGMGR.GGS_CHECKPOINTTABLE.GGSCI (localhost.localdomain) 9> ADD REPLICAT REPtyfc,EXTTRAIL ./dirdat/tk,checkpointtable ggmgr.ggs_checkpointtableREPLICAT added.GGSCI (localhost.localdomain) 10> edit params reptyfc摁i键,输入下面棕色字体内容,然后摁Esc键输入:wq! 最后摁回车,保存退出REPLICAT reptyfcUSERID ggmgr,PASSWORD "oracle"ASSUMETARGETDEFSDISCARDFILE ./dirrpt/reptyfc.dsc,PURGEMap test1.T1, target test1.T1;Map test1.T2,target test1.T2;Map test2.T3, target test2.T3;注意蓝色字体部分,test1和test2分别是两个生产用户!T1,T2,T3分别是需要同步的表,一个表写一行,每个表前分别加所属生产用户至此goldengate配置全部完成数据初始化登录生产服务器:[root@localhost ~]#ll -t /archive/总计5928-rw-r----- 1 oracle oinstall 1536 03-19 23:45 15_1_778124720.arc-rw-r----- 1 oracle oinstall 1536 03-19 23:45 14_1_778124720.arc-rw-r----- 1 oracle oinstall 1024 03-19 23:45 13_1_778124720.arc-rw-r----- 1 oracle oinstall 2477056 03-19 23:45 12_1_778124720.arc-rw-r----- 1 oracle oinstall 2048 03-19 22:02 11_1_778124720.arc-rw-r----- 1 oracle oinstall 1024 03-19 22:02 10_1_778124720.arc-rw-r----- 1 oracle oinstall 3567104 03-19 22:02 9_1_778124720.arc注意上面蓝色字体部分为日志序列号,记录最大的数!1.产生dump文件注:按用户导出,有几个用户导出几次[root@localhost ~]# su - oracle[oracle@localhost ~]$ exp test1/test1 file=test1_0319.dmp owner=test1 triggers=n grants=n INDEXES=n log=test1_0319.log注意,命令中的test1/test1分别是username/password 0319是日期,根据生产库实际情况修改命令Export: Release 11.2.0.1.0 - Production on Tue Mar 20 00:33:37 2012Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsExport done in AL32UTF8 character set and AL16UTF16 NCHAR character setNote: grants on tables/views/sequences/roles will not be exportedNote: indexes on tables will not be exportedNote: constraints on tables will not be exportedAbout to export specified users .... exporting pre-schema procedural objects and actions. exporting foreign function library names for user TEST1. exporting PUBLIC type synonyms. exporting private type synonyms. exporting object type definitions for user TEST1About to export TEST1's objects .... exporting database links. exporting sequence numbers. exporting cluster definitions. about to export TEST1's tables via Conventional Path .... . exporting table T1 14 rows exported. . exporting table T2 5 rows exported. exporting synonyms. exporting views. exporting stored procedures. exporting operators. exporting indextypes. exporting posttables actions. exporting materialized views. exporting snapshot logs. exporting job queues. exporting refresh groups and children. exporting dimensions. exporting post-schema procedural objects and actions. exporting statisticsExport terminated successfully without warnings.[oracle@localhost ~]$ exp test2/test2 file=test2_0319.dmp owner=test2 triggers=n grants=n INDEXES=n log=test2_0319.log注意,命令中的test2/test2分别是username/password 0319是日期,根据生产库实际情况修改命令Export: Release 11.2.0.1.0 - Production on Tue Mar 20 00:36:37 2012Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsExport done in AL32UTF8 character set and AL16UTF16 NCHAR character setNote: grants on tables/views/sequences/roles will not be exportedNote: indexes on tables will not be exportedNote: constraints on tables will not be exportedAbout to export specified users .... exporting pre-schema procedural objects and actions. exporting foreign function library names for user TEST2. exporting PUBLIC type synonyms. exporting private type synonyms. exporting object type definitions for user TEST2About to export TEST2's objects .... exporting database links. exporting sequence numbers. exporting cluster definitions. about to export TEST2's tables via Conventional Path .... . exporting table T3 14 rows exported. exporting synonyms. exporting views. exporting stored procedures. exporting operators. exporting indextypes. exporting posttables actions. exporting materialized views. exporting snapshot logs. exporting job queues. exporting refresh groups and children. exporting dimensions. exporting post-schema procedural objects and actions. exporting statisticsExport terminated successfully without warnings.2.SCP dump文件到镜像库服务器[oracle@localhost ~]$ scp *.dmp 10.10.40.201:/home/oracleThe authenticity of host '10.10.40.201 (10.10.40.201)' can't be established.RSA key fingerprint is 56:62:c6:bc:5c:98:57:67:48:56:7e:ea:78:b7:a2:a1.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '10.10.40.201' (RSA) to the list of known hosts.oracle@10.10.40.201's password:test1_0319.dmp 100% 16KB 16.0KB/s 00:00 test2_0319.dmp 100% 16KB 16.0KB/s 00:003.镜像库导入dump文件登录镜像服务器:[root@localhost ~]# su - oracle注意:若生产库字符集为UTF8,则参考下面的命令[oracle@localhost ~]$ imp test1/test1 fromuser=test1 touser=test1 grants=n log=test1_0319.log file=test1_0319.dmp注:test1/test1为镜像库与生产库同名的用户与密码0319为当前日期Import: Release 11.2.0.1.0 - Production on Tue Mar 20 01:36:43 2012Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsExport file created by EXPORT:V11.02.00 via conventional pathimport done in AL32UTF8 character set and AL16UTF16 NCHAR character set. . importing table "T1" 14 rows imported. . importing table "T2" 5 rows importedImport terminated successfully without warnings.[oracle@localhost ~]$ imp test2/test2 fromuser=test2 touser=test2 grants=n log=test2_0319.log file=test2_0319.dmpImport: Release 11.2.0.1.0 - Production on Tue Mar 20 01:43:46 2012Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsExport file created by EXPORT:V11.02.00 via conventional pathimport done in AL32UTF8 character set and AL16UTF16 NCHAR character set. . importing table "T3" 14 rows importedImport terminated successfully without warnings.注意:若生产库字符集为GBK,或者别的字符集,参考下面的命令(多加了参数rows=n)[oracle@localhost ~]$imp test1/test1 fromuser=test1 touser=test1 grants=n rows=n log=test1_0319.log file=test1_0319.dmp[oracle@localhost ~]$imp test2/test2 fromuser=test2 touser=test2 grants=n rows=n log=test2_0319.log file=test2_0319.dmp[oracle@localhost ~]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.1.0 Production on Tue Mar 20 01:48:48 2012Copyright (c) 1982, 2009, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> create or replace procedure zjb_expand_vchar(varUser in varchar2)is begindeclarev_length number;v_sql varchar(5000);beginfor v in (select a.owner,a.table_name,a.column_name,a.data_type,data_length from dba_tab_cols a,dba_tables bwhere a.owner=upper(varUser)and (a.data_type ='VARCHAR2' ora.data_type='CHAR')and b.owner=upper(varUser) and a.table_name=b.table_name order by a.table_name) loopv_sql:='';v_length:= v.data_length+ceil(v.data_length/2);if v.data_type='VARCHAR2' and v_length>4000 thenv_length:=4000;end if;if v.data_type='CHAR' and v_length>2000 thenv_length:=2000;end if;--DBMS_OUTPUT.PUT_LINE(v.data_length);--DBMS_OUTPUT.PUT_LINE(v_length);v_sql:='alter table '||v.owner||'.'||v.table_name ||' modify'||v.column_name||' '||v.data_type ||'('||v_length||') ';--DBMS_OUTPUT.PUT_LINE(v_sql);execute immediate v_sql; --动态执行DDL语句end loop;exceptionwhen others thendbms_output.put_line(sqlerrm);null;end;end zjb_expand_vchar;/Procedure created.SQL> exec zjb_expand_vchar('test1');PL/SQL procedure successfully completed.SQL> exec zjb_expand_vchar('test2');PL/SQL procedure successfully completed.注:蓝色字体部分为生产用户,每个用户都需要执行一次!SQL> exitDisconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options[oracle@localhost ~]$ imp test1/test1 fromuser=test1 touser=test1 grants=n ignore=y log=test1_0319.log file=test1_0319.dmp[oracle@localhost ~]$ imp test2/test2 fromuser=test2 touser=test2 grants=n ignore=y log=test2_0319.log file=test2_0319.dmp启动goldengate进程1.注意事项所有操作过程中尽量避免生产库有数据变化!如果在生产库操作第二步第四小节中查看到的最大日志序列号和产生dump文件前查看到的最大日志序列号不一致,则需要在启动所有进程前做如下操作:登录生产库:[root@localhost ~]# su - oracle[oracle@localhost ~]$ cd $ORACLE_BASE[oracle@localhost oracle]$ cd goldengate/[oracle@localhost goldengate]$ ./ggsciOracle GoldenGate Command Interpreter for OracleVersion 11.1.1.0.0 Build 078Linux, x64, 64bit (optimized), Oracle 11 on Jul 28 2010 13:13:42Copyright (C) 1995, 2010, Oracle and/or its affiliates. All rights reserved.GGSCI (localhost.localdomain) 1> alter extract exttyfc, tranlog, extseqno 15, extrba 0EXTRACT altered.2.启动goldengate进程1.启动生产库goldengate进程GGSCI (localhost.localdomain) 2> start exttyfcSending START request to MANAGER ...EXTRACT EXTTYFC startingGGSCI (localhost.localdomain) 3> info allProgram Status Group Lag Time Since ChkptMANAGER RUNNINGEXTRACT STOPPED DPETK 00:00:00 00:00:13 EXTRACT RUNNING EXTTYFC 00:00:00 00:00:07 GGSCI (localhost.localdomain)4> start dpetkSending START request to MANAGER ...EXTRACT DPETK startingGGSCI (localhost.localdomain) 5> info allProgram Status Group Lag Time Since ChkptMANAGER RUNNINGEXTRACT RUNNING DPETK 00:00:00 00:08:13 EXTRACT RUNNING EXTTYFC 00:00:00 00:00:072.启动镜像库goldengate进程登录镜像库[root@localhost ~]# su – oracle[oracle@localhost ~]$ cd /u01/app/home/oracle/goldengate/[oracle@localhost ~]$ cd $ORACLE_BASE/goldengate[oracle@localhost goldengate]$ ./ggsciOracle GoldenGate Command Interpreter for OracleVersion 11.1.1.0.0 Build 078Linux, x64, 64bit (optimized), Oracle 11 on Jul 28 2010 13:13:42Copyright (C) 1995, 2010, Oracle and/or its affiliates. All rights reserved.GGSCI (localhost.localdomain) 1> info allProgram Status Group Lag Time Since Chkpt MANAGER RUNNINGREPLICAT STOPPED REPTYFC 00:00:00 00:06:33 GGSCI (localhost.localdomain) 2> start reptyfcSending START request to MANAGER ...REPLICAT REPTYFC startingGGSCI (localhost.localdomain) 3> info allProgram Status Group Lag Time Since ChkptMANAGER RUNNINGREPLICAT RUNNING REPTYFC 00:00:00 00:00:02。
Oracle-11G搭建单实例GoldenGate步骤(汇编)
Oracle 11G 搭建单实例GoldenGate步骤1 GoldenGate安装准备在Oracle官网上下载GoldenGate介质,GoldenGate是包含在Fusion Middleware 类目下面,并上传到源数据库和目标数据库主机;2 GoldenGate安装过程注意:此步骤需要在两台主机上操作2.1 创建GoldenGate操作系统用户这里直接使用Oracle用户安装GoldenGate,而不创建新的用户。
2.2 创建GoldenGate安装路径[root@GMDBA ~]# mkdir -p /u01/ggs/11.2.0[root@GMDBA ~]# mv /u01/software/ogg112101_fbo_ggs_Linux_x86_ora11g_32bit.zip /u01/ggs/11.2.0/ [root@GMDBA ~]# chown -R oracle:oinstall /u01/ggs/[root@GMDBA ~]# su - oracle2.3 编辑用户环境变量[oracle@GMDBA ogg]$ vi ~/.bash_profile# .bash_profile# Get the aliases and functionsif [ -f ~/.bashrc ]; then. ~/.bashrcFi# User specific environment and startup programsPATH=$PATH:$HOME/binexport PATHexport ORACLE_SID=GMDBAexport ORACLE_BASE=/u01/app/oracleexport ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1export PATH=$ORACLE_HOME/bin:/u01/ggs/11.2.0:$PATHexport LD_LIBRARY_PATH=$ORACLE_HOME/lib:/u01/ggs/11.2.0:/libalias sqlplus='rlwrap sqlplus'alias rman='rlwrap rman'2.4 安装GoldenGate文件[oracle@GMDBA ~]$ cd /u01/ggs/11.2.0/[oracle@GMDBA 11.2.0]$ unzip ogg112101_fbo_ggs_Linux_x86_ora11g_32bit.zip Archive: ogg112101_fbo_ggs_Linux_x86_ora11g_32bit.zipinflating: fbo_ggs_Linux_x86_ora11g_32bit.tarinflating: OGG_WinUnix_Rel_Notes_11.2.1.0.1.pdfinflating: Oracle GoldenGate 11.2.1.0.1 README.txtinflating: Oracle GoldenGate 11.2.1.0.1 README.doc[oracle@GMDBA 11.2.0]$ tar -xvf fbo_ggs_Linux_x86_ora11g_32bit.tar [oracle@GMDBA 11.2.0]$ cd[oracle@GMDBA ~]$ cd /u01/ggs/11.2.0[oracle@GMDBA 11.2.0]$ ggsciOracle GoldenGate Command Interpreter for OracleVersion 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO Linux, x86, 32bit (optimized), Oracle 11g on Apr 23 2012 08:09:25Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.GGSCI (GMDBA) 1> create subdirsCreating subdirectories under current directory /u01/ggs/11.2.0Parameter files /u01/ggs/11.2.0/dirprm: already exists Report files /u01/ggs/11.2.0/dirrpt: created Checkpoint files /u01/ggs/11.2.0/dirchk: created Process status files /u01/ggs/11.2.0/dirpcs: createdSQL script files /u01/ggs/11.2.0/dirsql: created Database definitions files /u01/ggs/11.2.0/dirdef: createdExtract data files /u01/ggs/11.2.0/dirdat: created Temporary files /u01/ggs/11.2.0/dirtmp: created Stdout files /u01/ggs/11.2.0/dirout: createdGGSCI (GMDBA) 2>注意:需要进入ogg的安装目录在执行ggsci[oracle@GMDBA ~]$ cd /u01/ogg/11.2.0/[oracle@GMDBA 11.2.0]$ ggsciOracle GoldenGate Command Interpreter for OracleVersion 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO Linux, x86, 32bit (optimized), Oracle 11g on Apr 23 2012 08:09:25Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved. GGSCI (GMDBA) 1> helpGGSCI Command Summary:Object: Command:SUBDIRS CREATEER INFO, KILL, LAG, SEND, STATUS, START, STATS, STOP EXTRACT ADD, ALTER, CLEANUP, DELETE, INFO, KILL,LAG, REGISTER, SEND, START, STATS, STATUS, STOPUNREGISTEREXTTRAIL ADD, ALTER, DELETE, INFOGGSEVT VIEWMANAGER INFO, SEND, START, STOP, STATUSMARKER INFOPARAMS EDIT, VIEWREPLICAT ADD, ALTER, CLEANUP, DELETE, INFO, KILL, LAG, SEND,START, STATS, STATUS, STOPREPORT VIEWRMTTRAIL ADD, ALTER, DELETE, INFOTRACETABLE ADD, DELETE, INFOTRANDATA ADD, DELETE, INFOSCHEMATRANDATA ADD, DELETE, INFOCHECKPOINTTABLE ADD, DELETE, CLEANUP, INFOCommands without an object:(Database) DBLOGIN, LIST TABLES, ENCRYPT PASSWORD, FLUSH SEQUENCEMININGDBLOGIN(DDL) DUMPDDL(Miscellaneous) FC, HELP, HISTORY, INFO ALL, OBEY, SET EDITOR, SHELL,SHOW, VERSIONS, ! (note: you must type the wordCOMMAND after the !to display the ! help topic.)i.e.: GGSCI (sys1)>help !commandFor help on a specific command, type HELP .Example: HELP ADD REPLICATGGSCI (GMDBA) 2>2.5 配置源数据库2.5.1 开启归档[oracle@GMDBA ~]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.3.0 Production on Sun Dec 15 20:16:57 2013 Copyright (c) 1982, 2011, Oracle. All rights reserved.Connected to an idle instance.SQL> startupORACLE instance started.Total System Global Area 422670336 bytesFixed Size 1345380 bytesVariable Size 327157916 bytesDatabase Buffers 88080384 bytesRedo Buffers 6086656 bytesDatabase mounted.Database opened.SQL> show parameter log_archive_destNAME TYPE VALUE ------------------------------------ ----------- ------------------------------log_archive_dest stringlog_archive_dest_1 stringlog_archive_dest_10 stringlog_archive_dest_11 stringlog_archive_dest_12 stringlog_archive_dest_13 stringlog_archive_dest_14 stringlog_archive_dest_15 stringlog_archive_dest_16 stringlog_archive_dest_17 stringlog_archive_dest_18 stringlog_archive_dest_19 stringlog_archive_dest_2 stringlog_archive_dest_20 stringlog_archive_dest_21 stringlog_archive_dest_22 stringlog_archive_dest_23 stringlog_archive_dest_24 stringlog_archive_dest_25 stringlog_archive_dest_26 stringlog_archive_dest_27 stringlog_archive_dest_28 stringlog_archive_dest_29 stringlog_archive_dest_3 stringlog_archive_dest_30 stringlog_archive_dest_31 stringlog_archive_dest_4 stringlog_archive_dest_5 stringlog_archive_dest_6 stringlog_archive_dest_7 stringlog_archive_dest_8 stringlog_archive_dest_9 stringSQL> show parameter db_recoveryNAME TYPE VALUE------------------------------------ ----------- ------------------------------db_recovery_file_dest string /u01/app/oracle/fast_recovery_areadb_recovery_file_dest_size big integer 4977MSQL> shutdown immediateDatabase closed.Database dismounted.ORACLE instance shut down.SQL> startup mountORACLE instance started.Total System Global Area 422670336 bytesFixed Size 1345380 bytesVariable Size 327157916 bytesDatabase Buffers 88080384 bytesRedo Buffers 6086656 bytesDatabase mounted.SQL> alter database archivelog;Database altered.SQL> alter database open;Database altered.2.5.2 打开补充日志SQL> select SUPPLEMENTAL_LOG_DATA_MIN from v$database;SUPPLEME--------NOSQL> alter database add supplemental log data;Database altered.SQL> select SUPPLEMENTAL_LOG_DATA_MIN from v$database;SUPPLEME--------YES2.5.3 创建GoldenGate管理用户SQL> create user ggs identified by ggs default tablespace users temporary tablespace temp;User created.SQL> grant connect,resource to ggs;Grant succeeded.SQL> grant execute on utl_file to ggs;Grant succeeded.SQL> grant select any dictionary,select any table to ggs;Grant succeeded.SQL> grant alter any table to ggs;Grant succeeded.SQL> grant flashback any table to ggs;Grant succeeded.SQL> grant execute on DBMS_FLASHBACK to ggs; Grant succeeded.SQL>2.5.4 添加表级trandata对hr用户下的所有表进行同步[oracle@GMDBA ggs]$ cd 11.2.0/[oracle@GMDBA 11.2.0]$ ./ggsciOracle GoldenGate Command Interpreter for OracleVersion 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO Linux, x86, 32bit (optimized), Oracle 11g on Apr 23 2012 08:09:25Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.GGSCI (GMDBA) 1> dblogin userid ggs password ggsSuccessfully logged into database.GGSCI (GMDBA) 2> add trandata hr.*Logging of supplemental redo data enabled for table HR.COUNTRIES. Logging of supplemental redo data enabled for table HR.DEPARTMENTS. Logging of supplemental redo data enabled for table HR.EMPLOYEES.Logging of supplemental redo data enabled for table HR.JOBS.Logging of supplemental redo data enabled for table HR.JOB_HISTORY. Logging of supplemental redo data enabled for table HR.LOCATIONS. Logging of supplemental redo data enabled for table HR.REGIONS.GGSCI (GMDBA) 3>2.5.5 配置源端mgr管理进程组GGSCI (GMDBA) 1> edit params mgrport 7500dynamicportlist 7501-7505autorestart extract *,waitminutes 2,retries 5GGSCI (GMDBA) 2> view params mgrport 7500dynamicportlist 7501-7505autorestart extract *,waitminutes 2,retries 5GGSCI (GMDBA) 3> start mgrManager started.GGSCI (GMDBA) 4> info allProgram Status Group Lag at Chkpt Time Since ChkptMANAGER RUNNING2.5.6 配置Extract抽取进程组GGSCI (GMDBA) 6> edit params ext1extract ext1dynamicresolutionuserid ggs,password ggssetenv(ORACLE_SID=GMDBA)exttrail /u01/ggs/11.2.0/dirdat/ettable hr.*;GGSCI (GMDBA) 7> view params ext1extract ext1dynamicresolutionuserid ggs,password ggssetenv(ORACLE_SID=GMDBA)exttrail /u01/ggs/11.2.0/dirdat/ettable hr.*;创建extract进程GGSCI (GMDBA) 8> add extract ext1,tranlog,begin nowEXTRACT added.GGSCI (GMDBA) 9> add exttrail /u01/ggs/11.2.0/dirdat/et,extract EXT1 EXTTRAIL added.GGSCI (GMDBA) 10> info allProgram Status Group Lag at Chkpt Time Since ChkptMANAGER RUNNINGEXTRACT STOPPED EXT1 00:00:00 00:00:41 GGSCI (GMDBA) 11> start ext1Sending START request to MANAGER ...EXTRACT EXT1 startingGGSCI (GMDBA) 12> info allProgram Status Group Lag at Chkpt Time Since ChkptMANAGER RUNNINGEXTRACT RUNNING EXT1 00:12:29 00:00:072.5.7 配置pump投递进程组GGSCI (GMDBA) 13> edit params pump1extract pump1dynamicresolutionuserid ggs,password ggsrmthost 192.168.80.30,mgrport 7809,compressrmttrail /u01/ggs/11.2.0/dirdat/pttable hr.*;GGSCI (GMDBA) 14> add extract pump1,exttrailsource /u01/ggs/11.2.0/dirdat/et EXTRACT added.GGSCI (GMDBA) 15>ADD RMTTRAIL /u01/ggs/11.2.0/dirdat/pt, EXTRACT PUMP1 RMTTRAIL added.GGSCI (GMDBA) 16> start pump1Sending START request to MANAGER ...EXTRACT PUMP1 startingGGSCI (GMDBA) 17> info allProgram Status Group Lag at Chkpt Time Since ChkptMANAGER RUNNINGEXTRACT RUNNING EXT1 00:00:00 00:00:00 EXTRACT RUNNING PUMP1 00:00:00 00:04:072.6 目标端操作2.6.1 目标端用户创建SQL> create user ggs identified by ggs default tablespace users temporary tablespace temp;User created.SQL>grant connect,resource to ggs;Grant succeeded.SQL> grant execute on utl_file to ggs; Grant succeeded.SQL> grant select any table to ggs; Grant succeeded.SQL> grant insert any table to ggs; Grant succeeded.SQL> grant delete any table to ggs; Grant succeeded.SQL> grant update any table to ggs;Grant succeeded.SQL> GRANT ALTER SESSION TO ggs;Grant succeeded.SQL> GRANT SELECT ANY DICTIONARY to ggs;Grant succeeded.2.6.2 添加checkpoint表[oracle@GMDBAGC ogg]$ cd 11.2.0/[oracle@GMDBAGC 11.2.0]$ ./ggsciOracle GoldenGate Command Interpreter for OracleVersion 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO Linux, x86, 32bit (optimized), Oracle 11g on Apr 23 2012 08:09:25Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.GGSCI (GMDBAGC) 1> edit params ./GLOBALScheckpointtable ggs.checkpointGGSCI (GMDBAGC) 1> dblogin userid ggs password ggsERROR: Unable to connect to database using user ggs. Please check privileges. ORA-00942: table or view does not exist.GGSCI (GMDBAGC) 2> dblogin userid ggs password ggsSuccessfully logged into database.GGSCI (GMDBAGC) 3> add checkpointtable ggs.checkpointSuccessfully created checkpoint table ggs.checkpoint.GGSCI (GMDBAGC) 4>2.6.3 配置mgrGGSCI (GMDBAGC) 1> edit params mgrport 7809dynamicportlist 7800-8000autostart er *autorestart extract *,waitminutes 2,retries 5lagreporthours 1laginfominutes 3lagcriticalminutes 5purgeoldextracts /u01/ggs/11.2.0/dirdat/rt*,usecheckpoints,minkeepdays 3 GGSCI (GMDBAGC) 2> start mgrManager started.GGSCI (GMDBAGC) 3> info allProgram Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNING2.6.4 配置replicatGGSCI (GMDBAGC) 4> edit params replreplicat repluserid ggs,password ggsassumetargetdefsreperror default,discarddiscardfile /u01/ggs/11.2.0/dirrpt/repl.dsc,append,megabytes 50 dynamicresolutionmap hr.*,target hr.*;GGSCI (GMDBAGC) 5> add replicat repl,exttrail /u01/ggs/11.2.0/dirdat/pt REPLICAT added.GGSCI (GMDBAGC) 4> start replSending START request to MANAGER ...REPLICAT REPL startingGGSCI (GMDBAGC) 5> info allProgram Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNINGREPLICAT RUNNING REPL 00:00:00 00:00:01 3 测试源库SQL> create table test (a int,b int);Table created.SQL> insert into test values(1,1);1 row created.SQL> commit;Commit complete.SQL>目标库SQL> create table test (a int,b int);Table created.SQL>SQL> select * from test; no rows selectedSQL> select * from test;A B---------- ----------1 1 SQL>。
Oracle Goldengate 实验步骤
Veridata files /home/oracle/ggs/dirver: created
Veridata Lock files /home/oracle/ggs/dirver/lock: created
Veridata Report files /home/oracle/ggs/dirver/report: created
Veridata Status files /home/oracle/ggs/dirver/status: created
Veridata Trace files /home/oracle/ggs/dirver/trace: created
修改虚拟机数据库的归档模式:
su - oracle
$mkdir -p /home/oracle/oracle/product/archive
$sqlplus /nolog
SQL>conn / as sysdba
SQL>startup
SQL> alter system set log_archive_dest_1='location=/home/oracle/oracle/product/archive' scope=both;
SET, SHELL, SHOW, VERSIONS, !
For help on a specific command, type HELP <command> <object>.
Example: HELP ADD REPLICAT
START ER, STATS ER, STOP ER
oracle goldengate 使用方法
oracle goldengate 使用方法### Oracle GoldenGate 使用方法Oracle GoldenGate 是一种强大的数据复制和集成解决方案,支持实时数据集成和事务复制,广泛应用于数据迁移、数据同步和容灾恢复等多种场景。
下面将详细介绍Oracle GoldenGate 的使用方法。
#### 一、安装与配置1.**环境准备**:确保所有需要的操作系统补丁已安装,网络配置正确,所需端口开放。
2.**安装GoldenGate**:下载对应的GoldenGate 版本,使用命令行或图形界面安装。
```shell# 示例命令行安装./runInstaller -silent -responseFile <path_to_response_file>```3.**配置Manager**:Manager 是GoldenGate 的核心组件,负责管理整个复制过程。
- 创建必要的目录。
- 配置参数文件`f`,包括端口、跟踪文件位置等。
- 启动Manager。
```shellggsci > start manager```4.**配置Extract 和Pump**:Extract 用于从源数据库捕获数据变更,Pump 用于将数据传输到目标系统。
- 创建Extract 和Pump 的参数文件。
- 使用`add extract` 和`add pump` 命令在Manager 中注册Extract 和Pump。
- 启动Extract 和Pump。
```shellggsci > start extract <extract_name>ggsci > start pump <pump_name>```5.**配置Replicat**:Replicat 用于在目标端应用数据变更。
- 创建Replicat 的参数文件。
- 在Manager 中注册Replicat。
oraclegoldengate安装笔记
oraclegoldengate安装笔记ORACLE GoldenGate安装测试平台:REDHAT LINUX 6DB:ORACLE 10G205一、在源数据库操作系统上新增GoldenGate的用户,需要和oracle数据库用户在一个组:二、在源数据库的操作系统上安装GoldenGate软件三、设置源数据库为归档模式,回收站为off(设置DDL复制需要),并设置为最细log四、在源数据库上创建GoldenGate的账号,并赋权限五、在目的主机DB2上新增GoldenGate的用户,需要和oracle 数据库用户在一个组:十一、配置GGS的manager 1234十二、验证结果十三、问题总结:源数据库不配置SUPPLEMENTAL_LOG_DATA_MIN为YES的话,extract会一直起不来,且为stopped状态sys@RHDB> select SUPPLEMENTAL_LOG_DATA_MIN from v$database;SUPPLEME--------NO[ogg@RHDB-1 fbo_ggs_Linux_x64_ora10g_64bit]$ tail -42012-05-31 13:33:28 ERROR OGG-00730 Oracle GoldenGate Capture for Oracle, ext1.prm: No minimum supplemental logging is enabled. This may cause extract process to handle key update incorrectly if key column is not in first row piece.2012-05-31 13:33:28 ERROR OGG-01668 Oracle GoldenGate Capture for Oracle, ext1.prm: PROCESS ABENDING.开启数据库的最细log模式:sys@RHDB> alter database add supplemental log data;Database altered.sys@RHDB> select SUPPLEMENTAL_LOG_DATA_MIN from v$database;SUPPLEME--------YES-------------------------源数据库配置SUPPLEMENTAL_LOG_DATA_MIN为YES,目的数据库不配的话,extract会一直起不来,且为ABENDED状态GGSCI (RHDB-1) 11> start extract ext1Sending START request to MANAGER ...EXTRACT EXT1 startingGGSCI (RHDB-1) 12> info allProgram Status Group Lag at Chkpt Time Since ChkptMANAGER RUNNINGEXTRACT STOPPED EXT1 00:00:00 02:15:57GGSCI (RHDB-1) 13> info allProgram Status Group Lag at Chkpt Time Since ChkptMANAGER RUNNINGEXTRACT ABENDED EXT1 02:16:04 00:00:19[ogg@RHDB-1 fbo_ggs_Linux_x64_ora10g_64bit]$ tail -10target directories:/home/ogg/fbo_ggs_Linux_x64_ora10g_64bit/dirtmp.2012-05-31 13:41:24 INFO OGG-01515 Oracle GoldenGate Capture for Oracle, ext1.prm: Positioning to begin time May 31, 2012 11:25:26 AM.2012-05-31 13:41:24 INFO OGG-01516 Oracle GoldenGate Capture for Oracle, ext1.prm: Positioned to Sequence 104, RBA 24428048, SCN 0.0, May 31, 2012 11:25:26 AM.2012-05-31 13:41:24 INFO OGG-00993 Oracle GoldenGate Capture for Oracle, ext1.prm: EXTRACT EXT1 started.2012-05-31 13:41:30 INFO OGG-01226 Oracle GoldenGate Capture for Oracle, ext1.prm: Socket buffer size set to 27985 (flush size 27985).2012-05-31 13:41:30 INFO OGG-01052 Oracle GoldenGate Capture for Oracle, ext1.prm: No recovery is required for target file/home/ogg/fbo_ggs_Linux_x64_ora10g_64bit/dirdat/lt0000 00, at RBA 0 (file not opened).2012-05-31 13:41:30 INFO OGG-01478 Oracle GoldenGate Capture for Oracle, ext1.prm: Output file /home/ogg/fbo_ggs_Linux_x64_ora10g_64bit/dirdat/lt is using format RELEASE 11.2. 2012-05-31 13:41:30 ERROR OGG-00717 Oracle GoldenGate Capture for Oracle, ext1.prm: Found unsupported in-memory undo record in sequence 104, at RBA 24428048, with SCN 0.1454118 (1454118) ... Minimum supplemental logging must be enabled to prevent data loss. 2012-05-31 13:41:30 ERROR OGG-01668 Oracle GoldenGate Capture for Oracle, ext1.prm: PROCESS ABENDING.配置目的数据库的如下后,依然报错sys@RHDB> alter database add supplemental log data;Database altered.[ogg@RHDB-1 fbo_ggs_Linux_x64_ora10g_64bit]$ tail -4 ggserr.log2012-05-31 13:57:32 INFO OGG-01053 Oracle GoldenGate Capture for Oracle, ext1.prm: Recovery completed for target file /home/ogg/fbo_ggs_Linux_x64_ora10g_64bit/dirdat/lt000003, at RBA 1060.2012-05-31 13:57:32 INFO OGG-01057 Oracle GoldenGate Capture for Oracle, ext1.prm: Recovery completed for all targets.2012-05-31 13:57:32 ERROR OGG-00717 Oracle GoldenGate Capture for Oracle, ext1.prm: Found unsupported in-memory undo record in sequence 104, at RBA 24428048, with SCN 0.1454118 (1454118) ... Minimum supplemental logging must be enabled to prevent data loss. 2012-05-31 13:57:32 ERROR OGG-01668 Oracle GoldenGate Capture for Oracle, ext1.prm: PROCESS ABENDING.重启配置源端的EXTRACT,不再报错:GGSCI (RHDB-1) 30> alter extract ext1, tranlog, begin now EXTRACT altered.GGSCI (RHDB-1) 31> info allProgram Status Group Lag at Chkpt Time Since ChkptMANAGER RUNNINGEXTRACT STOPPED EXT1 00:00:00 00:00:03GGSCI (RHDB-1) 32> start EXTRACT ext1Sending START request to MANAGER ...EXTRACT EXT1 startingGGSCI (RHDB-1) 33> info allProgram Status Group Lag at Chkpt Time Since ChkptMANAGER RUNNINGEXTRACT RUNNING EXT1 00:00:00 00:00:19但在源端删除表时,目的端报错,由于目的端没有这个表,所以如下报错:[ogg@RHDB-2 fbo_ggs_Linux_x64_ora10g_64bit]$ tail -0f ggserr.log2012-05-31 14:15:46 INFO OGG-01407 Oracle GoldenGate Delivery for Oracle, rep1.prm: Setting current schema for DDL operation to [SYS].2012-05-31 14:15:47 ERROR OGG-00519 Oracle GoldenGate Delivery for Oracle, rep1.prm: Fatal error executing DDL replication: error [Error code [942], ORA-00942: table or view does not exist SQL drop table receiver."TESTTAB1" /* GOLDENGATE_DDL_REPLICATION */], no error handler present.2012-05-31 14:15:47 ERROR OGG-01668 Oracle GoldenGate Delivery for Oracle, rep1.prm: PROCESS ABENDING.查看目的端的gg状态,REPLICAT状态变为了ABENDED:GGSCI (RHDB-2) 22> info allProgram Status Group Lag at Chkpt Time Since ChkptMANAGER RUNNINGREPLICAT ABENDED REP1 00:00:33 00:02:56执行start命令后依然报错:GGSCI (RHDB-2) 23> START REPLICAT REP1Sending START request to MANAGER ...REPLICAT REP1 startingGGSCI (RHDB-2) 24> INFO ALLProgram Status Group Lag at Chkpt Time Since ChkptMANAGER RUNNINGREPLICAT ABENDED REP1 00:00:00 00:00:02在目的端创建表testtab1后,成功:receiver@RHDB2> create table testtab1 (id number,teststrvarchar2(12));Table created.receiver@RHDB2> select tname from tab;TNAME------------------------------TESTTAB11 row selected.receiver@RHDB2> select * from testtab1;ID TESTSTR---------- ------------1 adljfoiweur1 row selected.GGSCI (RHDB-2) 6> start replicat rep1Sending START request to MANAGER ...REPLICAT REP1 startingGGSCI (RHDB-2) 7> info allProgram Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNINGREPLICAT RUNNING REP1 00:08:06 00:00:01。
Oracle 11g 安装配置GoldenGate
Oracle 11gR2 RAC和GoldenGate都是Oracle比较热门的产品,经过简单的学习和阅读文档,配置单节点的GoldenGate进行数据的复制相信不是什么太有难度的事情,但是对于利用GoldenGate进行RAC系统到RAC系统的复制,还是有些配置的技巧和策略设置的,前阵子就遇到一个这样一个问题:假设源和目标分别是两节点的RAC系统,如何保证目标部分节点失效的时候replicate会自动切换?其实如果了解GG的工作机制和RAC的资源管理,问题的解决就十分清晰了。
今天就从系统的介绍下11gR2 RAC上OGG (Oracle GoldenGate的简称,下同)的完整配置步骤,并简单谈谈如何解决上面这个场景的问题。
第一阶段:下载OGG(可以参考之前的单节点的复制例子,不再赘述)OGG的下载地址第二阶段:OGG的安装1)登录源端的RAC系统中的任一个节点,并在ACFS上建立一个供OGG使用的共享目录,比如叫/cloudfs/goldengate2)解压OGG的安装包到/cloudfs/goldengate目录3) 设置好OGG工作的环境变量,比如export LIBRARY_PATH=/cloudfs/goldengate:$ORACLE_HOME/lib:$LD_LIBRARY_PATH4)启动ggsci并创建目录,然后进行必要的设置,启动manager$ ggsciGGSCI > create subdirs(optional, support for DDL/Sequence)Create and edit the parameter file for GLOBALS:GGSCI > EDIT PARAMS ./GLOBALSAdd this line to GLOBALS parameter file:GGSCHEMA ggsNOTE: 'ggs' is the example OGG user and will be used in the rest of this document.GGSCI > EDIT PARAMS mgrAdd the following lines to Manager parameter file:PORT 7809AUTOSTART ER *AUTORESTART ER *GGSCI > START mgr5)在目标端重复上面的步骤1-4,注意目录名的使用,我们在目标端使用/mycloudfs/goldengate以示区分。
OGG11g同构(GoldenGate-ORACLE)、异构(GoldenGate-MYSQL)同步配置及错误解析
OGG同构(ORACLE-ORACLE)、异构(ORACLE-MYSQL)同步配置及错误解析环境:11.2.0.3(已安装数据库实例)+OEL5.7192.168.1.55 zlm sid:zlm11g192.168.1.60 zlm2 sid:zlm11g一、安装软件,配置环境,创建相关用户1.1 下载介质并安装OGG软件从官方网址下载最新版OGG FOR ORACLE 11g ON LINUX X86-64软件:/technetwork/middleware/goldengate/downloads/index.html?ssSo urceSiteId=ocomenOracle GoldenGate V11.2.1.0.1 for Oracle 11g on Linux x86-64 (86 MB)介质名称:ogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zip1.2 把OGG软件包复制到源端oracle主目录,创建安装目录gg11后2次解压到gg11 [oracle@zlm ~]$ lsogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zip[oracle@zlm ~]$ cd $OACLE_BASE[oracle@zlm oracle]$ mkdir gg11[oracle@zlm oracle]$ cd gg11[oracle@zlm gg11]$ unzip /home/oracle/ogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zi p[oracle@zlm gg11]$ lltotal 223764-rw-rw-r-- 1 oracle oinstall 228556800 Apr 23 2012 fbo_ggs_Linux_x64_ora11g_64bit.ta r-rwxrwxrwx 1 oracle oinstall 220546 May 2 2012 OGG_WinUnix_Rel_Notes_11.2.1.0.1 .pdf-rwxrwxrwx 1 oracle oinstall 93696 May 2 2012 Oracle GoldenGate 11.2.1.0.1 READ ME.doc-rwxrwxrwx 1 oracle oinstall 24390 May 2 2012 Oracle GoldenGate 11.2.1.0.1 READ ME.txt[oracle@zlm gg11]$ tar xvof fbo_ggs_Linux_x64_ora11g_64bit.tar1.3 修改环境变量文件.bash_profile,加入OGG的环境变量export GGHOME=$ORACLE_BASE/gg11export PATH=$ORACLE_BASE/gg11:$ORACLE_HOME/bin:/usr/bin/:$PATH[oracle@zlm gg11]$ . ~/.bash_profile[oracle@zlm gg11]$ ggsciggsci: error while loading shared libraries: libnnz11.so: cannot open shared object file: N o such file or directory由于没有设置LD_LIBRARY_PATH环境变量,所以无法执行ggsci,添加export LD_LIBLARY_PATH=$ORACLE_BASE/gg11:$ORACLE_HOME/lib:$ORACLE_HOME/b in到环境变量.bash_profile并source,或者创建一个link文件:[oracle@zlm gg11]$ ln -s /u01/app/oracle/product/11.2.0/db_1/lib/libnnz11.so -/u01/app/oracle/product/11.2.0/db_1/lib/libnnz10.so1.4 创建OGG专用目录subdirsGGSCI (zlm) 1> create subdirsCreating subdirectories under current directory /u01/app/oracle/gg11Parameter files /u01/app/oracle/gg11/dirprm: already existsReport files /u01/app/oracle/gg11/dirrpt: createdCheckpoint files /u01/app/oracle/gg11/dirchk: createdProcess status files /u01/app/oracle/gg11/dirpcs: createdSQL script files /u01/app/oracle/gg11/dirsql: createdDatabase definitions files /u01/app/oracle/gg11/dirdef: createdExtract data files /u01/app/oracle/gg11/dirdat: createdTemporary files /u01/app/oracle/gg11/dirtmp: createdStdout files /u01/app/oracle/gg11/dirout: created1.5 开启归档模式、强制日志、附加日志查看v$database看这3个参数是否已开启,使用OGG必须是开启状态SQL> select LOG_MODE, SUPPLEMENTAL_LOG_DATA_MIN,FORCE_LOGGING from v$dat abase;LOG_MODE SUPPLEME FOR------------ -------- ---ARCHIVELOG YES YES各参数开启方法:--archivelogSQL> shutdown immediateSQL> startup mountSQL> alter database archivelog;SQL> alter database open;--force loggingSQL> alter database force logging;--supplemental log dataSQL> alter database add supplemental log data;1.6 关闭数据库的recyclebin(10gDDL必须,11gDDL可选)SQL> alter system set recyclebin=off scope=spfile; --同步DDL要求关闭10g中的回收站特性1.7 创建复制用户ogg并授予权限SQL> create user ogg identified by ogg default tablespace users temporary tablespace te mp;SQL> grant connect,resource,unlimited tablespace to ogg;1.8 创建测试用户sender并授予权限SQL> create user sender identified by sender default tablespace users temporary tablesp ace temp;SQL> grant connect,resource,unlimited tablespace to sender;1.9 配置复制的DDL支持(必须SYSDBA登录执行)SQL> grant execute on utl_file to ogg;SQL> @$GGHOME/marker_setup.sql; --建立一个DDL标记表SQL> @$GGHOME/ddl_setup.sql; --INITIALSETUP选项运行ddl_setup.sql 将在数据库中创建捕获DDL语句的Trigger等必要组件(注意,执行时必须断开GGSCI连接,否则报错) SQL> @$GGHOME/role_setup.sql; --建立GGS_GGSUSER_ROLE角色SQL> grant GGS_GGSUSER_ROLE to ogg; --授予给extract group参数中定义的userid用户SQL> @$GGHOME/ddl_enable.sql; --enable ddl捕获触发器注意:下面2个SQL脚本只是为了提高DDL复制性能,不是必须的SQL> @?/rdbms/admin/dbmspool --创建DBMS_SHARED_POOL包SQL> @ddl_pin --通过dbms_shared_pool.keep存储过程将DDLReplication相关的对象keep 在共享池中,以保证这些对象不要reload,提升性能1.10 目标端重复配置以上1.1-1.9全部内容,至此,ORACLE-ORACLE环境搭建完毕二、用EXPDP/IMPDP初始化测试数据(仅限ORACLE-ORACLE)2.1 创建EXPDP/IMPDP使用的directory及其对应的本地目录SQL> set lin 200 pages 999SQL> col owner for a5SQL> col directory_name for a25SQL> col directory_path for a75SQL> select * from dba_directories;OWNER DIRECTORY_NAME DIRECTORY_PATH----- ------------------------- ----------------------------------SYS GGS_DDL_TRACE /u01/app/oracle/diag/rdbms/zlm11g/zlm11g/trace SYS SUBDIR /u01/app/oracle/product/11.2.0/db_1/demo/schema/order_e ntry//2002/SepSYS SS_OE_XMLDIR /u01/app/oracle/product/11.2.0/db_1/demo/schema/orde r_entry/SYS BACKUP /u01/backupSYS LOG_FILE_DIR /u01/app/oracle/product/11.2.0/db_1/demo/schema/log/SYS MEDIA_DIR /u01/app/oracle/product/11.2.0/db_1/demo/schema/produ ct_media/SYS XMLDIR /u01/app/oracle/product/11.2.0/db_1/rdbms/xmlSYS DATA_FILE_DIR /u01/app/oracle/product/11.2.0/db_1/demo/schema/sale s_history/SYS DATA_PUMP_DIR /u01/app/oracle/admin/zlm11g/dpdump/SYS ORACLE_OCM_CONFIG_DIR /u01/app/oracle/product/11.2.0/db_1/ccr/state SQL> create directory expdump as '/u01/expdp';SQL> select * from dba_directories;OWNER DIRECTORY_NAME DIRECTORY_PATH----- ------------------------- ----------------------------------SYS GGS_DDL_TRACE /u01/app/oracle/diag/rdbms/zlm11g/zlm11g/trace SYS EXPDUMP /u01/expdpSYS SUBDIR /u01/app/oracle/product/11.2.0/db_1/demo/schema/order_e ntry//2002/SepSYS SS_OE_XMLDIR /u01/app/oracle/product/11.2.0/db_1/demo/schema/orde r_entry/SYS BACKUP /u01/backupSYS LOG_FILE_DIR /u01/app/oracle/product/11.2.0/db_1/demo/schema/log/ SYS MEDIA_DIR /u01/app/oracle/product/11.2.0/db_1/demo/schema/produ ct_media/SYS XMLDIR /u01/app/oracle/product/11.2.0/db_1/rdbms/xmlSYS DATA_FILE_DIR /u01/app/oracle/product/11.2.0/db_1/demo/schema/sale s_history/SYS DATA_PUMP_DIR /u01/app/oracle/admin/zlm11g/dpdump/SYS ORACLE_OCM_CONFIG_DIR /u01/app/oracle/product/11.2.0/db_1/ccr/state [oracle@zlm gg11]$ cd /u01/[oracle@zlm u01]$ lsapp backup[oracle@zlm u01]$ mkdir /u01/expdp[oracle@zlm u01]$ lltotal 16drwxr-xr-x 4 oracle oinstall 4096 Jul 13 03:12 appdrwxrwxr-x 2 oracle oinstall 4096 Jul 21 20:26 backupdrwxr-xr-x 2 oracle oinstall 4096 Aug 28 22:11 expdp2.2 登录sender用户并创建测试表testSQL> conn sender/senderConnected.SQL> begin2 for i in 1..3 loop3 insert into test values(i);4 end loop;5 end;6 /PL/SQL procedure successfully completed.SQL> select * from test1;ID----------1232.3 赋予sender读写directory的权限,执行expdp导出测试表testSQL> grant read,write on directory expdump to sender;SQL> ![oracle@zlm ~]$ expdp sender/sender directory=expdump dumpfile=test.dmp logfile=te st.log tables=test[oracle@zlm ~]$ cd /u01/expdp[oracle@zlm expdp]$ lstest.dmp test.log2.4 在目标端创建directory及相应的本地路径,复制dump文件到目标端SQL> create directory impdump as ‘/u01/impdp’;--target[oracle@zlm2 gg11]$ mkdir /u01/impdp[oracle@zlm2 gg11]$ ls /u01app backup impdp--source[oracle@zlm expdp]$ scp test.* zlm2:/u01/impdporacle@zlm2's password:test.dmp 100% 92KB 92.0KB/s 00:00 test.log 100% 1011 1.0KB/s 00:00 2.5 目标端赋予recerver用户权限,执行impdp导入测试表testSQL> grant read,write on directory impdump to sender;SQL> ![oracle@zlm2 ~]$ impdp sender/sender directory=impdump dumpfile=test.dmp tables=t est注意:expdp/impdp必须是在同一个schema下的object,否则不能执行成功,logfile可以无SQL> conn sender/senderConnected.SQL> select * from test;ID----------123此时完成test表的初始化同步,注意:如果非ORACLE-ORACLE方式同步,则只能使用OGG推荐的方式,即配置initial extract来初始化数据,具体可以参考我之前的一篇blog:OGG配置DML单向复制一例及错误分析/aaron8219/article/details/10275431三、不使用PUMP抽取进程的DML同步参数配置(ORACLE-ORACLE)3.1 单向复制3.1.1 创建并配置manager[ogg@zlm gg11]$ ./ggsciGGSCI (zlm) 1> info allGGSCI (zlm) 2> edit params mgrPORT 7809ggate (zlm) 3> start managerManager started.3.1.2 配置源端抽取组ext1GGSCI (zlm) 1> add extract ext1, tranlog, begin nowGGSCI (zlm) 2> add rmttrail ./dirdat/rt, extract ext1GGSCI (zlm) 3> edit params ext1extract ext1userid ogg, password oggrmthost zlm2, mgrport 7809rmttrail ./dirdat/rtddl include mapped objname sender.*;table sender.*;GGSCI (zlm) 4> info all3.1.3 配置目标端同步组3.1.3.1 在目标端添加checkpoint表[ogg@zlm gg11]$ ./ggsciGGSCI (zlm2) 1> edit params ./GLOBALGGSCHEMA oggCHECKPOINTTABLE ogg.ckptGGSCI (zlm2) 2> dblogin userid ogg password oggGGSCI (zlm2) 3> add checkpointtable ogg.ckpt3.1.3.2 创建同步组rep1GGSCI (zlm2) 4> add replicat rep1, exttrail ./dirdat/rt, checkpointtable ogg.ckpt GGSCI (zlm2) 5> edit params rep1replicat rep1ASSUMETARGETDEFSuserid ogg,password oggreperror default,discarddiscardfile ./dirrpt/rep1.dsc, append, megabytes 5DDLmap sender.*, target sender.*;3.1.4 源端开启抽取组ext1,目标端开启同步组rep1--sourceGGSCI (zlm) 1> start mgrGGSCI (zlm) 2> start extract ext1GGSCI (zlm) 3> info all--targetGGSCI (zlm2) 1> start mgrGGSCI (zlm2) 2> start replicat rep1GGSCI (zlm2) 3> info all3.1.5 测试DML同步3.1.5.1 insert--sourceSQL> select * from test2 /ID----------123SQL> insert into test values(4);1 row created.SQL> commit;Commit complete.--targetSQL> select * from test;ID----------1234注意:可以顺利同步,但是查看ext1和rep1的run time messages,都报了如下的错误:WARNING OGG-00869 No unique key is defined for table 'TEST'. All viable columns will be used to represent the key, but may not guarantee uniqueness. KEYCOLS may be used to define the key.Using the following key columns for source table SENDER.TEST: ID.该表没有主键,使用KEYCOLS代替,查询官方说明如下:OGG-00869: {0}Cause: The specified database error occurred, but can be ignored.Action: Contact Oracle Support only if a problem persists.由于这只是个警告,况且对实际的应用也没什么影响,是可以忽略掉的。
部分GoldenGate安装配置、常用命令与目标初始化
同步延迟
检查网络状况和数据库性能, 确保数据能够实时同步。
日志异常
检查日志文件,查找异常信息 ,并根据异常信息进行相应的
பைடு நூலகம்处理。
03 Goldengate常用命令
数据采集命令
DG_COMMAND
用于执行数据采集命令,如启动数据采集进程、停止数据采 集进程等。
DG_INFO
用于获取数据采集的详细信息,如数据采集状态、数据采集 进度等。
安装Goldengate服务器
按照安装向导的指示,完成Goldengate服务器的安装。
安装Goldengate客户端
在需要使用Goldengate的客户端计算机上安装Goldengate客户端。
配置Goldengate环境变量
设置Goldengate的环境变量,以便在命令行中调用Goldengate命令。
用于获取数据校验的详细信息,如数据校验状态、数据校验结果等。
其他常用命令
DG_CONFIG
用于配置Goldengate的相关参数,如设置数据采集频率、设置数据同步目标等 。
DG_STATUS
用于获取Goldengate的运行状态,如Goldengate的启动状态、运行日志等。
04 Goldengate目标初始化
无法连接到Goldengate目标数据库 。
解决方案
检查目标数据库的配置是否正确, 包括数据库连接字符串、用户名和 密码等。
02 Goldengate配置
数据源配置
数据源类型
支持多种数据源类型,如Oracle、MySQL、SQL Server等。
连接参数
需要提供数据库的地址、端口、用户名和密码等 连接参数。
集群版部署案例
Oracle数据库教程——goldengate常用函数使用说明
Oracle数据库教程——goldengate常用函数使用说明GoldenGate是一种用于实时数据同步和复制的事务复制产品。
在GoldenGate中,函数起着非常关键的作用,可以处理数据的转换、过滤、验证和传递等操作。
本教程将介绍一些常用的GoldenGate函数,以及它们的使用说明。
1.ADDCOLS-添加列ADDCOLS函数用于在源和目标之间添加列。
它可以在复制过程中自动添加新列。
语法如下:```ADDCOLS tablename, column_dependency```其中,tablename是要添加列的表的名称,column_dependency是一个字符串,指定新列和现有列之间的依赖关系。
2.UPDATECOLS-更新列UPDATECOLS函数用于对复制过程中的列进行更新。
它可以在复制过程中修改列的类型、长度和默认值等。
语法如下:```UPDATECOLS tablename, column_definition, column_value```其中,tablename是要进行更新的表的名称,column_definition是要更新的列的定义语句,column_value是要为更新的列指定的值。
3.TRANSLATE-转换TRANSLATE函数用于在源和目标之间转换数据。
它可以在复制过程中对数据进行转换,如修改日期格式、替换字符串等。
语法如下:```TRANSLATE source_column, target_column, translation_map```其中,source_column是源表中要转换的列,target_column是目标表中要转换的列,translation_map是一个字符串,指定源值与目标值之间的映射关系。
4.FILTER-过滤FILTER函数用于在复制过程中过滤数据。
它可以根据自定义的条件来过滤复制的数据,如指定特定的行、列、值等。
语法如下:```FILTER tablename, filter_condition```其中,tablename是要过滤数据的表的名称,filter_condition是一个布尔表达式,用于指定过滤条件。
手把手教你生产安装goldengate的步骤
手把手教你生产安装goldengate的步骤一、简介GoldenGate是Oracle公司的一款数据库同步工具,可以实现在不影响生产环境的情况下进行数据库的实时同步和迁移。
本文将以手把手的方式,介绍在生产环境中安装和配置GoldenGate的步骤。
二、环境准备在开始安装GoldenGate之前,需要确保以下环境准备工作已经完成:1.安装并配置Oracle数据库,确保数据库可以正常运行。
2.确定GoldenGate版本和操作系统平台的兼容性,并下载GoldenGate的安装包。
三、安装GoldenGate1.解压GoldenGate安装包到指定的安装目录。
可以使用以下命令解压:tar zxvf ggxx_linux64.tar.gz2.进入解压后的目录,并执行安装脚本。
具体命令如下:cd ggxx./gginstall3.根据安装向导的提示进行安装,包括选择安装类型、输入安装路径等。
一般情况下,可以选择完全安装和默认安装路径。
4.等待安装完成。
安装过程可能需要一些时间,取决于系统性能和GoldenGate的版本。
5.安装完成后,可以通过以下命令验证GoldenGate的安装是否成功:ggsci如果看到类似以下信息,则表示安装成功:GoldenGate Command Interpreter for OracleVersion 19.1.0.0.4 OGGCORE_19.1.0.0.0_PLATFORMS_191214.0354Linux, x64, 64bit (optimized), Oracle 19c on Dec 14 2019 05:55:59四、配置GoldenGate1.创建GoldenGate的主目录,一般命名为gg_home,并进入该目录:mkdir gg_homecd gg_home2.在gg_home中创建GoldenGate的子目录dirdat、dirrpt和dirprm。
GoldenGate基本原理、安装过程和基本维护
目录一、GoldenGate介绍 (3)二、GoldenGate安装实施 (5)2.1创建GoldenGate软件安装目录 (5)2.2 GoldenGate的管理用户 (5)2.3安装GoldenGate软件 (6)2.4设置数据库归档模式 (6)2.5打开数据库的附加日志 (7)2.6开启数据库强制日志模式 (7)2.7创建GoldenGate管理用户 (7)2.8编辑GLOBALS参数文件 (8)2.9管理进程MGR参数配置 (8)2.10抽取进程EXTN参数配置 (9)2.11 传输进程DPEN参数配置 (10)2.12建立OGG的DDL对象 (11)2.13 数据初始化 (12)2.14 容灾端管理进程MGR参数配置 (14)2.15编辑GLOBALS参数文件 (15)2.16 容灾端复制进程REPN参数配置 (15)2.17创建复制进程repn (17)2.18启动生产端传输进程和容灾端复制进程 (17)2.19测试场景 (17)三.GoldenGate基本运维命令 (17)四、常见故障排除 (18)一、GoldenGate介绍GoldenGate软件是一种基于日志的结构化数据复制软件。
GoldenGate 能够实现大量交易数据的实时捕捉、变换和投递,实现源数据库与目标数据库的数据同步,保持亚秒级的数据延迟。
GoldenGate能够支持多种拓扑结构,包括一对一,一对多,多对一,层叠和双向复制等等。
GoldenGate基本架构Oracle GoldenGate主要由如下组件组成●Extract●Data pump●Trails●Collector●Replicat●ManagerOracle GoldenGate 数据复制过程如下:利用抽取进程(Extract Process)在源端数据库中读取Online Redo Log或者Archive Log,然后进行解析,只提取其中数据的变化信息,比如DML操作——增、删、改操作,将抽取的信息转换为GoldenGate自定义的中间格式存放在队列文件(trail file)中。
oracle-11g实例创建过程
oracle 11g实例创建过程
1、[开始]/[程序]/[Oracle –OraDb119_home1]/[DataBAse Configuration Assistant],开始oracle实例的创建:
2、
3、选择数据库创建模板,一般选择“一般用途或事务处理”
4、输入全局数据库名,比如TRAIN,SID默认等于全局数据库名
5、设置oracle系统管理员的密码,如果是练习使用,则选择“所有账号使用同一管理口令”,输入口令和确认口令,这里统一输入oralce。
如果在生产环境中,建议sys、system等账号的密码设置为不一样,并且用数字和字母组合。
6、设置文件位置变量,系统默认了几个文件变量,不可编辑,但可以增加文件位置变量。
后面中讲到。
7、设置数据库参数:
8、数据库的字符集,默认选择中文简体字符集:ZHS16GBK
9、修改“控制文件”和“数据文件”的位置
10、oracle实例创建过程:。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Oracle 11G 搭建单实例GoldenGate步骤1 GoldenGate安装准备在Oracle官网上下载GoldenGate介质,GoldenGate是包含在Fusion Middleware 类目下面,并上传到源数据库和目标数据库主机;2 GoldenGate安装过程注意:此步骤需要在两台主机上操作2.1 创建GoldenGate操作系统用户这里直接使用Oracle用户安装GoldenGate,而不创建新的用户。
2.2 创建GoldenGate安装路径[root@GMDBA ~]# mkdir -p /u01/ggs/11.2.0[root@GMDBA ~]# mv /u01/software/ogg112101_fbo_ggs_Linux_x86_ora11g_32bit.zip /u01/ggs/11.2.0/ [root@GMDBA ~]# chown -R oracle:oinstall /u01/ggs/[root@GMDBA ~]# su - oracle2.3 编辑用户环境变量[oracle@GMDBA ogg]$ vi ~/.bash_profile# .bash_profile# Get the aliases and functionsif [ -f ~/.bashrc ]; then. ~/.bashrcFi# User specific environment and startup programsPATH=$PATH:$HOME/binexport PATHexport ORACLE_SID=GMDBAexport ORACLE_BASE=/u01/app/oracleexport ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1export PATH=$ORACLE_HOME/bin:/u01/ggs/11.2.0:$PATHexport LD_LIBRARY_PATH=$ORACLE_HOME/lib:/u01/ggs/11.2.0:/libalias sqlplus='rlwrap sqlplus'alias rman='rlwrap rman'2.4 安装GoldenGate文件[oracle@GMDBA ~]$ cd /u01/ggs/11.2.0/[oracle@GMDBA 11.2.0]$ unzip ogg112101_fbo_ggs_Linux_x86_ora11g_32bit.zip Archive: ogg112101_fbo_ggs_Linux_x86_ora11g_32bit.zipinflating: fbo_ggs_Linux_x86_ora11g_32bit.tarinflating: OGG_WinUnix_Rel_Notes_11.2.1.0.1.pdfinflating: Oracle GoldenGate 11.2.1.0.1 README.txtinflating: Oracle GoldenGate 11.2.1.0.1 README.doc[oracle@GMDBA 11.2.0]$ tar -xvf fbo_ggs_Linux_x86_ora11g_32bit.tar [oracle@GMDBA 11.2.0]$ cd[oracle@GMDBA ~]$ cd /u01/ggs/11.2.0[oracle@GMDBA 11.2.0]$ ggsciOracle GoldenGate Command Interpreter for OracleVersion 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO Linux, x86, 32bit (optimized), Oracle 11g on Apr 23 2012 08:09:25Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.GGSCI (GMDBA) 1> create subdirsCreating subdirectories under current directory /u01/ggs/11.2.0Parameter files /u01/ggs/11.2.0/dirprm: already exists Report files /u01/ggs/11.2.0/dirrpt: created Checkpoint files /u01/ggs/11.2.0/dirchk: created Process status files /u01/ggs/11.2.0/dirpcs: createdSQL script files /u01/ggs/11.2.0/dirsql: created Database definitions files /u01/ggs/11.2.0/dirdef: createdExtract data files /u01/ggs/11.2.0/dirdat: created Temporary files /u01/ggs/11.2.0/dirtmp: created Stdout files /u01/ggs/11.2.0/dirout: createdGGSCI (GMDBA) 2>注意:需要进入ogg的安装目录在执行ggsci[oracle@GMDBA ~]$ cd /u01/ogg/11.2.0/[oracle@GMDBA 11.2.0]$ ggsciOracle GoldenGate Command Interpreter for OracleVersion 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO Linux, x86, 32bit (optimized), Oracle 11g on Apr 23 2012 08:09:25Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved. GGSCI (GMDBA) 1> helpGGSCI Command Summary:Object: Command:SUBDIRS CREATEER INFO, KILL, LAG, SEND, STATUS, START, STATS, STOP EXTRACT ADD, ALTER, CLEANUP, DELETE, INFO, KILL,LAG, REGISTER, SEND, START, STATS, STATUS, STOPUNREGISTEREXTTRAIL ADD, ALTER, DELETE, INFOGGSEVT VIEWMANAGER INFO, SEND, START, STOP, STATUSMARKER INFOPARAMS EDIT, VIEWREPLICAT ADD, ALTER, CLEANUP, DELETE, INFO, KILL, LAG, SEND,START, STATS, STATUS, STOPREPORT VIEWRMTTRAIL ADD, ALTER, DELETE, INFOTRACETABLE ADD, DELETE, INFOTRANDATA ADD, DELETE, INFOSCHEMATRANDATA ADD, DELETE, INFOCHECKPOINTTABLE ADD, DELETE, CLEANUP, INFOCommands without an object:(Database) DBLOGIN, LIST TABLES, ENCRYPT PASSWORD, FLUSH SEQUENCEMININGDBLOGIN(DDL) DUMPDDL(Miscellaneous) FC, HELP, HISTORY, INFO ALL, OBEY, SET EDITOR, SHELL,SHOW, VERSIONS, ! (note: you must type the wordCOMMAND after the !to display the ! help topic.)i.e.: GGSCI (sys1)>help !commandFor help on a specific command, type HELP .Example: HELP ADD REPLICATGGSCI (GMDBA) 2>2.5 配置源数据库2.5.1 开启归档[oracle@GMDBA ~]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.3.0 Production on Sun Dec 15 20:16:57 2013 Copyright (c) 1982, 2011, Oracle. All rights reserved.Connected to an idle instance.SQL> startupORACLE instance started.Total System Global Area 422670336 bytesFixed Size 1345380 bytesVariable Size 327157916 bytesDatabase Buffers 88080384 bytesRedo Buffers 6086656 bytesDatabase mounted.Database opened.SQL> show parameter log_archive_destNAME TYPE VALUE ------------------------------------ ----------- ------------------------------log_archive_dest stringlog_archive_dest_1 stringlog_archive_dest_10 stringlog_archive_dest_11 stringlog_archive_dest_12 stringlog_archive_dest_13 stringlog_archive_dest_14 stringlog_archive_dest_15 stringlog_archive_dest_16 stringlog_archive_dest_17 stringlog_archive_dest_18 stringlog_archive_dest_19 stringlog_archive_dest_2 stringlog_archive_dest_20 stringlog_archive_dest_21 stringlog_archive_dest_22 stringlog_archive_dest_23 stringlog_archive_dest_24 stringlog_archive_dest_25 stringlog_archive_dest_26 stringlog_archive_dest_27 stringlog_archive_dest_28 stringlog_archive_dest_29 stringlog_archive_dest_3 stringlog_archive_dest_30 stringlog_archive_dest_31 stringlog_archive_dest_4 stringlog_archive_dest_5 stringlog_archive_dest_6 stringlog_archive_dest_7 stringlog_archive_dest_8 stringlog_archive_dest_9 stringSQL> show parameter db_recoveryNAME TYPE VALUE------------------------------------ ----------- ------------------------------db_recovery_file_dest string /u01/app/oracle/fast_recovery_areadb_recovery_file_dest_size big integer 4977MSQL> shutdown immediateDatabase closed.Database dismounted.ORACLE instance shut down.SQL> startup mountORACLE instance started.Total System Global Area 422670336 bytesFixed Size 1345380 bytesVariable Size 327157916 bytesDatabase Buffers 88080384 bytesRedo Buffers 6086656 bytesDatabase mounted.SQL> alter database archivelog;Database altered.SQL> alter database open;Database altered.2.5.2 打开补充日志SQL> select SUPPLEMENTAL_LOG_DATA_MIN from v$database;SUPPLEME--------NOSQL> alter database add supplemental log data;Database altered.SQL> select SUPPLEMENTAL_LOG_DATA_MIN from v$database;SUPPLEME--------YES2.5.3 创建GoldenGate管理用户SQL> create user ggs identified by ggs default tablespace users temporary tablespace temp;User created.SQL> grant connect,resource to ggs;Grant succeeded.SQL> grant execute on utl_file to ggs;Grant succeeded.SQL> grant select any dictionary,select any table to ggs;Grant succeeded.SQL> grant alter any table to ggs;Grant succeeded.SQL> grant flashback any table to ggs;Grant succeeded.SQL> grant execute on DBMS_FLASHBACK to ggs;Grant succeeded.SQL>2.5.4 添加表级trandata对hr用户下的所有表进行同步[oracle@GMDBA ggs]$ cd 11.2.0/[oracle@GMDBA 11.2.0]$ ./ggsciOracle GoldenGate Command Interpreter for OracleVersion 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO Linux, x86, 32bit (optimized), Oracle 11g on Apr 23 2012 08:09:25Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.GGSCI (GMDBA) 1> dblogin userid ggs password ggsSuccessfully logged into database.GGSCI (GMDBA) 2> add trandata hr.*Logging of supplemental redo data enabled for table HR.COUNTRIES. Logging of supplemental redo data enabled for table HR.DEPARTMENTS. Logging of supplemental redo data enabled for table HR.EMPLOYEES. Logging of supplemental redo data enabled for table HR.JOBS. Logging of supplemental redo data enabled for table HR.JOB_HISTORY. Logging of supplemental redo data enabled for table HR.LOCATIONS. Logging of supplemental redo data enabled for table HR.REGIONS.GGSCI (GMDBA) 3>2.5.5 配置源端mgr管理进程组GGSCI (GMDBA) 1> edit params mgrport 7500dynamicportlist 7501-7505autorestart extract *,waitminutes 2,retries 5GGSCI (GMDBA) 2> view params mgrport 7500dynamicportlist 7501-7505autorestart extract *,waitminutes 2,retries 5GGSCI (GMDBA) 3> start mgrManager started.GGSCI (GMDBA) 4> info allProgram Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNING2.5.6 配置Extract抽取进程组GGSCI (GMDBA) 6> edit params ext1extract ext1dynamicresolutionuserid ggs,password ggssetenv(ORACLE_SID=GMDBA)exttrail /u01/ggs/11.2.0/dirdat/ettable hr.*;GGSCI (GMDBA) 7> view params ext1extract ext1dynamicresolutionuserid ggs,password ggssetenv(ORACLE_SID=GMDBA)exttrail /u01/ggs/11.2.0/dirdat/ettable hr.*;创建extract进程GGSCI (GMDBA) 8> add extract ext1,tranlog,begin nowEXTRACT added.GGSCI (GMDBA) 9> add exttrail /u01/ggs/11.2.0/dirdat/et,extract EXT1 EXTTRAIL added.GGSCI (GMDBA) 10> info allProgram Status Group Lag at Chkpt Time Since ChkptMANAGER RUNNINGEXTRACT STOPPED EXT1 00:00:00 00:00:41 GGSCI (GMDBA) 11> start ext1Sending START request to MANAGER ...EXTRACT EXT1 startingGGSCI (GMDBA) 12> info allProgram Status Group Lag at Chkpt Time Since ChkptMANAGER RUNNINGEXTRACT RUNNING EXT1 00:12:29 00:00:07 2.5.7 配置pump投递进程组GGSCI (GMDBA) 13> edit params pump1extract pump1dynamicresolutionuserid ggs,password ggsrmthost 192.168.80.30,mgrport 7809,compressrmttrail /u01/ggs/11.2.0/dirdat/pttable hr.*;GGSCI (GMDBA) 14> add extract pump1,exttrailsource /u01/ggs/11.2.0/dirdat/et EXTRACT added.GGSCI (GMDBA) 15>ADD RMTTRAIL /u01/ggs/11.2.0/dirdat/pt, EXTRACT PUMP1 RMTTRAIL added.GGSCI (GMDBA) 16> start pump1Sending START request to MANAGER ...EXTRACT PUMP1 startingGGSCI (GMDBA) 17> info allProgram Status Group Lag at Chkpt Time Since ChkptMANAGER RUNNINGEXTRACT RUNNING EXT1 00:00:00 00:00:00 EXTRACT RUNNING PUMP1 00:00:00 00:04:072.6 目标端操作2.6.1 目标端用户创建SQL> create user ggs identified by ggs default tablespace users temporary tablespace temp;User created.SQL>grant connect,resource to ggs;Grant succeeded.SQL> grant execute on utl_file to ggs;Grant succeeded.SQL> grant select any table to ggs;Grant succeeded.SQL> grant insert any table to ggs;Grant succeeded.SQL> grant delete any table to ggs;Grant succeeded.SQL> grant update any table to ggs;Grant succeeded.SQL> GRANT ALTER SESSION TO ggs;Grant succeeded.SQL> GRANT SELECT ANY DICTIONARY to ggs;Grant succeeded.2.6.2 添加checkpoint表[oracle@GMDBAGC ogg]$ cd 11.2.0/[oracle@GMDBAGC 11.2.0]$ ./ggsciOracle GoldenGate Command Interpreter for OracleVersion 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO Linux, x86, 32bit (optimized), Oracle 11g on Apr 23 2012 08:09:25Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.GGSCI (GMDBAGC) 1> edit params ./GLOBALScheckpointtable ggs.checkpointGGSCI (GMDBAGC) 1> dblogin userid ggs password ggsERROR: Unable to connect to database using user ggs. Please check privileges. ORA-00942: table or view does not exist.GGSCI (GMDBAGC) 2> dblogin userid ggs password ggsSuccessfully logged into database.GGSCI (GMDBAGC) 3> add checkpointtable ggs.checkpointSuccessfully created checkpoint table ggs.checkpoint.GGSCI (GMDBAGC) 4>2.6.3 配置mgrGGSCI (GMDBAGC) 1> edit params mgrport 7809dynamicportlist 7800-8000autostart er *autorestart extract *,waitminutes 2,retries 5lagreporthours 1laginfominutes 3lagcriticalminutes 5purgeoldextracts /u01/ggs/11.2.0/dirdat/rt*,usecheckpoints,minkeepdays 3 GGSCI (GMDBAGC) 2> start mgrManager started.GGSCI (GMDBAGC) 3> info allProgram Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNING2.6.4 配置replicatGGSCI (GMDBAGC) 4> edit params replreplicat repluserid ggs,password ggsassumetargetdefsreperror default,discarddiscardfile /u01/ggs/11.2.0/dirrpt/repl.dsc,append,megabytes 50 dynamicresolutionmap hr.*,target hr.*;GGSCI (GMDBAGC) 5> add replicat repl,exttrail /u01/ggs/11.2.0/dirdat/pt REPLICAT added.GGSCI (GMDBAGC) 4> start replSending START request to MANAGER ...REPLICAT REPL startingGGSCI (GMDBAGC) 5> info allProgram Status Group Lag at Chkpt Time Since ChkptMANAGER RUNNINGREPLICAT RUNNING REPL 00:00:00 00:00:013 测试源库SQL> create table test (a int,b int);Table created.SQL> insert into test values(1,1);1 row created.SQL> commit;Commit complete.SQL>目标库SQL> create table test (a int,b int); Table created.SQL>SQL> select * from test;no rows selectedSQL> select * from test;A B---------- ----------1 1 SQL>。