正如上文提到的,我们只是释放出了一个技术预览版。此功能目前只是mysql的一个插件,使用memcached协议。

If you would just like to get a brief introduction on the

setup steps, there is a “README-innodb_memcached” in the

mysql-5.6.2-labs-innodb-memcached package. This is a more

elaborated description on these steps.

如果你想获取到更多关于安装的介绍步骤,请查看README-innodb_memcached文件,这个文件在

mysql-5.6.2-labs-innodb-memcached内。里面有更详细的介绍

1) Prerequisite:服务需求

Currently, the Memcached Daemon Plugin prototype is only

supported on Linux platform. And as a prerequisite, you must have

libevent installed, since it is required by memcached.

目前为止memcached守护进程插件只支持linux平台,并且你需要安装libevent,因为这个是memcached所需的

If you have the source code release, then there is a libevent

1.4.3 included in the package (plugin/innodb_memcached/libevent).

You can go to the directory and do autoconf, ./configure, make and

make install to make the libevent installed.

如果需要你可以去plugin/innodb_memcached/libevent来安装libevent

1.4.3,只需配置./configure 然后make &make

install

2) Build the server编译服务

Assuming you would like to build the server yourself

(otherwise, you can just skip this section), once libevent is

installed, you can just build the MySQL server as usual.

考虑到你可以更喜欢自己编译源代码来构建服务器,当然,如果不是可以跳过此章节,只要安装了libevent,你可以按之前方式编译mysql

Our source code is in the “plugin/innodb_memcached”

directory. As part of server build, it will generate two shared

libraries:

1) libmemcached.so: this is the memcached daemon plugin to

MySQL

2) innodb_engine.so: this is an InnoDB API plugin to

memcached

在plugin/innodb_memcached目录下的文件编译后会生成两个公共库

1) libmemcached.so 这个是mysql内的memcached插件

2)innodb_engine.so 这个是innodb调用memcached 的api插件

Make sure above two shared libraries are put in the MySQL

plugin directory. You can find MySQL plugin directory by doing

“select @@plugin_dir”:

确认将这两个文件拷贝到mysql的插件目录,你可以在mysql命令行下执行以下语句查找mysql插件保存地址

mysql> select @@plugin_dir;

+——————————————————————————-+

|

@@plugin_dir |

+——————————————————————————-+

| /home/jy/work2/mysql-5.6-memcached-labs/lib/plugin |

+——————————————————————————-+

1 row in set (0.00 sec)

3) Install configuration tables:安装创建表

Next, the memcached plugin needs a bit configuration to know

how to interact with InnoDB table. We have a configuration script

in “scripts/innodb_memcached_config.sql”. You can just install the

necessary configure tables by running “mysql

< scripts/innodb_memcached_config.sql”. If you do

not like to know the detail of these configuration tables, you can

just skip this section.

下一步,memcached插件需要一些配置。我们有一个配置脚本在scripts/innodb_memcached_config.sql,你可以直接用mysql执行他即可完成所有的配置。下面我们会介绍他都添加了哪些表,如果你对此没有兴趣可以跳过此章节

This configure script installs 3 tables needed by the InnoDB

Memcached. These tables are created in a dedicated database

“innodb_memcache”. We will go over these three tables

in a bit more detail:

这个脚本会添加三个表,这三个表是memcached插件所必须的,下面我们会详细介绍下这三个表的用途

1) “containers” – This table is the most important table for

“Memcached – InnoDB mapping”. It describes the table used to store

the memcached values. Currently, we can only map memcached to one

table at a time. So essentially, there will be only one row in the

table. In the future, we would consider making this configuration

more flexible and dynamic, or user can map memcached operations to

multiple tables.

1)container 数据存储表,这个表用于memcached -

innodb映射,这里将保存所有memcached的映射相关值,目前这个表只有一个,且数据只有一行。未来我们会考虑将这个配置的更灵活,比如用户可以根据自定规则将值存储到多个指定表。

The mapping is done through specifying corresponding column

values in the table:

“db_schema” and “db_table” columns describe the database and

table name for storing the memcached value.

“key_columns” describes the column (single column) name for

the column being used as “key” for the memcached operation

“value_columns” describes the columns (can be multiple) used

as “values” for the memcached operation. User can specify multiple

columns by separating them by comma (such as “col1, col2″

etc.)

“unique_idx_name_on_key” is the name of the index on the

“key” column. It must be a unique index. It can be primary or

secondary.

