(转)mysql监控工具箱 common_schema

http://jackyrong.iteye.com/blog/2020035


http://hi.baidu.com/edeed/item/3fa6e07f754457346dc37cbb 


common_schema是一个MySQL schema工具集(5.1以上版本才适用), 它通过在MySQL数据库里建立一个名为common_schema的数据库, 该数据库里包含许多有用的视图和函数, 用来做数据库分析,监控,管理和SQL代码生成, 其中大部分视图信息其实来自INFORMATION_SCHEMA数据库, 只是做了一些连接和汇总. 
下载地址: http://code.google.com/p/common-schema/downloads/list 
下载列表里包含如下三个发行版本: 
common_schema_mysql_51: 适合所有MySQL5.1以上版本; 
common_schema_innodb_plugin: 适合所有MySQL5.1(包含InnoDB插件和可用INFORMATION_SCHEMA)以上版本; 
common_schema_percona_server: 适合所有Percona5.1以上版本; 
对于没有使用Percona Server, 一般就使用其它两个版本, 它俩的区别就是common_schema_innodb_plugin多建了一个Innodb相关的视图. 所以一般下载安装common_schema_innodb_plugin这个发行版即可. 

1 安装 
# cd /u01/software/mysql/ 
# rz -bey                        (二进制上传安装文件) 
# mysql -uu_test -p       (以最高权限用户如root, 登录数据库) 
mysql> source common_schema_innodb_plugin-r50.sql 
mysql> show databases like '%schema'; 
+--------------------+ 
| Database (%schema) | 
+--------------------+ 
| information_schema | 
| common_schema      | 
+--------------------+ 
2 rows in set (0.00 sec) 
mysql> use common_schema; 
Database changed 
mysql> show full tables; 
+----------------------------+------------+ 
| Tables_in_common_schema    | Table_type | 
+----------------------------+------------+ 
| _columns_privileges        | VIEW       | 
| _flattened_keys            | VIEW       | 
| _global_status_sleep       | VIEW       | 
| _sql_grants_components     | VIEW       | 
| auto_increment_columns     | VIEW       | 
| data_size_per_engine       | VIEW       | 
| data_size_per_schema       | VIEW       | 
| global_status_diff         | VIEW       | 
| global_status_diff_clean   | VIEW       | 
| global_status_diff_nonzero | VIEW       | 
| no_pk_innodb_tables        | VIEW       | 
| numbers                    | BASE TABLE | 
| processlist_per_userhost   | VIEW       | 
| processlist_repl           | VIEW       | 
| processlist_summary        | VIEW       | 
| processlist_top            | VIEW       | 
| redundant_keys             | VIEW       | 
| routine_privileges         | VIEW       | 
| sql_alter_table            | VIEW       | 
| sql_foreign_keys           | VIEW       | 
| sql_grants                 | VIEW       | 
| sql_show_grants            | VIEW       | 
| table_charset              | VIEW       | 
| text_columns               | VIEW       | 
+----------------------------+------------+ 
24 rows in set (0.00 sec) 

2 举例子 
举一些还比较有用的例子. 
列出数据库中所有AUTO_INCREMENT类型列: 
mysql> select * from common_schema.auto_increment_columns; 
列出数据库中各种存储引擎下表数量和大小, 及其最大的表信息: 
mysql> select * from common_schema.data_size_per_engine; 
列出数据库中各schema下表数量和大小, 及其最大的表信息: 
mysql> select * from common_schema.data_size_per_schema; 
列出状态变量差异(10秒间隔), 从这里在一定程度上可以看出数据库繁忙程度: 
mysql> select * from common_schema.global_status_diff_nonzero; 
列出进程汇总信息: 
mysql> select * from common_schema.processlist_summary; 
列出TOP进程信息: 
mysql> select * from common_schema.processlist_top; 
列出各用户和主机进程汇总信息: 
mysql> select * from common_schema.processlist_per_userhost; 
列出存储过程权限信息: 
mysql> select * from common_schema.routine_privileges; 
列出用户权限信息(类似show grants for语句): 
mysql> select * from common_schema.sql_show_grants; 
返回按指定分隔符分隔后的token数量: 
mysql> SELECT get_num_tokens('the quick brown fox', ' ') AS num_token; 
+-----------+ 
| num_token | 
+-----------+ 
|         4 | 
+-----------+ 
返回按指定分隔符分隔后的某个token: 
mysql> SELECT split_token('the quick brown fox', ' ', 3) AS token; 
+-------+ 
| token | 
+-------+ 
| brown | 
+-------+ 

3 所有组件说明 
所有视图和函数说明参考: 
http://common-schema.googlecode.com/svn/trunk/common_schema/doc/html/download.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值