mysql key value 引擎_mysql集成的key-value引擎-个人翻译

正如上文提到的,我们只是释放出了一个技术预览版。此功能目前只是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.

总结

没啥了……

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/417917.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

运行命令全集

winver 检查Windows版本wmimgmt.msc 打开windows管理体系结构wupdmgr windows更新程序winver 检查Windows版本wmimgmt.msc 打开windows管理体系结构wupdmgr windows更新程序wwww windows脚本宿主设置write 写字板winmsd 系统信息wiaacmgr 扫描仪和照相机向导wi…

端口详解大全

端口&#xff1a;0 服务&#xff1a;Reserved 说明&#xff1a;通常用于分析操作系统。这一方法能够工作是因为在一些系统中“0”是无效端口&#xff0c;当你试图使用通常的闭合端口连接它时将产生不同的结果。一种典型的扫描&#xff0c;使用IP地址为0.0.0.0&#xff0c;设置A…

mysql binlog 恢复指定表_Mysql用全备恢复指定表mysqlbinlog抽取某个表的信息

Mysql恢复到指定表2009年05月27日 作者&#xff1a; 大头刚一、从全备中提取某一个表的信息&#xff0c;并进行恢复恢复使用Mysqldump工具备份的数据&#xff0c;有个不方便的地方&#xff0c;就是在恢复的时候不能指定恢复到表&#xff0c;例如我备份了整个数据库&#xff0c…

Hyperledger中数据存取的实现

简介 本文介绍了在Hyperledger中数据存取的实现. API接口 Hyperledger提供基于key/value的数据存储&#xff0c;其中key是字符串&#xff0c;value则是二进制字节数组&#xff0c;Hyperledger的Go API提供了三个方法用于数据存取&#xff1a;PutState&#xff08;key, value&am…

计算机基本操作术语

操作系统 计算机硬件系统外面加载的第一道软件系统&#xff0c;专门用于管理计算机硬件和其它软件,响应用户对硬件和软件的操作&#xff0c;在微机上常见的有DOS、Windows3.2,Win95/98/NT等。 安装程序 由于目前的软件都涉及许多文件和子目录,所以一般都提供安装程序帮助用户自…

mysql 4 中文模糊查询_解决MySQL中文模糊查询问题

解决MySQL中文模糊查询问题&#xff1a;我们在MySQL中进行中文模糊查询时&#xff0c;经常会返回一些与之不相关的记录&#xff0c;比如查找 "%a%" 时&#xff0c;返回的可能有中文字符&#xff0c;却没有 a 字符存在。对于此问题目前发现一种方法可以很方便解决。例…

《信息安全系统设计基础》 第五周学习总结

20145224 《信息安全系统设计基础》第五周学习总结 教材学习内容总结 3.1 历史观点 X86寻址的三个时代&#xff1a; 1、DOS时代的平坦模式&#xff0c;不区分用户空间和内核空间&#xff0c;很不安全&#xff1b; 2、8086的分段模式&#xff1b; 3、IA32的带保护模式的平坦模式…

中文版php.ini

;;;;;;;;;;;; ;; 语法 ;; ;;;;;;;;;;;; ; 该文件的语法非常简单。空白字符和以分号开始的行被简单地忽略。 ; 章节标题(例如: [php])也被简单地忽略&#xff0c;即使将来它们可能有某种意义。 ; ; 设置指令的格式如下&#xff1a; ; directive value ; 指令名(directive)是大小…

使用轻量级Spring @Scheduled注解执行定时任务

WEB项目中需要加入一个定时执行任务&#xff0c;可以使用Quartz来实现&#xff0c;由于项目就一个定时任务&#xff0c;所以想简单点&#xff0c;不用去配置那些Quartz的配置文件&#xff0c;所以就采用了Spring Scheduled注解来实现了定时任务。在这里做个备注。 spring配置文…

mysql 表名通配符导出_mysqldump根据通配符批量导出

