返回顶部
首页 > 资讯 > 数据库 >OGG单向DDL复制操作
  • 322
分享到

OGG单向DDL复制操作

2024-04-02 19:04:59 322人浏览 八月长安
摘要

实验目的:在两台虚机模拟实现简单的单向的DDL复制. 说明:因《OGG单机安装与配置,并实验单向DML复制操作》中已配置过单向的dml操作,所以本次配置内容在前一篇的基础之上。 环境解释:在《OGG单

实验目的:在两台虚机模拟实现简单的单向的DDL复制.

说明:因《OGG单机安装与配置,并实验单向DML复制操作》中已配置过单向的dml操作,所以本次配置内容在前一篇的基础之上。

环境解释:在《OGG单机安装与配置,并实验单向DML复制操作》中hostname:slient,db_name:test作为源库,而hostname:one,db_name:onemore作为目标库,本次只需要配置一次反向的操作即可:即slient为源端,  onemo为目标端.

实验步骤:

1.源端关闭回收站
注明:在oracle11g 中, recyclebin参数的 System Modifiable为DEFERRED,意思是要修改系统级的话,就要加deferred参数,对当前已经连接的sesion没有影响,但新连接的session将受到影响。(可以查询视图selectname,isses_modifiable,issys_modifiable from v$parameter wherename='recyclebin';)

SQL> set lines 200
SQL> col name for a30
SQL> select name,isses_modifiable,issys_modifiable from v$parameter where name='recyclebin';

NAME                           ISSES ISSYS_MOD
------------------------------ ----- ---------
recyclebin                     TRUE  DEFERRED

SQL> alter system set recyclebin=off DEFERRED;   

System altered.

SQL> select name,isses_modifiable,issys_modifiable from v$parameter where name='recyclebin';

NAME                           ISSES ISSYS_MOD
------------------------------ ----- ---------
recyclebin                     TRUE  DEFERRED

2.源端配置./GLOBALS(修改全局配置文件添加ggschema参数)
GGSCI (slient as ogg@test) 14> edit params ./GLOBALS  
ggschema ogg
~
"./GLOBALS" [New] 1L, 13C written

GGSCI (slient as ogg@test) 15>

GGSCI (slient as ogg@test) 16> view param ./GLOBALS  

ggschema ogg

GGSCI (slient as ogg@test) 17>

3.源库运行相关的sql脚本
[oracle@slient ogg_home]$ pwd
/opt/ogg/ogg_home
[oracle@slient ogg_home]$
[oracle@slient ogg_home]$ ls mark*
marker_remove.sql  marker_setup.sql  marker_status.sql
[oracle@slient ogg_home]$
[oracle@slient ogg_home]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Mon Oct 30 21:52:30 2017

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

--执行marker_setup.sql脚本:
SQL> @/opt/ogg/ogg_home/marker_setup.sql

Marker setup script

You 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:ogg


Marker setup table script complete, running verification script...
Please enter the name of a schema for the GoldenGate database objects:
Setting schema name to OGG

MARKER TABLE
-------------------------------
OK

MARKER SEQUENCE
-------------------------------
OK

Script complete.
SQL>

--执行ddl_setup.sql脚本
SQL> !ls ddl_setup*
ddl_setup.sql

SQL>@/opt/ogg/ogg_home/ddl_setup.sql

Oracle GoldenGate DDL Replication setup script

Verifying 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:ogg

Working, please wait ...
Spooling to file ddl_setup_spool.txt

Checking for sessions that are holding locks on Oracle Golden Gate metadata tables ...

Check complete.

Using OGG as a Oracle GoldenGate schema name.

Working, please wait ...

DDL replication setup script complete, running verification script...
Please enter the name of a schema for the GoldenGate database objects:
Setting schema name to OGG

CLEAR_TRACE STATUS:

Line/pos             Error
-------------------- -----------------------------------------------------------------
No errors            No errors

CREATE_TRACE STATUS:

Line/pos             Error
-------------------- -----------------------------------------------------------------
No errors            No errors

TRACE_PUT_LINE STATUS:

Line/pos             Error
-------------------- -----------------------------------------------------------------
No errors            No errors

