Detailed steps for manual installation of redis-3.2.8 in CentOS 6.8

Keywords: Redis vim CentOS yum

CentOS 6.8 installs with yum sometimes without a newer version, so install it manually. Here are the steps.


Download the latest version

Take 3.2.8 as an example. Attach the address: redis-3.2.8.tar.gz  http://download.redis.io/releases/redis-3.2.8.tar.gz

1. Download Redis 3.2.8 installation package

wget -C http://download.redis.io/releases/redis-3.2.8.tar.gz

2. Decompress, compile and install redis-3.2.8

tar -zxvf redis-3.2.8.tar.gz -C /usr/src/
cd /usr/src/redis-3.2.8/
make && make install

3. Create redis related directories:
mkdir -p /home/redis/bin
mkdir -p /home/redis/log
mkdir -p /home/redis/pid
mkdir -p /home/redis/db

4. Copy the executable file to your installation directory: / home/redis/
 ln -s /usr/local/bin/redis-*   /home/redis/bin/

5. Copy the configuration file to your installation directory: / home/redis/
cp /usr/src/redis-3.2.8/redis.conf /home/redis/

6. Enter your installation directory and edit redis.conf configuration file
cd /home/redis/
vim /home/redis/redis.conf


  • redis only allows local connections by default, so commenting out this line configuration allows remote access: bind 127.0.0.1
  • Redis version 3.0 adds protection mode, which requires us to set a password. If you don't want to set a password, turn off protection mode: protected-mode no
  • Set redis to start as a daemonize thread: daemonize yes
  • Add the save address of configuration pid, log, db files:
    pidfile /home/redis/pid/redis.pid
    logfile /home/redis/log/redis.log
    dir /home/redis/db
    Other configurations can be defaulted and modified as necessary.

    7. Create redis service startup scripts and grant privileges

  • vim /etc/init.d/redis
    #!/bin/sh
    #
    # Simple Redis init.d script conceived to work on Linux systems
    # as it does use of the /proc filesystem.
    PATH=/home/redis/bin:/sbin:/usr/bin:/bin
    REDISPORT=6379
    EXEC=/home/redis/bin/redis-server
    CLIEXEC=/home/redis/bin/redis-cli
    PIDFILE=/home/redis/pid/redis.pid
    CONF="/home/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
            ;;
        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

    8. Set permissions and add redis service to boot up:
    chmod a+x /etc/init.d/redis


    9. Start redis service:
    service redis start
    ps -ef | grep redis
    netstat -anptu | grep 6379

    10. Testing OK
              redis-cli
              set key1 hello
              get key1
              quit


    (Firewall enabled port 6379: iptables-A INPUT-p tcp-dport 6379-j ACCEPT)



    Reference material:


    http://www.cnblogs.com/jimmy-lin/p/6426925.html

    http://www.cnblogs.com/ahjx1628/p/6496529.html

  • redis only allows local connections by default, so commenting out this line configuration allows remote access: bind 127.0.0.1
  • Redis version 3.0 adds protection mode, which requires us to set a password. If you don't want to set a password, turn off protection mode: protected-mode no
  • Set redis to start as a daemonize thread: daemonize yes
  • Posted by kobmat on Tue, 11 Jun 2019 11:10:11 -0700