memcached centos6.3
memcached1,介绍
Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载。它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提供动态、数据库驱动网站的速度。Memcached基于一个存储键/值对的hashmap。其守护进程(daemon )是用C写的,但是客户端可以用任何语言来编写,并通过memcached协议与守护进程通信。
2,安装
root@cn-dns-test03 Packages]# yum install libevent
# yum install memcached-1.4.4-3.el6.x86_64.rpm
# yum install php-pecl-memcache-3.0.5-4.el6.x86_64.rpm
# memcached -h
# php -m|grep memcache
# chkconfig memcached on
# service memcached start
Starting memcached: [ OK ]
# service memcached status
memcached (pid 10548) is running...
#
3, 配置
# vi /etc/sysconfig/memcached
# cat /etc/sysconfig/memcached
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="512"
OPTIONS=""
#
# vi /etc/php.d/memcache.ini
# cat /etc/php.d/memcache.ini
; ----- Enable memcache extension module
extension=memcache.so
; ----- Options for the memcache module
; Whether to transparently failover to other servers on errors
memcache.allow_failover=1
; Data will be transferred in chunks of this size
memcache.chunk_size=32768
; Autocompress large data
;memcache.compress_threshold=20000
; The default TCP port number to use when connecting to the memcached server
memcache.default_port=11211
; Hash function {crc32, fnv}
memcache.hash_function=crc32
; Hash strategy {standard, consistent}
memcache.hash_strategy=standard
; Defines how many servers to try when setting and getting data.
;memcache.max_failover_attempts=20
; The protocol {ascii, binary} : You need a memcached >= 1.3.0 to use the binary protocol
; The binary protocol results in less traffic and is more efficient
;memcache.protocol=ascii
; Redundancy : When enabled the client sends requests to N servers in parallel
;memcache.redundancy=1
;memcache.session_redundancy=2
; Lock Timeout
;memcache.lock_timeout = 15
; ----- Options to use the memcache session handler
; Use memcache as a session handler
;session.save_handler=memcache
; Defines a comma separated of server urls to use for session storage
;session.save_path="tcp://localhost:11211?persistent=1&weight=1&timeout=1&retry_interval=15"
#
4,常用命令
# ps aux|grep memcached
498 10609 0.0 0.0 330836 988 ? Ssl 09:34 0:00 memcached -d -p 11211 -u memcached -m 64 -c 1024 -P /var/run/memcached/memcached.pid
root 10654 0.0 0.0 103240 840 pts/0 S+ 09:42 0:00 grep memcached
#
# echo stats | netstat -tulpn|grep :11211
tcp 0 0 0.0.0.0:11211 0.0.0.0:* LISTEN 10609/memcached
tcp 0 0 :::11211 :::* LISTEN 10609/memcached
udp 0 0 0.0.0.0:11211 0.0.0.0:* 10609/memcached
udp 0 0 :::11211 :::* 10609/memcached
#
页:
[1]