The installation and configuration of Redis is very simple, and Redis has been installed a long time ago. But I forgot some details when I installed it again over the past few days. It seems that the good memory is not as bad as what I wrote.
The installation and configuration of Redis is very simple, and Redis has been installed a long time ago. But I forgot some details when I installed it again over the past few days. It seems that the good memory is not as bad as what I wrote.
The installation and configuration of Redis is very simple, and Redis has been installed a long time ago. But I forgot some details when I installed it again these days. It seems that the good memory is not as bad as the pen, it is better to record it in the blog, at least you don't always have to hold your mother's thigh.
How many times have the files been compiled and installed today ?? After reading the results for half a day, I found that I used lowercase letters for the PREFIX...
It seems that you have to record the correct operation steps to avoid this embarrassment.
1. Select a version
Go to the official website:
Choose a suitable stable version, such as the latest redis-3.0 stable version (stable), to get:
Ii. Compilation and Installation
Cd/usr/local/src
Wget
Tar zxvf redis-3.0.0.tar.gz
Cd redis-3.0.0
Make
# Optional command: make test
# Remember that the PREFIX is in upper case and the lower case does not take effect!
Make PREFIX =/usr/local/redis-3.0.0 install
# Creating soft links
Ln-s/usr/local/redis-3.0.0/usr/local/redis
# Create a directory and copy the default configuration file
Mkdir-p/usr/local/redis/{etc, var}
Cp redis. conf/usr/local/etc/
# If it is to provide services to other machines, we recommend that you set the listening IP address to 0.0.0.0 in redis. conf, and start a process. The default value is 2 and there is also 127.0.0.1.
Bind 0.0.0.0
Cd/usr/local/src
Wget
Tar zxvf redis-3.0.0.tar.gz
Cd redis-3.0.0
Make
# Optional command: make test
# Remember that the PREFIX is in upper case and the lower case does not take effect!
Make PREFIX =/usr/local/redis-3.0.0 install
# Creating soft links
Ln-s/usr/local/redis-3.0.0/usr/local/redis
# Create a directory and copy the default configuration file
Mkdir-p/usr/local/redis/{etc, var}
Cp redis. conf/usr/local/etc/
# If it is to provide services to other machines, we recommend that you set the listening IP address to 0.0.0.0 in redis. conf, and start a process. The default value is 2 and there is also 127.0.0.1.
Bind 0.0.0.0
After the installation is complete, the redis directory structure is as follows:
[Root @ cache-ns-4 ~] # Tree/usr/local/redis
/Usr/local/redis
── Bin # store various execution files under bin
│ ── Redis-benchmark
│ ── Redis-check-aof
│ ── Redis-check-dump
│ ── Redis-cli # redis client execution File
│ ├ ── Redis-sentinel-& gt;/usr/local/redis-3.0.0/bin/redis-server
│ ── Redis-server # redis server execution File
── Dump. rdb # the data file generated by default after startup. You can set the dir path parameter in redis. conf to specify other directories.
── Etc
│ ── Redis. conf
── Var
[Root @ cache-ns-4 ~] # Tree/usr/local/redis
/Usr/local/redis
── Bin # store various execution files under bin
│ ── Redis-benchmark
│ ── Redis-check-aof
│ ── Redis-check-dump
│ ── Redis-cli # redis client execution File
│ ├ ── Redis-sentinel-& gt;/usr/local/redis-3.0.0/bin/redis-server
│ ── Redis-server # redis server execution File
── Dump. rdb # the data file generated by default after startup. You can set the dir path parameter in redis. conf to specify other directories.
── Etc
│ ── Redis. conf
── Var
Iii. Registration Service
① Write a service control script
Vi/etc/init. d/redis
#! /Bin/bash
#
# Redis-this script starts and stops the redis-server daemon
#
# Chkconfig:-80 12
# Description: Redis is a persistent key-value database
# Processname: redis-server
# Config:/usr/local/redis/etc/redis. conf
# Pidfile:/usr/local/redis/var/redis. pid
Source/etc/init. d/functions
BIN = "/usr/local/redis/bin"
CONFIG = "/usr/local/redis/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 :"
# In use, I occasionally find that the server is not transferred to the background after it is started, so I added an "&"
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
#! /Bin/bash
#
# Redis-this script starts and stops the redis-server daemon
#
# Chkconfig:-80 12
# Description: Redis is a persistent key-value database
# Processname: redis-server
# Config:/usr/local/redis/etc/redis. conf
# Pidfile:/usr/local/redis/var/redis. pid
Source/etc/init. d/functions
BIN = "/usr/local/redis/bin"
CONFIG = "/usr/local/redis/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 :"
# In use, I occasionally find that the server is not transferred to the background after it is started, so I added an "&"
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
② Register and start the service
# Grant execution permission
Chmod + x/etc/init. d/redis
# Start startup
Chkconfig redis on
# Start the service
Service redis start