笔记:在CentOS 5.8中通过yum安装Redis

1、导入epel yum源:
32位机器:rpm -Uvh http://mirrors.ustc.edu.cn/fedora/epel/5/i386/epel-release-5-4.noarch.rpm
65位机器:rpm -Uvh http://mirrors.ustc.edu.cn/fedora/epel/5/x86_64/epel-release-5-4.noarch.rpm
2、yum安装:
yum -y install redis
3、添加到自动启动项:
chkconfig redis on
4、启动:
service redis start
5、配置文件:
/etc/redis.conf
6、测试:
redis-cli
set myKey myValue
get myKey

启动脚本

#!/bin/bash
#
# redis    Startup script for redis processes
#
# author: snowolf
#
# processname: redis


redis_path="/usr/local/bin/redis-server"
redis_conf="/etc/redis/redis.conf"
redis_pid="/var/run/redis.pid"


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


[ -x $redis_path ] || exit 0


RETVAL=0
prog="redis"




# Start daemons.
start() {
    if [ -e $redis_pid -a ! -z $redis_pid ];then
        echo $prog" already running...."
        exit 1
    fi


    echo -n $"Starting $prog "
    # Single instance for all caches
    $redis_path $redis_conf
    RETVAL=$?
    [ $RETVAL -eq 0 ] && {
        touch /var/lock/subsys/$prog
        success $"$prog"
    }
    echo
    return $RETVAL
}




# Stop daemons.
stop() {
    echo -n $"Stopping $prog "
    killproc -d 10 $redis_path
    echo
    [ $RETVAL = 0 ] && rm -f $redis_pid /var/lock/subsys/$prog


    RETVAL=$?
    return $RETVAL
}




# See how we were called.
case "$1" in
        start)
            start
            ;;
        stop)
            stop
            ;;
        status)
            status $prog
            RETVAL=$?
            ;;
        restart)
            stop
            start
            ;;
        condrestart)
            if test "x`pidof redis`" != x; then
                stop
                start
            fi
            ;;
        *)
            echo $"Usage: $0 {start|stop|status|restart|condrestart}"
            exit 1
esac
exit $RETVAL

转:http://snowolf.iteye.com/blog/1630697
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值