CentOS 6.5 x64 Redis 安裝

yum install gcc make

安裝步驟:

    wget http://download.redis.io/releases/redis-2.8.19.tar.gz

    tar zxvf redis-2.8.19.tar.gz

    cd redis-2.8.19/src

    make PREFIX=/usr/local/redis  install

    make install

    mkdir -p /usr/local/redis/bin

    mkdir -p /usr/local/redis/etc

    mv mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-dump redis-cli redis-sentinel redis-server /usr/local/redis/bin/


配置步驟:

     cd /usr/local/redis/etc/

     vim redis.conf

--------------------------------

daemonize yes

pidfile /usr/local/redis/var/redis.pid

port 6379

timeout 300

loglevel debug

logfile /usr/local/redis/var/redis.log

databases 16

save 900 1

save 300 10

save 60 10000

rdbcompression yes

dbfilename dump.rdb

dir /usr/local/redis/var/

appendonly no

appendfsync always

--------------------------------

 mkdir /usr/local/redis/var/

 /usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf

 ps -ef | grep redis

 netstat -ntpl|grep 6379

tcp        0      0 0.0.0.0:6379                0.0.0.0:*                   LISTEN      4852/redis-server *

tcp        0      0 :::6379                     :::*                        LISTEN      4852/redis-server *

 /usr/local/redis/bin/redis-cli

    vim /etc/init.d/redis

-----------------------------------------

#!/bin/sh
#
# redis        init file for starting up the redis daemon
#
# chkconfig:   - 20 80
# description: Starts and stops the redis daemon.

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

name="redis-server"
basedir="/usr/local/redis"
exec="$basedir/bin/$name"
pidfile="$basedir/var/redis.pid"
REDIS_CONFIG="$basedir/etc/redis.conf"

[ -e /etc/sysconfig/redis ] && . /etc/sysconfig/redis

lockfile=/var/lock/subsys/redis

start() {
    [ -f $REDIS_CONFIG ] || exit 6
    [ -x $exec ] || exit 5
    echo -n $"Starting $name: "
    daemon --user ${REDIS_USER-redis} "$exec $REDIS_CONFIG"
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}

stop() {
    echo -n $"Stopping $name: "
    killproc -p $pidfile $name
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}

restart() {
    stop
    start
}

reload() {
    false
}

rh_status() {
    status -p $pidfile $name
}

rh_status_q() {
    rh_status >/dev/null 2>&1
}


case "$1" in
    start)
        rh_status_q && exit 0
        $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    restart)
        $1
        ;;
    reload)
        rh_status_q || exit 7
        $1
        ;;
    force-reload)
        force_reload
        ;;
    status)
        rh_status
        ;;
    condrestart|try-restart)
        rh_status_q || exit 0
        restart
        ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart}"
        exit 2
esac
exit $?

-----------------------------------------

    chmod 755 /etc/init.d/redis


測試redis服務

    redis-cli


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章