The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. February 12, 2012, 07:43:25 AM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: MS-SQL > MySQL replication  (Read 1882 times)
SEOidiot
Journeyman
***
Offline Offline

Posts: 84


^ Hes a pint sized Ned Flanders


View Profile
« on: January 02, 2010, 01:08:51 PM »

Hello all!!

Hope you guys are all well and have had an excellent holiday break...

I have been working as usual (urghghghghghhhh)

I have a big project on this month and there is one section of it that has me completely stumped, any help would be amazing please

Customer has all their back office systems run off a MS-SQL database (customers, accounts, stock etc)
However....
They want their website to run off MySQL and use lots of the data from the MS-SQL

Whats the best way to move data between the two easily and reliably?

The MS-SQL database is on a box where we may not be able to add ODBC drivers... (Sigh)
The data will be written one way from the MS-SQL to MySQL as we are writing an API of sorts to write orders back into the MS-SQL database etc

Thanks Chaps

Paul
Logged

<mango>Yummmmmmmmmmmmm</mango>
<pie>ewwwwwwwwwww</pie>
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 9792



View Profile
« Reply #1 on: January 03, 2010, 12:45:50 PM »

Firstly, welcome back mate. Nice to see you about Smiley

The ODBC drivers would need to be on a box accessing the MSSQL base, not that box itself. I did this for a client a bit ago, where we have a legacy MSSQL base and application but we wanted to integrate with another company that uses MySQL, and then export data out in an XML format to yet another service.

I installed another little box with RedHat on it and the ODBC drivers, as well as MySQL and and rather lush PHP installation. First step was getting the box to talk to the MSSQL box which is not difficult, but was intricate, as a I recall. Once there, accessing it via PHP was quite easy.

If there's no automated solution out there, then if I had this task I'd probably create a table that held that last-imported record from the original database. In other words, the contacts table I have gotten everything from id 37114 on 12/23/09 ... so that I'd know easily what to scan for and retrieve. Of course, you could just look at the max(id) of the new table and see if you have everything from the old...

This is obviously trickier if you want to do an actual sync of tables that are thrashing, rather than just adding. Please tell me you don't need to write your own journaling system for the old database. But if you do, I believe I'd use triggers to place a record of the change into another table (a new one on the original database) and then periodically grab those changes, interpret them and apply them in the new. That's going to be fun.

Nuts might know of a way to get journaled records from a MSSQL db into a usable format... that'd save you a boatload of work.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
SEOidiot
Journeyman
***
Offline Offline

Posts: 84


^ Hes a pint sized Ned Flanders


View Profile
« Reply #2 on: January 03, 2010, 03:07:32 PM »

Hey mate

Thanks for that - no journal required thankfully

tbh i think ill outsource the setup of the box this ia all going on and the task of setting up the data copy
the thing i need to work out is.. as the MS-SQL is a database running a full erp system we cant just say if there are records that dont exist copy them over as there will be row updates going on all the time

im tempted to write views that only pull the smallest dataset possible
then at a set time overnight (its a UK / EU only site really) delete and replace the dataset on the MySQL db

concern is the big tables
item file = 75,000 records
sales analysis = 200,000 records

sigh

thanks

paul
Logged

<mango>Yummmmmmmmmmmmm</mango>
<pie>ewwwwwwwwwww</pie>
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 9792



View Profile
« Reply #3 on: January 04, 2010, 08:28:32 AM »

If the machines are next to each other on a gig network, then that's really not too bad of a transfer. Prolly take 10 minutes or so.

I think that's the right tact - daily replacement when you're unbusy.

Hope all's well with the kiddies and the holidays were as good to them as they were to mom and dad Wink
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
SEOidiot
Journeyman
***
Offline Offline

Posts: 84


^ Hes a pint sized Ned Flanders


View Profile
« Reply #4 on: January 04, 2010, 12:25:46 PM »

hey matey - holidays were good for laura but sandra and i had a trying time tbh....

the boxes are on different continents Smiley sigh
Logged

<mango>Yummmmmmmmmmmmm</mango>
<pie>ewwwwwwwwwww</pie>
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 9792



View Profile
« Reply #5 on: January 04, 2010, 01:11:56 PM »

Ooog. Less pretty.

Can you get a box next to it in any case? Or could you write a script that exports the data and then tar.gz's it so that you could pull it nightly efficiently?

Paging Nutballs: what's the programmatic export options for an MSSQL db?

(Sorry the holidays were trying ... ours were as well. A screwy year for most it would seem...  Undecided )
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
nutballs
Administrator
Lifer
*****
Online Online

Posts: 5604


Back in my day we had 9 planets


View Profile
« Reply #6 on: January 04, 2010, 03:47:27 PM »

hmm been out of mssql for a while now, but.

you can export to almost anything. Though the drivers for anything special would need to be installed. So in this case, mysql-odbc. But Idiot said he can't. So, im not really sure.
out of the box though, is SQL, access, excel and flat file. I think thats it.

replication however is a whole other issue.


Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 9792



View Profile
« Reply #7 on: January 04, 2010, 03:49:07 PM »

Well, but he could therefore go SQL (pure text) to a tar.gz which would be much smaller, draw that across the net and the pump it back up into his MySQL box... that'd be reasonably light on processor and bandwidth I'm thinking...
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!