需求:
1.源数据库新增一条记录,目标库同时新增一条记录;
2.源数据库修改一条记录,目标库同时修改该条记录;
示例用到三个Kettle组件

下面详细说下每个组件的配置
Source:

本示例连接的是Mongodb数据库,四个字段,ID默认为主键,_id会系统自动生成暂时先不管。
值映射:

本步在本示例作用不大,只是为了测试效果。按照截图上进行配置即可
MongoDbOutput:
关键是这一步的配置

官网上对这个tab页的解释是这样的:
2.2 Selecting the write mode
The MongoDb output step provides a number of options that control what and how data is written to the target Mongo document collection. By default, data is inserted into the target collection. If the specified collection doesn't exist, it will be created before data is inserted. Selecting the Truncate option will delete any existing data in the target collection before inserting begins. Unless unique indexes are being used (see section on indexing below) then Mongo DB will allow duplicate records to be inserted. Mongo DB allows for fast bulk insert operations - the batch size can be configured using the Batch insert size field. If no value is supplied here, then the default size of 100 rows is used.
Selecting the Upsert option changes the write mode from insert to upsert (i.e. update if a match is found, otherwise insert a new record). Information on defining how records are matched can be found in the next section. Standard upsert replaces a matched record with an entire new record based on all the incoming fields specified in the Mongo document fields tab. Modifier update enables modifier ($ operators) to be used to mutate individual fields within matching documents. This type of update is fast and involves minimal network traffic; it also has the ability to update all matching documents, rather than just the first, if the Multi-update option is enabled
个人理解就是默认都不选择时往目标集合添加数据,如果指定的集合不存在则先创建集合然后插入数据;
Truncate:插入数据之前先把集合里的所有数据删除。(相当于数据删除同步);
Update:修改数据,存在则修改,不存在不操作。
upsert:找到匹配项则修改,找不到匹配项则添加。
勾选上红色圈着的选项之后,源数据修改、添加了,在目标库里都会有相应的操作。不过还要设置下面的一步

ID为主键match field for update时一定要选择Y否则运行时出错。
同步过程最主要的就是上边列出的几步设置,当然如果想要再设置更强大的功能,可详细去研究官网的API
MongoDB副本集配置系列十一:MongoDB 数据同步原理和自动故障转移的原理
1:数据同步的原理: 当Primary节点完成数据操作后,Secondary会做出一系列的动作保证数据的同步: 1:检查自己local库的oplog.rs集合找出最近的时间戳. 2:检查Primary ...
Oracle CDC (Change Data Capture)更新数据捕获——Asynchronous HotLog Mode(附带简单的kettle任务实现数据同步)
Performing Asynchronous HotLog Publishing Step 1 Source Database DBA: Set the database initializat ...
Elasticsearch 与 Mongodb 数据同步问题
1.mongo-connector工具 首先安装python环境 wget http://www.python.org/ftp/python/3.0.1/Python-3.0.1.tgz tar -z ...
MongoDB副本集配置系列十:MongoDB local库详解和数据同步原理
1:local库是MongoDB的系统库,记录着时间戳和索引和复制集等信息 gechongrepl:PRIMARY> use local switched to db local gechong ...
Kettle ETL 来进行mysql 数据同步——试验环境搭建(表中无索引,无约束,无外键连接的情况)
今天试验了如何在Kettle的图形界面(Spoon)下面来整合来mysql 数据库中位于不同数据库中的数据表中的数据. 试验用的数据表是customers: 第三方的数据集下载地址是:http://w ...
MongoDB 复制集 (三) 内部数据同步
一 数据同步 一个健康的secondary在运行时,会选择一个离自己最近的,数据比自己新的节点进行数据同步.选定节点后,它会从这个节点拉取oplog同步日志,具体流程是这样的: ...
Kettle 实现mysql数据库不同表之间数据同步——实验过程
下面是试验的主要步骤: 在上一篇文章中LZ已经介绍了,实验的环境和实验目的. 在本篇文章中主要介绍侧重于对Kettle ETL的相应使用方法, 在这里LZ需要说明一下,LZ成为了避免涉及索引和表连接等 ...
mongodb oplog与数据同步
1. 复制集(Replica sets)模式时,其会使用下面的local数据库local.system.replset 用于复制集配置对象存储 (通过shell下的rs.conf()或直接查询)loc ...
kettle数据同步
通过kettle实现两张表的数据同步,具体设计如下:
随机推荐
通过一个实例理解 offsetLeft,offsetTop; offsetWidth , offsetHeight
obj.offsetTop 指 obj 相对于版面或由 offsetParent 属性指定的父坐标的计算上侧位置,整型 obj.offsetLeft 指 obj 相对于版面或由 offsetParen ...
Web前端性能优化教程05:网站样式和脚本
本文是Web前端性能优化系列文章中的第五篇,主要讲述内容:网站样式和脚本代码的放置位置.使用外部javascript和css.完整教程可查看:Web前端性能优化 一.将样式表放在顶部 可视性回馈的重要 ...
Mac OS X 上的安装haskell开发环境
到haskell官方下载haskell的工具包: https://downloads.haskell.org/~platform/2014.2.0.0/Haskell%20Platform%20201 ...
js 数组去重 的5种方法
一万数组,4个重复项,先贴上成绩. 1.3毫秒 2.115毫秒 3.71毫秒 4.6毫秒 1.哈希表 2.JQuery (最快的方法是用JQuery 这句话是截图带的... 实际上Jq是最慢的) 3. ...
1.MyBaits无代理全套增删改
一.mybatis使用的准备工作 1.找到mybatis所需要的jar文件: mybatis-3.2.3.jar mybatis-spring-1.2.1.jar 2.解压mybatis-3.2.3. ...
Problem 2062 Suneast &; Yayamao 二进制(多重背包的理解基础)
Problem 2062 Suneast & Yayamao Accept: 143 Submit: 313T ...
洛谷 P2515 [HAOI2010]软件安装 解题报告
P2515 [HAOI2010]软件安装 题目描述 现在我们的手头有\(N\)个软件,对于一个软件\(i\),它要占用\(W_i\)的磁盘空间,它的价值为\(V_i\).我们希望从中选择一些软件安装到 ...
SJA1000 CAN驱动程序演示实验
SJA1000 CAN驱动程序演示实验 2016-04-12 20:41:22来源: eefocus 关键字:SJA1000 CAN 驱动程序 演示实验 收藏 评论(0) 分享到 微博 QQ ...
处理【由于 Web 服务器上的“ISAPI 和 CGI 限制”列表设置,无法提供您请求的页面】
处理[由于 Web 服务器上的“ISAPI 和 CGI 限制”列表设置,无法提供您请求的页面] 详细错误:HTTP 错误 404.2 - Not Found. 由于 Web 服务器上的“ISAPI 和 ...
ASP.NET中的另类控件
首先看一个aspx文件里的部分内容: html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " ...