[root@mysql5 ~]# pt-online-schema-change --alter="drop column address" h=127.0.0.1,P=,u=root,p=1qaz2wsx,D=test,t=ddl_test --print --dry-run
Operation, tries, wait:
copy_rows, , 0.25
create_triggers, ,
drop_triggers, ,
swap_tables, ,
update_foreign_keys, ,
Starting a dry run. `test`.`ddl_test` will not be altered. Specify --execute instead of --dry-run to alter the table.
步骤1,创建空表,其命名规则是_+原表名+_new
Creating new table...
CREATE TABLE `test`.`_ddl_test_new` (
`id` int() NOT NULL AUTO_INCREMENT,
`name` varchar() NOT NULL DEFAULT '',
`age` int() DEFAULT '',
`address` varchar() NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT= DEFAULT CHARSET=utf8
Created new table test._ddl_test_new OK.
#步骤2,根据语句更新新表结构
Altering new table...
ALTER TABLE `test`.`_ddl_test_new` drop column address
Altered `test`.`_ddl_test_new` OK.
#步骤3,在原表上创建触发器,以便后续原表上的操作同步到新表
Not creating triggers because this is a dry run.
CREATE TRIGGER `pt_osc_test_ddl_test_del` AFTER DELETE ON `test`.`ddl_test` FOR EACH ROW DELETE IGNORE FROM `test`.`_ddl_test_new` WHERE `test`.`_ddl_test_new`.`id` <=> OLD.`id`
CREATE TRIGGER `pt_osc_test_ddl_test_upd` AFTER UPDATE ON `test`.`ddl_test` FOR EACH ROW REPLACE INTO `test`.`_ddl_test_new` (`id`, `name`, `age`) VALUES (NEW.`id`, NEW.`name`, NEW.`age`)
CREATE TRIGGER `pt_osc_test_ddl_test_ins` AFTER INSERT ON `test`.`ddl_test` FOR EACH ROW REPLACE INTO `test`.`_ddl_test_new` (`id`, `name`, `age`) VALUES (NEW.`id`, NEW.`name`, NEW.`age`)
Not copying rows because this is a dry run.
步骤4,拷贝原表数据到新表,数据量大时会根据主键进行分段chunk插入
INSERT LOW_PRIORITY IGNORE INTO `test`.`_ddl_test_new` (`id`, `name`, `age`) SELECT `id`, `name`, `age` FROM `test`.`ddl_test` FORCE INDEX(`PRIMARY`) WHERE ((`id` >= ?)) AND ((`id` <= ?)) LOCK IN SHARE MODE /*pt-online-schema-change 26819 copy nibble*/
SELECT /*!40001 SQL_NO_CACHE */ `id` FROM `test`.`ddl_test` FORCE INDEX(`PRIMARY`) WHERE ((`id` >= ?)) ORDER BY `id` LIMIT ?, /*next chunk boundary*/ #最后清除临时生成的表、触发器。默认情况下会删除原表
Not swapping tables because this is a dry run.
Not dropping old table because this is a dry run.
Not dropping triggers because this is a dry run.
DROP TRIGGER IF EXISTS `test`.`pt_osc_test_ddl_test_del`;
DROP TRIGGER IF EXISTS `test`.`pt_osc_test_ddl_test_upd`;
DROP TRIGGER IF EXISTS `test`.`pt_osc_test_ddl_test_ins`;
--29T15:: Dropping new table...
DROP TABLE IF EXISTS `test`.`_ddl_test_new`;
--29T15:: Dropped new table OK.
Dry run complete. `test`.`ddl_test` was not altered.
[root@mysql5 ~]# 因为这不是真正执行,真正执行有个过程
拷贝完成后,移走原表,用新表代替(RENAME TABLE)。其通过一个RENAME TABLE同时处理两个表,实现原子操作。
--29T16:: Copied rows OK.
--29T16:: Swapping tables...
RENAME TABLE `test`.`ddl_test` TO `test`.`_ddl_test_old`, `test`.`_ddl_test_new` TO `test`.`ddl_test`
--29T16:: Swapped original and new tables OK.
##如果原表有触发器
Oracle可以在一个触发器触发insert,delete,update事件,
MySQL 触发器 只支持一个事件,然后一个表允许三个事件触发器(insert,update,deleted),在5.7之前,一个表只能一类型的触发器,不能存在两个(update )事件触发器,假设已经有了一个update的事件触发器,那么使用pt-online-schema-change加三个事件触发期的时候会加不上,导致工具无法使用。
那么下面来看看,整个实验过程,
##首先,执行这个工具,前面不能有长事务(如:大查询,大范围更新插入语句),下面就来看看又大事务会咋样
(mysql5.-)root@localhost [(none)]> show processlist;
+----+------+-----------------+------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------------+------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
| | root | localhost | test | Query | | optimizing | select count(*) from ddl_test |
| | root | localhost | NULL | Query | | starting | show processlist |
| | root | 127.0.0.1: | test | Query | | Waiting for table metadata lock | CREATE TRIGGER `pt_osc_test_ddl_test_del` AFTER DELETE ON `test`.`ddl_test` FOR EACH ROW DELETE IGNO |
| | root | 127.0.0.1: | test | Sleep | | | NULL |
+----+------+-----------------+------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
rows in set (0.00 sec) (mysql5.-)root@localhost [(none)]> (mysql5.-)root@localhost [(none)]> show processlist;
+----+------+-----------------+------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------------+------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
| | root | localhost | test | Query | | optimizing | select count(*) from ddl_test |
| | root | localhost | NULL | Query | | starting | show processlist |
| | root | 127.0.0.1: | test | Query | | Waiting for table metadata lock | CREATE TRIGGER `pt_osc_test_ddl_test_del` AFTER DELETE ON `test`.`ddl_test` FOR EACH ROW DELETE IGNO |
| | root | 127.0.0.1: | test | Sleep | | | NULL |
+----+------+-----------------+------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
rows in set (0.00 sec) (mysql5.-)root@localhost [(none)]> show processlist;
+----+------+-----------------+------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------------+------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
| | root | localhost | test | Query | | optimizing | select count(*) from ddl_test |
| | root | localhost | NULL | Query | | starting | show processlist |
| | root | 127.0.0.1: | test | Query | | Waiting for table metadata lock | CREATE TRIGGER `pt_osc_test_ddl_test_del` AFTER DELETE ON `test`.`ddl_test` FOR EACH ROW DELETE IGNO |
| | root | 127.0.0.1: | test | Sleep | | | NULL |
+----+------+-----------------+------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
rows in set (0.00 sec) (mysql5.-)root@localhost [(none)]> show processlist;
+----+------+-----------------+------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------------+------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
| | root | localhost | test | Query | | optimizing | select count(*) from ddl_test |
| | root | localhost | NULL | Query | | starting | show processlist |
| | root | 127.0.0.1: | test | Query | | Waiting for table metadata lock | CREATE TRIGGER `pt_osc_test_ddl_test_del` AFTER DELETE ON `test`.`ddl_test` FOR EACH ROW DELETE IGNO |
| | root | 127.0.0.1: | test | Sleep | | | NULL |
+----+------+-----------------+------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
rows in set (0.00 sec) (mysql5.-)root@localhost [(none)]> show processlist;
+----+------+-----------------+------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------------+------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
| | root | localhost | test | Query | | optimizing | select count(*) from ddl_test |
| | root | localhost | NULL | Query | | starting | show processlist |
| | root | 127.0.0.1: | test | Query | | Waiting for table metadata lock | CREATE TRIGGER `pt_osc_test_ddl_test_del` AFTER DELETE ON `test`.`ddl_test` FOR EACH ROW DELETE IGNO |
| | root | 127.0.0.1: | test | Sleep | | | NULL |
+----+------+-----------------+------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
rows in set (0.00 sec) (mysql5.-)root@localhost [(none)]> show processlist;
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| | root | localhost | test | Sleep | | | NULL |
| | root | localhost | NULL | Query | | starting | show processlist |
| | root | 127.0.0.1: | test | Query | | Sending data | INSERT LOW_PRIORITY IGNORE INTO `test`.`_ddl_test_new` (`id`, `name`, `age`) SELECT `id`, `name`, `a |
| | root | 127.0.0.1: | test | Sleep | | | NULL |
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
rows in set (0.00 sec) (mysql5.-)root@localhost [(none)]> show processlist;
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| | root | localhost | test | Sleep | | | NULL |
| | root | localhost | NULL | Query | | starting | show processlist |
| | root | 127.0.0.1: | test | Query | | Sending data | INSERT LOW_PRIORITY IGNORE INTO `test`.`_ddl_test_new` (`id`, `name`, `age`) SELECT `id`, `name`, `a |
| | root | 127.0.0.1: | test | Sleep | | | NULL |
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
rows in set (0.00 sec) (mysql5.-)root@localhost [(none)]> show processlist;
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| | root | localhost | test | Sleep | | | NULL |
| | root | localhost | NULL | Query | | starting | show processlist |
| | root | 127.0.0.1: | test | Query | | Sending data | INSERT LOW_PRIORITY IGNORE INTO `test`.`_ddl_test_new` (`id`, `name`, `age`) SELECT `id`, `name`, `a |
| | root | 127.0.0.1: | test | Sleep | | | NULL |
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
rows in set (0.00 sec) 哈哈,有前面大查询一样要等待MDL锁,MDL锁这个坑很大,所以有在线DDL也不能随心所欲的执行 测试一下删除字段 (mysql5.-)root@localhost [(none)]>
[root@mysql5 ~]# pt-online-schema-change --alter="drop column address" h=127.0.0.1,P=,u=root,p=1qaz2wsx,D=test,t=ddl_test --charset=utf8 --print --execute
No slaves found. See --recursion-method if host mysql5. has slaves.
Not checking slave lag because no slaves were found and --check-slave-lag was not specified.
Operation, tries, wait:
copy_rows, , 0.25
create_triggers, ,
drop_triggers, ,
swap_tables, ,
update_foreign_keys, ,
Altering `test`.`ddl_test`...
Creating new table...
CREATE TABLE `test`.`_ddl_test_new` (
`id` int() NOT NULL AUTO_INCREMENT,
`name` varchar() NOT NULL DEFAULT '',
`age` int() DEFAULT '',
`address` varchar() NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT= DEFAULT CHARSET=utf8
Created new table test._ddl_test_new OK.
Altering new table...
ALTER TABLE `test`.`_ddl_test_new` drop column address
Altered `test`.`_ddl_test_new` OK.
--29T15:: Creating triggers...
CREATE TRIGGER `pt_osc_test_ddl_test_del` AFTER DELETE ON `test`.`ddl_test` FOR EACH ROW DELETE IGNORE FROM `test`.`_ddl_test_new` WHERE `test`.`_ddl_test_new`.`id` <=> OLD.`id`
CREATE TRIGGER `pt_osc_test_ddl_test_upd` AFTER UPDATE ON `test`.`ddl_test` FOR EACH ROW REPLACE INTO `test`.`_ddl_test_new` (`id`, `name`, `age`) VALUES (NEW.`id`, NEW.`name`, NEW.`age`)
CREATE TRIGGER `pt_osc_test_ddl_test_ins` AFTER INSERT ON `test`.`ddl_test` FOR EACH ROW REPLACE INTO `test`.`_ddl_test_new` (`id`, `name`, `age`) VALUES (NEW.`id`, NEW.`name`, NEW.`age`)
--29T15:: Created triggers OK.
--29T15:: Copying approximately rows...
INSERT LOW_PRIORITY IGNORE INTO `test`.`_ddl_test_new` (`id`, `name`, `age`) SELECT `id`, `name`, `age` FROM `test`.`ddl_test` FORCE INDEX(`PRIMARY`) WHERE ((`id` >= ?)) AND ((`id` <= ?)) LOCK IN SHARE MODE /*pt-online-schema-change 26826 copy nibble*/
SELECT /*!40001 SQL_NO_CACHE */ `id` FROM `test`.`ddl_test` FORCE INDEX(`PRIMARY`) WHERE ((`id` >= ?)) ORDER BY `id` LIMIT ?, /*next chunk boundary*/
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
--29T16:: Copied rows OK.
--29T16:: Swapping tables...
RENAME TABLE `test`.`ddl_test` TO `test`.`_ddl_test_old`, `test`.`_ddl_test_new` TO `test`.`ddl_test`
--29T16:: Swapped original and new tables OK.
--29T16:: Dropping old table...
DROP TABLE IF EXISTS `test`.`_ddl_test_old`
--29T16:: Dropped old table `test`.`_ddl_test_old` OK.
--29T16:: Dropping triggers...
DROP TRIGGER IF EXISTS `test`.`pt_osc_test_ddl_test_del`;
DROP TRIGGER IF EXISTS `test`.`pt_osc_test_ddl_test_upd`;
DROP TRIGGER IF EXISTS `test`.`pt_osc_test_ddl_test_ins`;
--29T16:: Dropped triggers OK.
Successfully altered `test`.`ddl_test`.
[root@mysql5 ~]# (mysql5.-)root@localhost [test]> show processlist;
+----+------+-----------------+------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------------+------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
| | root | localhost | test | Query | | optimizing | select count(*) from ddl_test |
| | root | localhost | test | Query | | starting | show processlist |
| | root | 127.0.0.1: | test | Query | | Waiting for table metadata lock | CREATE TRIGGER `pt_osc_test_ddl_test_del` AFTER DELETE ON `test`.`ddl_test` FOR EACH ROW DELETE IGNO |
| | root | 127.0.0.1: | test | Sleep | | | NULL |
+----+------+-----------------+------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
rows in set (0.00 sec) (mysql5.-)root@localhost [test]> show processlist;
+----+------+-----------------+------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------------+------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
| | root | localhost | test | Query | | optimizing | select count(*) from ddl_test |
| | root | localhost | test | Query | | starting | show processlist |
| | root | 127.0.0.1: | test | Query | | Waiting for table metadata lock | CREATE TRIGGER `pt_osc_test_ddl_test_del` AFTER DELETE ON `test`.`ddl_test` FOR EACH ROW DELETE IGNO |
| | root | 127.0.0.1: | test | Sleep | | | NULL |
+----+------+-----------------+------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
rows in set (0.00 sec) (mysql5.-)root@localhost [test]> show processlist;
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| | root | localhost | test | Sleep | | | NULL |
| | root | localhost | test | Query | | starting | show processlist |
| | root | 127.0.0.1: | test | Query | | Sending data | INSERT LOW_PRIORITY IGNORE INTO `test`.`_ddl_test_new` (`id`, `name`, `age`) SELECT `id`, `name`, `a |
| | root | 127.0.0.1: | test | Sleep | | | NULL |
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
rows in set (0.00 sec) (mysql5.-)root@localhost [test]> show processlist;
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| | root | localhost | test | Sleep | | | NULL |
| | root | localhost | test | Query | | starting | show processlist |
| | root | 127.0.0.1: | test | Query | | Sending data | INSERT LOW_PRIORITY IGNORE INTO `test`.`_ddl_test_new` (`id`, `name`, `age`) SELECT `id`, `name`, `a |
| | root | 127.0.0.1: | test | Sleep | | | NULL |
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
rows in set (0.00 sec) (mysql5.-)root@localhost [test]> show processlist;
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| | root | localhost | test | Sleep | | | NULL |
| | root | localhost | test | Query | | starting | show processlist |
| | root | 127.0.0.1: | test | Query | | Sending data | INSERT LOW_PRIORITY IGNORE INTO `test`.`_ddl_test_new` (`id`, `name`, `age`) SELECT `id`, `name`, `a |
| | root | 127.0.0.1: | test | Sleep | | | NULL |
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
rows in set (0.00 sec) (mysql5.-)root@localhost [test]> delete from ddl_test where id=;
Query OK, row affected (0.05 sec) (mysql5.-)root@localhost [test]> show processlist;
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| | root | localhost | test | Sleep | | | NULL |
| | root | localhost | test | Query | | starting | show processlist |
| | root | 127.0.0.1: | test | Query | | Sending data | INSERT LOW_PRIORITY IGNORE INTO `test`.`_ddl_test_new` (`id`, `name`, `age`) SELECT `id`, `name`, `a |
| | root | 127.0.0.1: | test | Sleep | | | NULL |
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
rows in set (0.00 sec)

###执行一下DML语句
(mysql5.-)root@localhost [test]> update ddl_test set name='12eswq' where id=;
Query OK, rows affected (0.00 sec)
Rows matched: Changed: Warnings: (mysql5.-)root@localhost [test]> update ddl_test set name='12eswq' where id=;
Query OK, row affected (0.00 sec)
Rows matched: Changed: Warnings: (mysql5.-)root@localhost [test]> show processlist;
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| | root | localhost | test | Sleep | | | NULL |
| | root | localhost | test | Query | | starting | show processlist |
| | root | 127.0.0.1: | test | Query | | Sending data | SELECT /*!40001 SQL_NO_CACHE */ `id` FROM `test`.`ddl_test` FORCE INDEX(`PRIMARY`) WHERE ((`id` >= ' |
| | root | 127.0.0.1: | test | Sleep | | | NULL |
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
rows in set (0.00 sec) (mysql5.-)root@localhost [test]> show processlist;
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| | root | localhost | test | Sleep | | | NULL |
| | root | localhost | test | Query | | starting | show processlist |
| | root | 127.0.0.1: | test | Query | | Sending data | INSERT LOW_PRIORITY IGNORE INTO `test`.`_ddl_test_new` (`id`, `name`, `age`) SELECT `id`, `name`, `a |
| | root | 127.0.0.1: | test | Sleep | | | NULL |
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
rows in set (0.00 sec) (mysql5.-)root@localhost [test]> ##增加字段测试
[root@mysql5 ~]# pt-online-schema-change --alter="add column address varchar(100) not null default ''" h=127.0.0.1,P=,u=root,p=1qaz2wsx,D=test,t=ddl_test --print --execute
No slaves found. See --recursion-method if host mysql5. has slaves.
Not checking slave lag because no slaves were found and --check-slave-lag was not specified.
Operation, tries, wait:
copy_rows, , 0.25
create_triggers, ,
drop_triggers, ,
swap_tables, ,
update_foreign_keys, ,
Altering `test`.`ddl_test`...
Creating new table...
CREATE TABLE `test`.`_ddl_test_new` (
`id` int() NOT NULL AUTO_INCREMENT,
`name` varchar() NOT NULL DEFAULT '',
`age` int() DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT= DEFAULT CHARSET=utf8
Created new table test._ddl_test_new OK.
Altering new table...
ALTER TABLE `test`.`_ddl_test_new` add column address varchar() not null default ''
Altered `test`.`_ddl_test_new` OK.
--29T16:: Creating triggers...
CREATE TRIGGER `pt_osc_test_ddl_test_del` AFTER DELETE ON `test`.`ddl_test` FOR EACH ROW DELETE IGNORE FROM `test`.`_ddl_test_new` WHERE `test`.`_ddl_test_new`.`id` <=> OLD.`id`
CREATE TRIGGER `pt_osc_test_ddl_test_upd` AFTER UPDATE ON `test`.`ddl_test` FOR EACH ROW REPLACE INTO `test`.`_ddl_test_new` (`id`, `name`, `age`) VALUES (NEW.`id`, NEW.`name`, NEW.`age`)
CREATE TRIGGER `pt_osc_test_ddl_test_ins` AFTER INSERT ON `test`.`ddl_test` FOR EACH ROW REPLACE INTO `test`.`_ddl_test_new` (`id`, `name`, `age`) VALUES (NEW.`id`, NEW.`name`, NEW.`age`)
--29T16:: Created triggers OK.
--29T16:: Copying approximately rows...
INSERT LOW_PRIORITY IGNORE INTO `test`.`_ddl_test_new` (`id`, `name`, `age`) SELECT `id`, `name`, `age` FROM `test`.`ddl_test` FORCE INDEX(`PRIMARY`) WHERE ((`id` >= ?)) AND ((`id` <= ?)) LOCK IN SHARE MODE /*pt-online-schema-change 26858 copy nibble*/
SELECT /*!40001 SQL_NO_CACHE */ `id` FROM `test`.`ddl_test` FORCE INDEX(`PRIMARY`) WHERE ((`id` >= ?)) ORDER BY `id` LIMIT ?, /*next chunk boundary*/
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
--29T16:: Copied rows OK.
--29T16:: Swapping tables...
RENAME TABLE `test`.`ddl_test` TO `test`.`_ddl_test_old`, `test`.`_ddl_test_new` TO `test`.`ddl_test`
--29T16:: Swapped original and new tables OK.
--29T16:: Dropping old table...
DROP TABLE IF EXISTS `test`.`_ddl_test_old`
--29T16:: Dropped old table `test`.`_ddl_test_old` OK.
--29T16:: Dropping triggers...
DROP TRIGGER IF EXISTS `test`.`pt_osc_test_ddl_test_del`;
DROP TRIGGER IF EXISTS `test`.`pt_osc_test_ddl_test_upd`;
DROP TRIGGER IF EXISTS `test`.`pt_osc_test_ddl_test_ins`;
--29T16:: Dropped triggers OK.
Successfully altered `test`.`ddl_test`.
[root@mysql5 ~]# (mysql5.-)root@localhost [test]> show processlist;
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| | root | localhost | test | Sleep | | | NULL |
| | root | localhost | test | Query | | starting | show processlist |
| | root | 127.0.0.1: | test | Query | | Sending data | SELECT /*!40001 SQL_NO_CACHE */ `id` FROM `test`.`ddl_test` FORCE INDEX(`PRIMARY`) WHERE ((`id` >= ' |
| | root | 127.0.0.1: | test | Sleep | | | NULL |
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
rows in set (0.00 sec) ##来个DML看看
(mysql5.-)root@localhost [test]> delete from ddl_test where id=;
Query OK, rows affected (0.03 sec) (mysql5.-)root@localhost [test]> delete from ddl_test where id=;
Query OK, rows affected (0.00 sec) (mysql5.-)root@localhost [test]> update ddl_test set name='adfadf' where id=;
Query OK, rows affected (0.00 sec)
Rows matched: Changed: Warnings: (mysql5.-)root@localhost [test]> show processlist;
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| | root | localhost | test | Sleep | | | NULL |
| | root | localhost | test | Query | | starting | show processlist |
| | root | 127.0.0.1: | test | Query | | Sending data | INSERT LOW_PRIORITY IGNORE INTO `test`.`_ddl_test_new` (`id`, `name`, `age`) SELECT `id`, `name`, `a |
| | root | 127.0.0.1: | test | Sleep | | | NULL |
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
rows in set (0.00 sec) (mysql5.-)root@localhost [test]> ###
[root@mysql5 ~]# pt-online-schema-change --alter="add column address varchar(100) not null default ''" h=127.0.0.1,P=,u=root,p=1qaz2wsx,D=test,t=ddl_test --print --execute
No slaves found. See --recursion-method if host mysql5. has slaves.
Not checking slave lag because no slaves were found and --check-slave-lag was not specified.
Operation, tries, wait:
copy_rows, , 0.25
create_triggers, ,
drop_triggers, ,
swap_tables, ,
update_foreign_keys, ,
Altering `test`.`ddl_test`...
Creating new table...
CREATE TABLE `test`.`_ddl_test_new` (
`id` int() NOT NULL AUTO_INCREMENT,
`name` varchar() NOT NULL DEFAULT '',
`age` int() DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT= DEFAULT CHARSET=utf8
Created new table test._ddl_test_new OK.
Altering new table...
ALTER TABLE `test`.`_ddl_test_new` add column address varchar() not null default ''
Altered `test`.`_ddl_test_new` OK.
--29T16:: Creating triggers...
CREATE TRIGGER `pt_osc_test_ddl_test_del` AFTER DELETE ON `test`.`ddl_test` FOR EACH ROW DELETE IGNORE FROM `test`.`_ddl_test_new` WHERE `test`.`_ddl_test_new`.`id` <=> OLD.`id`
CREATE TRIGGER `pt_osc_test_ddl_test_upd` AFTER UPDATE ON `test`.`ddl_test` FOR EACH ROW REPLACE INTO `test`.`_ddl_test_new` (`id`, `name`, `age`) VALUES (NEW.`id`, NEW.`name`, NEW.`age`)
CREATE TRIGGER `pt_osc_test_ddl_test_ins` AFTER INSERT ON `test`.`ddl_test` FOR EACH ROW REPLACE INTO `test`.`_ddl_test_new` (`id`, `name`, `age`) VALUES (NEW.`id`, NEW.`name`, NEW.`age`)
--29T16:: Created triggers OK.
--29T16:: Copying approximately rows...
INSERT LOW_PRIORITY IGNORE INTO `test`.`_ddl_test_new` (`id`, `name`, `age`) SELECT `id`, `name`, `age` FROM `test`.`ddl_test` FORCE INDEX(`PRIMARY`) WHERE ((`id` >= ?)) AND ((`id` <= ?)) LOCK IN SHARE MODE /*pt-online-schema-change 26858 copy nibble*/
SELECT /*!40001 SQL_NO_CACHE */ `id` FROM `test`.`ddl_test` FORCE INDEX(`PRIMARY`) WHERE ((`id` >= ?)) ORDER BY `id` LIMIT ?, /*next chunk boundary*/
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
--29T16:: Copied rows OK.
--29T16:: Swapping tables...
RENAME TABLE `test`.`ddl_test` TO `test`.`_ddl_test_old`, `test`.`_ddl_test_new` TO `test`.`ddl_test`
--29T16:: Swapped original and new tables OK.
--29T16:: Dropping old table...
DROP TABLE IF EXISTS `test`.`_ddl_test_old`
--29T16:: Dropped old table `test`.`_ddl_test_old` OK.
--29T16:: Dropping triggers...
DROP TRIGGER IF EXISTS `test`.`pt_osc_test_ddl_test_del`;
DROP TRIGGER IF EXISTS `test`.`pt_osc_test_ddl_test_upd`;
DROP TRIGGER IF EXISTS `test`.`pt_osc_test_ddl_test_ins`;
--29T16:: Dropped triggers OK.
Successfully altered `test`.`ddl_test`.
[root@mysql5 ~]# pt-online-schema-change --alter="modify column address varchar(255) not null default ''" h=127.0.0.1,P=,u=root,p=1qaz2wsx,D=test,t=ddl_test --print --execute
No slaves found. See --recursion-method if host mysql5. has slaves.
Not checking slave lag because no slaves were found and --check-slave-lag was not specified.
Operation, tries, wait:
copy_rows, , 0.25
create_triggers, ,
drop_triggers, ,
swap_tables, ,
update_foreign_keys, ,
Altering `test`.`ddl_test`...
Creating new table...
CREATE TABLE `test`.`_ddl_test_new` (
`id` int() NOT NULL AUTO_INCREMENT,
`name` varchar() NOT NULL DEFAULT '',
`age` int() DEFAULT '',
`address` varchar() NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT= DEFAULT CHARSET=utf8
Created new table test._ddl_test_new OK.
Altering new table...
ALTER TABLE `test`.`_ddl_test_new` modify column address varchar() not null default ''
Altered `test`.`_ddl_test_new` OK.
--29T16:: Creating triggers...
CREATE TRIGGER `pt_osc_test_ddl_test_del` AFTER DELETE ON `test`.`ddl_test` FOR EACH ROW DELETE IGNORE FROM `test`.`_ddl_test_new` WHERE `test`.`_ddl_test_new`.`id` <=> OLD.`id`
CREATE TRIGGER `pt_osc_test_ddl_test_upd` AFTER UPDATE ON `test`.`ddl_test` FOR EACH ROW REPLACE INTO `test`.`_ddl_test_new` (`id`, `name`, `age`, `address`) VALUES (NEW.`id`, NEW.`name`, NEW.`age`, NEW.`address`)
CREATE TRIGGER `pt_osc_test_ddl_test_ins` AFTER INSERT ON `test`.`ddl_test` FOR EACH ROW REPLACE INTO `test`.`_ddl_test_new` (`id`, `name`, `age`, `address`) VALUES (NEW.`id`, NEW.`name`, NEW.`age`, NEW.`address`)
--29T16:: Created triggers OK.
--29T16:: Copying approximately rows...
INSERT LOW_PRIORITY IGNORE INTO `test`.`_ddl_test_new` (`id`, `name`, `age`, `address`) SELECT `id`, `name`, `age`, `address` FROM `test`.`ddl_test` FORCE INDEX(`PRIMARY`) WHERE ((`id` >= ?)) AND ((`id` <= ?)) LOCK IN SHARE MODE /*pt-online-schema-change 26897 copy nibble*/
SELECT /*!40001 SQL_NO_CACHE */ `id` FROM `test`.`ddl_test` FORCE INDEX(`PRIMARY`) WHERE ((`id` >= ?)) ORDER BY `id` LIMIT ?, /*next chunk boundary*/
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
Copying `test`.`ddl_test`: % : remain
--29T16:: Copied rows OK.
--29T16:: Swapping tables...
RENAME TABLE `test`.`ddl_test` TO `test`.`_ddl_test_old`, `test`.`_ddl_test_new` TO `test`.`ddl_test`
--29T16:: Swapped original and new tables OK.
--29T16:: Dropping old table...
DROP TABLE IF EXISTS `test`.`_ddl_test_old`
--29T16:: Dropped old table `test`.`_ddl_test_old` OK.
--29T16:: Dropping triggers...
DROP TRIGGER IF EXISTS `test`.`pt_osc_test_ddl_test_del`;
DROP TRIGGER IF EXISTS `test`.`pt_osc_test_ddl_test_upd`;
DROP TRIGGER IF EXISTS `test`.`pt_osc_test_ddl_test_ins`;
--29T16:: Dropped triggers OK.
Successfully altered `test`.`ddl_test`.
[root@mysql5 ~]# (mysql5.-)root@localhost [test]> show processlist;
+----+------+-----------------+------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------------+------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
| | root | localhost | test | Query | | Waiting for table metadata lock | select count(*) from ddl_test |
| | root | localhost | test | Query | | starting | show processlist |
| | root | localhost | test | Query | | optimizing | select count(*) from ddl_test |
| | root | 127.0.0.1: | test | Query | | Waiting for table metadata lock | CREATE TRIGGER `pt_osc_test_ddl_test_del` AFTER DELETE ON `test`.`ddl_test` FOR EACH ROW DELETE IGNO |
| | root | 127.0.0.1: | test | Sleep | | | NULL |
+----+------+-----------------+------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
rows in set (0.00 sec) (mysql5.-)root@localhost [test]> show processlist;
+----+------+-----------------+------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------------+------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
| | root | localhost | test | Query | | optimizing | select count(*) from ddl_test |
| | root | localhost | test | Query | | starting | show processlist |
| | root | localhost | test | Sleep | | | NULL |
| | root | 127.0.0.1: | test | Query | | Waiting for table metadata lock | CREATE TRIGGER `pt_osc_test_ddl_test_upd` AFTER UPDATE ON `test`.`ddl_test` FOR EACH ROW REPLACE INT |
| | root | 127.0.0.1: | test | Sleep | | | NULL |
+----+------+-----------------+------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
rows in set (0.00 sec) (mysql5.-)root@localhost [test]>
(mysql5.-)root@localhost [test]> show processlist;
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| | root | localhost | test | Sleep | | | NULL |
| | root | localhost | test | Query | | starting | show processlist |
| | root | localhost | test | Sleep | | | NULL |
| | root | 127.0.0.1: | test | Query | | Sending data | INSERT LOW_PRIORITY IGNORE INTO `test`.`_ddl_test_new` (`id`, `name`, `age`, `address`) SELECT `id`, |
| | root | 127.0.0.1: | test | Sleep | | | NULL |
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
rows in set (0.00 sec) (mysql5.-)root@localhost [test]> update ddl_test set name='12eswq' where id=;
Query OK, rows affected (0.00 sec)
Rows matched: Changed: Warnings: (mysql5.-)root@localhost [test]> update ddl_test set name='12eswq' where id=;
Query OK, rows affected (0.00 sec)
Rows matched: Changed: Warnings: (mysql5.-)root@localhost [test]> update ddl_test set name='12eswq' where id=;
Query OK, row affected (0.24 sec)
Rows matched: Changed: Warnings: (mysql5.-)root@localhost [test]> show processlist;
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| | root | localhost | test | Sleep | | | NULL |
| | root | localhost | test | Query | | starting | show processlist |
| | root | localhost | test | Sleep | | | NULL |
| | root | 127.0.0.1: | test | Query | | Sending data | SELECT /*!40001 SQL_NO_CACHE */ `id` FROM `test`.`ddl_test` FORCE INDEX(`PRIMARY`) WHERE ((`id` >= ' |
| | root | 127.0.0.1: | test | Sleep | | | NULL |
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
rows in set (0.00 sec) (mysql5.-)root@localhost [test]> update ddl_test set name='12eswq' where id=;
Query OK, row affected (0.08 sec)
Rows matched: Changed: Warnings: (mysql5.-)root@localhost [test]> delete from ddl_test where id=;
Query OK, row affected (0.01 sec) (mysql5.-)root@localhost [test]> show processlist;
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| | root | localhost | test | Sleep | | | NULL |
| | root | localhost | test | Query | | starting | show processlist |
| | root | localhost | test | Sleep | | | NULL |
| | root | 127.0.0.1: | test | Query | | Sending data | SELECT /*!40001 SQL_NO_CACHE */ `id` FROM `test`.`ddl_test` FORCE INDEX(`PRIMARY`) WHERE ((`id` >= ' |
| | root | 127.0.0.1: | test | Sleep | | | NULL |
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
rows in set (0.00 sec)
(mysql5.-)root@localhost [test]> show processlist;
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| | root | localhost | test | Sleep | | | NULL |
| | root | localhost | test | Query | | starting | show processlist |
| | root | localhost | test | Sleep | | | NULL |
| | root | 127.0.0.1: | test | Query | | Sending data | INSERT LOW_PRIORITY IGNORE INTO `test`.`_ddl_test_new` (`id`, `name`, `age`, `address`) SELECT `id`, |
| | root | 127.0.0.1: | test | Sleep | | | NULL |
+----+------+-----------------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
rows in set (0.00 sec) (mysql5.-)root@localhost [test]>

注意事项 --critical-load type: Array; default: Threads_running=50 Examine SHOW GLOBAL STATUS after every chunk, and abort if the load is too high. The option accepts a comma-separated list of MySQL status variables and thresholds. An optional =MAX_VALUE (or :MAX_VALUE) can follow each variable. If not given, the tool determines a threshold by examining the current value at startup and doubling it. See --max-load for further details. These options work similarly, except that this option will abort the tool’s operation instead of pausing it,  and the default value is computed differently if you specify no threshold.  The reason for this option is as a safety check in case the triggers on the  original table add so much load to the server that it causes downtime.  There is probably no single value of Threads_running that is wrong for  every server, but a default of 50 seems likely to be unacceptably high  for most servers, indicating that the operation should be canceled immediately. 大致的意思如下: 每次chunk操作前后,会根据show global status统计指定的状态量的变化,默认是统计Thread_running。 目的是为了安全,防止原始表上的触发器引起负载过高。这也是为了防止在线DDL对线上的影响。 超过设置的阀值,就会终止操作,在线DDL就会中断。提示的异常如上报错信息。

还有一个--max-load 参数也要考虑 --max-load type: Array; default: Threads_running=25 Examine SHOW GLOBAL STATUS after every chunk, and pause if any status variables are higher than their thresholds. The option accepts a comma-separated list of MySQL status variables. An optional =MAX_VALUE (or :MAX_VALUE) can follow each variable. If not given, the tool determines a threshold by examining the current value and increasing it by 20%. For example, if you want the tool to pause when Threads_connected gets too high, you can specify “Threads_connected”,  and the tool will check the current value when it starts working and add 20% to that value. If the current value is 100,  then the tool will pause when Threads_connected exceeds 120, and resume working when it is below 120 again. If you want to  specify an explicit threshold, such as 110, you can use either “Threads_connected:110” or “Threads_connected=110”. The purpose of this option is to prevent the tool from adding too much load to the server. If the data-copy queries are intrusive, or if they cause lock waits, then other queries on the server will tend to block and queue. This will typically cause Threads_running to increase, and the tool can detect that by running SHOW GLOBAL STATUS immediately after each query finishes. If you specify a threshold for this variable, then you can instruct the tool to wait until queries are running normally again. This will not prevent queueing, however; it will only give the server a chance to recover from the queueing. If you notice queueing, it is best to decrease the chunk time. --max-load 选项定义一个阀值,在每次chunk操作后,查看show global status状态值是否高于指定的阀值。


注意这个参数不会像--critical-load终止操作,而只是暂停操作。当status值低于阀值时,则继续往下操作。


最好加上--max-load="Threads_running=100" --critical-load="Threads_running=200"。

--chunk-size       type: size; default: 1000


Number of rows to select for each chunk copied.  Allowable suffixes            are k, M, G.

         This option can override the default behavior, which is to adjust 
chunk size dynamically to try to make chunks run in exactly           
"--chunk-time" seconds.  When this option isn’t set explicitly, its           
default value is used as a starting point, but after that, the tool           
ignores this option’s value.  If you set this option explicitly,           
however, then it disables the dynamic adjustment behavior and tries           
to make all chunks exactly the specified number of rows.
         There is a subtlety: if the chunk index is not unique, then it’s            
possible that chunks will be larger than desired. For example, if a           
table is chunked by an index that contains 10,000 of a given value,           
there is no way to write a WHERE clause that matches only 1,000 of           
the values, and that chunk will be at least 10,000 rows large.           
Such a chunk will probably be skipped because of
  "--chunk-size-limit".

结论:

有大查询一样要等待MDL锁,跟官方DDL比,修改列这个情况不锁表,可以DML,因为是按chunk来拷贝数据可以比较平稳的运行,IO比较均衡,就是有个表复制的情况,也就是全表select,会冲刷innodb_buffer_poo,热数据给冲刷掉,IO有压力,也不建议在繁忙的线上使用。

pt-online-schema-change的更多相关文章

  1. schema change + ogg 变更手册

    Check OGG  until no data queuing in replication process:testRO:a)login  test5 –l oggmgrb)oggc)#ggsci ...

  2. Online Schema Change for MySQL

    It is great to be able to build small utilities on top of an excellent RDBMS. Thank you MySQL. This ...

  3. AppBoxFuture(四). 随需而变-Online Schema Change

      需求变更是信息化过程中的家常便饭,而在变更过程中如何尽可能小的影响在线业务是比较头疼的事情.举个车联网监控的例子:原终端设备上传车辆的经纬度数据,新的终端设备支持同时上传速度数据,而旧的车辆状态表 ...

  4. Online, Asynchronous Schema Change in F1

    F1: A Distributed SQL Database That Scales   http://disksing.com/understanding-f1-schema-change   ma ...

  5. Online Schema Upgrade in MySQL Galera Cluster using TOI Method

    http://severalnines.com/blog/online-schema-upgrade-mysql-galera-cluster-using-toi-method     As a fo ...

  6. Schema 与数据类型优化

    这是<高性能 MySQL(第三版)>第四章<Schema 与数据类型优化>的读书笔记. 1. 选择优化的数据类型 数据类型的选择原则: 越小越好:选择满足需求的最小类型.注意, ...

  7. Awesome Go精选的Go框架,库和软件的精选清单.A curated list of awesome Go frameworks, libraries and software

    Awesome Go      financial support to Awesome Go A curated list of awesome Go frameworks, libraries a ...

  8. MyCat源码分析系列之——SQL下发

    更多MyCat源码分析,请戳MyCat源码分析系列 SQL下发 SQL下发指的是MyCat将解析并改造完成的SQL语句依次发送至相应的MySQL节点(datanode)的过程,该执行过程由NonBlo ...

  9. SQLite剖析之存储模型

    前言 SQLite作为嵌入式数据库,通常针对的应用的数据量相对于DBMS的数据量小.所以它的存储模型设计得非常简单,总的来说,SQLite把一个数据文件分成若干大小相等的页面,然后以B树的形式来组织这 ...

  10. erlang 分布式数据库Mnesia 实现及应用

    先推荐一篇:mnesia源码分析(yufeng)   - linear hash   ETS/DETS/mnesia 都使用了linear hash算法 http://en.wikipedia.org ...

随机推荐

  1. Aspose 数字和日期 设置

    Microsoft Excel一个非常强大的功能就是使客户可以设置数字和日期的显示格式,众所周知数字可以显示为不同的值格式,包含:小数.货币.百分数.分数.账面价值等,同样地Aspose.Cells也 ...

  2. Careercup - Facebook面试题 - 5110993575215104

    2014-04-30 16:12 题目链接 原题: The beauty of a number X is the number of 1s in the binary representation ...

  3. 工程移除CocoaPods依赖库

    http://zanderzhang.gitcafe.io/2015/09/26/工程移除CocoaPods依赖库/ 点这里--->CocoaPods安装和使用教程 当我们工程安装很多第三方开源 ...

  4. 邻结矩阵的建立和 BFS,DFS;;

    邻结矩阵比较简单,, 它的BFS,DFS, 两种遍历也比较简单,一个用队列, 一个用数组即可!!!但是邻接矩阵极其浪费空间,尤其是当它是一个稀疏矩阵的时候!!!-------------------- ...

  5. Codeforces Round #347 (Div. 2) C. International Olympiad 找规律

    题目链接: http://codeforces.com/contest/664/problem/C 题解: 这题最关键的规律在于一位的有1989-1998(9-8),两位的有1999-2098(99- ...

  6. IntelliJ IDEA 14 利用JRebel实现热部署 二

    前言:今天下午和一个qq群里讨论JRebel时,忽然得到“自动部署”的奥秘--真有听君一席话,胜读十年书的感悟. 这是此群友的热部署博客:http://blog.csdn.net/martinkey/ ...

  7. CSS3技巧:利用css3径向渐变做一张优惠券(转)

    在很多购物网站上都能看到优惠券,代金券,什么什么的券,但基本都是图片直接放上去,那么你有没有想过css来做一个呢,反正我是这样想过.那么你怎么做呢,切图做背景平铺边缘,嗯,有这样想过,如今css3技术 ...

  8. 【POJ】【3537】Crosses and Crosses

    博弈论 相当于放了x的位置,左右4格都不能再放x了,谁无处可放就输. n<=2000 直接枚举后继状态,暴力求SG函数即可. 例: 0000000->x..0000 / .x..000 / ...

  9. [unity3d]手游资源热更新策略探讨

    原地址:http://blog.csdn.net/dingxiaowei2013/article/details/20079683 我们学习了如何将资源进行打包.这次就可以用上场了,我们来探讨一下手游 ...

  10. Properties --- C++读配置信息的类(一)

    http://blog.csdn.net/billow_zhang/article/details/4304980 在开发实践中,积累了一些通用的C++ 类库,在此写出来给大家分享.也希望能给出更好的 ...