一 、安裝
[root@master opt]# tar -zxvf memcached-1.4.25.tar.gz
[root@master opt]# mv memcached-1.4.25 memcached
[root@master opt]# cd memcached
[root@master memcached]# ./configure
checking for library containing gethostbyname... none required
checking for libevent directory... configure: error: libevent is required. you can get it from
if it's already installed, specify its path using --with-libevent=/dir/
解決方案:
[root@master opt]# wget
[root@master opt]# tar -zxvf libevent-1.4.14b-stable.tar.gz
[root@master opt]# cd libevent-1.4.14b-stable
[root@master libevent-1.4.14b-stable]# #./configure --prefix=/usr
[root@master libevent-1.4.14b-stable]# make && make install
重新編譯配置memcached
[root@master memcached]# ./configure --with-libevent=/usr
[root@master memcached]# make && make install
二 、啟動
1.啟動memcache的伺服器端:
# /usr/local/bin/memcached -d -m 10 -u root -l 192.168.0.200 -p 12000 -c 256 -p /tmp/memcached.pid
-d選項是啟動乙個守護程序,
-m是分配給memcache使用的記憶體數量,單位是mb,我這裡是10mb,
-u是執行memcache的使用者,我這裡是root,
-l是監聽的伺服器ip位址,如果有多個位址的話,我這裡指定了伺服器的ip位址192.168.0.200,
-p是設定memcache監聽的埠,我這裡設定了12000,最好是1024以上的埠,
-c選項是最大執行的併發連線數,預設是1024,我這裡設定了256,按照你伺服器的負載量來設定,
-p是設定儲存memcache的pid檔案,我這裡是儲存在 /tmp/memcached.pid,
2.如果要結束memcache程序,執行:
# kill `cat /tmp/memcached.pid`
也可以啟動多個守護程序,不過埠不能重複。
驗證是否啟動成功
[root@master memcached]# netstat -tnpl |grep 11211
tcp 0 0 127.0.0.1:11211 0.0.0.0:* listen 19061/memcached
三 、測試
[root@master ~]# telnet 127.0.0.1 11211
trying 127.0.0.1...
connected to localhost.localdomain (127.0.0.1).
escape character is '^]'.
stats
stat pid 19061
stat uptime 586
stat time 1451687276
stat version 1.4.25
stat libevent 1.4.14b-stable
stat pointer_size 64
stat rusage_user 0.008998
stat rusage_system 0.046992
stat curr_connections 6
stat total_connections 7
stat connection_structures 7
stat reserved_fds 20
stat cmd_get 2
stat cmd_set 0
stat cmd_flush 0
stat cmd_touch 0
stat get_hits 0
stat get_misses 2
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 193
stat bytes_written 108
stat limit_maxbytes 134217728
stat accepting_conns 1
stat listen_disabled_num 0
stat time_in_listen_disabled_us 0
stat threads 4
stat conn_yields 0
stat hash_power_level 16
stat hash_bytes 524288
stat hash_is_expanding 0
stat malloc_fails 0
stat bytes 0
stat curr_items 0
stat total_items 0
stat expired_unfetched 0
stat evicted_unfetched 0
stat evictions 0
stat reclaimed 0
stat crawler_reclaimed 0
stat crawler_items_checked 0
stat lrutail_reflocked 0
end>>set key 33 0 4 \r\n
1234
stored
>>get key 33
value key 33 4
1234
endquit
connection closed by foreign host.
[root@master ~]#
在Linux上安裝Memcached服務
2.先安裝libevent tar zxvf libevent 1.2.tar.gz cd libevent 1.2 configure prefix usr make make install 3.測試libevent是否安裝成功 ls al usr lib grep libevent lrwxr...
在Linux上安裝Memcached服務
2.先安裝libevent tar zxvf libevent 1.2.tar.gz cd libevent 1.2 configure prefix usr make make install 3.測試libevent是否安裝成功 ls al usr lib grep libevent lrwxr...
在Linux上安裝Memcached服務
2.先安裝libevent tar zxvf libevent 1.2.tar.gz cd libevent 1.2 configure prefix usr make make install 3.測試libevent是否安裝成功 ls al usr lib grep libevent lrwxr...