博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
GoldenGate单向复制配置示例
阅读量:5282 次
发布时间:2019-06-14

本文共 9410 字,大约阅读时间需要 31 分钟。

一:环境介绍

--source端ip地址:192.168.123.10数据库版本:11.2.0.1.0 32 bit操作系统版本:centos 4.5 32 bitogg版本:fbo_ggs_Linux_x86_ora11g_32bit.tar--target端ip地址:192.168.123.11数据库版本:11.2.0.1.0 32 bit操作系统版本:centos 4.5 32 bitogg版本:fbo_ggs_Linux_x86_ora11g_32bit.tar

二:安装 GG 软件

2.1 安装GG[root@oracle ~]# su - oracle[oracle@oracle ~]$ lsawrrpt_1_259_276.html  fbo_ggs_Linux_x86_ora11g_32bit.tar  oradiag_oracle[oracle@oracle ~]$ mkdir /u01/GG[oracle@oracle ~]$ tar -xvf fbo_ggs_Linux_x86_ora11g_32bit.tar -C /u01/GG  //将软件解压到/u01/GG2.2 添加环境变量在/home/oracle/.bash_profile文件里添加如下内容:export PATH=/u01/GG:$PATHexport LD_LIBRARY_PATH=/u01/GG:$LD_LIBRARY_PATHexport GGATE=/u01/GG注意:本实验的GG 和Oracle 使用的是相同的用户,所以把GG 的变量加上就可以了。加载刚刚设置的环境变量:[oracle@oracle ~]$ source /home/oracle/.bash_profile2.3 使用ggsci工具,创建必要的目录[oracle@oracle ~]$ cd /u01/GG        //要在安装目录下登陆,否则可能报错[oracle@oracle GG]$ ggsciOracle GoldenGate Command Interpreter for OracleVersion 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBOLinux, x86, 32bit (optimized), Oracle 11g on Apr 23 2012 08:09:25Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.GGSCI (oracle.11g) 1> create subdirsCreating subdirectories under current directory /u01/GGParameter files                /u01/GG/dirprm: already existsReport files                   /u01/GG/dirrpt: createdCheckpoint files               /u01/GG/dirchk: createdProcess status files           /u01/GG/dirpcs: createdSQL script files               /u01/GG/dirsql: createdDatabase definitions files     /u01/GG/dirdef: createdExtract data files             /u01/GG/dirdat: createdTemporary files                /u01/GG/dirtmp: createdStdout files                   /u01/GG/dirout: createdGGSCI (oracle.11g) 2>

以上就是GG 的安装,在source 和target database 都执行

三:配置Source database

  GoldenGate通过抓取源端数据库重做日志进行分析,将获取的数据应用到目标端,实现数据同步。因此,源数据库需要必须处于归档模式,并启用附加日志和强制日志。

3.1 归档模式、附加日志、强制日志--查看SQL> select log_mode,supplemental_log_data_min,force_logging from v$database;LOG_MODE     SUPPLEME FOR------------ -------- ---ARCHIVELOG   NO       NOSQL>--修改1)archivelogSQL>shutdown immediateSQL>startup mountSQL>alter database archivelog;SQL>alter database open;2) force loggingSQL>alterdatabase force logging;3)supplemental log dataSQL>alterdatabase add supplemental log data;3.2 启用DDL 支持 3.2.1禁用Recycle Bin如果启用DDL 支持,必须关闭recycle bin。SQL> show parameter recyclebinNAME                                 TYPE        VALUE------------------------------------ ----------- ------------------------------recyclebin                           string      onSQL>--11g(如果是10g,则需要重启)SQL> alter system set recyclebin=off scope=spfile;System altered.3.2.2 创建存放DDL 信息的user并赋权SQL> create user ggs identified by 123456;SQL> grant connect,resource to ggs;SQL> grant execute on utl_file to ggs;SQL> 3.2.3 用SYSDBA权限的用户执行如下脚本:[oracle@oracle GG]$ sqlplus /nologSQL> conn /as sysdbaConnected.SQL>-----脚本1SQL> @/u01/GG/marker_setup.sqlMarker setup scriptYou will be prompted for the name of a schema for the Oracle GoldenGate database objects.NOTE: The schema must be created prior to running this script.NOTE: Stop all DDL replication before starting this installation.Enter Oracle GoldenGate schema name:ggs  ---输入创建的用户Marker setup table script complete, running verification script...Please enter the name of a schema for the GoldenGate database objects:Setting schema name to GGSMARKER TABLE-------------------------------OKMARKER SEQUENCE-------------------------------OKScript complete.SQL>-----脚本2SQL> @/u01/GG/ddl_setup.sql;Oracle GoldenGate DDL Replication setup scriptVerifying that current user has privileges to install DDL Replication...You will be prompted for the name of a schema for the Oracle GoldenGate database objects.NOTE: For an Oracle 10g source, the system recycle bin must be disabled. For Oracle 11g and later, it can be enabled.NOTE: The schema must be created prior to running this script.NOTE: Stop all DDL replication before starting this installation.Enter Oracle GoldenGate schema name:ggs ---输入创建的用户Working, please wait ...Spooling to file ddl_setup_spool.txtChecking for sessions that are holding locks on Oracle Golden Gate metadata tables ...Check complete.......................STATUS OF DDL REPLICATION------------------------------------------------------------------------------------------------------------------------SUCCESSFUL installation of DDL Replication software componentsScript complete.SQL> ------脚本3SQL> @/u01/GG/role_setup.sql;GGS Role setup scriptThis script will drop and recreate the role GGS_GGSUSER_ROLETo use a different role name, quit this script and then edit the params.sql script to change the gg_role parameter to the preferred name. (Do not run the script.)You will be prompted for the name of a schema for the GoldenGate database objects.NOTE: The schema must be created prior to running this script.NOTE: Stop all DDL replication before starting this installation.Enter GoldenGate schema name:ggsWrote file role_setup_set.txtPL/SQL procedure successfully completed.Role setup script completeGrant this role to each user assigned to the Extract, GGSCI, and Manager processes, by using the following SQL command:GRANT GGS_GGSUSER_ROLE TO 
where
is the user assigned to the GoldenGate processes.SQL> ------脚本4:赋权SQL> grant GGS_GGSUSER_ROLE to ggs;------脚本5SQL> @/u01/GG/ddl_enable.sql;Trigger altered.SQL>