这个映射配置内有很多设置对应如下:

db_schema and

db_table行用来说明存储memcached的值,table是指保存数据的表,而schema是存储数据库名

key_column 表内哪列用于key标识

value_columns 表内哪列用于保存key对应的值

unique_idx_name_on_key

这个是key_column指定的数据表内的key的索引名,必须是唯一索引,当然可以使用主键或二级索引

Above 5 column values (table name, key column, value column

and index) must be supplied. Otherwise, the setup will

fail.

Following are optional values, however, to fully comply with

memcached protocol, you will need these column values supplied

too.

“flags” describes the columns used as “flag” for memcached. It

also used as “column specifier” for some operations (such as incr,

prepend) if memcached “value” is mapped to multiple columns. So the

operation would be done on specified column. For example, if you

have mapped value to 3 columns, and only want the “increment”

operation performed on one of these columns, you can use flags to

specify which column will be used for these operations.

“cas_column” and “exp_column” are used specifically to store

the “cas” and “exp” value of memcached.

上面的5个设置必须提供,否则会失败,下面的几个选项可以选填

flag表示类似memcached的flag,他的用途用来表示某“列”比方说当memcached

映射的值包含多列。比如我们有三列,我们只想incr操作其中的一列,你可以通过flags指定哪行进行此操作

case_column以及exp_column是用来保存cas以及exp设置(这俩你知道的……查下cas以及超时)

2. Table “cache_policies” specifies whether we’ll use InnoDB

as the data store of memcached (innodb_only) or use memcached’s

“default engine” as the backstore (cache-only) or both (caching).

In the last case, only if the default engine operation fails, the

operation will be forwarded to InnoDB (for example, we cannot find

a key in the memory, then it will search InnoDB).

2.

表“cache_policies”制定了我们是否使用innodb保存数据,我们可以指定使用那种方式进行数据保存,如:使用innodb(innodb_only),使用memcached默认引擎(default

engine)并且不保存在innodb,或者使用memcached保存并使用innodb保存(caching)。在最后一个选项内,当默认引擎查询失败,查询将会在innodb内查询(如内存内没有这个key的数据,他将会自动查询innodb)

3) Table “config_options”, currently, we only support one

config option through this table. It is the “separator” used to

separate values of a long string into smaller values for multiple

columns values. For example, if you defined “col1, col2″ as value

columns. And you define “|” as separate, you could issue following

command in memcached to insert values into col1 and col2

respectively:

set keyx 10 0 19

valuecolx|valuecoly

So “valuecol1x” will send to col1 and valuecoly will send to

col2.

3.表"config_options"目前我们只在这提供了一个配置选项,此选项用于拆分"separator",当我们有一个很长的字符串,我们可以通过此功能把他拆分成多列内保存。比如定义“列1,列2”为value_COLUMNS

。"|"符号为分隔符的时候,我们可以使用下面命令把列1和列2内容分别插入

set keyx 10 0 19

列1|列2

这时列1值和列2值将会分别存在两个对应顺序的字段内

4) Example tables

Finally, as part of the configuration script, we created a

“demo_test” in the “test” database as an example. It also allows

the Daemon Memcached to work out of box, and no need to for any

additional configurations.

As you would notice, this “demo_test” table has more columns

than needed, so it would need the entries in the “container” table

to tell which column is used for what purpose as described

above.

4)示例表

最后,在我们的配置脚本内,他会自动建立一个 demo_test在test数据库内。

当然这个可以直接使用,无需其他特殊配置

可能你会发现,这个表内有很多列超过了我们的需要。我们可以再container内自行更改下配置只保留我们用的

4) Install the Daemon Plugin(安装守护插件)

The final step would be installing the daemon plugin. It is

the same as installing any other MySQL plugin:

最后一步就是安装守护插件,这个步骤和安装其他mysql插件一样执行以下命令

mysql> install plugin daemon_memcached soname

“libmemcached.so”;

If you have any memcached specific configure parameters,

although it takes effect when the plugin is installed, you would

need to specify it during MySQL server boot time

or enter them in the MySQL configure files.

如果你有任何附加的memcached插件配置参数,你可以把他放在mysql的配置文件。重启mysql即可生效

For example, if you would like the memcached to listen on

port “11222″ instead of the default port “11211″, then you would

need to add “-p11222″ to MySQL system configure variable

“daemon_memcached_option”:

比如你想让memcached监听11222端口而非默认的11211端口,你需要指定

