Installation MEMCACHE_ENGINE for MySQL5.1

18 篇文章 0 订阅

installation memcache

[root@test software]# tar -zxvf libevent-1.2.tar.gz 
[root@test software]# cd libevent-1.2
[root@test libevent-1.2]# ./configure --prefix=/service/libevent
[root@test libevent-1.2]# make && make install
[root@test software]# tar -zxvf memcached-1.2.2.tar.gz
[root@test software]# cd memcached-1.2.2
[root@test memcached-1.2.2]# ./configure --prefix=/service/memcached --with-libevent=/service/libevent
[root@test memcached-1.2.2]# make && make install 

start memcached

[root@test service]# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/service/libevent/lib
[root@test service]# /service/memcached/bin/memcached -h
memcached 1.2.2
-p <num>      TCP port number to listen on (default: 11211)
-U <num>      UDP port number to listen on (default: 0, off)
-s <file>     unix socket path to listen on (disables network support)
-l <ip_addr>  interface to listen on, default is INDRR_ANY
-d            run as a daemon
-r            maximize core file limit
-u <username> assume identity of <username> (only when run as root)
-m <num>      max memory to use for items in megabytes, default is 64 MB
-M            return error on memory exhausted (rather than removing items)
-c <num>      max simultaneous connections, default is 1024
-k            lock down all paged memory
-v            verbose (print errors/warnings while in event loop)
-vv           very verbose (also print client commands/reponses)
-h            print this help and exit
-i            print memcached and libevent license
-b            run a managed instanced (mnemonic: buckets)
-P <file>     save PID in <file>, only used with -d option
-f <factor>   chunk size growth factor, default 1.25
-n <bytes>    minimum space allocated for key+value+flags, default 48
[root@test service]# /service/memcached/bin/memcached -d -m 64 -u root -p 11211 -c 1024 -P /tmp/memcached.pid
[root@test service]# netstat -lanp|grep 11211
tcp        0      0 192.168.1.19:11211           0.0.0.0:*                   LISTEN      12204/memcached     


installation memcache-engine for MySQL5.1

[root@test software]# tar -zxvf libmemcached-0.23.tar.gz
[root@test software]# cd libmemcached-0.23
[root@test libmemcached-0.23]# ./configure --prefix=/service/memcache_engine
[root@test libmemcached-0.23]# make && make install

[root@test software]# tar -zxvf libxml2-2.6.32.tar.gz
[root@test software]# cd libxml2-2.6.32
[root@test libxml2-2.6.32]# ./configure --prefix=/service/memcache_engine
[root@test libxml2-2.6.32]# make && make install

[root@test software]# tar -zxvf libxmlrow-0.2.tar.gz
[root@test software]# cd libxmlrow-0.2
[root@test libxmlrow-0.2]# export PKG_CONFIG_PATH=/service/memcache_engine/lib/pkgconfig/
[root@test libxmlrow-0.2]# ./configure --prefix=/service/memcache_engine
[root@test libxmlrow-0.2]# make && make install

[root@test software]# tar -zxvf memcache_engine-0.7.tar.gz
[root@test software]# cd memcache_engine-0.7
[root@test memcache_engine-0.7]# sed -i "s#uint16_t#uint32_t#g" ./src/ha_memcache.cc
[root@test memcache_engine-0.7]# export PKG_CONFIG_PATH=/service/memcache_engine/lib/pkgconfig/
[root@test memcache_engine-0.7]# ./configure --prefix=/service/memcache_engine --with-mysql=/service/software/mysql-5.1.26-rc
[root@test memcache_engine-0.7]# make && make install

configuration memcache_engine

Simple Interface for working with memcache as a storage engine

[root@test memcache_engine-0.7]# cp /service/memcache_engine/lib/libmemcache_engine.so.0.0.0 /service/mysql/lib/mysql/plugin/libmemcache_engine.so
[root@test memcache_engine-0.7]# /service/mysql/bin/mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.26-rc-mysql_memcache-log Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> INSTALL PLUGIN memcache SONAME 'libmemcache_engine.so';
Query OK, 0 rows affected (0.00 sec)