四:测试GG

4.1 在Source 和 Target database上创建测试用户--source databaseSQL> create user sender identified by 123456;SQL> grant connect,resource,dba to sender;SQL> --target databaseSQL> create user receiver identified by 123456;   SQL> grant connect,resource,dba to receiver;SQL>4.2 在Source 和Target 上配置Manager--source[oracle@oracle GG]$ cd /u01/GG    //此过程最好在安装目录下执行[oracle@oracle GG]$ ggsciOracle GoldenGate Command Interpreter for OracleVersion 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBOLinux, x86, 32bit (optimized), Oracle 11g on Apr 23 2012 08:09:25Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.GGSCI (oracle.11g) 2> info allProgram     Status      Group       Lag at Chkpt  Time Since ChkptMANAGER     STOPPED                                           GGSCI (oracle.11g) 3> edit params mgr  //配置管理进程的端口号PORT 7809GGSCI (oracle.11g) 4> start managerManager started.GGSCI (oracle.11g) 5> 以上是在Source 库上执行的,在Target 库上执行同样的操作。4.3 配置SourceDB 的复制队列4.3.1 先连接到数据库,测试连接:GGSCI (oracle.11g) 5> dblogin userid ggs, password 123456;Successfully logged into database.GGSCI (oracle.11g) 6>4.3.2 添加一个抽取: GGSCI (oracle.11g) 6> add extract ext1,tranlog, begin nowEXTRACT added.GGSCI (oracle.11g) 7> add exttrail /u01/GG/dirdat/lt, extract ext1EXTTRAIL added.--修改ext1的参数GGSCI (oracle.11g) 8> edit params ext1  extract ext1userid ggs, password 123456rmthost 192.168.0.11, mgrport 7809rmttrail /u01/GG/dirdat/ltddl include mapped objname sender.*;table sender.*;GGSCI (oracle.11g) 10> info allProgram     Status      Group       Lag at Chkpt  Time Since ChkptMANAGER     RUNNING                                           EXTRACT     STOPPED     EXT1        00:00:01      00:04:23    GGSCI (oracle.11g) 11> 4.4 配置TargetDB 同步队列4.4.1 创建用户ggtSQL> create user ggt identified by 123456;  SQL> grant connect,resource,dba to ggt;  --要赋予dba权限,否则后期启动进程时会报:--OCI Error describe for query (status = 942-ORA-00942: table or view does not exist), --SQL

五.验证

在Source DB上的sender 用户下创建一张表,然后看这张表是否同步到了Target DB的receiver用户下--Source DB:SQL> conn sender/123456;Connected.SQL> create table gg_test as select * from sys.all_users;SQL> --Target DB:SQL> conn receiver/123456;Connected.SQL> select count(*) from gg_test;  COUNT(*)----------        41SQL> 数据同步过来了,因为启用了DDL的支持,所以这里把表给复制过来了。 --在Source DB上在插入一些记录,在验证下GG的同步情况:SQL> insert into gg_test select * from sys.all_users;41 rows created.SQL> commit;Commit complete.SQL> --Target DB 验证:SQL> select count(*) from gg_test;  COUNT(*)----------        82SQL> 同步正常,以上就是Oracle to Oracle 下的一个GG 单向复制示例。

 

转载于:https://www.cnblogs.com/polestar/p/4273848.html

你可能感兴趣的文章
876. Middle of the Linked List - LeetCode
查看>>
打印沙漏形
查看>>
kickstart一键自动安装Linux系统
查看>>
实现求n个随机数和为sum的haskell程序
查看>>
ActiveMq
查看>>
tomcat启动后产生的日志
查看>>
ASP.NET Core Web Api之JWT(一)
查看>>
Java Security:Java加密框架(JCA)简要说明
查看>>
DLib库Base64编解码示例
查看>>
C++ algorithm算法库
查看>>
(转)LINQ to SQL语句
查看>>
Linux上搭建Elasticsearch服务器并同步数据库
查看>>
docker快速搭建wordpress(centos7)
查看>>
获取页面元素的几种方式
查看>>
JFlow与CCBPM的对比
查看>>
(动态规划) leetcode 647. Longest Continuous Increasing Subsequence
查看>>
《学习之道》第十三章为何要总结
查看>>
软工团队作业
查看>>
调整扩大VMDK格式VirtualBox磁盘空间
查看>>
DK NIO的BUG,例如臭名昭著的epoll bug,它会导致Selector空轮询,最终导致CPU 100%。...
查看>>