INITIAL_SETUP STATUS:

Line/pos             Error
-------------------- -----------------------------------------------------------------
No errors            No errors

DDLVERSIONSPECIFIC PACKAGE STATUS:

Line/pos             Error
-------------------- -----------------------------------------------------------------
No errors            No errors

DDLREPLICATION PACKAGE STATUS:

Line/pos             Error
-------------------- -----------------------------------------------------------------
No errors            No errors

DDLREPLICATION PACKAGE BODY STATUS:

Line/pos             Error
-------------------- -----------------------------------------------------------------
No errors            No errors

DDL IGNORE TABLE
-----------------------------------
OK

DDL IGNORE LOG TABLE
-----------------------------------
OK

DDLAUX  PACKAGE STATUS:

Line/pos             Error
-------------------- -----------------------------------------------------------------
No errors            No errors

DDLAUX PACKAGE BODY STATUS:

Line/pos             Error
-------------------- -----------------------------------------------------------------
No errors            No errors

SYS.DDLCTXINFO  PACKAGE STATUS:

Line/pos             Error
-------------------- -----------------------------------------------------------------
No errors            No errors

SYS.DDLCTXINFO  PACKAGE BODY STATUS:

Line/pos             Error
-------------------- -----------------------------------------------------------------
No errors            No errors

DDL HISTORY TABLE
-----------------------------------
OK

DDL HISTORY TABLE(1)
-----------------------------------
OK

DDL DUMP TABLES
-----------------------------------
OK

DDL DUMP COLUMNS
-----------------------------------
OK

DDL DUMP LOG GROUPS
-----------------------------------
OK

DDL DUMP PARTITIONS
-----------------------------------
OK

DDL DUMP PRIMARY KEYS
-----------------------------------
OK

DDL SEQUENCE
-----------------------------------
OK

GGS_TEMP_COLS
-----------------------------------
OK

GGS_TEMP_UK
-----------------------------------
OK

DDL TRIGGER CODE STATUS:

Line/pos             Error
-------------------- -----------------------------------------------------------------
No errors            No errors

DDL TRIGGER INSTALL STATUS
-----------------------------------
OK

DDL TRIGGER RUNNING STATUS
----------------------------------------------------------------------
ENABLED

STAYMETADATA IN TRIGGER
----------------------------------------------------------------------
OFF

DDL TRIGGER SQL TRACING
----------------------------------------------------------------------
0

DDL TRIGGER TRACE LEVEL
----------------------------------------------------------------------
NONE

LOCATION OF DDL TRACE FILE
------------------------------------------------------------------------------------------------------------------------
/u01/app/oracle/diag/rdbms/test/test/trace/ggs_ddl_trace.log

Analyzing installation status...


VERSION OF DDL REPLICATION
------------------------------------------------------------------------------------------------------------------------
OGGCORE_12.2.0.1.0_PLATFORMS_151211.1401

STATUS OF DDL REPLICATION
------------------------------------------------------------------------------------------------------------------------
SUCCESSFUL installation of DDL Replication software components

Script complete.
SQL>

--执行role_setup.sql脚本
SQL> !pwd
/opt/ogg/ogg_home

SQL> @role_setup.sql

GGS Role setup script

This script will drop and recreate the role GGS_GGSUSER_ROLE
To 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:ogg
SP2-0606: Cannot create SPOOL file "role_setup_spool.txt"
SP2-0606: Cannot create STORE file "role_setup_set.txt"

PL/SQL procedure successfully completed.


Role setup script complete

Grant this role to each user assigned to the Extract, GGSCI, and Manager processes, by using the following SQL command:

GRANT GGS_GGSUSER_ROLE TO <loggedUser>

where <loggedUser> is the user assigned to the GoldenGate processes.
SQL>

--根据上述提示执行授权:
SQL> GRANT GGS_GGSUSER_ROLE TO ogg;

Grant succeeded.

SQL>

--执行ddl_enable.sql 脚本:
SQL>  @ddl_enable.sql  

Trigger altered.

sql>

--执行dbmspool.sql  
SQL> @?/rdbms/admin/dbmspool.sql  


