首页 > 其他分享 >OGG数据同步如何屏蔽表的drop、delete及truncate操作

OGG数据同步如何屏蔽表的drop、delete及truncate操作

时间:2023-08-07 21:35:03浏览次数:46  
标签:00 PARTITION enmodb truncate drop jinksom 01 TAB OGG

适用范围

源端生产库用户数据实时同步到历史归档库,只同步insert、update这类操作,所有表都不同步delete、drop、truncate操作;历史归档库保留全部数据不被修改。

实施步骤

1.源库与目标库创建相同普通表、分区表
#创建用户jinksom、enmotech,然后创建普通表T、分区表RANGE_PART_TAB

CREATE TABLE "JINKSOM"."T"
   (    "N1" NUMBER,
        "N2" NUMBER,
        "N3" NUMBER,
        "N4" NUMBER,
        "N5" NUMBER,
        "N6" NUMBER,
        "N7" NUMBER,
        "N8" NUMBER,
        "N9" NUMBER,
        "PAD" VARCHAR2(1000)
   ) TABLESPACE "USERS";

CREATE TABLE "JINKSOM"."RANGE_PART_TAB"
   (    "ID" NUMBER,
        "DEAL_DATE" DATE,
        "AREA_CODE" NUMBER,
        "CONTENTS" VARCHAR2(4000)
   ) TABLESPACE "USERS"
  PARTITION BY RANGE ("DEAL_DATE")(
 PARTITION "P1"  VALUES LESS THAN (TO_DATE(' 2012-02-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS')) TABLESPACE "USERS" ,
 PARTITION "P3"  VALUES LESS THAN (TO_DATE(' 2012-04-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS')) TABLESPACE "USERS" ,
 PARTITION "P4"  VALUES LESS THAN (TO_DATE(' 2012-05-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS')) TABLESPACE "USERS" ,
 PARTITION "P5"  VALUES LESS THAN (TO_DATE(' 2012-06-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS')) TABLESPACE "USERS" ,
 PARTITION "P6"  VALUES LESS THAN (TO_DATE(' 2012-07-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS')) TABLESPACE "USERS" ,
 PARTITION "P7"  VALUES LESS THAN (TO_DATE(' 2012-08-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS')) TABLESPACE "USERS" ,
 PARTITION "P8"  VALUES LESS THAN (TO_DATE(' 2012-09-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS')) TABLESPACE "USERS" ,
 PARTITION "P9"  VALUES LESS THAN (TO_DATE(' 2012-10-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS')) TABLESPACE "USERS" ,
 PARTITION "P10" VALUES LESS THAN (TO_DATE(' 2012-11-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS')) TABLESPACE "USERS" ,
 PARTITION "P11" VALUES LESS THAN (TO_DATE(' 2012-12-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS')) TABLESPACE "USERS" ,
 PARTITION "P12" VALUES LESS THAN (TO_DATE(' 2013-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS')) TABLESPACE "USERS" ,
 PARTITION "P_MAX" VALUES LESS THAN (MAXVALUE) TABLESPACE "USERS" );

#数据略
2.配置OGG抽取进
dblogin USERID goldengate@enmodb, password Enmo#2020
register extract pext2 database
add extract pext2, integrated tranlog, begin now
add exttrail /u01/app/extract/dirdatpext2/lt,extract pext2, megabytes 200

edit param pext2
EXTRACT pext2
USERID goldengate@enmodb, password Enmo#2020
EXTTRAIL /u01/app/extract/dirdatpext2/lt
CACHEMGR CACHESIZE 4GB
WARNLONGTRANS 1h, CHECKINTERVAL 5m, SKIPEMPTYTRANS
REPORTCOUNT EVERY 1 MINUTES, RATE
DISCARDFILE /u01/app/extract/dirrpt/pext2.dsc, APPEND, MEGABYTES 1024
DISCARDROLLOVER AT 6:00
DDL INCLUDE ALL & 
    EXCLUDE OPTYPE DROP &
    EXCLUDE OPTYPE TRUNCATE &
    EXCLUDE INSTR 'DROP PARTITION' &
    EXCLUDE INSTR 'TRUNCATE PARTITION'
