MySQL common_schema简介

2014-11-24 17:54:28 · 作者: · 浏览: 0

common_schema的简介:


Shlomi Noach 的common_schema项目(http://code.openark.org/forge/common_schema)是一套针对服务器脚本化和管理的强大的代码和视图。common_schema对于MySQL好比jQuery对于java script。


common_schema 是一个MySQL服务器的管理框架。


common_schema为MySQL提供了查询脚本,分析并且信息化的视图和一个函数库,以便更容易的管理和诊断。它引入的一些基于SQL的工具简化了原本复杂的shell和客户端的脚本,允许DBA独立于操作系统,来安装软件包及其依赖包。


common_schema的构成组件有:
i.
Views library : 提供一组功能强大的视图,来操作和呈现服务器的元数据。


ii.
Routines library : 它为MySQL提供一组补充的程序,包括元数据的处理


iii.
QueryScript:一种SQL脚本语言。


iv.
Redebug :调试器和调试API为MySQL存储程序。


common_schema的下载:
i.
common_schema是一个开源的纯文本的SQL文件。


iii.
common_schema的下载地址:http://code.google.com/p/common-schema/


common_schema的安装:


由于common_schema是一个开源的纯文本文件,在server上直接执行就可以了。当然一定要有足够的权限。如:


creation of schema, tables, views & routines的权限。


在MySQL上安装:


Within MySQL


SOURCE /path/to/common_schema_distribution_file.sql;



From Shell,execute:


mysql < /path/to/common_schema_distribution_file.sql



安装结果如下:


To verify installation, check that thecommon_schemadatabase exists. e.g.:


mysql> show databases;


+--------------------+


| Database |


+--------------------+


| information_schema |


| 51auto_v4 |


| common_schema |


| mysql |


| performance_schema |


| test |


+--------------------+


使用common_schema潜在风险:


在information_schema中,有些视图用来一次获取所有表的元数据,如:TABLES,COLUMNS,STATISTICS etc。或许只是简单的查询,就可能锁住数据库很长时间,甚至导致宕机。想了解相关内容请看:http://www.xaprb.com/blog/2009/10/29/making-changes-to-many-tables-at-once/


设置innodb_stats_on_metadata=0可以用来解决查询INFORMATION_SCHEMA慢的问题。这个参数其实就是关闭每次查询INFORMATION_SCHEMA的相关视图时,不更新InnoDB相关的统计;但是并不会真正关闭了InnoDB表的统计信息,每当第一次打开表时,都会更新其统计的信息。想了解相关内容请看:


http://www.mysqlperformanceblog.com/2011/12/23/solving-information_schema-slowness/