Open Source RDBMS - Seamless, Scalable, Stable and Free

English | Login |Register

author
message
[레벨:0]idan

Post subject: how to setup sharding

registered: 05/13/2012

아이피: *.64.199.155

views: 4

I read the document but I can't still figure out how to use sharding. Can you please spread some more info about it, a step by step guide, or what happens when I want to add another shard, any sharding configuration strategies, etc.

Quote
[레벨:8]CUBRID

# Post subject:Re: how to setup sharding

profile

registered: 03/28/2010

아이피: *.91.139.67

Hi idam, I will give you the information about Sharding soon.

Quote
[레벨:8]CUBRID

# Post subject:Re: how to setup sharding

profile

registered: 03/28/2010

아이피: *.91.139.67

Quote

I read the document but I can't still figure out how to use sharding. Can you please spread some more info about it, a step by step guide, or what happens when I want to add another shard, any sharding configuration strategies, etc.


For a really quick getting started tutorial you can check out "Database Sharding the Right Way: Easy, Reliable, and Open source" presentation we have delivered at HighLoad++ 2012 Conference a few weeks ago. Particularly slides from 23 to 40. All you have to do to get started is:

  1. Prepare shards:
    1. Create independent databases (shards) on each host server. The architecture of host servers must be the same as the SHARD Broker's, i.e. if Broker is 64 bit, the host servers should also be 64-bit.
      1. Database names can be different.
    2. Create a database user in each shard.
      1. on all shards.
    3. Username and password should be identical on all shards.
    4. Then start each shard with cubrid server start shard_name.
  2. Now choose which host will be the main where SHARD Broker will be run.
    1. If you already have 2 shard servers, you can either create 3rd CUBRID Server which will have only SHARD Broker running with no shard/database, or you can run SHARD Broker on one of those 2 shard servers.
    2. Whatever you choose, you will find shard.conf configuration file under $CUBRID/conf directory. There are a few parameters you will want to change like:
      1. SHARD_DB_NAME: the database name which will be used in your applications. It will serve as a wrapper which will provide a single database view to client applications.
      2. SHARD_DB_USER and SHARD_DB_PASSWORD should be the one that you've already set above. This username and password should be identical on all shards so that CUBRID SHARD Broker can access all your shards with the same credentials.
      3. The rest parameters can be left untouched. They will work out of the box. By default, modulo 256 is the default sharding strategy which is defined with SHARD_KEY_MODULAR parameter. Details about the rest configurations parameters can be found in the manual.
    3. The second configuration file is shard_key.txt where you indicate the shard key ranges for modulo 256. In the given manual page you can see the sample template.
    4. The final third configuration file is shard_connection.txt file. There you indicate where each database is hosted, i.e. shard ID, shard name, and host name.
  3. Once you configure everything, you are ready to start CUBRID SHARD with cubrid shard start command.

That's all! Here is a sample Java program which demonstrates how to connect and retrieve data from CUBRID SHARD. In your application you can indicate these Shard SQL Hints to get specific sharding behavior.

If you are interested in feeding your own library to generate the sharding strategy, refer to Setting User-Defined Hash Function.

Once you get started you may want to monitor the system. In that case, see various CUBRID SHARD Utilities. You may also be interested in CUBRID SHARD Logs.

Also check out this forum thread where one of the user has asked a similar question regarding CUBRID Sharding. More information can be found at CUBRID SHARD Documentation.

Regarding "what happens when I want to add another shard", at this moment CUBRID 9.0 doesn't provide data auto rebalancing. You can add or remove shards by changing your shard_key.txt and shard_connection.txt files. However, you need to rebalance the data manually, if necessary. We plan to add data auto-rebalancing feature to CUBRID SHARD in the next version.

So, for now, you should determine what will your data size be and decide how many shard you want to start. You can also start with one or two shards and create multiple (2+) shard key ranges in shard_key.txt file. Some of the ranges will resolve to the first shard id, while the rest will resolve to the second shard id. Later when these two shards become too large and you want to add one more shard, you can simply change and set some shard key ranges to this newly added shard id. Thus you can add or remove shards.

If you have any specific question, feel free to ask. I will be glad to help you!

Quote




You are either using a very old browser or a browser that is not supported.
In order to browse cubrid.org you need to have one of the following browsers:



Internet Explorer: Mozilla Firefox: Google Chrome: