ラベル memcached の投稿を表示しています。 すべての投稿を表示
ラベル memcached の投稿を表示しています。 すべての投稿を表示

2011年9月1日木曜日

memcached を複数起動する方法

memcachedを複数動かしたいと言われたので対応。

■ /etc/sysconfig/memcached を適当にコピーして変更
# cp /etc/sysconfig/memcached /etc/sysconfig/memcached-2

PORT="11212"
USER="nobody"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS=""
■ /etc/init.d/memcached を適当にコピーして変更

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

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

PORT=11212
USER=nobody
MAXCONN=1024
CACHESIZE=64
OPTIONS=""

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

# Check that networking is up.
if [ "$NETWORKING" = "no" ]
then
    exit 0
fi

RETVAL=0
prog="memcached"

start () {
    echo -n $"Starting $prog: "
    # insure that /var/run/memcached has proper permissions
    chown $USER /var/run/memcached
    daemon memcached -d -p $PORT -u $USER  -m $CACHESIZE -c $MAXCONN -P /var/run/memcached/memcached-2.pid $OPTIONS
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/memcached-2
}
stop () {
    echo -n $"Stopping $prog: "
    killproc memcached
    RETVAL=$?
    echo
    if [ $RETVAL -eq 0 ] ; then
        rm -f /var/lock/subsys/memcached-2
        rm -f /var/run/memcached-2.pid
    fi
}

restart () {
    stop
    start
}


# See how we were called.
case "$1" in
    start)
        start
        ;;
    stop)
    stop
    ;;
    status)
    status memcached
    ;;
    restart|reload)
    restart
    ;;
    condrestart)
    [ -f /var/lock/subsys/memcached-2 ] && restart || :
    ;;
    *)
    echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
    exit 1
esac

exit $?
ロックファイルとpidファイルだけリネームしておけばよさそう。

■ chkconfigに登録と起動
# chkconfig --add memcached-2
# service memcached-2 start
※chkconfig動いてない場合は、普通に/etc/init.d/memcached-2 start で起動する

■ 変更したポートで動いてるか確認
# telnet localhost 11212
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
set foo 0 100 4
test
STORED
get foo
VALUE foo 0 4
test
END
めでたし。

2011年5月30日月曜日

memcachedのmake testでエラー

前回とは違う環境下でmemcachedをrpmbuildしてたんだけど、以下のエラーが。
プロジェクトサイトにもIssueとして報告があがってて、 どうやらシングルコアのcpuだとbinary.tのテストに失敗するっぽい。
マルチコア環境だとエラーは出ないので、原因はCPUのコア数みたい・・・。勘弁してよって感じ。
#   Failed test 'Expected read length'
#   in t/binary.t at line 539.
#          got: '10'
#     expected: '24'
Use of uninitialized value in multiplication (*) at t/binary.t line 545.
Use of uninitialized value in addition (+) at t/binary.t line 545.
Use of uninitialized value in numeric eq (==) at t/binary.t line 547.
t/binary.............NOK 243
#   Failed test 'Expected read length'
#   in t/binary.t at line 539.
#          got: '14'
#     expected: '24'
t/binary.............NOK 244
#   Failed test 'Got proper response magic'
#   in t/binary.t at line 543.
#          got: '0'
#     expected: '129'
Use of uninitialized value in multiplication (*) at t/binary.t line 545.
Use of uninitialized value in addition (+) at t/binary.t line 545.
t/binary.............NOK 251
#   Failed test 'Flags is set properly'
#   in t/binary.t at line 63.
#          got: undef
#     expected: '19'
Argument "somevalue" isn't numeric in numeric eq (==) at t/binary.t line 64.
Argument "" isn't numeric in numeric eq (==) at t/binary.t line 64.
t/binary.............NOK 255
#   Failed test 'Expected opaque'
#   in t/binary.t at line 560.
#          got: '38518301'
#     expected: '3628040576'
t/binary.............NOK 258
#   Failed test 'Didn't get a result from get'
#   in t/binary.t at line 76.
#          got: '3'
#     expected: '0'
Can't call method "not_found" without a package or object reference at t/binary.t line 77.
# Looks like you planned 3361 tests but only ran 258.
# Looks like you failed 6 tests of 258 run.
# Looks like your test died just after 258.
t/binary.............dubious
        Test returned status 255 (wstat 65280, 0xff00)
DIED. FAILED tests 240, 243-244, 251, 255, 258-3361
        Failed 3109/3361 tests, 7.50% okay