Redis linux environment construction

Written in front: I am just making a record here. The following contents are all transferred from
http://www.cnblogs.com/_popc/p/3684835.html
Do not spray, if possible, go to the original website to visit
1. Installation
1. Download the resource package http://redis.io/download , the latest is 3.2.3
2. Put the compressed package in
/usr/local/src

3. Switch to /usr/local/src and perform decompression
tar -zxvf redis-3.2.3.tar.gz  

4. Create the folder /urs/local/redis
mkdir /usr/local/redis

5、ln -s redis-3.2.3 redis
6、
make PREFIX=/usr/local/redis install #Install to the specified directory

(PREFIX is used here to specify the installation path of make)
7. After redis is installed successfully, you will be able to see a bin directory in /usr/local/redis, which contains some commonly used redis command files
2. Configure redis as a daemon
1. Copy the redis_init_script in the /usr/local/src/redis/utils directory to /etc/init.d/ and change its name to redis,
cp /usr/local/src/redis/utils/redis_init_script /etc/init.d/redis

2. Modify the redis execution script
vim /usr/init.d/redis

3. After the file is modified, it is
#!/bin/sh
# chkconfig: 2345 80 90
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.

REDISPORT=6379
EXEC=/usr/local/redis/bin/redis-server
CLIEXEC=/usr/local/redis/bin/redis-cli

PIDFILE=/var/run/redis_${REDISPORT}.pid
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 &
        be
        ;;
    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"
        be
        ;;
    *)
        echo "Please use start or stop as first argument"
        ;;
nit_scriptesac

4. Modifications:
   a. #chkconfig: 2345 80 90
   b. EXEC and CLIEXEC paths
   c. Change the start part to background execution $EXEC $CONF &
5. Since the configuration file in the script has not changed, we need to configure the redis here Copy the file to the corresponding directory and go to CONF="/etc/redis/${REDISPORT}.conf", named after the port number. The redis configuration file is in /urs/local/src/redis/redis.conf, so you only need to copy in the past
mkdir /etc/redis
cp /usr/local/src/redis/redis.conf /etc/redis/6379.conf

6. Add as daemon
chkconfgi --add redis #Here will automatically go to the /etc/init.d directory to find the corresponding service By
the way, quote the author's sentence above: /etc/init.d is similar to the one in windows The registry, but the registry under linux can be directly based on the directory
7. Start service redis start, close servie redis stop
3. Client connection
1. Configure the system environment variable /etc/profile
vi /etc/profile

2. Add export PATH="$PATH:/usr/local/redis/bin" at the end,
3. Apply profile
source /etc/profile

4. Connect to redis-cli [-h ip] [-a pwd] (explain, redis does not set a password by default, if necessary, enable the password in the configuration file, field: requirepass).

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326667227&siteId=291194637