mysql slow query---pt-query-digest----db structure consistency,monitor table records before and after transaction.
将数据库脚本纳入版本管理是很必要的,尤其对于需要在客户那里部署升级的系统。
对于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参数设置得很合理。
|
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
最新文章
- java获取类的信息
- 初步了解yield_python
- Android MuPDF 阅读PDF文件
- background-clip 制作文字火焰效果
- bootstrap框架应用
- Mob短信验证的具体使用
- CentOS 中 YUM 安装桌面环境(转)
- i++,++i 作为参数
- Struts2的配置和一个简单的例子
- SSM-MyBatis-05:Mybatis中别名,sql片段和模糊查询加getMapper
- Kubernetes - 腾讯蓝鲸配置平台(CMDB)开源版部署
- springboot自带定时任务和集成quartz
- Codeforces Round #548 (Div. 2) C dp or 排列组合
- MT【72】一个不等式
- js处理时间时区问题
- Java线程池 / Executor / Callable / Future
- spoon 更新数据
- DexHunter脱壳神器分析
- .split(";,";, -1);和.split(";,";)的区别
- [转]LAMP(Linux-Apache-MySQL-PHP)网站架构