mysql> show engines;
+------------+---------+----------------------------------------------------------------+--------------+-----+------------+
| Engine     | Support | Comment                                                        | Transactions | XA  | Savepoints |
+------------+---------+----------------------------------------------------------------+--------------+-----+------------+
| CSV        | YES     | CSV storage engine                                             | NO           | NO  | NO         | 
| MEMCACHE   | YES     | Simple Interface for working with memcache as a storage engine | NO           | NO  | NO         | 
| MRG_MYISAM | YES     | Collection of identical MyISAM tables                          | NO           | NO  | NO         | 
| InnoDB     | YES     | Supports transactions, row-level locking, and foreign keys     | YES          | YES | YES        | 
| MyISAM     | DEFAULT | Default engine as of MySQL 3.23 with great performance         | NO           | NO  | NO         | 
| MEMORY     | YES     | Hash based, stored in memory, useful for temporary tables      | NO           | NO  | NO         | 
+------------+---------+----------------------------------------------------------------+--------------+-----+------------+
6 rows in set (0.00 sec)

mysql> show plugins;
+------------+--------+----------------+-----------------------+---------+
| Name       | Status | Type           | Library               | License |
+------------+--------+----------------+-----------------------+---------+
| binlog     | ACTIVE | STORAGE ENGINE | NULL                  | GPL     | 
| CSV        | ACTIVE | STORAGE ENGINE | NULL                  | GPL     | 
| MEMORY     | ACTIVE | STORAGE ENGINE | NULL                  | GPL     | 
| InnoDB     | ACTIVE | STORAGE ENGINE | NULL                  | GPL     | 
| MyISAM     | ACTIVE | STORAGE ENGINE | NULL                  | GPL     | 
| MRG_MYISAM | ACTIVE | STORAGE ENGINE | NULL                  | GPL     | 
| MEMCACHE   | ACTIVE | STORAGE ENGINE | libmemcache_engine.so | GPL     | 
+------------+--------+----------------+-----------------------+---------+
7 rows in set (0.00 sec)

mysql> select * from mysql.plugin;
+----------+-----------------------+
| name     | dl                    |
+----------+-----------------------+
| memcache | libmemcache_engine.so | 
+----------+-----------------------+
1 row in set (0.00 sec)

create memcache tables

[root@test mysql-5.1.26-rc]# /service/mysql/bin/mysql -D test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.26-rc-mysql_memcache Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> select @@version;
+--------------------------+
| @@version                |
+--------------------------+
| 5.1.26-rc-mysql_memcache | 
+--------------------------+
1 row in set (0.00 sec)

mysql> create table tab_mem( id int(10) not null default 0, name varchar(50) default null, primary key(id) )engine=memcache connection='localhost:11211';
Query OK, 0 rows affected (0.00 sec)

mysql> insert into tab_mem(id,name) values(1,'zwc'),(2,'ZHONGWC');
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> select * from tab_mem;
Empty set (0.00 sec)

mysql> select * from tab_mem where id =1;
+----+------+
| id | name |
+----+------+
|  1 | zwc  | 
+----+------+
1 row in set (0.00 sec)

mysql> select * from tab_mem where id =2;
+----+---------+
| id | name    |
+----+---------+
|  2 | ZHONGWC | 
+----+---------+
1 row in set (0.00 sec)

mysql> show create table tab_mem\G
*************************** 1. row ***************************
       Table: tab_mem
Create Table: CREATE TABLE `tab_mem` (
  `id` int(10) NOT NULL DEFAULT '0',
  `name` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MEMCACHE DEFAULT CHARSET=utf8 CONNECTION='localhost:11211'
1 row in set (0.00 sec)

mysql> 
mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2013-11-17 00:57:26 | 
+---------------------+
1 row in set (0.00 sec)

mysql> 

NOTE:
1. Memcache engine must have a primary key in the table.
2. Only according to the primary key,in this case,"select * from tab_mem where id =1;".
3. No support auto_incremental id.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值