Installation of Redis under Linux

Source: Internet
Author: User
Tags memcached install redis redis server

Redis is one of the most popular NoSQL systems today, and it is a key-value storage system. Similar to memcached, but largely compensates for the lack of memcached, which supports storing more value types, including string, list, set, Zset, and hash. These data types support Push/pop, Add/remove, and intersection sets and differences, and richer operations. Based on this, Redis supports sorting in a variety of different ways. Redis data is cached in the computer's memory and periodically writes the updated data to disk or writes the modification to the appended record file.

Redis website Address: http://www.redis.io/

1, download the source code, unzip and compile the source code

  

PS: If not made into service, you can start Redis-server redis.conf, client test: REDIS-CLI

2. Make Redis a service

  (1) Copy script to/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/src/redis/utils/redis_init_script

It must be copied to the /etc/rc.d/init.d directory:

Cp/usr/local/src/redis/utils/redis_init_script/etc/rc.d/init.d/redis

Copy the Redis_init_script to/etc/rc.d/init.d/and easily name Redis.

If you add the registration service at this point:chkconfig--add redis, the error will be reported: Redis service does not support Chkconfig. To do this, we need to change the Redis script.

  (2) Change Redis script

Open the script using VI to view the script information:Vim/etc/rc.d/init.d/redis  

What you see is as follows (the following is a change of good information):

#!/bin/sh#chkconfig: 2345# simple Redis INIT.D script conceived to work on the Linux systems # as it does use of the/proc filesystem. redisport=6379Exec=/usr/local/redis/bin/redis-server cliexec=/usr/local/redis/bin/redis-cliPidfile=/var/run/redis_${redisport}.pid conf= "/etc/redis/${redisport}.conf" case "$" in start) if [-F $PI                 Dfile] 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 was not running " Else pid=$ (cat $PIDFILE) echo "Stopping ..." $CLIEXEC-P $REDISPORT s Hutdown while [-x/proc/${pid}] does echo "Waiting for Redis to Shutdo     WN ... "Sleep 1 done echo" Redis stopped "FI;; *) echo "Please use Start or stop as first argument";; Esac

Compared to the original configuration file:

1. The original document does not have the following 2nd line of content,#chkconfig: 2345

2. The original file exec, cliexec parameters, is also changed.

  EXEC=/usr/local/redis/bin/redis-server   

  CLIEXEC=/usr/local/redis/bin/redis-cli 

3.redis commands that are enabled to run in the background. $EXEC $CONF &

4. Copy the Redis configuration file to/etc/redis/${redisport}.conf

    

After the above operation is complete, you can register Yedis service: Chkconfig--add Redis

  (3) Start Redis service

    Service Redis Start

3. Add the directory of the Redis command to the system parameter path

Modify Profile:vi/etc/profile

Append in last line:export PATH="$PATH:/usr/local/redis/bin"

Then apply this file immediately:./etc/profile

This makes it possible to invoke the REDIS-CLI command directly, as follows:

  

At this point, Redis is installed successfully.

Installation of Redis under Linux

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.