# rpm -ivh http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm # rpm -ivh http://rpms.famillecollet.com/enterprise/5/remi/x86_64/remi-release-5-8.el5.remi.noarch.rpm # yum -y --enablerepo=remi,epel install memcached
# cat /etc/sysconfig/memcached
PORT="11211" USER="memcached" MAXCONN="1024" CACHESIZE="64" OPTIONS=""
# /etc/rc.d/init.d/memcached start (# yum -y --enablerepo=remi install php-pecl-memcache)
# chkconfig memcached on
memcached -u daemon -d -m 128 -p 11211 -c 100000 -l 127.0.0.1
set hoge 0 0 3 123 =>STORED
get hoge =>VALUE hoge 0 3 =>123 =>END
# yum -y --enablerepo=remi install php-pecl-memcache
# echo "extension=memcache.so" | sudo tee /etc/php.d/memcache.ini
# /etc/rc.d/init.d/httpd restart
# php -r '$m=new Memcache;$m->connect("memcachedサーバ");print_r($m->getstats());'
出力概要
Array ( [pid] => プロセスID [uptime] => memcachedの起動時間(秒) [time] => 現在時刻のタイムスタンプ [version] => memcacheのバージョン [pointer_size] => OSが32bit又は64bit [rusage_user] => プロセスがユーザモードで動作した累計時間?(秒.マイクロ秒) [rusage_system] => プロセスがカーネルモードで動作した累計時間?(秒.マイクロ秒) [curr_connections] => 現在のコネクション数 [total_connections] => memcacheの起動からの累計コネクション数 [connection_structures] => memcacheが確保したコネクション構造体数 [cmd_get] => GETコマンド発行の累計 [cmd_set] => SETコマンド発行の累計 [cmd_flush] => [get_hits] => リクエストでキーが見つかった数 [get_misses] => リクエストでキーが見つからなかった数 [delete_misses] => [delete_hits] => [incr_misses] => [incr_hits] => [decr_misses] => [decr_hits] => [cas_misses] => [cas_hits] => [cas_badval] => [auth_cmds] => [auth_errors] => [bytes_read] => ネットワークから受信したバイト数 [bytes_written] => ネットワークへ送信したバイト数 [limit_maxbytes] => memcacheの最大容量(バイト) [accepting_conns] => [listen_disabled_num] => [threads] => リクエスト当たりに動作するスレッド数 [conn_yields] => [bytes] => [curr_items] => [total_items] => [evictions] => [reclaimed] => )
# php -r '$m=new Memcache;$m->connect("127.0.0.1");$c=$m->getstats();$c1=$c["get_hits"];$c2=$c["cmd_get"];$c3=($c1<>0 and $c2<>0)?$c1/$c2:0;print $c3;'
# echo 'stats' | nc 127.0.0.1 11211 STAT pid 4574 STAT uptime 13918140 STAT time 1389948852 STAT version 1.4.15 STAT libevent 1.4.13-stable STAT pointer_size 64 STAT rusage_user 908.325913 STAT rusage_system 2409.051768 STAT curr_connections 5 STAT total_connections 17983490 STAT connection_structures 166 STAT reserved_fds 20 STAT cmd_get 17358812 STAT cmd_set 17358229 STAT cmd_flush 0 STAT cmd_touch 0 STAT get_hits 15102293 STAT get_misses 2256519 STAT delete_misses 567296 STAT delete_hits 101671 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 2796046793 STAT bytes_written 2173543015 STAT limit_maxbytes 5368709120 STAT accepting_conns 1 STAT listen_disabled_num 0 STAT threads 4 STAT conn_yields 0 STAT hash_power_level 18 STAT hash_bytes 2097152 STAT hash_is_expanding 0 STAT bytes 21909458 STAT curr_items 125919 STAT total_items 17358229 STAT expired_unfetched 2128513 STAT evicted_unfetched 0 STAT evictions 0 STAT reclaimed 2128513 END
CloudForecastでmemcachedのコネクション数をモニタリング
http://d.hatena.ne.jp/taka512/20100324/1269428213
「stats settings」コマンド
http://blog.nomadscafe.jp/2010/08/cloudforecastmemcached.html
memcached 起動時オプション
http://tech.feedforce.jp/memcached.html
memcachedの安定稼働のためのメモ
http://wiki.livedoor.jp/puriketu99/d/memcached%A4%CE%B0%C2%C4%EA%B2%D4%C6%AF%A4%CE%A4%BF%A4%E1%A4%CE%A5%E1%A5%E2
Memcached
http://webmemo.uzuralife.com/category/336
memcachedコマンド一覧
http://l-w-i.net/t/memcached/command_001.txt