1简介:
高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载
示例图:
2运行方式:
读取:
读取操作的顺序是从 Web 层获取请求(需要执行一次数据库查询)并检查之前在缓存中存储的查询结果。如果我找到所需的值,则返回它。如果未找到,则执行查询并将结果存储在缓存中,然后再将结果返回给 Web 层。
写入:
将数据写入到数据库中时,首先需要执行数据库写入操作,然后将之前缓存的任何受此写入操作影响的结果设定为无效。此过程有助于防止缓存和数据库之间出现数据不一致性。
3安装:
异步事件通知库 libevent: http://libevent.org/
缓存系统 memcached: http://www.memcached.org/
[root@localhost libevent-2.0.21-stable]# ./configure
[root@localhost libevent-2.0.21-stable]# make
[root@localhost libevent-2.0.21-stable]# make install
[root@localhost memcached-1.4.20]# chmod +x configure
[root@localhost memcached-1.4.20]# ./configure
[root@localhost memcached-1.4.20]# make
[root@localhost memcached-1.4.20]# make install
4启动命令:
./memcached -d -m 128 -u root -l 192.168.31.137 -p 11211 -c 256 -P /tmp/memcached.pid
-d选项是启动一个守护进程,
-m是分配给Memcache使用的内存数量,单位是MB,我这里是128MB,
-u是运行Memcache的用户,我这里是root,
-l是监听的服务器IP地址,如果有多个地址的话,我这里指定了服务器的IP地址192.168.31.137(不指定为本机)
-p是设置Memcache监听的端口,我这里设置了11211,最好是1024以上的端口,
-c选项是最大运行的并发连接数,默认是1024,我这里设置了256,按照你服务器的负载量来设定,
-P是设置保存Memcache的pid文件,我这里是保存在 /tmp/memcached.pid,
使用netstat -tnlp查看监听
[root@localhost memcached]# ps aux|grep memcached
weblogic 27051 0.0 0.0 54052 844 ? Ssl 14:13 0:00 ./memcached -d -m 1024 -l 192.168.31.137 -p 11211
root 27117 0.0 0.0 5008 652 pts/1 R+ 14:16 0:00 grep memcached
5关闭命令:
kill them
5问题:
1 memacheded在make时报错
make[2]: *** [memacheded] Error 1
make[2]: Leaving directory `/data/soft/memcached-1.4.5'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/data/soft/memcached-1.4.5'
make: *** [all] Error 2
方案:版本问题,重新重新选择
make[2]: *** [testapp.o] Error 1
make[2]: Leaving directory `/data/soft/memcached-1.4.5'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/data/soft/memcached-1.4.5'
make: *** [all] Error 2
方案:注视掉testapp.o的200行(未遇到,待验证)
2 memacached在make时找不到libevent-2.0.so.5的所在的目录
./memcached: error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory
方案:做个软链接
[root@localhost lib]# ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5
3 无法启动memcached(增加-u root)
can't run as root without the -u switch
./memcached -d -m 1024 -l 192.168.31.137 -p 11211 -u root
5下载
MemcachePHP监控
http://livebookmark.net/memcachephp/memcachephp.zip
Memcached-Java-Client
https://github.com/gwhalin/Memcached-Java-Client/downloads
- 大小: 265.9 KB
分享到:
相关推荐
安装Memcached及Memcached配置
安装Memcached及Memcached配置
memcached 共享内存解决方案,memcached安装,使用
详细介绍安装Memcached及Memcached配置
文件详细描述了Memcached相关原理和使用方法,内容包括:Memcached原理介绍、Memcached安装和使用说明、Memcached使用的技巧等。
memcached安装软件 libevent-2.0.21-stable.tar.gz magent.tar.gz memcached-1.4.15.tar.gz
安装Memcached及Memcached配置
-d install 安装memcached服务 -d uninstall 卸载memcached服务 -u 以的身份运行 (仅在以root运行的时候有效) -m 最大内存使用,单位MB。默认64MB -M 内存耗尽时返回错误,而不是删除项 -c 最大同时连接数,默认是...
文档描述了在linux下如何安装JDK,memcached、magent等软件的步骤。
压缩包有: 1、memcached的安装程序 2、PHP_memcached的扩展(5.4.xx)
win7 安装memcached安装,内含有memcached.exe安装资源以及php_memcache5.4-ts
PHP安装memcached
memcached安装,memcached,缓存安装,linux memcached安装
wampsever安装memcached需要的安装包及php_memcached.dll文件
memcached缓存安装使用说明,包含windows和linux的安装和使用 集群
linux下安装memcached详细步骤,加安装包
memcached 安装文件,libevent库, C/C++ memcached 客户端库:libmemcached 全套工具:libevent-1.3.tar.gz,memcached-1.2.2.tar.gz,libmemcached-0.42.tar.gz 测试通过的
linux下memcached安装,不错的学习资源。