IGNOREDELETES
TABLE jinksom.t;
TABLE jinksom.RANGE_PART_TAB;
TABLE jinksom.NORM_TAB;
3.配置应用进程
add replicat prep2, integrated exttrail /u01/app/extract/dirdatpext2/lt

edit param prep2
REPLICAT prep2
USERID goldengate@enmodb, password Enmo#2020
ASSUMETARGETDEFS
DBOPTIONS INTEGRATEDPARAMS(max_sga_size 128, parallelism 2)
DISCARDFILE /u01/app/extract/dirrpt/prep2.dsc, APPEND, MEGABYTES 1024  
DISCARDROLLOVER AT 6:00
REPORTCOUNT EVERY 1 MINUTES, RATE
map jinksom.t, target enmotech.t;
map jinksom.RANGE_PART_TAB, target enmotech.RANGE_PART_TAB;
map jinksom.NORM_TAB, target enmotech.NORM_TAB;
4.执行delete操作
GGSCI (enmoedu1 as goldengate@enmodb) 50> stats pext2 total 

Sending STATS request to EXTRACT PEXT2 ...

Start of Statistics at 2023-06-19 01:23:57.

Output to /u01/app/extract/dirdatpext2/lt:

Extracting from JINKSOM.T to JINKSOM.T:

*** Total statistics since 2023-06-19 01:23:32 ***
        Total inserts                                      0.00
        Total updates                                      0.00
        Total deletes                                      0.00
        Total upserts                                      0.00
        Total discards                                     0.00
        Total ignores                                     10.00
        Total operations                                   0.00

End of Statistics.

SYS@enmodb> select count(*) from jinksom.t;

  COUNT(*)
----------
      9990

SYS@enmodb> select count(*) from enmotech.t;

  COUNT(*)
----------
     10000
5.执行drop操作
SYS@enmodb> alter table jinksom.RANGE_PART_TAB drop partition p2;

Table altered.

GGSCI (enmoedu1) 17> stats pext2 total

Sending STATS request to EXTRACT PEXT2 ...

No active extraction maps.
DDL replication statistics (for all trails):

*** Total statistics since extract started     ***
        Operations                                         1.00
        Mapped operations                                  1.00
        Unmapped operations                                0.00
        Other operations                                   0.00
        Excluded operations                                1.00


SYS@enmodb> select count(*) from jinksom.t;
select count(*) from jinksom.t
                             *
ERROR at line 1:
ORA-00942: table or view does not exist


SYS@enmodb> select count(*) from enmotech.t;

  COUNT(*)
----------
     10010

SYS@enmodb> select count(*) from jinksom.RANGE_PART_TAB partition(p2);
select count(*) from jinksom.RANGE_PART_TAB partition(p2)
                                                      *
ERROR at line 1:
ORA-02149: Specified partition does not exist


SYS@enmodb> select count(*) from enmotech.RANGE_PART_TAB partition(p2);

  COUNT(*)
----------
        40
6.执行truncate操作
SYS@enmodb> alter table jinksom.RANGE_PART_TAB truncate partition p2;

Table truncated.

GGSCI (enmoedu1) 34> stats pext2 total

Sending STATS request to EXTRACT PEXT2 ...

Start of Statistics at 2023-06-20 00:03:44.

DDL replication statistics (for all trails):

*** Total statistics since extract started     ***
        Operations                                         2.00
        Mapped operations                                  2.00
        Unmapped operations                                0.00
        Other operations                                   0.00
        Excluded operations                                2.00

SYS@enmodb> select count(*) from jinksom.RANGE_PART_TAB partition(p2);

  COUNT(*)
----------
         0

SYS@enmodb> select count(*) from enmotech.RANGE_PART_TAB partition(p2);

  COUNT(*)
----------
        20


