Tuesday, May 27, 2014

MySQL Fabric: The --update_only option because one size does not fit all

MySQL Fabric is a distributed framework that has high availability and sharding as targets. It organizes the servers in groups which use the standard MySQL Replication to providing fault-tolerance. Shards are assigned to different groups thus allowing applications to distribute both reads and writes and exploit resilience to failures as well.

Information on groups, servers and shards are stored in a MySQL Instance called state store or backing store. This instance is a repository for all this information and the engine used might be any supported by MySQL, although a transactional engine must be picked to truly provide fault-tolerance. Note though that we have been testing MySQL Fabric with Innodb and currently this the only official engine supported.

Built upon the repository there are several functions that, besides being used to retrieve information from and update the repository, are responsible for the execution of some administrative tasks. For example, adding a server into a group has two steps: creating an entry into the state store and making the server point to the current primary, if there is any.

Promoting a new primary requires to:

  • choose among a set of candidates which one will become the new primary when a candidate is not promptly specified;
  • stop accepting writes on the current primary;
  • synchronize the primary with the secondaries and reconfigure replication;
  • update the repository with the new information.

However, there might be users who want to use their own scripts to execute these administrative tasks and want to update MySQL Fabric to reflect the changes made to the servers. For these users, we have introduce the --update_only option into some commands so that they might continue using their own scripts and take advantage of MySQL Fabric at the same time as well.

Executing commands

MySQL Fabric's command might be invoked as a command-line script as follow:

mysqlfabric group add my_group localhost:13001 --update_only

Or using a MySQL Fabric-aware connector (e.g. Connector Python) through a direct call to a XML-RPC function as follows:

ERROR, SUCCESS = range(1, 3)

