Memcached is a caching daemon designed especially for dynamic web applications to decrease database load by storing objects in memory.
http://www.ibm.com/developerworks/kr/library/os-memcached/index.html
Memcached : http://memcached.org/
PECL:package:memcache : http://pecl.php.net/package/memcache
libevent - an event notification library : http://monkey.org/~provos/libevent/
- memcached
wget http://memcached.googlecode.com/files/memcached-1.4.7.tar.gz
tar xvzf memcached-1.4.7.tar.gz
cd memcached-1.4.7
./configure --with-libevent=/usr/lib/
make && make install
- 테스트 실행
cd /usr/local/memcached
bin/memcached -u 실행사용자 & (실행사용자 root 안됨)
netstat -an | grep 11211
LISTEN 상태 확인
- php-pecl-memcache (memcache extension)
wget http://pecl.php.net/get/memcache-2.2.6.tgz
tar xvfz memcache-2.2.6.tgz
cd memcache-2.2.6
phpize && ./configure --enable-memcache && make
cp libs/memcache.so php설치 경로/modules
vi /etc/php.d/memcache.ini
: extension=memcache.so
// 더 쉬운 방법
php 컴파일 했다면, /usr/bin/php -> /usr/local/php/bin/php 심볼릭링크
# pecl install memcache
ln -s /usr/local/php/lib/php/extensions/no-debug-zts-20060613/memcache.so /usr/lib/php/modules/
php.ini에 extension=memcache.so 추가 후에 아파치 재시작
모듈 확인 : php -m | grep memcache
- memcache 설치 중 checking for libevent directory... configure: error: libevent is required
wget http://monkey.org/~provos/libevent-2.0.13-stable.tar.gz
tar zxvf libevent-2.0.13-stable.tar.gz
cd libevent-2.0.13-stable
./configure
make && make install
ls -l /usr/local/lib/libevent*
ldconfig (vi /etc/ld.so.conf 에 /usr/local/lib 추가)
- 설정 파일
vi /etc/memcached.conf
#Memory a usar
-m 16
# default port
-p 11211
# user to run daemon nobody/apache/www-data
-u nobody
# only listen locally
-l 127.0.0.1
- 데몬 파일
/usr/local/bin/start-memcached
/etc/init.d/memcached
chmod +x /usr/local/bin/start-memcached
chmod +x /etc/init.d/memcached
chkconfig memcached on
chkconfig --list memcached
- 관련 문서
http://www.ibm.com/developerworks/java/library/j-memcached1/
http://download.tangent.org/talks/Memcached%20Study.pdf
memcached test http://dorkage.net/blog/2009/02/05/memcached-test/
//yum 설치
wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm
rpm -ivh rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
yum install memcached php-pecl-memcache memcached-selinux
vi /etc/sysconfig/memcached
PORT="11211"
USER="memcached"
# max connection 2048
MAXCONN="2048"
# set ram size to 2048 - 2GiB
CACHESIZE="4096"
# listen to loopback ip 127.0.0.1, for network connection use real ip e.g., 10.0.0.4
OPTIONS="-l 127.0.0.1
chkconfig memcached on
service memcached start
'Network' 카테고리의 다른 글
Nginx 1.x 413 request entity too large (0) | 2012.02.05 |
---|---|
Server SSL 설정 방법 (0) | 2012.01.18 |
[warn] module php5_module is already loaded, skipping (0) | 2011.12.08 |
LAMP 시스템 조율 (0) | 2011.10.12 |
APACHE 2.x 아파치 모듈 아파치 상태 mod_status (0) | 2010.12.27 |