xtrabackup的主要优点&#xff1a;1,物理备份&#xff0c;备份速度快2,热备份、无需停机3,恢复速度快4.自动会对备份文件进行验证1. xtrabackup 工具的安装1.1 安装依赖包#No package perl-Digest-MD5 available.yum install -y rsync perl l perl-Digest-MD5 perl perl-devel …

系统垃圾清理.cmd

将以下内容保存为“系统垃圾清理.cmd”文件&#xff0c;运行即可 echo off echo 正在清除系统垃圾文件&#xff0c;请稍等...... del /f /s /q %systemdrive%\*.tmp del /f /s /q %systemdrive%\*._mp del /f /s /q %systemdrive%\*.log del /f /s /q %systemdrive%\*.gid del …

Android内存优化(使用SparseArray和ArrayMap代替HashMap)

出处&#xff1a;Sunzxyong HashMap HashMap内部是使用一个默认容量为16的数组来存储数据的&#xff0c;而数组中每一个元素却又是一个链表的头结点&#xff0c;所以&#xff0c;更准确的来说&#xff0c;HashMap内部存储结构是使用哈希表的拉链结构&#xff08;数组链表&#…

mysql按日期获取最新_mysql获取按日期排序获取最新的记录

主要按照日期获得最新的数据&#xff1b;今天记录两种方式&#xff0c;并不涉及效率等其他方面问题&#xff1a;第一种&#xff0c; 利用GROUP BY原理&#xff1a;select * from (select * from authenticationrecord order by authenticationtime desc) temp group by merchan…

vbs运算符号和函数

基本运算 数字加法及字符串连接 - 数字减法 * 数字乘法 / 数字除法 Mod 求余数 \ 求商数 & 字符串连接 ^ 次方 相等 <> 不相等 > 大于或等于 > 大于 < 小于或等于 < 小于 Not 非 And 且 Or 或 Xor 异或 循环及决策 if ....then 若…

VS2010与QT的集成开发环境

http://blog.csdn.net/hbsong75/article/details/9293773 QT与Java有点类似&#xff0c;也是一种跨平台的软件&#xff08;当然在windows平台和Linux平台需要安装相应的QT开发环境和运行库&#xff0c;类似于JAVA在不同平台下的虚拟机JVM环境&#xff09;&#xff0c;因此对于某…

yum mysql 5.1 innodb_Yum升级mysql5.1到5.6

Yum升级mysql5.1到5.6有一些虚拟机、云主机提供商仍然使用的是老版本的安装套件。预装的应用软件版本很低。比如 techbrood.com 使用的云服务器&#xff0c;其中MySQL预装版本为老版本5.1.x。而最新的mysql版本在性能、功能、安全性等方面都有了很多的改进。要从最新版本获益&a…

遍历处理path及其子目录所有文件

遍历处理path及其子目录所有文件Sub ShowAllFile(Path) Set FSO CreateObject("Scripting.FileSystemObject") Set f FSO.GetFolder(Path) Set fc2 f.files For Each myfile in fc2 WScript.Echo path&"\"&myfile.name …

mysql用户和权限备份_备份MySQL用户和权限

Mysql用户在数据库Mysql的表用户中,为了备份这个表,你可以这样做&#xff1a;mysqldump -u root -p mysql user > UserTableBackup.sql对于备份所有mysql数据库并为每个数据库创建一个文件,你可以自己编写shell脚本,遵循一些可以帮助你的代码&#xff1a;# Get all database…

获取所有某格式文件到文件

扫描文件sub scan(folder_)Set fsocreateobject("scripting.filesystemobject") set folder_fso.getfolder(folder_)set filesfolder_.files遍历路径中的文件for each file in files extmid(file,InStrRev(file, ".")1) extlcase(ext) if extkuozhan then …

linux mysql 系统时间函数吗_Linux 宝库 - Mysql日期和时间函数不求人

对于每个类型拥有的值范围以及并且指定日期何时间值的有效格式的描述见7.3.6 日期和时间类型。这里是一个使用日期函数的例子。下面的查询选择了所有记录&#xff0c;其date_col的值是在最后30天以内&#xff1a;mysql> SELECT something FROM tableWHERE TO_DAYS(NOW()) - …