tar xf /home/source/redis-3.0.6.tar.gz
cd redis-3.0.6
make PREFIX=/usr/local/redis install
mkdir /etc/redis
/bin/cp -f redis.conf /etc/redis/redis.conf
sed -i ‘s@^daemonize no@daemonize yes@‘ /etc/redis/redis.conf
redis服务脚本
#!/bin/sh
#
# chkconfig : 2345 45 90
# as it does use of the /proc filesystem.
REDISPORT=6379
EXEC=/usr/local/redis/bin/redis-server
CLIEXEC=/usr/local/redis/bin/redis-cli
PIDFILE=/var/run/redis.pid
CONF="/etc/redis/redis.conf"
start() {
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed"
else
echo "Starting Redis server..."
$EXEC $CONF
fi
}
stop() {
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
$CLIEXEC -p $REDISPORT shutdown
while [ -x /proc/${PID} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Please use start or stop as first argument"
;;
esac
启动redis
[root@iZ25jyqlmgdZ ~]# /etc/init.d/redis start
连接redis
[root@iZ25jyqlmgdZ ~]# /usr/local/redis/bin/redis-cli -h 127.0.0.1
127.0.0.1:6379>
获取redis中所有的key
127.0.0.1:6379> keys *
本文出自 “逢场做戏。” 博客,请务必保留此出处http://xiaofengmo.blog.51cto.com/10116365/1757451
原文:http://xiaofengmo.blog.51cto.com/10116365/1757451