-p111222参数,到my.cnf内的daemon_memcached_option字段内写法如下

mysqld …. –loose-daemon_memcached_option=”-p11222″.

Of course, you can add other memcached command line options

to “daemon_memcached_option” string.

The other configure options are:

1) daemon_memcached_engine_lib_name (default

“innodb_engine.so”)指定默认存储引擎so文件

2) daemon_memcached_engine_lib_path (default NULL, the plugin

directory).指定memcached插件lib地址

当然,你可以增加其他命令行参数到配置内如上

By default, you do not need to set/change anything with these

two configure option. We have above two configure options because

they allow you to load any other storage engine for memcached (such

as NDB memcached engine). This opens door for more interesting

exploration.

总的来说你不需要改变上面两个参数。我们提供者两个参数是为了提供其他存储引擎给memcached,如NDB

存储引擎,这样可以提供更多有趣的体验。

3) daemon_memcached_r_batch_size, batch commit size for read

operation (get operations. It specifies after how many ops we will

do a commit. By default, this is set as a very large number,

1048576.

守护进程的读取操作批量更新(每多少次操作后将会做一次数据提交到存储引擎,默认会设置很大如1048576)

4) daemon_memcached_w_batch_size, batch commit for any write

operations (set, replace, append, prepend, incr, decr etc.) By

default, this is set as 32.

多少次写操作后才会更新存储引擎,默认32

Again, please note that you will have these configuration

parameter in your MySQL configure file or MySQL boot command line.

And they will take effect when you load the memcached

plugin.

另外,注意,当你在命令行启动mysql服务或者在配置文件内指定,都会改变memcached插件的配置

5) Start to play:

Now you have everything set up, you can start to

play:

现在我们可以玩一下拉~

telnet 127.0.0.1 11211

使用telnet连11211端口(memcached协议都可以直接这么玩)

set a11 10 0 9

123456789

STORED

get a11

VALUE a11 0 9

123456789

END

You can access the InnoDB table (“demo_test”) through the

standard SQL interfaces. However, there are some catches:

1) If you would like to take a look at what’s in the

“demo_test” table, please remember we had batched the commits (32

ops by default) by default. So you will need to do “read

uncommitted” select to find the just inserted rows:

这时你可以访问innodb表“demo_test”去看下里面的内容,另外要注意,我们上面设置了写操作执行了32次后才会保存同步一次数据到存储引擎,所以你必须使用读取未提交数据来列出

mysql> set session TRANSACTION ISOLATION

LEVEL

-> read uncommitted;

Query OK, 0 rows affected (0.00 sec)

mysql> select * from demo_test;

+——+——+——+——+———–+——+——+——+——+——+——+

| cx |

cy |

c1 |

cz |

c2 | ca |

CB |

c3 |

cu |

c4 |

C5 |

+——+——+——+——+———–+——+——+——+——+——+——+

| NULL | NULL | a11 | NULL | 123456789 | NULL |

NULL | 10 | NULL

| 3 | NULL

|

+——+——+——+——+———–+——+——+——+——+——+——+

1 row in set (0.00 sec)

2) The InnoDB table would be IS (shared intention) or IX

(exclusive intentional) locked for all operations in a transaction.

So unless you change “daemon_memcached_r_batch_size” and

“daemon_memcached_w_batch_size” to small number (like 1), the table

is most likely intentionally locked between each operations. So you

cannot do any DDL on the table.

当innodb在提交同步事务中,他将会使用锁锁定表,所以当你把“daemon_memcached_r_batch_size”

and

“daemon_memcached_w_batch_size”设置的值十分低的时候(如1)将会导致innodb频繁的锁表,所以你无法做任何DDL操作到表上

Summary

Now you have everything setup. And you can directly interact

with InnoDB storage engine through Memcached interfaces. In

addition, as you might notice while going through this extended

“README”, we still have a lot interesting options open for

exploration and enhancement. This is the beginning

of opening InnoDB to the outside world, and NoSQL

is a perfect place for it to play.

总结

没啥了……

