CentOS 6.3 安装 Redis

1.tar-zvxfredis-3.0.0.tar.gz

2.cdredis-3.0.0

3.makePREFIX=/usr/local/redisinstall

4.mkdir-p/etc/redis

5.cpredis.conf/etc/redis

cdsrc

cp-pfredis-server/usr/local/bin

cp-pfredis-benchmark/usr/local/bin

cp-pfredis-cli/usr/local/bin

cp-pfredis-check-dump/usr/local/bin

cp-pfredis-check-aof/usr/local/bin

6.mkdir-p/data/logs/redis

7.vi/etc/redis/redis.conf

daemonizeyes#redis以后台进程运行

pidfile/var/run/redis.pid#给后台进程绑定一个PID

loglevelnotice#日志级别

logfile/data/logs/redis/redis.log#日志文件

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

9./usr/local/bin/redis-cli-hlocalhost

setnameadmin

OK

getname

"admin"

10.配置开机启动Redis

#cd/etc/rc.d/init.d

#touchredisd

#chmod+xredisd

#viredisd

添加如下内容:

#!/bin/sh

#chkconfig:3458613

#description:StartupandshutdownscriptforRedis

PROGDIR=/usr/local/bin/

PROGNAME=redis-server

DAEMON=$PROGDIR/$PROGNAME

CONFIG=/etc/redis/redis.conf

PIDFILE=/var/run/redis.pid

DESC="redisdaemon"

SCRIPTNAME=/etc/rc.d/init.d/redisd

start()

{

iftest-x$DAEMON

then

echo-e"Starting$DESC:$PROGNAME"

if$DAEMON$CONFIG

then

echo-e"OK"

else

echo-e"failed"

fi

else

echo-e"Couldn'tfindRedisServer($DAEMON)"

fi

}

stop()

{

iftest-e$PIDFILE

then

echo-e"Stopping$DESC:$PROGNAME"

ifkill`cat$PIDFILE`

then

echo-e"OK"

else

echo-e"failed"

fi

else

echo-e"NoRedisServer($DAEMON)running"

fi

}

restart()

{

echo-e"Restarting$DESC:$PROGNAME"

stop

start

}

list()

{

psaux|grep$PROGNAME

}

case$1in

start)

start

;;

stop)

stop

;;

restart)

restart

;;

list)

list

;;

*)

echo"Usage:$SCRIPTNAME{start|stop|restart|list}">&2

exit1

;;

esac

exit0

添加到开机启动服务:

chkconfig--addredisd

chkconfigredisdon

chkconfig--list#查看开机启动的服务

然后就可以使用

#serviceredisdstart|stop|restart|list

启动|停止|重启|清单啦