conn = mysql.connector.connect(
    fabric={"host" : "localhost",
            "username": "admin", "password" : "adminpass"
    user="webuser", password="webpass"
proxy = conn._fabric.get_instance().proxy
status = proxy.group.add("my_group", "localhost:13001", 5, True)
if status[1][-1]["success"] == ERROR:
    raise Error("Something bad happened %s." % (str(status), ))

Note that the "mysqlfabric" script uses XML-RPC to call the appropriate functions and both examples try to add "localhost:13001" server into the "my_group" group. In the latter case, besides setting the group's name, server's address and the update only arguments, we also need to set the timeout argument as the XML-RPC does not support named/keyword arguments. For a complete list of commands available check the documentation or execute the following command:

mysqlfabric help commands

Currently the command-line solution has two issues:

We are working on fixing these as soon as possible.

Adding a server into a group

Users must set up replication on a new MySQL Server and inform MySQL Fabric about its existence as follows:

mysqlfabric group add group-name server-id --update_only

To avoid cluttering the post with unnecessary details, we are going to write examples using the command-line script. Note though that there are issues with this solution as aforementioned. The group-name and server-id must be replaced by the group which the server belongs to and its real UUID or address, respectively. The remove command does have the option --update_only as it only removes a reference to the server from the repository and does not try to access the server or reconfigure replication.

Promoting a new primary

If users want to promote a new primary, they must first demote the current one as follows:

mysqlfabric group demote group-name --update_only

After that, they should forbid any attempt to write to the old primary, make sure that the primary and secondaries are synchronized, elect a new primary and then reconfigure replication accordingly. How these is done depends on the particularities of their environments and scripts. Finally to inform the connectors that there is a new primary, they should execute the following:

mysqlfabric group promote group-name --slave_id=server-id --update_only


Seth Williams said...

Hey Alfranio, these My SQL codes were really useful. Thanks for the update.We have our own My SQL tutorials as well that may benefit your readers at https://www.linkedin.com/company/firebox-training

Jr. Williams said...

difference between sql server and mysql?
Unlimited MySQL Databases

Jr. Williams said...

Thanks for the update you have nicely covered this topic. keep it up
best domain name registrar

Haritha said...

Nice to see your blog post.. I really enjoyed by reading your blog post. Thanks a lot for sharing this with us.. Keep on sharing like this informative post.
Android Training in Chennai Velachery

deeksha said...

This is a great post! As a new blogger myself, I search for new ways to attract new people to read my blog.I know it takes time and dedication, and the most important thing is to do what you love no matter what!

salesforce Training instiute in Chennai

Maani kamili said...

I read a weblog, I hope that it doesn't sadden me as much as this one. I’m talking about, I know it was my selection to read, but I actually thought you'd have something interesting to say. Great work admin..

Web development company in Chennai

Abiya Carol said...

I just see the post i am so happy the post of information's.So I have really enjoyed and reading your blogs for these posts.Any way I’ll be subscribing to your feed and I hope you post again soon.

aws training in chennai

Vignesh PV said...

Learning new technolgy would help oneself at hard part of their career. And staying updated is the only way to survive in current position. Your content tells the same. Thanks for sharing this information in here. Keep blogging like this. android Training in Chennai

Nandhini said...

I just see the post i am so happy the post of information's.So I have really enjoyed and reading your blogs for these posts.Any way I’ll be subscribing to your feed and I hope you post again soon.
House Cleaning Service in Chennai

tessa tessa said...

Hi I read your post very carefully and I think you are right that a well written post should be at least a 100 words and should capture the essence of your blog, book or article.

Digital Marketing Company in India

Aasha said...

This blog explains the details about changing the ways of doing that business. That is understand well and doing some different process. Provides he best output of others. Thanks for this blog.
Digital Marketing Company in Chennai
SEO Company in Chennai

amala amala said...

Thank you for sharing such a nice and interesting blog with us. I have seen that all will say the same thing repeatedly. But in your blog, I had a chance to get some useful and unique information. I would like to suggest your blog in my dude circle.
Jobs in Chennai
Jobs in Bangalore
Jobs in Delhi
Jobs in Hyderabad
Jobs in Kolkata
Jobs in Mumbai
Jobs in Noida
Jobs in Pune

Shalini said...

Great post!I am actually getting ready to across this information,i am very happy to this commands.Also great blog here with all of the valuable information you have.Well done,its a great knowledge.

Digital Marketing Company in Chennai

buyket said...

تتعدد الشركات التي تقدم خدمات ىالتنظيف لاكن لا يمكن ان تكون كلها في نفس مستوي الجوده فان كنت من الباحثين عن جودة الشركه قبل اي شئ اخر فانصحة بزيارة احدي تلك الصفحات
شركة تنظيف مساجد بالرياض
شركة تنظيف خزانات بالخرج
شركة تنظيف بالخرج
والتي تقدم افضل خدمات التنظيف بالمنزل باعلي مستوي من الكفائه

Sindhuja Ravi said...

Thank you for taking the time to provide us with your valuable information. We strive to provide our candidates with excellent care and we take your comments to heart.As always, we appreciate your confidence and trust in us
Digital Marketing Company in India

Shalini said...

I just see the post i am so happy the post of information's.So I have really enjoyed and reading your blogs for these posts.Any way I’ll be subscribing to your feed and I hope you post again soon.

Digital Marketing Company in Chennai

john stany said...

This article is very much helpful and i hope this will be an useful information for the needed one. Keep on updating these kinds of informative things...

Android App Development Company

john stany said...

Nice it seems to be good post... It will get readers engagement on the article since readers engagement plays an vital role in every blog.i am expecting more updated posts from your hands.
iOS App Development Company
iOS App Development Company

louis philip said...

Pretty article! I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing..
Fitness SMS
Fitness Text
Salon SMS
Salon Text
Investor Relation SMS
Investor Relation Text
Mobile Marketing Services
mobile marketing companies

louis philip said...

These ways are very simple and very much useful, as a beginner level these helped me a lot thanks fore sharing these kinds of useful and knowledgeable information.
Texting API
Text message marketing
Digital Mobile Marketing
Mobile Marketing Services
Mobile marketing companies
Fitness SMS

Rohit Mishra said...

Here in I web technology we provide the best SEO and web development service in Faridabad. You can join us for the best and affordable Seo Service.

Seo Service Faridabad | Web Development Service Faridabad

Ansha Khan said...

Ansha Khan is one of the hot and sizzling escorts in Bangalore offers exotic escorts services in Bangalore. Hire VIP escorts in Bangalore with hire profile background.
Bangalore escorts | Escorts in Bangalore

sreenu usha said...

There will always be winners and losers, and I think many of these probably do have quite a diverse range of material, with a common thread running through them. This is how I think of Oracle Code, a diverse collection of subjects loosely woven together by an Oracle thread.
Oracle SQL/PLSQL course

pujitha ps said...

All the latest updates from the Python Automationminds team. Python Automationminds lets you program in Python, in your browser. No need to install any software, just start coding straight away. There's a fully-functional web-based console and a programmer's text-editor
Phyton training in Chennai

Rohit Mishra said...

Get the best escorts service in Bangalore from one of the top escort agency in Bangalore. We provide the Hot Bangalore Escorts, Independent Bangalore Escorts, VIP Bangalore Escorts, High Class Female escorts.
Bangalore Escorts Service