Package created.


Grant succeeded.

--执行ddl_pin.sql
SQL> @ddl_pin.sql            
Enter value for 1: ogg

PL/SQL procedure successfully completed.

Enter value for 1: ogg

PL/SQL procedure successfully completed.


PL/SQL procedure successfully completed.

SQL>


4.源库修改extract进程的params文件,添加"ddl include all"参数,重启extract进程
GGSCI (slient as ogg@test) 19> edit param exta
EXTRACT exta
setenv (ORACLE_SID=test)
setenv (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)
userid ogg,password ogg
ddl include all
exttrail /opt/ogg/ogg_home/dirdat/r1
dynamicresolution
TABLE scott.*;
~
"dirprm/exta.prm" 8L, 203C written


GGSCI (slient as ogg@test) 20>

--重启extract进程:
GGSCI (slient as ogg@test) 20> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING                                           
EXTRACT     RUNNING     DPEA        00:00:00      00:00:05    
EXTRACT     RUNNING     EXTA        00:00:00      00:00:10    
REPLICAT    STOPPED     REP_REV     00:00:00      01:16:00    


GGSCI (slient as ogg@test) 21>

GGSCI (slient as ogg@test) 21>

GGSCI (slient as ogg@test) 21> stop exta

Sending STOP request to EXTRACT EXTA ...
Request processed.


GGSCI (slient as ogg@test) 22> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING                                           
EXTRACT     RUNNING     DPEA        00:00:00      00:00:07    
EXTRACT     STOPPED     EXTA        00:00:00      00:00:20    
REPLICAT    STOPPED     REP_REV     00:00:00      01:16:32    

GGSCI (slient as ogg@test) 23> start EXTA

Sending START request to MANAGER ...
EXTRACT EXTA starting


GGSCI (slient as ogg@test) 24> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING                                           
EXTRACT     RUNNING     DPEA        00:00:00      00:00:07    
EXTRACT     RUNNING     EXTA        00:00:00      00:00:03    
REPLICAT    STOPPED     REP_REV     00:00:00      01:16:42    


GGSCI (slient as ogg@test) 25> info extract EXTA

EXTRACT    EXTA      Last Started 2017-10-30 22:30   Status RUNNING
Checkpoint Lag       00:00:00 (updated 00:00:08 ago)
Process ID           21542
Log Read Checkpoint  Oracle Redo Logs
                     2017-10-30 22:30:38  Thread 1, Seqno 336, RBA 7193088
                     SCN 0.21418576 (21418576)


GGSCI (slient as ogg@test) 26>  


5.目标库修改replicat进程的params文件,添加"ddl include all"和"ddlerrordefault ignore retryop maxretries 3 retrydelay 5" 参数,重启replicat进程
GGSCI (one as ogg@onemo) 67>   edit param rep_demo
replicat rep_demo
setenv (oracle_sid=onemo)
setenv (nls_lang ="american_america.zhs16gbk")
userid ogg,password ogg
ddl include all
ddlerror default ignore retryop maxretries 3 retrydelay 5
--report at 01:59
--reportrollover at 02:00
reperror default,abend
discardfile /u01/app/oracle/ogg/dirrpt/repa.dsc,append, megabytes 10
assumetargetdefs
--allownoopupdates
dynamicresolution
--insertallrecords
map scott.*,target scott.*;
~
~
"dirprm/rep_demo.prm" 15L, 431C written


GGSCI (one as ogg@onemo) 68>

GGSCI (one as ogg@onemo) 68> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING                                           
EXTRACT     STOPPED     DPE_REV     00:00:00      01:24:21    
EXTRACT     STOPPED     EXT_REV     00:00:00      01:24:27    
REPLICAT    STOPPED     REP_DEMO    00:00:00      00:04:09    

--重启replicat进程
GGSCI (one as ogg@onemo) 69> start REP_DEMO

Sending START request to MANAGER ...
REPLICAT REP_DEMO starting


GGSCI (one as ogg@onemo) 70> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING                                           
EXTRACT     STOPPED     DPE_REV     00:00:00      01:24:28    
EXTRACT     STOPPED     EXT_REV     00:00:00      01:24:34    
REPLICAT    RUNNING     REP_DEMO    00:00:00      00:00:01    


