SQL Server 到 MySQL 数据传输

发布于 2024-11-29 14:09:16 字数 455 浏览 2 评论 0原文

我正在尝试将批量数据从 SQL Server 数据库恒定且连续地传输到 MYSQL 数据库。我想使用 SQL Server 的 SSMS 复制,但这显然仅适用于 SQL Server 到 Oracle 或 IBM DB2 的连接。目前,我们正在使用 SSIS 来转换数据并将其推送到 MYSQL 数据库中的临时位置并进行复制。我想要最快的数据传输方法,并且使多种方法变得复杂。

我计划采用一种新方法来转换数据,我确信这将解决大多数时间问题,但我想确保我们将来不会遇到时间问题。我已经设置了一个链接服务器,它使用 MYSQL ODBC 驱动程序在 SQL Server 和 MYSQL 之间进行通信。这看起来很慢。我有一些代码也使用 Microsoft 的 ODBC 驱动程序,但使用得很少,以至于我无法衡量性能。有谁知道这两个数据库之间的快速通信方式?我一直在研究 MYSQL 的数据提供程序,它们似乎与 OleDB 层进行通信。我不太确定该相信什么以及该走哪条路,有什么想法吗?

I am trying to transfer bulk data on a constant and continuous based from a SQL Server database to a MYSQL database. 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. 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. 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. 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. Im not too sure what to believe and which way to steer towards, any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

女中豪杰 2024-12-06 14:09:16

过去我使用 Java 中的 jdbc-odbc 桥来完成此操作,但通过 ODBC 的性能不是很好。我建议查看类似 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
}

以下性能数字让您了解它的执行情况:
http://jtds.sourceforge.net/benchTest.html

您可能会发现一些性能优势将数据转储为 mysql dumpfile 格式并使用 mysql loaddata 而不是逐行写入。如果您加载 infile 并执行诸如原子表交换之类的操作,MySQL 对于大型数据集会有一些显着的性能改进。

我们使用类似的方法将大型数据文件从一个系统快速加载到 mysql 到另一个系统,例如,这是将数据加载到 mysql 的最快机制。但实时逐行可能是在 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

I used the jdbc-odbc bridge in Java to do just this in the past, but performance through ODBC is not great. 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:

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

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 has some significant performance improvements for large data sets if you load infile's and doing things like atomic table swaps.

We use something like this to quickly load large datafiles into mysql from one system to another e.g. This is the fastest mechanism to load data into 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.

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
抱着落日 2024-12-06 14:09:16

我发现传输 SQL 数据(如果有空间)的最佳方法是以一种语言进行 SQL 转储,然后使用转换软件工具(或 perl 脚本,两者都很流行)将 SQL 转储从 MSSQL 转换为 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 :) .

给不了的爱 2024-12-06 14:09:16

我们在 ssis 中使用了 ado.net mysql 驱动程序,并取得了相当大的成功。基本上,在安装了集成服务的计算机上安装驱动程序,重新启动 bids,当您创建 ado.net 连接管理器时,它应该显示在驱动程序列表中。

至于复制,您到底想实现什么目标?

如果您正在监视更改,请将其视为类型 1 缓慢变化的维度(数据仓库术语,但适用相同的原理)。插入新记录,更新更改的记录。

如果您只对新记录感兴趣并且不打算更新以前加载的数据,请尝试增量加载策略。在 source.id > 处插入记录最大(目的地.id)。

测试包后,在 sql server 代理中安排一个作业,每 x 分钟运行一次包。

We've used the ado.net driver for mysql in ssis with quite a bit of success. 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.

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). 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).

After you've tested the package, schedule a job in the sql server agent to run the package every x minutes.

盛夏已如深秋| 2024-12-06 14:09:16

还可以尝试以下方法。
http://kofler.info/english/mssql2mysql/

我之前尝试过很长时间并且它有效为我。但我不会推荐给你。
真正的问题是什么,你想做什么?
您是否没有获得 MSSQL DB 连接(例如来自 Linux)?

Cou can also try the following.
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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文