β

centos redis 配置

CSS大海 118 阅读

redis 安装:

redis 安装无需./configure

.make 执行编译
.make PREFIX=/usr/local/redis install 安装并制定安装路径
.cp /opt/redis-2.8.17/redis.conf ./ 拷贝配置文件

redis启动:

./bin/redis-server ./redis.conf  启动redis进程,并按照redis.conf的配置

启动后,关闭中断,redis服务即会结束掉

使redis在后台进程运行,修改配置文件redis.conf 下的 daemonize no改为daemonize yes,redis既会在后台进程中运行

redis客户端连接:

./bin/redis-cli

redis 目录介绍: 

redis 启动&&关闭shell:

#!/bin/sh
#
# redis        Startup script for Redis Server
#
# chkconfig: - 90 10
# description: Redis is an open source, advanced key-value store.
#
# processname: redis-server
# config: /etc/redis.conf
# pidfile: /var/run/redis.pid
REDISPORT=6379
EXEC=/usr/local/redis/bin/redis-server
REDIS_CLI=/usr/local/redis/bin/redis-cli
PIDFILE=/var/run/redis.pid
CONF="/usr/local/redis/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

redis 监控:

作者:CSS大海
热爱用户体验,关注前端开发。
原文地址:centos redis 配置, 感谢原作者分享。