Online Schema Change for MySQL
Project description
OnlineSchemaChange is a tool for making schema changes for MySQL tables in a non-blocking way
Examples
OSC must be run on the same host as MySQL server.
copy mode
Say we have an existing table named my_table under database test:
CREATE TABLE `my_table` (
`id` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
Now if we want to run ALTER TABLE ``my_table add column data varchar(10);`` against it. Instead of feed the ALTER TABLE statement to OSC, we just need to put a CREATE TABLE statement representing the desired schema into a file /tmp/foo.sql like below:
CREATE TABLE `my_table` (
`id` int(11) NOT NULL,
`data` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
Then run the following command:
osc_cli copy --ddl-file-list=foo.sql --socket=/tmp/mysql.socket --database=test
cleanup mode
To cleanup the table left behind by last run of OSC
osc_cli cleanup --socket=/tmp/mysql.socket --database=test
To terminate a currently running OSC process on certain MySQL Instance:
osc_cli cleanup
direct mode
This mode is reserved for utilizing MySQL’s native online ddl for schema change, and help DBA manage all the schema related operation into this one tool. For now, if you plan to use OSC for all your schema management, this mode is here for you to create a empty new table. Following command will create an empty table into database test
osc_cli direct --ddl-file-list=foo.sql --socket=/tmp/mysql.socket --database=test
Requirements
OnlineSchemaChange requires
System packages
For Python2
sudo apt-get install python-dev libmysqlclient-dev # Debian / Ubuntu
sudo yum install python-devel mysql-devel # Red Hat / CentOS
For Python3
sudo apt-get install python3-dev # debian / Ubuntu
sudo yum install python3-devel # Red Hat / CentOS
Python requirements * python >= 2.7 * python module: six, pyparsing, MySQLdb
Installing OnlineSchemaChange
Run following command to install dependency
python setup.py install --install-scripts=/usr/local/bin
If you have multiple python version available in your environment, or you don’t want mess up with system’s default python, you can use pyenv and virtualenv
How OnlineSchemaChange works
Check wiki page for more detail, and some advanced usage.
How to contribute
Check this wiki page if you want to contribute to this project.
License
OnlineSchemaChange is BSD-licensed. We also provide an additional patent grant.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for online-schema-change-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06cecfd32552fc74a9b61c60eeddd1f4cde896b611968b65d1d51a0d4ae54738 |
|
MD5 | ebcd6fa6b8863f9a589c6e3ac0fcc423 |
|
BLAKE2b-256 | 1224b1422055e024ec1eb7ab7a308e34128f2a5c57d2788b4cf36706659232a1 |
Hashes for online_schema_change-0.0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a91349796b6b177ecd9f3b918e5812d741f99209c7c6dec8777a99577b9b56c7 |
|
MD5 | ced7c01f0bc0dcee5b435a64f5012c6a |
|
BLAKE2b-256 | f54e1b251f4fa88a3678d55f5e7375059dec3b7f3f53db3ca177537918d0a22c |