Install Redis and set up related services under Linux _redis

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

First, Introduction

Redis is an open source, advanced key-value Storage and a perfect solution for building high-performance, scalable Web applications.

Redis three main features inherited from its many competitions:

    • The Redis database is fully in memory and uses the disk for persistence only.
    • Redis has a richer set of data types than many key-value data stores.
    • Redis can copy data to any number of servers.

Redis Advantage

unusually fast: The Redis is very fast and can perform about 110,000 episodes per second, about 81000 + records per second.

support for rich data types : Redis support Most developers already know like lists, collections, ordered collections, hash data types. This makes it very easy to solve a wide variety of problems because we know which problems can be handled better by its data type.

operations are atomic: all Redis operations are atomic, which guarantees that if two clients simultaneously access the Redis server, the updated value will be obtained.

Multi-functional utilities: Redis is a practical tool that can be used in multiple applications such as caching, messaging, queue use (Redis native support publish/subscribe), any transient data, application, such as Web application sessions, Web page hit counts, and more.

Second, the installation

Introduce the system environment first. Enter Cat/etc/issue.

If Linux can be linked to the network, you can download it directly online. Direct input code: WGETHTTP://REDIS.GOOGLECODE.COM/FILES/REDIS-3.0.2.TAR.GZ But this is not recommended because Google's services in China seem to be blocked and may not be linked. So we go directly to other places to download and upload to Linux services. Here I downloaded the redis-3.0.2.tar.gz version. Then use the TAR-ZXVF redis_3.0.2.tar.gz

We'll see a file in that directory, redis-3.0.2,

We go into the directory, and then compile execute command make, wait around 10, we will see that we have finished compiling, we see the following interface, we have a successful installation.

We will see a few more files in the redis-3.0.2 directory, where Redis-server is used to start the service, REDIS-CLI is used to start the client, the other is not clear, we can check.

We can start by typing the./redis-server command in this directory, and you'll see the following figure.

This shows that our Redis installation was successful. You can also use the./redis.cli–p 6379 as a client to test, and this is no longer done.

Third, set up services

Can see if we start Redis service, every time to enter the installation directory, this is not very cumbersome, so we will redis into a service, we start directly.

First, the Utils/redis_init_script file is copied to the/ETC/INIT.D, and the Redis is easily named. Execute command

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

Then execute the command, Vi/etc/rc.d/init.d/redis, and add the # chkconfig:2345 80 90 in the second line of the document. If there are no redis-server and redis-cli files in the/usr/local/redis/bin, we need to copy one from our installation directory. Otherwise, Redis-server cannot be found at service startup. The following figure shows the second red box. and add an ampersand behind the third $exec $CONF, which means that Redis is started as a background service, otherwise the service will monopolize the input screen.

You can see this line in the/etc/init.d/redis file: conf= "/etc/redis/${redisport}.conf". The Redis configuration file is then copied to the/etc/redis/.

Mkdir/etc/redis 

  CP/USR/LOCAL/REDIS-3.0.2/REDIS.CONF/ETC/REDIS/6379.CONFF

Once you have completed the above, you can register the service:

Chkconfig--add Redis

and start the Redis service.

 Service Redis Start

So we're going to register the Redis service, but if you test the Redis stop, you'll notice/var/run/redis_6379.pid does not exist, and the process is not running this explains Run does not have this file, we enter to/var/run issued first really did not this file, but there are redis.pid files.

We are going to modify the redis_${redisport}.pid in the/etc/rc.d/init.d/redis file to redis.pid.

So after we restart the service, we can close it with this command. Here our Redis service is installed and a service is done.

Above is the whole process that installs Redis under Linux, hope to install Redis to be helpful to everybody.

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.