1. XenForo 1.5.14 中文版——支持中文搜索!现已发布!查看详情
  2. Xenforo 爱好者讨论群:215909318 XenForo专区

安装 memcached 服务端

本帖由 admin2013-04-12 发布。版面名称:应用交流

  1. admin

    admin 管理员 管理成员

    注册:
    2011-11-01
    帖子:
    3,671
    赞:
    2,425
    代码:
    wget -c http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz
    tar xvfz memcached-1.4.15.tar.gz
    cd memcached-1.4.15
    ./configure --prefix=/usr/local/memcache --with-libevent=/usr
    make
    make install 
    memcached至/etc/rc.d/init.d/
    代码:
    #! /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=11211
    USER=root
    MAXCONN=1024
    CACHESIZE=256
    OPTIONS=""
    
    if [ -f /etc/sysconfig/memcached ];then
        . /etc/sysconfig/memcached
    fi
    
    # Check that networking is up.
    if [ "$NETWORKING" = "no" ]
    then
        exit 0
    fi
    
    RETVAL=0
    
    start () {
        echo "Starting memcached ..."
        # insure that /var/run/memcached has proper permissions
        chown $USER /usr/local/memcache/bin/memcached
        /usr/local/memcache/bin/memcached -d -p $PORT -u $USER -m $CACHESIZE -c $MAXCONN -P /var/run/memcached.pid $OPTIONS
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/memcached
    }
    stop () {
        echo "Stopping memcached ..."
        killproc memcached
        RETVAL=$?
        echo
        if [ $RETVAL -eq 0 ] ; then
            rm -f /var/lock/subsys/memcached
            rm -f /var/run/memcached.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 ] && restart || :
        ;;
        *)
        echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
        exit 1
    esac
    
    exit $?
    chmod +x /etc/init.d/memcached
    chkconfig --add memcached
    chkconfig --level 235 memcached on
    service memcached start
     

    附件文件:

    最后编辑: 2014-03-09
正在加载...