MySQL工具集openark-kit(官方网站http://code.openark.org/forge/openark-kit),内部包含很多小工具,在5.6之前用于实现网上ddl操作,
本文以CentOS为操作系统,且默认操作系统中已经安装Python环境。
,
1.0、安装openark-kit工具包
安装Python模块包之MySQL-python,用于使用Python连接操作MySQL使用。
yum安装- y MySQL-python
RPM安装方式
获得RPM包https://code.google.com/p/openarkkit/downloads/detail?name=openark -工具- 196 - 1. - noarch.rpm
执行命令rpm -ivh openark -工具- 196 - 1. - noarch.rpm
TAR包安装方式
获取- 196. tar.gz tar包https://code.google.com/p/openarkkit/downloads/detail?name=openark工具包
解压tar包焦油-zxvf openark -工具- 196. -焦油。广州- c/usr/local/openark-kit/
安装openark-kit工具的python安装。py安装
,
1.1 sysbench加载数据
/u01/sysbench - 0.5/sysbench/sysbench——测试=/u01/sysbench - 0.5/sysbench/测试/db/插入。lua - oltp-table-size=1000000 - mysql-table-engine=innodb——mysql用户=根——mysql-password=root123 mysql-port=3306——mysql-host=127.0.0.1数据库=replTestDB——max-requests=0, max-time=60 oltp-tables-count=2——报告的时间间隔=10 num_threads=2准备
/u01/sysbench - 0.5/sysbench/sysbench——测试=/u01/sysbench - 0.5/sysbench/测试/db/插入。lua - oltp-table-size=1000000 - mysql-table-engine=innodb——mysql用户=根——mysql-password=root123 mysql-port=3306——mysql-host=127.0.0.1数据库=replTestDB——max-requests=0, max-time=60 oltp-tables-count=2——报告的时间间隔=10 num_threads=2
1.2检查ONLINE_DDL表是否有外键触发器有则删除
* *通过information_schema.key_column_usage * *
选择TRIGGER_SCHEMA、TRIGGER_NAME EVENT_OBJECT_SCHEMA,
EVENT_OBJECT_TABLE
从information_schema.TRIGGERS
event_object_schema=& # 39; replTestDB& # 39;;
从information_schema选择*。key_column_usage哪里
Referenced_table_schema=& # 39; replTestDB& # 39;和
Referenced_table_name=& # 39; sbtest1& # 39;;
1.3 ONLINE_DDL
cd/u01/工具/openark -工具- 196/脚本/
根——ask-pass python oak-online-alter-table - u - s/u01/mysql/my3306/运行/mysql。袜子- d replTestDB - t sbtest1 - g new_sbtest1——“last_update_time添加时间戳NOT NULL违约CURRENT_TIMESTAMP CURRENT_TIMESTAMP更新,添加关键last_update_time (last_update_time)“;——睡眠=300——skip-delete-pass
1.4 ONLINE_DDL后数据校验
从sbtest1 select count (*)
union all
从new_sbtest1 select count (*);
mysql>desc new_sbtest1
→;
+ - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
| |字段类型零额外默认关键| | | | |
+ - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
| | int id(10)无符号|没有零| | PRI | auto_increment |
k | | int(10)无符号没有| | MUL | 0 | |
c | | char (120) | | | | |
|垫| char (60) | | | | |
| last_update_time |时间戳不| | MUL | CURRENT_TIMESTAMP |在更新CURRENT_TIMESTAMP |
+ - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
5行集(0.02秒)
1.5表切换
使用replTestDB;
设置名字utf8;
重命名表sbtest1 old_sbtest1, new_sbtest1 sbtest1;
mysql>选择TRIGGER_SCHEMA、TRIGGER_NAME EVENT_OBJECT_SCHEMA,
→EVENT_OBJECT_TABLE
→从information_schema.TRIGGERS
→event_object_schema=& # 39; replTestDB& # 39;;