标签:
Redis,V3.2,官网l官方链接:http://www.redis.io/download,参考:http://blog.csdn.net/mlks_2008/article/details/19001595
1、安装Redis
wget http://download.redis.io/releases/redis-3.2.1.tar.gz tar xzf redis-3.2.1.tar.gz cd redis-3.2.1 make
2、设置Redis为开机启动
cp redis.conf /etc/
脚本内容如下:
# chkconfig: 2345 10 90
# description: Start and Stop redis PATH=/usr/local/bin:/sbin:/usr/bin:/bin REDISPORT=6379 EXEC=/usr/local/bin/redis-server REDIS_CLI=/usr/local/bin/redis-cli PIDFILE=/var/run/redis.pid CONF="/etc/redis.conf" case "$1" in start) if [ -f $PIDFILE ] then echo "$PIDFILE exists, process is already running or crashed" else echo "Starting Redis server..." $EXEC $CONF fi if [ "$?"="0" ] then echo "Redis is running..." fi ;; stop) if [ ! -f $PIDFILE ] then echo "$PIDFILE does not exist, process is not running" else PID=$(cat $PIDFILE) echo "Stopping ..." $REDIS_CLI -p $REDISPORT SHUTDOWN while [ -x ${PIDFILE} ] do echo "Waiting for Redis to shutdown ..." sleep 1 done echo "Redis stopped" fi ;; restart|force-reload) ${0} stop ${0} start ;; *) echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}" >&2 exit 1 esac ##############################
chmod +x /etc/init.d/redis
vim /etc/redis.conf
chkconfig redis on
3、常用命令
启动服务:
/etc/init.d/redis start
停止服务:
/etc/init.d/redis stop
测试命令:
redis-cli redis 127.0.0.1:6379> set foo 123 redis 127.0.0.1:6379> get foo redis 127.0.0.1:6379> exit
【安装Redis】CentOS7 下安装NodeJs+Express+MongoDB+Redis
标签:
原文地址:http://www.cnblogs.com/ficohu/p/5595414.html