标签:00,PARTITION,enmodb,truncate,drop,jinksom,01,TAB,OGG
From: https://blog.51cto.com/u_13482808/6997847

相关文章

  • jenkins 0x80070533 -Error logging on 解决 win10家庭版 jenkins 安装时 admin
     netuserjenkinspsw/addnetuserusernamepsw/add1.第一步管理员身份打开dos窗口,命令行形式添加一个账号比如 jenkins 密码比如psw 2.第二步进入安全策略添加一个账号 大功告成  ......
  • PostgreSQL-unlogged table
    PostgreSQL中,有一种表的类型为unloggedtable,该种类型的表不会写入wal日志中,所以在写入的速度上比普通的堆表快很多,但是该表在数据库崩溃的时候,会被truncate,数据会丢失,而且该表也不支持流复制,所以在standby节点是无法查到该表数据的。在该表上创建的索引也是unlogged索引。创建un......
  • Python logging模块怎么使用,你会了吗?
    Pythonlogging模块使用在开发和维护Python应用程序时,日志记录是一项非常重要的任务。Python提供了内置的logging模块,它可以帮助我们方便地记录应用程序的运行时信息、错误和调试信息。本文将介绍如何使用Pythonlogging模块进行日志记录。logging模块logging是Python自带的用于记......
  • "No appenders found for logger" and "Please configure log4j properly"
    WhydoIseeawarningabout"Noappendersfoundforlogger"and"Pleaseconfigurelog4jproperly"?Thisoccurswhenthedefaultconfigurationfileslog4j.propertiesandlog4j.xmlcannotbefoundandtheapplicationperformsnoexplici......
  • Vulnhub: blogger:1靶机
    kali:192.168.111.111靶机:192.168.111.176信息收集端口扫描nmap-A-sC-v-sV-T5-p---script=http-enum192.168.111.176在80端口的/assets/fonts/目录下发现blog目录,访问后发现为wordpress利用wpscan发现wordpress插件wpdiscuz存在任意文件上传漏洞wpscan--urlhtt......
  • 报错:WARNING: cannot load logging configuration file, logging is disabled
    问题:在webots里使用rospy时报warning。分析:无解决方案:参考https://blog.csdn.net/ckkboy/article/details/985048801.在/etc/下创建ros目录cd/etc/sudomkdirros2.将python_logging.conf文件复制到/etc/ros/下sudocp/opt/ros/melodic/etc/ros/python_log......
  • Mit6.s081 Lec15: xv6 的 logging system
    Logginglayerfilesystem设计的一大重要问题就是crashrecovery。这是因为文件系统操作往往涉及向磁盘多次写入,而几次写入之后的crash可能导致磁盘上的文件系统处于一个不一致的状态。Forexample,supposeacrashoccursduringfiletruncation(settingthelengthof......
  • 无涯教程-jQuery - Dropable移动函数
    Drop-able功能可与JqueryUI中的交互一起使用。此功能可在任何DOM元素上启用可放置功能。Dropable-语法$("#droppable").droppable();Dropable-示例以下是一个简单的示例,显示了drop-able的用法-<html><head><title>ThejQueryExample</title><s......
  • 安装spark local运行出现错误NoClassDefFoundError: org/slf4j/Logger 原来是要设置
    Error:Unabletoinitializemainclassorg.apache.spark.deploy.SparkSubmitCausedby:java.lang.NoClassDefFoundError:org/slf4j/Logger HowtoinstallsparklocallyConsideringsparkwithouthadoopbuilt-in.Downloadhadoopunpackto/opt/hadoop/Downloadsp......
  • Starting MySQL.Logging to '/data/mysql8/data/zwzxzkptapp.err'. . ERROR! The
    实现MySQL日志文件路径修改1.了解MySQL日志文件MySQL服务器在运行时会产生多个日志文件,其中包括错误日志、查询日志、二进制日志等。每个日志文件都有一个特定的作用和存储路径。2.修改MySQL错误日志文件路径在MySQL中,错误日志文件用于记录MySQL服务器的错误信息。默认情况下......