Sunday, January 8, 2012

Memcached Server Installation

For Windows
1. download memcached for windows (memcached-1.2.6-win32-bin.zip) from here
2. unzip memcached-1.2.6-win32-bin.zip in any folder (e.g., D:\memcached-1.2.6-win32\).
3. install: D:\memcached-1.2.6-win32\memcached.exe -d install.
4. start: memcached.exe -d start.



Yum install
1. using yum to install memcached
# yum install memcached
2. 開機啟動 memcached 設定
# chkconfig memcached on
3. 啟動 memcached server 
# service memcached start
4. 簡單測試 memcached service
# echo stats | nc localhost 11211
會產生以下內容: 
STAT pid 13576
STAT uptime 1114
STAT time 1326179848
STAT version 1.4.10
STAT libevent 1.4.13-stable
STAT pointer_size 64
STAT rusage_user 0.008998
STAT rusage_system 0.013997
STAT curr_connections 13
STAT total_connections 16
STAT connection_structures 14
STAT reserved_fds 20
STAT cmd_get 113
STAT cmd_set 226
STAT cmd_flush 0
STAT cmd_touch 0
STAT get_hits 0
STAT get_misses 113
STAT delete_misses 0
STAT delete_hits 0
STAT incr_misses 0
STAT incr_hits 0
STAT decr_misses 0
STAT decr_hits 0
STAT cas_misses 0
STAT cas_hits 0
STAT cas_badval 0
STAT touch_hits 0
STAT touch_misses 0
STAT auth_cmds 0
STAT auth_errors 0
STAT bytes_read 31426
STAT bytes_written 3403
STAT limit_maxbytes 67108864
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT threads 4
STAT conn_yields 0
STAT hash_power_level 16
STAT hash_bytes 524288
STAT hash_is_expanding 0
STAT expired_unfetched 0
STAT evicted_unfetched 0
STAT bytes 40793
STAT curr_items 226
STAT total_items 226
STAT evictions 0
STAT reclaimed 0
END
5. 參數設定
# vi /etc/sysconfig/memcached
以下為預設參數值: 
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS=""
6. 防火牆設定
# vi/etc/sysconfig/iptables
增加以下內容
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 11211 -j ACCEPT
7. 重新啟動 memcached server
# service memcached restart


For Linux
1. 下载memcached-1.2.1.tar.gz和libevent-1.3b.tar.gz
2. 安装libevent
# tar xvfz  libevent-1.3.tar.gz
# cd libevent-1.3
# ./configure --prefix=/usr
# make & make install
# ls -al /usr/lib | grep libevent
3. 安装 memcached
# tar xvfz  memcached-1.2.5.tar.gz
#  cd  memcached-1.2.5
# ./configure --with-libevent=/usr
#  make & make install
#  ls -al /usr/local/bin/mem*
4. 將 libevent 安裝的/usr/local/lib 輸出到涵式庫路徑
# vi ~/.bash_profile
add the following sentence
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
5.  啟動 memcached: /usr/local/bin/memcached
# memcached  -d  -m 128 -l 192.168.152.143 -p 11211 -u root

No comments:

Post a Comment