Redis Advanced Practice II How to install and install Redis on Linux systems

Source: Internet
Author: User
Tags benchmark ssh secure file transfer ssh secure shell install redis

Original: Redis Advanced Practice II How to install Redis on Linux systems

I. Introduction

      Previous article wrote "How to install a VMware Pro virtual machine" and install the Linux operating system on a virtual machine. That was the first step, and with the Linux operating system, we were able to install Redis on that system. Starting with the first article, this is also my official start to learn Redis journey. Talking about Redis, has been exposed long ago, but also used, but a lot of knowledge points are fragmented, no formation system. Right now there is time, just a good research, the knowledge point from the point of formation of a boundless face. I used to be a lot of redis operations are based on the Windows operating system, Linux-based system operations are very few, from the beginning of both systems are written in, based on multi-system to form a separate client code, so that their understanding more comprehensive. Linux to go to school, and then less contact, and always deal with the Windows system, I will open a column, write about the Linux operating system. Well, don't say much, let's start today's course.

Second, preparation

     installing Redis on a Linux operating system is not complicated, it can be said to be simple, but first contact, If not very clear, there will be a lot of pits waiting for you. These pits I have already filled up, as long as everyone according to my writing to do, basically no problem. Insurance point, I said "basic", haha. We'll do the preparatory work first, and these preparations will be pits.

     2.1, installing support for wget commands on Linux systems

            There are two ways to install Redis on a Linux system, the first is to download, unzip, and compile the installation directly online, and the second way is to download the installation package directly from the official website. Then upload to the Linux server, continue to unzip, compile, I chose the second method, the first installation method is the Redis official website steps, the steps are as follows:

Installation process 1, download, unzip, and then, compile the Redis program: $ wget http://download.redis.io/releases/redis-4.0.6.tar.gz$ tar xzf redis-4.0.6.tar.gz$ CD After redis-4.0.6$ make compiles, related files such as redis-server,redis-cli are generated in the SRC directory. Start Redis Service: $ src/redis-server Now you can interact with the Redis client and its service side: $ src/redis-cliredis> set foo barokredis> get foo "bar"

The official website is the use of the wget command to download the Redis software package, if the Linux system did not install the command, the following error will appear:-bash:wget command not found, it is obvious that wget package is not installed. Wget will not be installed by default when Linux is minimized in general. There are two solutions for this problem:

2.1.1), RPM installation

RPM Download Source Address: http://mirrors.163.com/centos/6.2/os/x86_64/Packages/

Download wget RPM Package: http://mirrors.163.com/centos/6.2/os/x86_64/Packages/wget-1.12-1.4.el6.x86_64.rpm

RPM IVH wget-1.12-1.4.el6.x86_64.rpm installation.

What do I do if I can't upload a file when the client uses a RZSZ package that is not loaded under Securecrt,linux? I was thinking of installing another SSH client: SSH Secure Shell. Then to the server to install, this is more laborious, so the second method is recommended, but if the Yum package is not installed, it can only use this method.

2.1.2), yum installation

The command is as follows:yum-y Install wget

Obviously the second method is relatively simple and fast.

2.2. Support for installing GCC commands on Linux systems

We said that Redis needs to be downloaded, decompressed, and then compiled, so what do we use to compile it? That is GCC, if the first installation of the Linux system, the GCC command is not installed, the execution of the command will appear the following error: Gcc:comman not found, so we install ahead of time. The installation command is simple.

Workaround: Install GCC
The command is as follows:Yum Install gcc

2.3. Install the team VIM command support on Linux system

When we download, unzip and compile Redis, there is a job to do, which is to modify the Redis configuration file, The name of the configuration file is redis.conf, how do we open the configuration file and edit it, that is, through the VIM command, of course, the command is not installed by default, the operation will appear the following error: Command not found. Let's install it.

The command is as follows:Yum Install vim

2.4. Create a directory where Redis packages are stored

My directory structure is:/root/software/download/redis/Passmkdircommand to create the directory

2.5. Create a directory to hold the Redis run files

My directory structure is:/root/application/program/redis-tool/, create the directory with the mkdir command

2.6. Create a directory where Redis logs are stored

My directory structure is:/root/application/program/redis-tool/logs/redis.log (log name is defined by itself)

2.7. Create a directory that holds Redis persisted data

My directory structure is: /root/application/program/redis-tool/datas/

third, installation steps

