需求:

1.源数据库新增一条记录,目标库同时新增一条记录;

2.源数据库修改一条记录,目标库同时修改该条记录;

示例用到三个Kettle组件

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

Source:

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

本节点的详细说明,可见官网:http://wiki.pentaho.com/display/EAI/MongoDB+Input

值映射:

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

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

官网API地址:http://wiki.pentaho.com/display/EAI/

示例kri文件下载地址:http://files.cnblogs.com/nyzhai/mongodbTran.rar

kettle之mongodb数据同步的更多相关文章

  1. MongoDB副本集配置系列十一:MongoDB 数据同步原理和自动故障转移的原理

    1:数据同步的原理: 当Primary节点完成数据操作后,Secondary会做出一系列的动作保证数据的同步: 1:检查自己local库的oplog.rs集合找出最近的时间戳. 2:检查Primary ...

  2. Oracle CDC (Change Data Capture)更新数据捕获——Asynchronous HotLog Mode(附带简单的kettle任务实现数据同步)

    Performing Asynchronous HotLog Publishing Step 1   Source Database DBA: Set the database initializat ...

  3. Elasticsearch 与 Mongodb 数据同步问题

    1.mongo-connector工具 首先安装python环境 wget http://www.python.org/ftp/python/3.0.1/Python-3.0.1.tgz tar -z ...

  4. MongoDB副本集配置系列十:MongoDB local库详解和数据同步原理

    1:local库是MongoDB的系统库,记录着时间戳和索引和复制集等信息 gechongrepl:PRIMARY> use local switched to db local gechong ...

  5. Kettle ETL 来进行mysql 数据同步——试验环境搭建(表中无索引,无约束,无外键连接的情况)

    今天试验了如何在Kettle的图形界面(Spoon)下面来整合来mysql 数据库中位于不同数据库中的数据表中的数据. 试验用的数据表是customers: 第三方的数据集下载地址是:http://w ...

  6. MongoDB 复制集 (三) 内部数据同步

    一 数据同步        一个健康的secondary在运行时,会选择一个离自己最近的,数据比自己新的节点进行数据同步.选定节点后,它会从这个节点拉取oplog同步日志,具体流程是这样的:      ...

  7. Kettle 实现mysql数据库不同表之间数据同步——实验过程

    下面是试验的主要步骤: 在上一篇文章中LZ已经介绍了,实验的环境和实验目的. 在本篇文章中主要介绍侧重于对Kettle ETL的相应使用方法, 在这里LZ需要说明一下,LZ成为了避免涉及索引和表连接等 ...

  8. mongodb oplog与数据同步

    1. 复制集(Replica sets)模式时,其会使用下面的local数据库local.system.replset 用于复制集配置对象存储 (通过shell下的rs.conf()或直接查询)loc ...

  9. kettle数据同步

    通过kettle实现两张表的数据同步,具体设计如下:

随机推荐

  1. vs安装失败,发生严重错误,错误号:Error 0x80070643

    发生这个的原因很大的可能是vs安装的目录不是系统默认目录,改一下就好了. C:\Program File(x86) 不要看网上那些没有的,都TM骗人的. 不要问我是怎么知道的,你只要知道我的电脑让我重 ...

  2. 前端学习 第六弹: javascript中的函数与闭包

    前端学习 第六弹:  javascript中的函数与闭包 当function里嵌套function时,内部的function可以访问外部function里的变量 function foo(x) {   ...

  3. tcpdf最新版 6.2版

    tcpdf6.2版,地址记 录 http://download.csdn.net/detail/hayywcy/9547873

  4. 随机函数的代码(srand、rand)

    #include<stdio.h> int main() int counter; for(counter=0;counter<10;counter++) { srand(count ...

  5. HYPER V 文件共享 复制文件 共享硬盘 来宾服务

    虚拟机的设置   -->  集成服务 –> 来宾服务  勾选    文件就可以在本地机器和虚拟机上来回复制了. 他可让 Hyper-V 管理员在运行虚拟机的同时将文件复制到虚拟机,且无需使 ...

  6. CentOS源 Ubuntu 源 OpenSUSE-----持续汇总

    CentOS 基础(常用)的源:http://dl.fedoraproject.org/pub/epel/epel-release-latest-5.noarch.rpmhttp://dl.fedor ...

  7. AT指令获取基站信息

    AT+CREG 网络注册和漫游    命令发送(command):     AT+CREG=<mode>     命令响应(Response):     +CREG :<mode&g ...

  8. 关于lemon oa的数据库

    lemonOA的数据库默认用的是hsqldb,这个数据库还是第一次听说,暂且不论. 也就说Lemon OA默认使用HSQLDB数据库,是嵌入式的数据库不需要单独安装. lemon-1.4.0\weba ...

  9. Rails 之微信开发 : OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

    微信公众平台,使用Ruby On Rails + Win7 在取得OpenID时,如果简单的使用http.get方法,会出现如下 SSL_connect returned=1 errno=0 stat ...

  10. 【DNS】简单聊聊DNS如何工作

    随便聊聊 我们知道,网络上传输的数据包是一层一层的包起来的,典型的是mac地址层,ip层,tcp/udp层,应用层数据 这么几个层,那用户在浏览器中打开www.baidu.com数据包如何传到baid ...