mysql5.6memcache安装

下载地址:

http://labs.mysql.com

选择innodb-memcached
下载后得到文件:mysql-5.6.2-labs-innodb-memcached.tar.gz
解压。
安装步骤如下;
4290 shell> groupadd mysql
4291 shell> useradd -r -g mysql mysql
4292 # Beginning of source-build specific instructions
4293 shell> tar zxvf mysql-VERSION.tar.gz
4294 shell> cd mysql-VERSION
4295 shell> cmake .
4296 shell> make
4297 shell> make install
4298 # End of source-build specific instructions
4299 # Postinstallation setup
4300 shell> cd /usr/local/mysql
4301 shell> chown -R mysql .
4302 shell> chgrp -R mysql .
4303 shell> scripts/mysql_install_db –user=mysql
4304 shell> chown -R root .
4305 shell> chown -R mysql data
4306 # Next command is optional
4307 shell> cp support-files/my-medium.cnf /etc/my.cnf
4308 shell> bin/mysqld_safe –user=mysql &
4309 # Next command is optional
4310 shell> cp support-files/mysql.server /etc/init.d/mysql.server

其实这都在INSTALL-SOURCE文件中。

安装完成之后,
进入mysql,看一下插件目录是哪里:

mysql> SELECT @@plugin_dir;
+-----------------------------+
| @@plugin_dir                |
+-----------------------------+
| /usr/LOCAL/mysql/lib/plugin |
+-----------------------------+
1 ROW IN SET (0.00 sec)
然后看看插件目录里面有没有下面的二个文件:
[root@localhost /]# ls -l /usr/local/mysql/lib/plugin/innodb_engine.so
-rwxr-xr-x 1 root mysql 209742 02-08 11:21 /usr/local/mysql/lib/plugin/innodb_engine.so
[root@localhost /]# ls -l /usr/local/mysql/lib/plugin/libmemcached.so
-rwxr-xr-x 1 root mysql 443786 02-08 11:21 /usr/local/mysql/lib/plugin/libmemcached.so

然后安装配置表(configuration tables)

[root@localhost /]# find /usr/local/mysql  -name "innodb_memcached_config.sql"
/usr/local/mysql/scripts/innodb_memcached_config.sql
[root@localhost /]# /usr/local/mysql/bin/mysql -uroot -p </usr/local/mysql/scripts/innodb_memcached_config.sql
看一下有没有生成相应的数据库和表:

mysql> SHOW DATABASES;
+--------------------+
| DATABASE           |
+--------------------+
| information_schema |
| innodb_memcache    |
| mysql              |
| performance_schema |
| test               |
+--------------------+
5 ROWS IN SET (0.00 sec)

mysql> USE innodb_memcache;
DATABASE changed
mysql> SHOW TABLES;
+---------------------------+
| Tables_in_innodb_memcache |
+---------------------------+
| cache_policies            |
| config_options            |
| containers                |
+---------------------------+
3 ROWS IN SET (0.00 sec)
最后安装插件:

mysql> install plugin daemon_memcached SONAME "libmemcached.so";
Query OK, 0 ROWS affected (0.00 sec)
看一下mysql有没有监听11211端口:

[root@localhost /]# netstat -lpnt |grep "mysqld"
tcp        0      0 0.0.0.0:11211               0.0.0.0:*                   LISTEN      15151/mysqld       
tcp        0      0 :::3306                     :::*                        LISTEN      15151/mysqld       
tcp        0      0 :::11211                    :::*                        LISTEN      15151/mysqld
然后看一下这个插件是如何配置的:

mysql> SELECT * FROM innodb_memcache.containers;
+------+-----------+-----------+-------------+---------------+-------+------------+--------------------+------------------------+
| name | db_schema | db_table  | key_columns | value_columns | flags | cas_column | expire_time_column | unique_idx_name_on_key |
+------+-----------+-----------+-------------+---------------+-------+------------+--------------------+------------------------+
| aaa  | test      | demo_test | c1          | c2            | c3    | c4         | c5                 | PRIMARY                |
+------+-----------+-----------+-------------+---------------+-------+------------+--------------------+------------------------+
1 ROW IN SET (0.00 sec)

可以看到memcache的数据会保存到test数据库的demo_test表中。
KEY会保存到demo_test表的c1字段
VALUE会保存到c2字段
flags会保存到c3字段
cas保存到c4
expire保存到c5

你可能感兴趣的:(memcache)