GGSCI (one as ogg@onemo) 71>
GGSCI (one as ogg@onemo) 71> info REPLICAT REP_DEMO

REPLICAT   REP_DEMO  Last Started 2017-10-27 08:45   Status RUNNING
Checkpoint Lag       00:00:00 (updated 00:00:05 ago)
Process ID           11591
Log Read Checkpoint  File /u01/app/oracle/ogg/dirdat/ra000000000
                     2017-10-30 21:11:03.153747  RBA 5075


GGSCI (one as ogg@onemo) 72>


6.测试源端和目标端的数据
--先检查源库和目标库:
源库:
SQL> conn scott/tiger;
Connected.
SQL> select * from tab;

TNAME                          TABTYPE  CLUSTERID
------------------------------ ------- ----------
BONUS                          TABLE
DEPT                           TABLE
EMP                            TABLE
SALGRADE                       TABLE
TB_PT                          TABLE
TREE_VIEW                      VIEW

6 rows selected.

目标库:
SQL> conn scott/tiger;
Connected.
SQL>
SQL> select * from tab;

TNAME                          TABTYPE  CLUSTERID
------------------------------ ------- ----------
BONUS                          TABLE
DEPT                           TABLE
EMP                            TABLE
SALGRADE                       TABLE

SQL>

--开始测试:
源库:
SQL> create table t5(a int);

Table created.

SQL> insert into t5 values(111);  

1 row created.

SQL> commit;

Commit complete.

SQL> select * from tab;

TNAME                          TABTYPE  CLUSTERID
------------------------------ ------- ----------
BONUS                          TABLE
DEPT                           TABLE
EMP                            TABLE
SALGRADE                       TABLE
T5                             TABLE
TB_PT                          TABLE
TEST                           TABLE
TREE_VIEW                      VIEW

8 rows selected.

SQL>

检查目标库:
SQL>  select * from tab;

TNAME                          TABTYPE  CLUSTERID
------------------------------ ------- ----------
BONUS                          TABLE
DEPT                           TABLE
EMP                            TABLE
SALGRADE                       TABLE
T5                             TABLE
TEST                           TABLE

6 rows selected.

SQL> select * from t5;

         A
----------
       111

SQL>   

测试数据同步成功,实现了单向DDL复制!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

您可能感兴趣的文档:

--结束END--

本文标题: OGG单向DDL复制操作

本文链接: https://lsjlt.com/news/49799.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

