Excellent question.

Unfortunately, you're not going to find any universal/pushbutton tool to
migrate data from an SQL db to Riak.

Fortunately, writing that migration tool that is specific to your
application is fairly straightforward. All of the variations out there boil
down to:
1) Export your data from one or more SQL tables into one or more CSV files,
XML files or JSON files.

2) Write a script in your preferred language (Python/Ruby/Java/etc) to read
each piece of data in the files, create an object that's appropriate to
store in Riak (a JSON blob, an XML snippet, a serialized binary string,
whatever), and:

3) Issue one or more write requests to Riak, storing that object. (I say
one or more write requests because, depending on your models/relationships,
you may need to update several riak objects with a key from a newly
inserted object).

The reason this can't really be done with automated tools at the moment is
-- migrating from a traditional relational database data model to a
Riak-appropriate model takes some rethinking and re-architecting. In many
cases, it will make sense to de-normalize data from many different tables
into one JSON object, for easy one-read retrieval. In other cases, you will
have to model RDBMS-style relational joins with Secondary Index queries,
search queries, link walking or Map/Reduce jobs.

So, my advice to you is to take it in several steps:
* Familiarize yourself with one of the Riak client libraries (see
http://docs.basho.com/riak/1.2.0/references/Client-Libraries/ and
http://docs.basho.com/riak/1.2.0/references/Community-Developed-Libraries-and-Projects/).
 Write a simple test program where you can write a JSON blob or an XML
blob or an integer to a Riak cluster.

* Think about how you want to change your data model, in migrating from SQL
to Riak. For example, "I'm migrating a simple web app session storage
table, with a SessionID and a big json blob SessionPayload. In Riak, I'll
store them in a 'sessions' bucket, using SessionID as a key, and the json
blob as the object value".  Or "I'm migrating user accounts and email
preference data. I'll de-normalize the Account and EmailPreference table
into one XML object, and store that in a 'users' bucket, keyed by userId".
Some reading that will help with this step:
http://basho.com/blog/technical/2010/03/19/schema-design-in-riak---introduction/
http://docs.basho.com/riak/latest/cookbooks/use-cases/

* Write your migration tool. Iterate over your existing SQL data, query one
or more relevant rows (or read them from an exported table dump), compose
your Riak object (json, xml, serialized object string, binary blob like an
image or an mp3, whatever), and write that object to the appropriate Riak
bucket.

Does that make sense?

Dmitri



On Thu, Nov 1, 2012 at 1:40 PM, Kevin Burton <[email protected]>wrote:

> I would like some scripts or programming tools that I could use to
> transfer existing data held in Microsoft SQL Server databases into Riak. Do
> such tools exist?****
>
> _______________________________________________
> riak-users mailing list
> [email protected]
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>
>
_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to