spring bootRedis

Redis的安装以及启动

2018-11-08  本文已影响0人  Okami_

安装

wget http://download.redis.io/releases/redis-5.0.0.tar.gz
tar xvf redis-5.0.0.tar.gz 
# 进入到redis的目录, 执行指令make
okamideMBP:softwear root# cd redis-5.0.0
okamideMBP:redis-5.0.0 root# make
vi redis.conf

启动

# 进入到redis的src目录
cd /usr/local/softwear/redis/bin
# 执行脚本redis-server
redis-server
redis-server ../redis.conf
# 1.修改redis.conf,将daemonize 设置为yes
vi redis.conf

daemonize yes
#!/bin/sh
#
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.
 
#redis服务器监听的端口
REDISPORT=6379
 
#服务端所处位置
EXEC=/usr/local/bin/redis-server
 
#客户端位置
CLIEXEC=/usr/local/bin/redis-cli
 
#redis的PID文件位置,需要修改
PIDFILE=/var/run/redis_${REDISPORT}.pid
 
#redis的配置文件位置,需将${REDISPORT}修改为文件名
CONF="/etc/redis/${REDISPORT}.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
        ;;
    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
        ;;
    *)
        echo "Please use start or stop as first argument"
        ;;
esac
mkdir /etc/redis
cp redis.conf /etc/redis/6379.conf
cp redis_init_script /etc/init.d/redisd
#打开服务
service redisd start
#关闭服务
service redisd stop
#设置为开机自启动服务器
chkconfig redisd on
上一篇下一篇

猜你喜欢

热点阅读