
{"id":957,"date":"2010-09-20T12:43:15","date_gmt":"2010-09-20T11:43:15","guid":{"rendered":"http:\/\/dasini.net\/blog\/?p=957"},"modified":"2010-09-20T12:43:15","modified_gmt":"2010-09-20T11:43:15","slug":"online-schema-change-for-mysql","status":"publish","type":"post","link":"https:\/\/dasini.net\/blog\/2010\/09\/20\/online-schema-change-for-mysql\/","title":{"rendered":"Online Schema Change for MySQL"},"content":{"rendered":"<p>It is great to be able to build small utilities on top of an excellent RDBMS. Thank you MySQL.<\/p>\n<p>This is a small but complex utility to perform online schema change for MySQL. We call it OSC and the\u00a0<a title=\"http:\/\/bazaar.launchpad.net\/~mysqlatfacebook\/mysqlatfacebook\/tools\/annotate\/head:\/osc\/OnlineSchemaChange.php\" rel=\"nofollow\" href=\"http:\/\/bazaar.launchpad.net\/~mysqlatfacebook\/mysqlatfacebook\/tools\/annotate\/head:\/osc\/OnlineSchemaChange.php\" target=\"_blank\">source is here<\/a>.<\/p>\n<p>Some ALTER TABLE statements take too long form the perspective of some MySQL users. The\u00a0<a title=\"http:\/\/dev.mysql.com\/doc\/innodb-plugin\/1.0\/en\/innodb-create-index.html\" rel=\"nofollow\" href=\"http:\/\/dev.mysql.com\/doc\/innodb-plugin\/1.0\/en\/innodb-create-index.html\" target=\"_blank\">fast index create<\/a> feature for the InnoDB plugin in MySQL 5.1 makes this less of an issue but this can still take minutes to hours for a large table and for some MySQL deployments that is too long.<\/p>\n<p>A workaround is to perform the change on a slave first and then promote the slave to be the new master. But this requires a slave located near the master. MySQL 5.0 added support for triggers and some replication systems have been built using triggers to capture row changes. Why not use triggers for this? The\u00a0<a title=\"openarkkit\" rel=\"nofollow\" href=\"http:\/\/code.google.com\/p\/openarkkit\/\" target=\"_blank\">openarkkit<\/a> toolkit did just that with oak-online-alter-table. We have published our version of an online schema change utility (OnlineSchemaChange.php aka OSC).<\/p>\n<p>The remainder of this document is copied from the internal documents that were written for this project. Note that this project was done by Vamsi and he did an amazing job with it. In addition to writing the tool, writing the docs and doing a lot of testing he also found and fixed or avoided a few bugs in MySQL to make sure OSC would be reliable.<\/p>\n<p>&#8230;<\/p>\n<p><a title=\"Online Schema Change for MySQL by Mark Callaghan\" href=\"http:\/\/www.facebook.com\/notes\/mysql-at-facebook\/online-schema-change-for-mysql\/430801045932\" target=\"_blank\">http:\/\/www.facebook.com\/notes\/mysql-at-facebook\/online-schema-change-for-mysql\/430801045932<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>It is great to be able to build small utilities on top of an excellent RDBMS. Thank you MySQL.<\/p>\n<p>This is a small but complex utility to perform online schema change for MySQL. We call it OSC and the source is here.<\/p>\n<p>Some ALTER TABLE statements take too long form the perspective of some MySQL users. The fast index create feature for the InnoDB plugin in MySQL 5.1 makes this less of an issue but this can still take minutes to hours for a large table and for some MySQL deployments that is too long.<\/p>\n<p>A workaround is to perform the change on a slave first and then promote the slave to be the new master. But this requires a slave located near the master. MySQL 5.0 added support for triggers and some replication systems have been built using triggers to capture row changes. Why not use triggers for this? The openarkkit toolkit did just that with oak-online-alter-table. We have published our version of an online schema change utility (OnlineSchemaChange.php aka OSC).<\/p>\n<p>The remainder of this document is copied from the internal documents that were written for this project. Note that this project was done by Vamsi and he did an amazing job with it. In addition to writing the tool, writing the docs and doing a lot of testing he also found and fixed or avoided a few bugs in MySQL to make sure OSC would be reliable.<\/p>\n<p>&#8230;<\/p>\n<p> ??????????????http:\/\/www.facebook.com\/notes\/mysql-at-facebook\/online-schema-change-for-mysql\/430801045932<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":""},"categories":[8],"tags":[162,163],"class_list":["post-957","post","type-post","status-publish","format-standard","hentry","category-mysql","tag-mark-callaghan","tag-online-schema-change"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9LfWW-fr","jetpack-related-posts":[{"id":4121,"url":"https:\/\/dasini.net\/blog\/2020\/12\/10\/setting-up-replication-with-various-methods\/","url_meta":{"origin":957,"position":0},"title":"Setting up Replication with various methods for MySQL 8","author":"Anastasia Papachristopoulou","date":"10 d\u00e9cembre 2020","format":false,"excerpt":"In the world of the Databases, one of the most important value that we are all trying to achieve is High Availability. Not to loose our valuable data or in case one server fails to always have another to step in and take control. So, it is critical to have\u2026","rel":"","context":"Dans &quot;Backup \/ Restore&quot;","block_context":{"text":"Backup \/ Restore","link":"https:\/\/dasini.net\/blog\/category\/backup-restore\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2549,"url":"https:\/\/dasini.net\/blog\/2018\/08\/21\/tutoriel-deployer-mysql-5-7-innodb-cluster\/","url_meta":{"origin":957,"position":1},"title":"Tutoriel \u2013 D\u00e9ployer MySQL 5.7 InnoDB Cluster","author":"Olivier DASINI","date":"21 ao\u00fbt 2018","format":false,"excerpt":"L'un des principaux besoins de mes clients est la\u00a0Haute Disponibilit\u00e9 avec MySQL. On va voir, dans cet article, comment d\u00e9ployer et g\u00e9rer un cluster MySQL 5.7 \"from scratch\"\u00a0, sous la forme d'un tutoriel, gr\u00e2ce \u00e0 la solution HA tout en un : MySQL 5.7 InnoDB Cluster.","rel":"","context":"Dans &quot;Group Replication&quot;","block_context":{"text":"Group Replication","link":"https:\/\/dasini.net\/blog\/category\/group-replication\/"},"img":{"alt_text":"MySQL InnoDB Cluster PoC Architecture","src":"https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/MySQL_InnoDB_Cluster_Production_post2.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/MySQL_InnoDB_Cluster_Production_post2.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/MySQL_InnoDB_Cluster_Production_post2.png?resize=525%2C300 1.5x"},"classes":[]},{"id":1450,"url":"https:\/\/dasini.net\/blog\/2013\/08\/26\/mysql-techday-le-10-octobre-2013\/","url_meta":{"origin":957,"position":2},"title":"MySQL TechDay, le 10 Octobre 2013","author":"Olivier DASINI","date":"26 ao\u00fbt 2013","format":false,"excerpt":"Le 10 octobre 2013, Oracle et Le MySQL User Group Francophone (lemug.fr) vous invitent au MySQL Tech Day \u00e0 Paris. Une journ\u00e9e technique bien pleine o\u00f9 les diff\u00e9rentes \u00e9quipes MySQL chez Oracle vont nous pr\u00e9senter les am\u00e9liorations pr\u00e9sentes et futures des versions 5.6 et 5.7 de MySQL. Au programme: Overview:\u2026","rel":"","context":"Dans &quot;Conf\u00e9rence&quot;","block_context":{"text":"Conf\u00e9rence","link":"https:\/\/dasini.net\/blog\/category\/conference\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3299,"url":"https:\/\/dasini.net\/blog\/2019\/09\/03\/tutoriel-deployer-mysql-8-0-innodb-cluster-09-2019\/","url_meta":{"origin":957,"position":3},"title":"Tutoriel \u2013 D\u00e9ployer MySQL 8.0 InnoDB Cluster (09-2019)","author":"Olivier DASINI","date":"3 septembre 2019","format":false,"excerpt":"Cela fait maintenant 1 an que j\u2019ai \u00e9cris la v1 de ce tuto sur MySQL InnoDB Cluster et durant ce laps de temps, mes coll\u00e8gues d\u2019Oracle MySQL ont travaill\u00e9 tr\u00e8s dur pour enrichir la solution et d\u00e9velopper pas mal de nouvelles fonctionnalit\u00e9s. En fait que du bon ? \u2013 gr\u00e2ce\u2026","rel":"","context":"Dans &quot;Group Replication&quot;","block_context":{"text":"Group Replication","link":"https:\/\/dasini.net\/blog\/category\/group-replication\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1915,"url":"https:\/\/dasini.net\/blog\/2017\/05\/11\/tutoriel-deployer-mysql-innodb-cluster\/","url_meta":{"origin":957,"position":4},"title":"Tutoriel &#8211; D\u00e9ployer MySQL innoDB Cluster","author":"Olivier DASINI","date":"11 mai 2017","format":false,"excerpt":"Dans les \u00e9pisodes pr\u00e9c\u00e9dents on a vu comment d\u00e9ployer \"manuellement\" MySQL Group Replication, comprendre et tester MySQL InnoDB Cluster ainsi que comment g\u00e9rer ais\u00e9ment un cluster Group Replication d\u00e9ja d\u00e9ploy\u00e9 avec MySQL Shell. Aujourd'hui, dans la s\u00e9rie Haute Disponibilit\u00e9 avec MySQL on va voir comment d\u00e9ployer et g\u00e9rer un cluster\u2026","rel":"","context":"Dans &quot;Group Replication&quot;","block_context":{"text":"Group Replication","link":"https:\/\/dasini.net\/blog\/category\/group-replication\/"},"img":{"alt_text":"Warning","src":"https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/warning.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1832,"url":"https:\/\/dasini.net\/blog\/2017\/03\/13\/tester-mysql-innodb-cluster\/","url_meta":{"origin":957,"position":5},"title":"Tester MySQL InnoDB Cluster","author":"Olivier DASINI","date":"13 mars 2017","format":false,"excerpt":"MySQL InnoDB Cluster est la (future) solution out-of-the-box HA de MySQL (\u00e0 ne pas confondre avec MySQL NDB Cluster). Ce produit est compos\u00e9 de 3 \u00e9l\u00e9ments : MySQL Group Replication Plugin de r\u00e9plication multi-ma\u00eetre, avec r\u00e9solution de conflits et basculement (failover) automatique. MySQL Router Middleware l\u00e9ger et performant qui fournit\u2026","rel":"","context":"Dans &quot;Group Replication&quot;","block_context":{"text":"Group Replication","link":"https:\/\/dasini.net\/blog\/category\/group-replication\/"},"img":{"alt_text":"MySQL InnoDB Cluster Architecture","src":"https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/MySQL_InnoDB_Cluster_Architecture.png?resize=350%2C200","width":350,"height":200},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/posts\/957","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/comments?post=957"}],"version-history":[{"count":5,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/posts\/957\/revisions"}],"predecessor-version":[{"id":962,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/posts\/957\/revisions\/962"}],"wp:attachment":[{"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/media?parent=957"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/categories?post=957"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/tags?post=957"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}