mysql key value 引擎_mysql集成的key-value引擎-个人翻译相关推荐

  1. mysql and常用引擎_MySQL两大常用存储引擎MyISAM,InnoDB的区别

    本文主要整理了MySQL两大常用的存储引擎MyISAM,InnoDB的六大常见区别,来源于Mysql手册以及互联网的资料 InnoDB与Myisam的六大区别 MyISAM InnoDB 构 成上的区 ...

  2. 适合mysql的网络存储_mysql 选择合适的存储引擎

    1 MyISAM:默认的MySQL 插件式存储引擎.如果应用是以读操作和插入操作为主, 只有很少的更新和删除操作,并且对事务的完整性.并发性要求不是很高,那么选择这个存 储引擎是非常适合的.MyISA ...

  3. MySQL unique啥意思_mysql – UNIQUE,UNIQUE KEY和CONSTRAINT’name’UNIQUE有什么区别?

    我有一个基本的"用户"表,我想在MySQL中创建. 我不希望在数据库中出现重复的电子邮件或重复的用户名. >创建餐桌时防止这种情况的最佳方法是什么? >以下是什么区别: ...

  4. MySQL里 unique 用法_mysql中unique key中在查询中的使用

    1.建表语句: sql">CREATE TABLE `employees` ( `emp_no` int(11) NOT NULL,`birth_date` date NOT NULL ...

  5. mysql有那些存储引擎_MySQL有那哪些存储引擎

    实际我们在平时的开发中,经常会遇到的,在用SQLyog等工具创建表时,就有一个引擎项要你去选.如下图: Mysql的存储引擎有这么多种,实际我们在平时用的最多的莫过于InnoDB和MyISAM了. 所 ...

  6. mysql myisam存储引擎_MySQL浅谈MyISAM存储引擎

    本文来源于:IT摆渡网---一个IT实时问答系统快速解决你的任何IT问题,无需等待! mysql中用的最多存储引擎就是innodb和myisam.做为Mysql的默认存储引擎,myisam值得我们学习 ...

  7. mysql的存储引擎_Mysql数据库3种存储引擎有什么区别?

    展开全部 MySQL常见的三种存储e68a843231313335323631343130323136353331333366306561引擎为InnoDB.MyISAM和MEMORY.其区别体现在事 ...

  8. mysql innodb文件存储_MySQL数据库和InnoDB存储引擎文件

    参数文件 当MySQL示例启动时,数据库会先去读一个配置参数文件,用来寻找数据库的各种文件所在位置以及指定某些初始化参数,这些参数通常定义了某种内存结构有多大等.在默认情况下,MySQL实例会按照一定 ...

  9. mysql常用的两种数据库引擎_Mysql数据库常用两种引擎的介绍

    1.数据库引擎介绍 MySQL数据库引擎取决于MySQL在安装的时候是如何被编译的.要添加一个新的引擎,就必须重新编译MYSQL.在MySQL数据库中,常用的引擎主要就是2个:Innodb和MyIAS ...

最新文章

  1. AT4437-[AGC028C]Min Cost Cycle【结论,堆】
  2. 37岁程序员失业投500份简历就3次面试猎头:超35岁不要
  3. 2018上C语言程序设计(高级)作业-第0次作业
  4. Spark DataFrameRDD案例实现
  5. 嵌入式开发之cmos---前端采集aptina cmos
  6. 查看dll是32还是64
  7. R语言数据分析及可视化实战
  8. 第六篇:A133 用DragonSN工具刷SN号,MAC地址细节问题
  9. java短信验证码接口demo分享
  10. python写诗代码_python实现诗歌游戏(类继承)
  11. 你写论文时发现了哪些神网站?
  12. 网络流量监控iptraf
  13. MySQL8 免安装版安装
  14. Tomcat 部署多个SpringBoot 项目:ERROR org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanExporter
  15. 开源好物分享!文档在线预览平台
  16. Windows系统下如何截屏
  17. 实现 swiper 的左右箭头放到外面,定制箭头的样式
  18. 牛!鸿星尔克登上亚马逊新品榜第一;中国跨境电商半年交易额近九千亿元;商务部回应亚马逊封号事件;亚马逊下架盲盒产品…|洞悉跨境
  19. IntelliJ IDEA 字体设置
  20. FPGA学习之按键控制led

热门文章

  1. 前端学习(2369):组件的创建使用和组件的生命周期
  2. 前端学习(2116):为什么组件data必须是函数
  3. 前端学习(2055)vuejs的认识和特点介绍
  4. 前端学习(1392):多人管理项目12加密
  5. 前端学习(1311):请求报文
  6. 前端学习(1156):let var const的区别
  7. html:(24):内联式css和嵌入式css
  8. http:(5):http状态码
  9. 计算机无法同步时间,为什么在Win7中无法同步计算机时间?
  10. android imageview 图片切换动画,在Android中以动画方式将ImageView移动到不同的位置...