Mysql Zero Downtime Deployment

Source: Internet
Author: User

Why we cannot perform a ALTER TABLE directly to update schema?

How MySQL performs ALTER TABLE:

    1. Lock the table

    2. Make a copy of the table

    3. Modify the copy (the "New Table")

    4. Copy all the rows into the new table

    5. Swap the old and new table

    6. Unlock the table

The key issue here was that lock time would be quite long for large table, whick blocks online transaction.


Percona ' s Solution:

    • Pt-online-schema-change Tool:

      How Pt-online-schema-change performs ALTER TABLE?

    1. Make a copy of the table

    2. Modify the copy (the "New Table")

    3. Copy all the rows into the new table (does in small chunks, insert: Select)

    4. ADD triggers to keep track of changes

    5. Swap the old and new table

Pros:
Remove the Lock/unlock steps, no longer blocking
Replication-awareness
Load awareness-Chunk size is auto adjusted

Cons:
About 4th slower than ALTER TABLE directly

Limitation:
Cannot handle foreign key perfectly

Xtrabackup



This article from "Shadowisper" blog, declined reprint!

Mysql Zero Downtime Deployment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.