memcached1.4.5に対応したrepcaheをインストールしてみる

参考

  • ここで知った。

repcachedのmemcached 1.4対応 - Atzy->getLog()

  • 64bit版だとエラーがでる。
memcached.c:1074:16: error: dereferencing type-punned pointer will break strict-aliasing rules

"-Wstrict-aliasing"で抑止する。
フリーソフトウェア徹底活用講座(12)

Fedora14にインストール

Gitとコンパイルツールをインストール
yum install git
yum install libevent-devel
yum install autoconf automake sysconftool m4
memcachedのインストール
cd /usr/local/src
git clone https://github.com/mdounin/memcached.git
  • repcachedのブランチを引っ張ってくる
cd memcached
git pull origin repcached
export CFLAGS=-Wstrict-aliasing
./configure --enable-replication --enable-64bit
make
make install
mkdir -p /var/run/memcached
chown -R root:root /var/run/memcached
cp -p scripts/memcached-tool /usr/local/bin/.

memcachedのサービス設定

※ 前のコピー Repcacheを調べてみる - sadaharu28の日記

  • 設定ファイル作成

/etc/sysconfig/memcached

PORT=11211
USER=root
MAXCONN=1024
CACHESIZE=640
OPTIONS=
REPHOST=リモート側のノード

/etc/init.d/repcache

#! /bin/sh
#
# chkconfig: - 55 45
# description:  The memcached daemon is a network memory cache service.
# processname: memcached
# config: /etc/sysconfig/memcached
# pidfile: /var/run/memcached/memcached.pid

# Standard LSB functions
#. /lib/lsb/init-functions

# Source function library.
. /etc/init.d/functions

#EXEC=/opt/memcached-1.2.8-repcached-2.2/bin/memcached
EXEC=/usr/local/bin/memcached
REPHOST=localhost

PORT=11211
USER=memcached
MAXCONN=1024
CACHESIZE=64
OPTIONS=""

if [ -f /etc/sysconfig/memcached ];then
        . /etc/sysconfig/memcached
fi

# Check that networking is up.
. /etc/sysconfig/network

if [ "$NETWORKING" = "no" ]
then
        exit 0
fi

RETVAL=0
prog="repcache(memcached)"
pidfile=${PIDFILE-/var/run/memcached/memcached.pid}
lockfile=${LOCKFILE-/var/lock/subsys/memcached}

start () {
        echo -n $"Starting $prog: "
        # Ensure that /var/run/memcached has proper permissions
        if [ "`stat -c %U /var/run/memcached`" != "$USER" ]; then
                chown $USER /var/run/memcached
        fi

        daemon --pidfile ${pidfile} $EXEC -d -x $REPHOST -p $PORT -u $USER  -m $CACHESIZE -c $MAXCONN -P ${pidfile} $OPTIONS
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch ${lockfile}
}
stop () {
        echo -n $"Stopping $prog: "
        killproc -p ${pidfile} $EXEC
        RETVAL=$?
        echo
        if [ $RETVAL -eq 0 ] ; then
                rm -f ${lockfile} ${pidfile}
        fi
}

restart () {
        stop
        start
}

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        status -p ${pidfile} $prog
        RETVAL=$?
        ;;
  restart|reload|force-reload)
        restart
        ;;
  condrestart|try-restart)
        [ -f ${lockfile} ] && restart || :
        ;;
  *)
        echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart|try-restart}"
        RETVAL=2
        ;;
esac

exit $RETVAL
chmod +x /etc/init.d/repcache
chkconfig --add repcache
chkconfig repcache on
chkconfig --list | grep repcache
  • サービスとして起動&停止
service repcache start
service repcache stop