Mysql5.6.4 supports nosql

Source: Internet
Author: User

In the latest mysql-5.6.4-labs-innodb-memcached, The nosql function of key/value is implemented, and its main principle is as follows:
That is, in addition to listening to port 3306, mysqld listens to port 11211 at the same time. Put the mysqld and memcached services in the same process. Pass
Ing between databases, tables, and fields inserts data cached in memcache into the ing table. The installation package provides three tables: containers.
Cache_policies and config_options. containers provides ing relationships. cache_policies provides three storage methods (
Innodb_only data is inserted only into the table, cache_only only data is cached, and caching is used to cache and insert data into the table.
The default delimiter "|", that is, if the field col1, col2. .. is defined in the values field of the containers table, the cache value is set.
You can use val1 | val2 to insert val1 to col1 and val2 to col2.
The new version provides two important files:
1) libmemcached. so: this is the memcached daemon plugin to MySQL
2) innodb_engine.so: this is an InnoDB API plugin to memcached
After the libmemcached. so plug-in is installed, memcache can directly access mysql through the APIS provided by innodb, which is fast and convenient.

Installation Method

For basic installation, refer to the INSTALL-BINARY file in the installation package, one of which is as follows:



Then we can use ln for a soft link.
Commands: ln-s path (path is the mysql installation package directory)/usr/local/mysql

Installation configuration table

The scripts folder of the installation package contains innodb_memcached_config. SQL, which imports the file to mysql.
Commands:/usr/local/mysql/bin/ mysql-uroot-P 3306-S/tmp/mysql. sock <path/scripts/innodb_memcached_config. SQL
Run:/usr/local/mysql/bin/mysql. The innodb_memcache database is displayed. By default, the containers configuration inserts the cached data to test.
In the demo_test table of the database, field c1 is the cache key, and field c2 is the cache data ......

Install the innodbmemcache plug-in

You can run: show variables like '% memcache %'; to check whether the plug-in is installed.
Connect to mysql and install commands: install plugin daemon_memcached soname "libmemcached. so ";
Install the memcache service.

Test

Connect to memcache through telnet 127.0.0.1 11211, simple test
Set a11 10 0 9
123456789
STORED
Get a11
VALUE a11 0 9
123456789
END
In this way, a piece of data is cached. At this time, you can go to the database to view test. demo_test and cannot find this piece of data:
1) If you wowould 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:

Mysql> set session TRANSACTION ISOLATION LEVEL
-> Read uncommitted;

Execute the above statement, set the read to unrestricted, and then execute: select * from test. demo_test; to find two pieces of data. Congratulations, you have succeeded!

If you are interested, please study it in depth. You can also take a look at mysql cluster processing. The latest mysql-cluster version is 7.2.4.

 

This article is from sunny5211, the columnist "Lao Wang's Technical Summary ".

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.