innodb_ruby的简要介绍
[This post refers to innodb_ruby version 0.8.8 as of February 3, 2014.]
[此帖子是关于innodb_ruby版本0.8.8,截至2014年2月3日。]
In On learning InnoDB: A journey to the core I introduced a new library and command-line tool in the innodb_ruby project. Now I’ll show off a few of the things it can do. I won’t try to explain all of the InnoDB structures exposed, since that will get the demos here way off track. We’ll come back to those structures later on!
在On learning InnoDB: A journey to the core中,我介绍了一个新的库和命令行工具,位于innodb_ruby项目中。现在我将展示它可以做些什么。我不会尝试解释所有暴露的InnoDB结构,因为那会让这里的演示偏离轨道。我们稍后会回到这些结构!
Installing innodb_ruby
安装 innodb_ruby
If you’re familiar with Ruby and gems (or you just happen to have a well-configured Ruby installation), I regularly push innodb_ruby gems to RubyGems, so you should only need to:
如果您熟悉Ruby和gems(或者您刚好有一个配置良好的Ruby安装),我定期将innodb_ruby gems推送到RubyGems,所以您只需要:
gem install innodb_ruby
gem install innodb_ruby
If that doesn’t work, you might want to check out The RubyGems manual to try and get your installation working. Or abandon all hope. :-D
如果这样不起作用,您可能想查看RubyGems手册,尝试使您的安装工作起来。或者放弃一切希望。:-D
When you have a working installation, you should have an innodb_space command in your path:
当您安装成功后,您的路径中应该有一个innodb_space命令:
$ innodb_space Error: File must be provided with -f argument
$ innodb_space 错误:必须使用-f参数提供文件
Usage: innodb_space -f
[-p ] [-l ] [ , ...] 用法:innodb_space -f
[-p ] [-l ] [ , ...]
Generating some data
生成一些数据
For these examples, I need more than a few rows to exist in order to properly examine different data structures. Make sure you’re running a new enough server (MySQL 5.5 is good) with Barrracuda tables and that you have innodb_file_per_table enabled. Create and populate a very simple table with a small bit of Ruby:
对于这些示例,我需要存在多行才能正确检查不同的数据结构。确保您运行的是足够新的服务器(MySQL 5.5很好),并且启用了innodb_file_per_table。使用一小段Ruby创建和填充一个非常简单的表:
#!/usr/bin/env ruby
#!/usr/bin/env ruby
require "mysql"
require "mysql"
m = Mysql.new("127.0.0.1", "root", "", "test")
m = Mysql.new("127.0.0.1", "root", "", "test")
m.query("DROP TABLE IF E...