本篇文章主要是讲如何在Windows操作系统上安装Memcached。
原文地址:Installing Memcached on Windows
在上一篇文章当中,主要先简述了一下Object Caching存在的缺点,接着又说明了一下Memcached可以避免这些缺点,最后,说Memcached的分为两部分:Memcached Server和Memcached Client两部分。本文,就是讲述Memcached Server如何安装。
值得注意的是,Memcached的windows binary主要有两个主要来源:Jellycan和Northscale。之所以强调这个问题,是因为今天上午和下午一直没有安装成功,到后来才发现有这个差异,发现这个差异之后,才安装成功了。
【Memcached的简介】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的由来】Memcached is originally a linux application, but since it is open-source, it has been compiled for windows. 【Memcached的两个主要来源】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
在本文的结尾处,有这6个版本的打包附件,还有一个地址:http://blog.elijaa.org/2010/10/15/memcached-for-windows/
【在1.4.5之前的版本,可以将Memcached安装为Windows的服务】In versions earlier than 1.4.5, memcached can install itself as a service. 【在1.4.5之后,Memcached就不能再安装为Windows服务了】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.
Extract the memcached windows binary to any directroy.
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
Extract the memcached windows binary to any directroy.
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 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
补充一下常用设置
常用设置:
-p <num> 监听的端口
-l <ip_addr> 连接的IP地址, 默认是本机
-d start 启动memcached服务
-d restart 重起memcached服务
-d stop|shutdown 关闭正在运行的memcached服务
-d install 安装memcached服务
-d uninstall 卸载memcached服务
-u <username> 以<username>的身份运行 (仅在以root运行的时候有效)
-m <num> 最大内存使用,单位MB。默认64MB
-M 内存耗尽时返回错误,而不是删除项
-c <num> 最大同时连接数,默认是1024
-f <factor> 块大小增长因子,默认是1.25
-n <bytes> 最小分配空间,key+value+flags默认是48
-h 显示帮助
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 |
---|---|---|
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. |
Source: https://github.com/memcached/memcached/blob/master/doc/protocol.txt
还有一个地方可以下载:http://blog.elijaa.org/2010/10/15/memcached-for-windows/
This post contains various binaries versions of Memcached for Windows as finding some of them may be difficult.
Memcached 1.2.4 for Windows (32 Bits) : memcached 1.2.4 win32.zip
Memcached 1.2.5 for Windows (32 Bits) : memcached 1.2.5 win32.zip
Memcached 1.2.6 for Windows (32 Bits) : memcached 1.2.6 win32.zip
Memcached 1.4.2 for Windows (32 Bits) : memcached 1.4.2 win32.zip
Memcached 1.4.4 for Windows (32 Bits) : memcached 1.4.4 win32.rar
Memcached 1.4.5 for Windows (32 Bits) : memcached 1.4.5 win32.zip
Memcached 1.4.5 for Windows (64 Bits) : memcached 1.4.5 win64.zip
All credits goes to Jellycan for 1.2.5 and 1.2.6 and Northscale (now Membase) for 1.4.X.