Part I: Installing Redis
I downloaded 4.0. The 2 version of the Redis installation package is directly uploaded to the Linux server/usr/local directory
Then the installation process is as follows:
TAR-ZXVF redis-4.0.2.tar.gz
CD redis-4.0.2
Direct make compilation
If it is not successful, install GCC first and then make it again
After the successful compilation, the SRC directory appears, below the REDIS-CLI, Redis-server and other files
Part II: Making Redis a service
1. Copy the script to the/ETC/RC.D/INIT.D directory
PS: The script in the/etc/rc.d/init.d/directory is similar to the registry in Windows, and some of the specified scripts will be executed when the system is started
When you install Redis as per the above steps, its service script is located at:/usr/local/redis-4.0.2/utils/redis_init_script
Copy it to the/ETC/RC.D/INIT.D directory:
Cp/usr/local/redis-4.0.2/utils/redis_init_script/etc/rc.d/init.d/redis Copy the Redis_init_script to/etc/rc.d/init.d/, It is also known as Redis.
2. Change the Redis script
#!/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-4.0.2/src/redis-server//modify path changed to install the SRC directory that appears when compiling Redis
CLIEXEC=/USR/LOCAL/REDIS-4.0.2/SRC/REDIS-CLI//Ibid.
Pidfile=/var/run/redis_${redisport}.pid
conf= "/etc/redis/${redisport}.conf"
Case "$" in
Start
If [-F $PIDFILE]
Then
echo "$PIDFILE exists, process is already running or crashed"
Else
echo "Starting Redis server ..."
# $EXEC The contents of the source file $CONF//Here, I am logged off
$EXEC $CONF &//Modified here, plus a & symbol, with this symbol Redis will run in the background, or Redis will run in the foreground, will hinder the execution of other commands, of course, would like to re-open the terminal with you
Fi
;;
Stop
3. Copy the Redis configuration file to/etc/redis/${redisport}.conf
mkdir /etc/redis
cp /usr/local/src/redis。4.0.2/redis.conf /etc/redis/6379.conf
In this way, the conf specified by the Redis service script exists. By default, Redis does not have authentication enabled, and you can specify a verification password by turning on the requirepass of 6379.conf.
After the above operation is complete, you can register Yedis service: Chkconfig--add Redis
You can start the Redis service: Service Redis start, press CTRL + C to exit the interface, but Redis is actually running in the background
4. Third, add the directory where the Redis command resides to the system parameter path
Modify Profile: Vi/etc/profile
Append in last line:export PATH=
"$PATH:/usr/local/redis/src"
Then apply this file immediately:. /etc/profile//Note that there are spaces between. and/
This makes it possible to invoke the REDIS-CLI command directly, as follows:
[Email protected] local]# REDIS-CLI
127.0.0.1:6379>
At this point, Redis is installed successfully.
Configuring Redis under Linux Installation