首页 > Linux系统 > centos > Centos6.x 安装Redis
2018
03-06

Centos6.x 安装Redis

一.介绍

  redis在做数据库缓存,session存储,消息队列上用的比较多

二.安装

$ yum install -y wget gcc make tcl
$ wget http://download.redis.io/releases/redis-3.0.2.tar.gz
$ tar zxvf redis-3.0.2.tar.gz
$ cd redis-3.0.2
$ make
$ make test
$ make install

三.配置

$ cp redis.conf /etc/
$ touch /etc/init.d/redis
$ chmod 755 /etc/init.d/redis
$ vi /etc/init.d/redis

#!/bin/bash
#
# Init file for redis
#
# chkconfig: - 80 12
# description: redis daemon
#
# processname: redis
# config: /etc/redis.conf
# pidfile: /var/run/redis.pid
source /etc/init.d/functions
#BIN="/usr/local/bin"
BIN="/usr/local/bin"
CONFIG="/etc/redis.conf"
PIDFILE="/var/run/redis.pid"
### Read configuration
[ -r "$SYSCONFIG" ] && source "$SYSCONFIG"
RETVAL=0
prog="redis-server"
desc="Redis Server"
start() {
        if [ -e $PIDFILE ];then
             echo "$desc already running...."
             exit 1
        fi
        echo -n $"Starting $desc: "
        daemon $BIN/$prog $CONFIG
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
        return $RETVAL
}
stop() {
        echo -n $"Stop $desc: "
        killproc $prog
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog $PIDFILE
        return $RETVAL
}
restart() {
        stop
        start
}
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        restart
        ;;
  condrestart)
        [ -e /var/lock/subsys/$prog ] && restart
        RETVAL=$?
        ;;
  status)
        status $prog
        RETVAL=$?
        ;;
   *)
        echo $"Usage: $0 {start|stop|restart|condrestart|status}"
        RETVAL=1
esac
exit $RETVAL


#记得在redis.conf中修改
daemonize yes
logfile "/var/log/redis.log"
dir /data

四.运行

$ /etc/init.d/redis start
$ chkconfig redis on

五.检查
Centos6.x 安装Redis - 第1张  | 大博辞

Centos6.x 安装Redis - 第2张  | 大博辞

最后编辑:
作者:admin
捐 赠如果您觉得这篇文章有用处,请支持作者!鼓励作者写出更好更多的文章!

留下一个回复