将数据库脚本纳入版本管理是很必要的,尤其对于需要在客户那里部署升级的系统。

对于Python Django等框架,由于数据库是通过Model生成的,因此框架本身包括数据库升级工具,并通过代码版本间接管理了数据库脚本。
对于直接通过数据库脚本来维护数据库schema和数据的框架,或者使用DbMaintain / Liquibase工具,它们提供了一些工具来跟踪当前数据库的版本并可以自动升级、回退、比较数据库等。(DbMaintain使用SQL,相比之下更自然一些,建议使用。)

DbMaintain
http://dbmaintain.org/overview.html
https://github.com/DbMaintain/dbmaintain

Liquibase
http://www.liquibase.org



mysqldump --skip-comments --skip-extended-insert -d --no-data -u root -p dbName1>file1.sql
mysqldump --skip-comments --skip-extended-insert -d --no-data -u root -p dbName2>file2.sql
diff file1.sql file2.sql

monitor table records before and after transaction.

SELECT table_name, table_rows
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = '**YOUR SCHEMA**';
mysqldump --skip-comments --skip-extended-insert -d --no-data -u webuser01 -p -S /tmp/mysql3306.sock uexercise>ue.sql

http://blog.csdn.net/lanbingkafei/article/details/8525187

high performance MySQL笔记:

孔子说“工欲善其事,必先利其器”, 今天就介绍一下percona toolkit中的pt-query-digest。

下载地址:

http://www.percona.com/software/percona-toolkit/

官方文档:

http://www.percona.com/doc/percona-toolkit/pt-query-digest.html

请先确定在my.ini中打开了mysql的slow_query_log,并且保证long_query_time参数设置得很合理。

  1. # Log slow queries. Slow queries are queries which take more than the
  2. # amount OF TIME defined IN "long_query_time" OR which do NOT USE
  3. # indexes well, IF log_short_format IS NOT enabled. It IS normally good idea
  4. # TO have this turned ON IF you frequently ADD NEW queries TO the
  5. # system.
  6. slow_query_log
  7. # ALL queries taking more than this amount OF TIME (IN seconds) will be
  8. # trated AS slow. Do NOT USE "1" AS a VALUE here, AS this will RESULT IN
  9. # even very fast queries being logged FROM TIME TO TIME (AS MySQL
  10. # currently measures TIME WITH SECOND accuracy ONLY).
  11. long_query_time = 2

pt-query-digest是一个perl脚本,只需下载即可。

[root@sso bianxuehui]# wget percona.com/get/pt-query-digest
[root@sso bianxuehui]# file pt-query-digest
pt-query-digest: a perl script text executable
[root@sso bianxuehui]# ll pt-query-digest
-rw-r--r-- 1 root root 499727 09-02 00:01 pt-query-digest
[root@test_dx modify]# chmod u+x pt-query-digest

使用如下,如果slow log够大的话,会消耗相当多的cpu和内存,所以最好把slow log和pt-query-digest放到其它的server上面运行。

[root@test_dx bianxuehui]# ./pt-query-digest  slow.log  >digest.log

最新文章

  1. java获取类的信息
  2. 初步了解yield_python
  3. Android MuPDF 阅读PDF文件
  4. background-clip 制作文字火焰效果
  5. bootstrap框架应用
  6. Mob短信验证的具体使用
  7. CentOS 中 YUM 安装桌面环境(转)
  8. i++,++i 作为参数
  9. Struts2的配置和一个简单的例子
  10. SSM-MyBatis-05:Mybatis中别名,sql片段和模糊查询加getMapper
  11. Kubernetes - 腾讯蓝鲸配置平台(CMDB)开源版部署
  12. springboot自带定时任务和集成quartz
  13. Codeforces Round #548 (Div. 2) C dp or 排列组合
  14. MT【72】一个不等式
  15. js处理时间时区问题
  16. Java线程池 / Executor / Callable / Future
  17. spoon 更新数据
  18. DexHunter脱壳神器分析
  19. .split(",", -1);和.split(",")的区别
  20. [转]LAMP(Linux-Apache-MySQL-PHP)网站架构

热门文章

  1. C/C++:C++中static,extern和extern "C"关键字
  2. windows2008r2的时间同步小结
  3. python学习笔记(2)
  4. AutoMapper搬运工之自定义类型转换
  5. c# 针对SAP服务通讯
  6. iOS 线程间共享资源添加排它锁
  7. 【centOS】账号管理
  8. Android开发环境(IDE)
  9. Spring泛型依赖注入
  10. python之 rabbitmq