Now that we're done with the preparations, we'll start installing Redis. Everything is smooth, for beginners to see clearly, I try to explain in the form, we begin.first of all, in Linux, some are related to directory operations, if the current directory can be directly manipulated, if not in the current directory, the operation of the directory needs to specify the absolute path.

3.1, go to the Redis official website to download the package, the address is as follows: Https://redis.io/download, download the latest version of the package is available, the current version is 4.0.6.



3.2. Using the remote management tool SSH Secure File Transfer Client, copy the Redis compressed package to the Linux server and place it in the/root/software/download/redis/directory.



3.3, on the Linux server, through the CD command into the software/download/redis/directory, and then local decompression Redis the latest compressed package files. Execute command: Tar zxvf redis-4.0.6.tar.gz

CD software/download/redis/  enters the current directory and then performs an operation

Tar zxvf redis-4.0.6.tar.gz   performing decompression in the current directory




3.4, decompression completed will be in when the directory "/root/software/download/redis/" to generate a folder named redis-4.0.6, into the extracted folder: CD redis-4.0.6, use the LL command below, or use ls-l (lowercase in L) to view the file structure:

Current directory is:/ROOT/SOFTWARE/DOWNLOAD/REDIS/CD redis-4.0.6 into the folder root directory ll view the file or directory structure (2 L lowercase)




3.5. Under the current redis-4.0.6 root directory, execute the make command to compile the files after Redis decompression.



Compile complete



3.6, after the completion of the compilation, in the SRC directory, there are four executables redis-server, Redis-benchmark, Redis-cli and redis.conf (this file under the root directory, not under the SRC directory). And then copy it to a directory.

Current directory:/ROOT/SOFTWARE/DOWNLOAD/REDIS/REDIS-4.0.6/SRC


         Mkdir-p/application/program/redis-tool/  This directory is used to store Redis running files         CP redis-server (server side of Redis)/root/application/ program/redis-tool/         CP redis-benchmark (Test tool)/root/application/program/redis-tool/         CP REDIS-CLI (Redis client)/root/application/program/redis-tool/         CP redis.conf (Redis configuration file)/root/application/ program/redis-tool/         CD application/program/redis-tool/


3.7, through the CD command into the application/program/redis-tool/directory, through the VIM command to modify the redis.conf configuration file.

CD application/program/redis-tool/

Vim./application/program/redis-tool/redis.conf


Modify the project as follows:

3.7.1, bind address modification: Bind 127.0.0.1 changed to your address, for example, my IP address is 192.168.127.128



3.7.2, Port port number: Port 6379 can be modified, or can remain unchanged



3.7.3, logfile log file: LogFile (the address of the log file) the file name of the "/root/application/program/redis-tool/logs/redis.log" log is defined by itself



3.7.4, datafile persistent file address: Dir/root/application/program/redis-tool/datas



3.8, redis.conf configuration file Modified, save exit (press ESC, and then press: Colon, last enter Wq, save exit). Start the server side of Redis. CD/Go back to the root directory and execute the following command:

This is done under the root directory./application/program/redis-tool/redis-server./application/program/redis-tool/redis.conf If the current directory is a CD Application/program/redis-tool, that command is easy to execute, Redis-server redis.conf.

The service has started and we should start the client next.

3.9. Now look at the datas and logs directories below, there will be corresponding files, also indicates the server-side success of starting Redis.



3.10, start the Redis client, under the root directory, execute the following command:./application/program/redis-tool/redis-cli-h 192.168.127.128-p 6379, the interface is as follows.

The current directory is located in a different location, the command will be different, this note. I am currently under the root directory, everyone can also CD target directory, using commands and simple.



3.11, REDIS-CLI client started successfully, let's test it.

Set name Liuleiget nameset age 18get agemset Sex nan address Jiangxi post 12345mget sex address Postkeys *

As follows:


Iv. End of


This is the first time I've installed Redis on Linux, and it's the first time I've used a Linux system. The installation process is not very difficult, just for the first time using a Linux system, many commands are unfamiliar, so some pits, such as: Return to the top level directory, in the Windows environment, Direct CD: But in the Linux environment, there is a space between the CD and two points, And then I learned some Linux commands well. The use of Linux for some time, the use of the line is also very convenient to use. Linux Environment Installation Redis is successful, the next step is to introduce how to install Redis in a Windows environment. Keep on going and learn.

Redis Advanced Practice II How to install and install Redis on Linux systems

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.