본문 바로가기
Network

Memcached 설치

by 세계정보ㄱ 2011. 8. 31.
728x90
반응형

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

memcached

start-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


728x90
반응형