验证InnoDB和memcached安装
3. 验证InnoDB和memcached安装现在都安装好了,你需要将InnoDB和memcached连接起来:
# Point memcached-related commands at the memcached attached to the mysqld process.
export MEMCACHED_SERVERS=127.0.0.1:11211
# Store the contents of a modestly sized text file in memcached, with the data passed
# to MySQL and stored in a table. The key is the basename of the file, 'mime.types'.
memcp /etc/apache2/mime.types
# Retrieve the data we just stored, from the memory cache.
memcat mime.types
这里有一个通过ASCII协议,使用telnet来发送memcached命令,接收结果的示例:
telnet 127.0.0.1 11211
set a11 10 0 9
123456789
STORED
get a11
VALUE a11 0 9
123456789
END
quit
为了说明同样的数据已经存储到MySQL,连接到MySQL服务器,并执行:
mysql> select * from test.demo_test; 现在,关闭MySQL服务,也同时关闭了集成的memcached服务。后面尝试访问memcached数据,失败并返回连接错误。一般情况下,memcached数据这时会消失,你会写应用程序逻辑来当memcached重启后将数据导入到内存。但是MySQL / memcached集成自动化了这个过程:
? 重启MySQL服务。
? 运行install plugin语句,再次启动InnoDB memcached插件。
? 现在任何memcat命令或get操作再次返回你存储在早期memcached会话中的键/值对。当请求键,而相应的值已经不在内存缓存中,它自动从MySQL表中查询,默认test.demo_test。
页:
[1]