猜你喜欢
  • OGG单向DDL复制操作
    实验目的:在两台虚机模拟实现简单的单向的DDL复制. 说明:因《OGG单机安装与配置,并实验单向DML复制操作》中已配置过单向的dml操作,所以本次配置内容在前一篇的基础之上。 环境解释:在《OGG单...
    99+
    2024-04-02
  • 1.--Goldgate单向复制(支持DDL)
    OGG单向复制(支持DDL) 版本说明: ./ggsci -v Oracle GoldenGate Command Interpreter for Oracle Version 11.2.1....
    99+
    2024-04-02
  • oracle ogg 单机环境单向复制搭建
    OGG安装fbo_ggs_Linux_x64_shiphome.zip---------------------同时支持11g和12c 添加用户useradd -u 1003 -g oinsta...
    99+
    2024-04-02
  • Goldengate 实现Oracle for Oracle 单向DDL操作同步
    在http://lqding.blog.51cto.com/9123978/1695162 文章中我们实现了表的DML操作同步。我们做如下测试在源端执行表的truncateSQL> ...
    99+
    2024-04-02
  • OGG双向DML复制怎么实现
    本篇内容主要讲解“OGG双向DML复制怎么实现”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“OGG双向DML复制怎么实现”吧!环境解释:hostname:sli...
    99+
    2024-04-02
  • OGG 单表初始化操作步骤
    有时候ogg两端数据不一致,且数据量较大,手工修改比较复杂的情况下,我们需要对这些表进行初始化。初始化的大概思路是:停止两端OGG如果业务不可以停很长时间,就需要配置目标端进程,暂停这些问题表的同步。待新数...
    99+
    2024-04-02
  • HADR复制的操作以及不复制的操作
    (HADR) 复制的操作:高可用性灾难恢复 (HADR) 使用数据库日志将数据从主数据库复制到备用数据库。在备用数据库上重放日志时,某些活动可能会导致备用数据库落后于主数据库。某些活动要进行大量记录,它们生...
    99+
    2024-04-02
  • MySQL主从复制操作
    前期准备:两台安装Mysql的服务器,或者在一台服务器上部署两个Mysql实例。       为了避免出现不必要的错误,Mysql版本最好保持一致。+--------...
    99+
    2024-04-02
  • python文件操作--复制
    文件的写入和文件的读取一样,文件的写入也有多种方法,write()和writelines()方法。二者之间的区别是:write()方法用于将字符串写入文件,如果要写入文件的字符串不多,使用write()方法即可,writelines()用于...
    99+
    2023-01-31
    操作 文件 python
  • logminer挖掘归档日志,针对DDL误操作的恢复
            日志挖掘,未开启补充日志功能,利用归档对DDL操作进行恢复:        Oracle&...
    99+
    2024-04-02
  • Mysql主从复制操作笔记
    前提,主从服务器上的mysql 数据库内的数据应该完全一致,才可以实施.如果之前只有一个主mysql 则应该先数据备份出来,还原到从mysql内,先保证数据一致,必要时可能要先停止业务再进行. 1.先建立一...
    99+
    2024-04-02
  • H5如何实现复制操作
    小编给大家分享一下H5如何实现复制操作,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧! 一开始,在 ...
    99+
    2024-04-02
  • 怎么理解Oracle数据库的单向复制
    这篇文章主要讲解了“怎么理解Oracle数据库的单向复制”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“怎么理解Oracle数据库的单向复制”吧!1.&nbs...
    99+
    2024-04-02
  • OGG运维优化脚本(二十)-进程操作类--强制时间点调整
    文件名: fullrestart.sh路径 $HOME/ggscript/ggoperat这个脚本属于为了应付某台非常头疼的业务数据库服务器OGG频繁延时的问题而特别写的因为这台数据库每天晚上会调...
    99+
    2024-04-02
  • 关于数据结构单向链表的各种操作
    目录关于节点数据添加:尾添加头添加一次性添加n个x数据节点:关于查找:根据指定数据:根据下标查找:删除头节点:删除尾节点:删除中间节点:删除全部节点:关于节点数据添加: 尾添加 最核...
    99+
    2023-05-15
    数据结构 数据结构单向链表
  • java数据结构单向链表的操作有哪些
    本文小编为大家详细介绍“java数据结构单向链表的操作有哪些”,内容详细,步骤清晰,细节处理妥当,希望这篇“java数据结构单向链表的操作有哪些”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。关于节点数据添加:尾添...
    99+
    2023-07-06
  • Python复制文件操作实例详解
    本文实例讲述了Python复制文件操作用法。分享给大家供大家参考,具体如下: 这里用python实现了一个小型的自动发版本的工具。这个“自动发版本”有点虚, 只是简单地把debug 目录下的配置文件复制到指...
    99+
    2022-06-04
    详解 实例 操作
  • Redis主从复制操作和配置详情
    目录前言一、Redis-server环境变量二、配置集群的Redis.conf三、配置主从服务器四、启动三台Redis服务器前言 环境:Centos7下安装Redis集群,默认已安装好5.0及以上版本,操作包括: Red...
    99+
    2024-04-02
  • mysql主从复制的安装流程操作
    本篇内容主要讲解“mysql主从复制的安装流程操作”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“mysql主从复制的安装流程操作”吧!Mysql主从复制一、一主...
    99+
    2024-04-02
  • MySQL 5.6 延迟复制,误操作后的数据库恢复
    MySQL 5.6 支持延迟复制,可以在Slave服务器指定一个延迟的值。默认值为0秒。使用MASTER_DELAY 选项为CHANGE MASTERTO 设置N秒延迟。 1. 下面来实...
    99+
    2024-04-02
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作