Redis summary (2) - Redis installation and simple operation

Introduction:

Redis is compatible with most POSIX systems, such as Linux, OS, OpenBSD, NetBSD and FreeBSD, among which Linux operating systems are more typical, such as CentOS, Redhat, Ubuntu, etc. There are usually two ways to install software on Linux. The first is to install through software management software of various operating systems. For example, CentOS has yum management tool, and Ubuntu has apt. The update speed of Redis is relatively fast, and these management tools may not be updated to the latest version. At the same time, the installation of Redis itself is not complicated. The second installation method is recommended: the source code method.

Install:

This time, take version 3.0.7 as an example to install from source code

$ wget http://download.redis.io/releases/redis-3.0.7.tar.gz
$ tar xzf redis-3.0.7.tar.gz
$ ln -s redis-3.0.7 redis
$ cd redis
$ make
$ make install

1) Download the source code package of the specified version of Redis to the current directory

2) Unzip the Redis source code package

3) Establish a soft connection to the redis directory, pointing to redis-3.0.7

4) Enter the redis directory

5) Compile

6) Installation

Three points to note here:

First, a soft link to the redis directory is established in step 3. This is to prevent the redis directory from being fixed at the specified version, which is beneficial to the upgrade of the Redis version.

Second, make sure that the operating system has installed gcc before compiling, and install the gcc compilation environment yum install gcc-c++.

Third, the installation in step 6 is to put the relevant running files of redis in /usr/local/bin/, so that the redis command can be executed in any directory. If you want to specify the installation directory, you can also pass make PREFIX=/usr /local/redis install to implement. PREFIX is capitalized, where /usr/local/redis is the installation path.

View version:

redis-cli -v

If the corresponding version number appears, the redis installation is successful.

Redis executable description:


Start reids:

redis-server


Start the Redis command line client:

After starting the Redis service through redis-server, you can use redis-cli to link and operate the Redis service.


If there is no -h parameter, the default connection is 127.0.0.1; if there is no -p, the default port is 6379.


Stop the Redis service:

Redis provides shutdown command to stop Redis service. When you use redis-cli to connect after stopping, you can see that redis has "disconnected"


There are three points to note here:

1) The process of Redis closing: Disconnecting from the client and generating persistent files is a relatively elegant way to close.

2) In addition to shutting down the Redis service through the shutdown command, you can also shut down Redis by killing the process number, but don't use it rudely

kill-9 forcibly kills the Redis service, which not only does not perform persistent operations, but also causes AOF and

Replicate the case of missing data.

3) There is also a parameter for shutdown, which represents whether to generate a persistent file before shutting down Redis:
redis-cli shutdown nosave|save

Let redis run as a background process:

( Modify configuration file reference )

Edit the redis.conf configuration file and change the default daemonize no to daemonize yes.

Start redis as a configuration file: redis-server redis.conf

And view the redis process as shown below


Basic configuration of Redis:


Summarize:

There is more than one way to install and configure each software, just master and summarize the ones that you feel are more convenient to operate. There are some configurations and commands that require constant practice to get a better grasp.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324682589&siteId=291194637