简体   繁体   English

使用talend将数据从一个mysql数据库迁移到另一个

[英]Migrating data from one mysql database to another using talend

The goal is to migrate data from one mysql database to another, my concern is to define a text file that contains the parameters that defines the source database (host, port, databasename, etc.) and also the file parameters of the output database. 目的是将数据从一个mysql数据库迁移到另一个mysql数据库,我关心的是定义一个文本文件,其中包含定义源数据库的参数(主机,端口,数据库名称等)以及输出数据库的文件参数。

Actually, what I use is the following schema: 实际上,我使用的是以下架构:

tContextLoad_1 -> tFileInputDelimited_1-> tMysqlInput_1 (db_source) -> tMap->
tMysqlInput_2 (db_destination)

depending on the problem that has occurred is: 根据发生的问题是:

1- The tContextLoad_1 text file content change is not supported and the pointing is always on the first database "source database". 1-不支持tContextLoad_1文本文件内容更改,并且指向始终位于第一个数据库“源数据库”上。

2- When I create a second tContextLoad_2 can not be connected by a (but) or (trigger-On subject Ok) with tFileOutputDelimited_1 that linked with tMysqlInput_2 (db_destination), how to define a file that contains the definition parameters of a base output data (host, databasename, identifier, password, etc.) ? 2-当我创建第二个tContextLoad_2时,无法通过(但)或(触发主题为Ok)与与tMysqlInput_2 (db_destination)链接的tFileOutputDelimited_1连接,如何定义一个文件,该文件包含基本输出数据的定义参数(主机,数据库名称,标识符,密码等)?

You can use a configuration file like following, 您可以使用如下配置文件,

<connections>
  <connection>
    <host></host>
    <port></port>
    <database></database>
    <table></table> 
    <user></user>
    </password></password>
  </connection>

  <connection>
    <host></host>
    <port></port>
    <database></database>
    <table></table> 
    <user></user>
    </password></password>
  </connection>
</connections>

And then you can iterate on connection tag to fetch the DB details and then assign them to variables and use it. 然后,您可以遍历连接标签以获取数据库详细信息,然后将其分配给变量并使用它。

So the flow would be like, tFileInputXML-->SetGlobalVar-->tMySQLConnection-->tMySQLInput-->tMap-->tMySQLOutput 因此流程如下所示:tFileInputXML-> SetGlobalVar-> tMySQLConnection-> tMySQLInput-> tMap-> tMySQLOutput

You can either define a single file, but with different parameter names for the source connection and target connection, or define 2 files : one for the source and one for the target, in that case your parameters can have the same name : 您可以定义一个文件,但是为源连接和目标连接使用不同的参数名称,或者定义2个文件:一个用于源文件,一个用于目标文件,在这种情况下,您的参数可以具有相同的名称:

  1. Single context file with different parameter names: 具有不同参数名称的单个上下文文件:

tFileInputDelimited_1 (context file) -- tContextLoad_1 | OnSubjobOk | Source(host1,db1,user1,pwd1) -- target(host2,db2,user2,pwd2)

  1. Different context files having the same parameter names: 具有相同参数名称的不同上下文文件:

tFileInputDelimited_1 (1st context file) -- tContextLoad_1 | OnSubjobOk | Source(host,db,user,pwd) -- temp_file | OnSubjobOk | tFileInputDelimited_2 (2nd context file) -- tContextLoad_2 | OnSubjobOk | temp_file -- target(host,db,user,pwd)

I'm sure you'll agree with me that the 1st solution is simpler, and more efficient. 我相信您会同意我的观点,即第一种解决方案更简单,更有效。

Your context files could be like this : key=value 您的上下文文件可能是这样的:key = value

host=myHost
db=myDB
user=myUser

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM