Configuring Redis under Linux Installation

Source: Internet
Author: User
Tags install redis redis server

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.