Inicio » memcached » Pasos para la instalación de memcached

Pasos para la instalación de memcached

Creación del usuario:

#groupadd memcached
#useradd -u 504 -d /users/memcached -g memcached -c "User for memcached" memcached
#passwd memcached
#chage -M -1 memcached

Colocar en /usr/local/src

libevent-2.0.21-stable.tar.gz
Colocar en /var/spool/pkg
memcached-1.4.20.tar.gz
Crear los siguietes directorios:
/opt/memcached/bin
/opt/memcached/conf
mkdir /var/run/memcached
chown memcached:memcached /var/run/memcached
mkdir /var/lock/subsys/memcached
chown root:root /var/lock/subsys/memcached
chown memcached:memcached /opt/memcached/
chown memcached:memcached /opt/memcached/bin
chown memcached:memcached /opt/memcached/conf

Primero hay que instalar las librerias libevent
La API libevent es un notificador de eventos asincrono.

Esto lo haremos como usuario root
cd /usr/local/src
# tar zxvf libevent-2.0.21-stable.tar.gz
# cd libevent-2.0.21-stable
# ./configure
# make && make install

Es necesario añadir este link a la instalacion de lebevent

#ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5

Ahora instalamos como memcached, el software
cd /var/spool/pkg
tar zxvf memcached-1.4.20.tar.gz
cd memcached-1.4.20
./configure –prefix=/opt/memcached –enable-64bit
//Con la opcion prefix indicamos sobre que directorio lo queremos instalar
make && make install

rm -rf memcached-1.4.20
rm -rf memcached-1.4.20.tar.gz

como root

Creamos un link para la referencia del man
ln -s /opt/memcachedshare/man/man1/memcached.1 /usr/share/man/man1/memcached.1
Creamos el fichero de arranque del servicio, más adelante está el código
/etc/init.d/memcached
chmod 755 /etc/init.d/memcached
mkdir /var/run/memcached

chkconfig memcached on
chkconfig –list | grep memcached

Fichero de arranque

#! /bin/sh
#
# chkconfig: - 55 45
# description: The memcached daemon is a network memory cache service.
# processname: memcached
# config: /opt/memcached/conf/memcached
# Source function library.
. /etc/rc.d/init.d/functions
PORT=11211
USER=memcached
MAXCONN=1024
CACHESIZE=64
OPTIONS=""
if [ -f /opt/memcached/conf/memcached ];then
 . /opt/memcached/conf/memcached
 #Esto un fichero de configuracion con las opciones de arranque
fi
# Check that networking is up.
 . /etc/sysconfig/network
if [ "$NETWORKING" = "no" ]
then
 exit 0
fi
RETVAL=0
prog="memcached"
pidfile=/var/run/memcached/memcached.pid
lockfile=/var/lock/subsys/memcached
basedir=/opt/memcached/bin
start () {
 
 echo -n $"Starting $prog: "
 # insure that /var/run/memcached has proper permissions
 #chown $USER /var/run/memcached
 
 daemon ${basedir}/memcached -d -p $PORT -u $USER -m $CACHESIZE -c $MAXCONN -P ${pidfile} -l $ADDRESS -b $BACKLOGQ -R $REQXEVEP -t $THREADS -k $OPTIONS
 RETVAL=$?
 echo
 
 [ $RETVAL -eq 0 ] && touch ${lockfile}
}
stop () {
 echo -n $"Stopping $prog: "
 killproc memcached
 RETVAL=$?
 echo
 if [ $RETVAL -eq 0 ] ; then
 rm -f ${lockfile}
 rm -f ${pidfile}
 fi
}
restart () {
 stop
 start
}
# See how we were called.
case "$1" in
 start)
 start
 ;;
 stop)
 stop
 ;;
 status)
 status -p ${pidfile} memcached
 RETVAL=$?
 ;;
 restart|reload)
 restart
 ;;
 condrestart)
 [ -f /var/lock/subsys/memcached ] && restart || :
 ;;
 *)
 echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
 exit 1
esac
exit $?

Ejemplo del /opt/memcached/conf/memcached

#TCP port to use for connections. -p
PORT="18080"
#User for executing memcached -u
USER="memcached"
#Maximum number of simultaneous connections to the memcached service. -c
MAXCONN="1024"
#Memory allocated to memcached for object storage. -m
CACHESIZE="512"
#Network interface/address to listen for connections -l
ADDRESS="127.0.0.1"
#backlog queue limit. -b
BACKLOGQ="1024"
#Maximum number of requests per event process -R
REQXEVEP="20"
#Number of threads to use when processing incoming requests.
THREADS="4"
#Log level.
#Verbose mode. Prints errors and warnings
#OPTIONS="-v >> /var/opt/memcached/logs/memcached.log 2>&1"
#Verbose mode. Prints errors and warnings + client command and the response
#OPTIONS="-vv >> /var/opt/memcached/logs/memcached.log 2>&1"
#Verbose mode. Prints errors and warnings + client command and the response + internal state transitions
#OPTIONS="-vvv >> /var/opt/memcached/logs/memcached.log 2>&1"

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s