简体   繁体   English

SQL 服务器到 MySQL 数据传输

[英]SQL Server to MySQL data transfer

I am trying to transfer bulk data on a constant and continuous based from a SQL Server database to a MYSQL database.我正在尝试将基于常量和连续的批量数据从 SQL 服务器数据库传输到 MYSQL 数据库。 I wanted to use SQL Server's SSMS's replication but this apparently is only for SQL Server to Oracle or IBM DB2 connection. I wanted to use SQL Server's SSMS's replication but this apparently is only for SQL Server to Oracle or IBM DB2 connection. Currently we are using SSIS to transform data and push it to a temporary location at the MYSQL database where it is copied over.目前,我们正在使用 SSIS 来转换数据并将其推送到 MYSQL 数据库中的临时位置,然后将其复制过来。 I would like the fastest way to transfer data and am complication several methods.我想要最快的数据传输方式,并且使几种方法复杂化。

I have a new way I plan on transforming the data which I am sure will solve most time issues but I want to make sure we do not run into time problems in the future.我有一种新的方法来转换数据,我相信这将解决大多数时间问题,但我想确保我们将来不会遇到时间问题。 I have set up a linked server that uses a MYSQL ODBC driver to talk between SQL Server and MYSQL.我已经设置了一个链接服务器,它使用 MYSQL ODBC 驱动程序在 SQL 服务器和 Z14498B83DD16AF67BZF77 之间进行通信。 This seems VERY slow.这似乎很慢。 I have some code that also uses Microsoft's ODBC driver but is used so little that I cannot gauge the performance.我有一些代码也使用 Microsoft 的 ODBC 驱动程序,但使用得很少,以至于我无法衡量性能。 Does anyone know of lightening fast ways to communicate between these two databases?有谁知道这两个数据库之间的快速通信方式? I have been researching MYSQL's data providers that seem to communicate with a OleDB layer.我一直在研究似乎与 OleDB 层通信的 MYSQL 数据提供程序。 Im not too sure what to believe and which way to steer towards, any ideas?我不太确定该相信什么以及该转向哪种方式,有什么想法吗?

The best way I have found to transfer SQL data (if you have the space) is a SQL dump in one language and then to use a converting software tool (or perl script, both are prevalent) to convert the SQL dump from MSSQL to MySQL. The best way I have found to transfer SQL data (if you have the space) is a SQL dump in one language and then to use a converting software tool (or perl script, both are prevalent) to convert the SQL dump from MSSQL to MySQL . See my answer to this question about what converter you may be interested in:).请参阅我对这个问题的回答,了解您可能对什么转换器感兴趣:)。

I used the jdbc-odbc bridge in Java to do just this in the past, but performance through ODBC is not great.过去我使用 Java 中的 jdbc-odbc 桥接器来做到这一点,但是通过 ODBC 的性能不是很好。 I would suggest looking at something like http://jtds.sourceforge.net/ which is a pure Java driver that you can drop into a simple Groovy script like the following:我建议查看类似http://jtds.sourceforge.net/ 之类的东西,这是一个纯 Java 驱动程序,您可以将其放入一个简单的 Groovy 脚本中,如下所示:

import groovy.sql.Sql
sql = Sql.newInstance( 'jdbc:jtds:sqlserver://serverName/dbName-CLASS;domain=domainName',     
'username', 'password', 'net.sourceforge.jtds.jdbc.Driver' )
sql.eachRow( 'select * from tableName' ) { 
  println "$it.id -- ${it.firstName} --" 
  // probably write to mysql connection here or write to file, compress, transfer, load
}

The following performance numbers give you a feel for how it might perform: http://jtds.sourceforge.net/benchTest.html以下性能数据让您了解它的性能: http://jtds.sourceforge.net/benchTest.html

You may find some performance advantages to dumping data to a mysql dumpfile format and using mysql loaddata instead of writing row by row.您可能会发现将数据转储到 mysql 转储文件格式并使用 mysql 加载数据而不是逐行写入的一些性能优势。 MySQL has some significant performance improvements for large data sets if you load infile's and doing things like atomic table swaps.如果您加载 infile 并执行诸如原子表交换之类的操作,MySQL 对大型数据集有一些显着的性能改进。

We use something like this to quickly load large datafiles into mysql from one system to another eg This is the fastest mechanism to load data into mysql.我们使用类似的方法将大型数据文件从一个系统快速加载到 mysql 到另一个系统,例如这是将数据加载到 mysql 的最快机制。 But real time row by row might be a simple loop to do in groovy + some table to keep track of what row had been moved.但实时逐行可能是在 groovy + 一些表中执行的简单循环,以跟踪已移动的行。

mysql> select * from table into outfile 'tablename.dat';  

shell> myisamchk --keys-used=0 -rq '/data/mysql/schema_name/tablename'

mysql> load data infile 'tablename.dat' into table tablename;

shell> myisamchk -rq /data/mysql/schema_name/tablename

mysql> flush tables;
mysql> exit;

shell> rm tablename.dat

We've used the ado.net driver for mysql in ssis with quite a bit of success.我们已经在 ssis 中使用了 mysql 的 ado.net 驱动程序并取得了相当大的成功。 Basically, install the driver on the machine with integration services installed, restart bids, and it should show up in the driver list when you create an ado.net connection manager.基本上,在安装了集成服务的机器上安装驱动程序,重新启动投标,当您创建 ado.net 连接管理器时,它应该显示在驱动程序列表中。

As for replication, what exactly are you trying to accomplish?至于复制,您到底想完成什么?

If you are monitoring changes, treat it as a type 1 slowly changing dimension (data warehouse terminology, but same principal applies).如果您正在监视更改,请将其视为类型 1 缓慢变化的维度(数据仓库术语,但适用相同的原则)。 Insert new records, update changed records.插入新记录,更新更改的记录。

If you are only interested in new records and have no plans to update previously loaded data, try an incremental load strategy.如果您只对新记录感兴趣并且没有计划更新以前加载的数据,请尝试增量加载策略。 Insert records where source.id > max(destination.id).在 source.id > max(destination.id) 处插入记录。

After you've tested the package, schedule a job in the sql server agent to run the package every x minutes.测试 package 后,在 sql 服务器代理中安排一个作业,以每 x 分钟运行一次 package。

Cou can also try the following.凑也可以试试下面的。 http://kofler.info/english/mssql2mysql/ http://kofler.info/english/mssql2mysql/

I tried this a longer time before and it worked for me.我之前尝试了更长的时间,它对我有用。 But I woudn't recommend it to you.但我不会向你推荐它。 What is the real problem, what you try to do?真正的问题是什么,你想做什么? Don´t you get a MSSQL DB Connection, for example from Linux?您是否没有获得 MSSQL DB 连接,例如来自 Linux?

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

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