[转]Installing Memcached on Windows
Installing Memcached on Windows
Memcached is a high performance, in-memory key-value store or caching system. Its main purpose is to speed up web applications by caching database queries, contents, or other computed results.
Memcached is originally a linux application, but since it is open-source, it has been compiled for windows. There are two major sources for the pre-built windows binary: Jellycan and Northscale, and both versions can be used. The following are the download links for the memcached windows binaries:
http://code.jellycan.com/files/memcached-1.2.5-win32-bin.zip
http://code.jellycan.com/files/memcached-1.2.6-win32-bin.zip
http://downloads.northscale.com/memcached-win32-1.4.4-14.zip
http://downloads.northscale.com/memcached-win64-1.4.4-14.zip
http://downloads.northscale.com/memcached-1.4.5-x86.zip
http://downloads.northscale.com/memcached-1.4.5-amd64.zip
In versions earlier than 1.4.5, memcached can install itself as a service. However, the ability to run memcached as a service is removed since version 1.4.5. Therefore, the installation steps are divided into two categories, part A for memcached prior to version 1.4.5. and part B for memcached version 1.4.5 and later.
A) Installation of memcached < 1.4.5:
- Extract the memcached windows binary to any directory.
- In versions earlier than 1.4.5, memcached can install itself as a service. Run a command prompt with elevated privileges, and type:
c:\memcached\memcached.exe -d install
* Replace c:\memcached\memcached.exe with the actual path of your installation.
- Then, start or stop the memcached service with the following command:
c:\memcached\memcached.exe -d start
c:\memcached\memcached.exe -d stop - To change the configuration of memcached, run regedit.exe and navigate to the key "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\memcached". Suppose you wish to increase the memory limit of memcached, edit the value of ImagePath to the following:
"c:\memcached\memcached.exe" -d runservice -m 512
* Besides '-m 512', you may also append other memcached parameters to the path. Run "c:\memcached\memcached.exe -h" to view the list of available parameters.
- Meanwhile, to uninstall the memcached serivce, run the following command:
c:\memcached\memcached.exe -d uninstall
B) Installation of memcached >= 1.4.5:
- Extract the memcached windows binary to any directory.
- In version 1.4.5 or later, memcached cannot run as a service. It must be started as a normal process using the task scheduler. To configure the memcached process to run automatically every time windows start, run a command prompt with elevated privileges, and type the following:
schtasks /create /sc onstart /tn memcached /tr "'c:\memcached\memcached.exe' -m 512"
* Replace c:\memcached\memcached.exe with the actual path of your installation.
** Besides '-m 512', you may also append other memcached parameters to the path. Run "c:\memcached\memcached.exe -h" to view the list of available parameters. - Meanwhile, to remove the scheduled memcached task, run the following command:
schtasks /delete /tn memcached
Integrating with PHP
To interface with memcached in PHP, you need to install the memcache extension for PHP:
- Check that your PHP extension folder has the file php_memcache.dll. If not, download the file from https://pecl.php.net/package/memcache (select the windows dll file), and place it in the PHP extension folder.
- Add the following line in php.ini to enable the memcache extension.
extension=php_memcache.dll - Create this simple php script file to test that it works.
<?php $memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ("Could not connect"); $version = $memcache->getVersion();
echo "Server's version: ".$version."<br/>\n"; $tmp_object = new stdClass;
$tmp_object->str_attr = 'test';
$tmp_object->int_attr = 123; $memcache->set('key', $tmp_object, false, 10) or die ("Failed to save data at the server");
echo "Store data in the cache (data will expire in 10 seconds)<br/>\n"; $get_result = $memcache->get('key');
echo "Data from the cache:<br/>\n"; var_dump($get_result); ?>
Integrating with Python
To interface with memcached in Python, you need to install the memcached client for Python.
- Execute one of the following command to install the memcached client. The first is for Python 2.x while the second is for Python 3.x.
pip install python-memcached
pip install python3-memcached - Create this simple python script to test that it works.
import memcache
mc = memcache.Client(['127.0.0.1:11211'], debug=0)
mc.set("some_key", "Some value")
value = mc.get("some_key")
mc.set("another_key", 3)
mc.delete("another_key")
mc.set("key", "1") # note that the key used for incr/decr must be a string.
mc.incr("key")
mc.decr("key")
Memcached statistics
To view the statistics for memcached, bring up a telnet connection to memcached by the command:
telnet 127.0.0.1 11211
Then, type stats and enter.
Here is an explanation of the different memcached stats.
| Name | Type | Meaning |
|---|---|---|
| pid | 32u | Process id of this server process |
| uptime | 32u | Number of secs since the server started |
| time | 32u | current UNIX time according to the server |
| version | string | Version string of this server |
| pointer_size | 32 | Default size of pointers on the host OS (generally 32 or 64) |
| rusage_user | 32u.32u | Accumulated user time for this process (seconds:microseconds) |
| rusage_system | 32u.32u | Accumulated system time for this process (seconds:microseconds) |
| curr_items | 32u | Current number of items stored |
| total_items | 32u | Total number of items stored since the server started |
| bytes | 64u | Current number of bytes used to store items |
| curr_connections | 32u | Number of open connections |
| total_connections | 32u | Total number of connections opened since the server started running |
| connection_structures | 32u | Number of connection structures allocated by the server |
| reserved_fds | 32u | Number of misc fds used internally |
| cmd_get | 64u | Cumulative number of retrieval reqs |
| cmd_set | 64u | Cumulative number of storage reqs |
| cmd_flush | 64u | Cumulative number of flush reqs |
| cmd_touch | 64u | Cumulative number of touch reqs |
| get_hits | 64u | Number of keys that have been requested and found present |
| get_misses | 64u | Number of items that have been requested and not found |
| delete_misses | 64u | Number of deletions reqs for missing keys |
| delete_hits | 64u | Number of deletion reqs resulting in an item being removed. |
| incr_misses | 64u | Number of incr reqs against missing keys. |
| incr_hits | 64u | Number of successful incr reqs. |
| decr_misses | 64u | Number of decr reqs against missing keys. |
| decr_hits | 64u | Number of successful decr reqs. |
| cas_misses | 64u | Number of CAS reqs against missing keys. |
| cas_hits | 64u | Number of successful CAS reqs. |
| cas_badval | 64u | Number of CAS reqs for which a key was found, but the CAS value did not match. |
| touch_hits | 64u | Numer of keys that have been touched with a new expiration time |
| touch_misses | 64u | Numer of items that have been touched and not found |
| auth_cmds | 64u | Number of authentication commands handled, success or failure. |
| auth_errors | 64u | Number of failed authentications. |
| evictions | 64u | Number of valid items removed from cache to free memory for new items |
| reclaimed | 64u | Number of times an entry was stored using memory from an expired entry |
| bytes_read | 64u | Total number of bytes read by this server from network |
| bytes_written | 64u | Total number of bytes sent by this server to network |
| limit_maxbytes | 32u | Number of bytes this server is allowed to use for storage. |
| threads | 32u | Number of worker threads requested. (see doc/threads.txt) |
| conn_yields | 64u | Number of times any connection yielded to another due to hitting the -R limit. |
| hash_power_level | 32u | Current size multiplier for hash table |
| hash_bytes | 64u | Bytes currently used by hash tables |
| hash_is_expanding | bool | Indicates if the hash table is being grown to a new size |
| expired_unfetched | 64u | Items pulled from LRU that were never touched by get/incr/append/etc before expiring |
| evicted_unfetched | 64u | Items evicted from LRU that were never touched by get/incr/append/etc. |
| slab_reassign_running | bool | If a slab page is being moved |
| slabs_moved | 64u | Total slab pages moved |
| crawler_reclaimed | 64u | Total items freed by LRU Crawler |
| lrutail_reflocked | 64u | Times LRU tail was found with active ref. Items moved to head to avoid OOM errors. |
| Name | Type | Meaning |
Source: https://github.com/memcached/memcached/blob/master/doc/protocol.txt
另,stackoverflow:
http://stackoverflow.com/questions/8896/can-i-get-memcached-running-on-a-windows-x64-64bit-environment
North Scale labs have released a build of memcached 1.4.4 for Windows x64:
http://blog.couchbase.com/memcached-windows-64-bit-pre-release-available
http://labs.northscale.com/memcached-packages/
UPDATE: they have recently released Memcached Server - still FREE but enhanced distro with clustering, web-based admin/stats UI etc. (I'm not related to them in any way) Check it out at http://northscale.com/products/memcached.html and download at: http://www.northscale.com/download.php?a=d
UPDATE 2: NorthScale Memcached is no longer available as a standalone download. Now they have made it part of their commercial No-SQL DB offering called Membase. It can be configured to run in Memcached-only mode (i.e. without persistence) and there's a 100% free version too. Check it out here: http://www.membase.org/downloads
UPDATE 3: MemBase has slept with CouchDB and produced a hybrid product offering, called CouchBase. They still do offer a free "Community" version at http://www.couchbase.com/download
[转]Installing Memcached on Windows的更多相关文章
- Memcached在windows下安装与使用
建议:windows系统下仅为测试所有,生产环境下服务端应使用Linux系统. 本文最后更新于:2014-08-03 18:24 原文:http://www.yaosansi.com/post/mem ...
- Memcached 在windows环境下安装
1.memcached简介 memcached是一个高性能的分布式内存对象缓存系统,它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态.数据库驱动应用的访问性 能.memcached基于 ...
- memcached 在windows下安装及启动
memcached 在windows下安装及启动 Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载.它通过在内存中缓存数据和对象来减少读取数据库的次数, ...
- Memcached for windows x64 x32 安装
Memcached for windows 一.安装Memcached 1.下载 Memcached32位:http://s3.amazonaws.com/downloads.northscale.c ...
- (转)Memcached 在windows下的java使用
Memcached 在windows下的java使用 研究这个东东主要是为了解决在教务管理中选课系统的大并发情况下数据库频繁读写造成速度慢的问题,但要使用WEB服务器的内存,是不是可靠还需要验证, ...
- memcached在windows下多实例并存
文章来源:http://blog.csdn.net/xingxing513234072/article/details/39343999 memcached.exe的-d install命令安装时其他 ...
- memcached for windows 修改端口和最大内存,以及常用命令
在windows中使用memcached,必须先下载memcached for win32安装. PHP模块MemCache下载地址:http://downloads.php.net/pierre 服 ...
- memcached for windows 修改端口和最大内存
解压后只要在命令窗口中输入下面命令c:\memcached\memcached.exe -d install 就可以把memcached安装为windows服务了. 启动该服务后,memcached ...
- memcached在windows下的安装与命令使用方法
先下载memcached for win32 下载地址1:http://filemarkets.com/fs/8tdo6ndg41d919599/ 下载地址2:http://www.400gb.com ...
随机推荐
- 浅谈HTML5中的浮动问题
浮动是我们在前端页面中经常会用到的一种布局方式.那什么是浮动呢? 首先我们先来看一下它的定义.浮动是指让元素脱离文档标准流(脱标),按照指定的方向去横向排列.浮动的取值有两个,分别是float:lef ...
- IE浏览器下使用AJAX登陆接口请求缓存与登陆不了的问题解决
问题: 在IE浏览器下面,登陆的时候老是登陆不上,但是打开控制台的时候再登陆却能登陆上. 分析: 通过抓包,发现,在不打开控制台的时候,少了一个接口的请求,却返回了改接口的返回信息,但是返回信息并不是 ...
- 009 Java集合浅析4
前面一篇教程中,我们分析了List派别中的最常见也最重要的一个类ArrayList<E>.从我们的分析来看,ArrayList作为动态数组的模拟,使用的是连续内存空间来存储数据,带来了可随 ...
- 基于Spring Cloud和Netflix OSS构建微服务,Part 2
在上一篇文章中,我们已使用Spring Cloud和Netflix OSS中的核心组件,如Eureka.Ribbon和Zuul,部分实现了操作模型(operations model),允许单独部署的微 ...
- Android使用Aspectj
使用AspectJ 集成步骤: 1.AS配置Aspectj环境 2.配置使用ajc编译 4.定义注解 5.配置规则 6.使用 7.注意事项 AS配置Aspectj环境.Aspect目前最新版本为 1. ...
- .Net轻量级ORM-NPoco的使用方法-摘自NPoco国外官方Wiki
文章引用自NPoco官方Wiki,地址:https://github.com/schotime/NPoco/wiki,因公司网络不稳定,有时无法访问,特将其摘抄. Home Adam Schroder ...
- Centos6.8 安装 nginx
rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm ...
- Spring Boot 注解的使用
Spring Boot 优于Spring mvc ,SSM,SSH 的一个亮点就是他使用了好多的注解. 1. @Autowired 这个注解的作用是将其他的类,接口引入,类似于之前的类的初始化等,用这 ...
- DBProxy 入门到精通系列(二):DBProxy快速入门教程
这里主要用来了解有关DBProxy方面的部署及基本的配置,以及模拟架构 1 DBProxy方面的安装部署 1)基础环境的部署 # .x86_64 Percona-Server-client-.x86_ ...
- centos6.5 源码安装 gtk 环境
解决 No package 'gtk+-2.0′ found问题方法:yum install libgnomeui-devel 执行了上面的,下面的就可以放弃了,yum 大法好 首先 yum 安装下面 ...