Redis download and installation (Linux download)

Posted by Plex on Sat, 18 Dec 2021 10:04:04 +0100

Redis download and installation (Linux download)

1. Environmental preparation

  1. Virtual machine version: VMware ® Workstation 16 Pro
  2. Linux system: Centos7
  3. Remote command side: xshell
  4. File transfer tool: SecureFXPortable

2.Redis installation

2.1 Redis compilation language

Redis is developed in C language. To install redis, you need to download the source code from the official website for compilation. The compilation depends on the GCC compilation environment. If the GCC compilation environment is not installed on CentOS, it needs to be installed in advance. The installation commands are as follows:

[root@localhost ~]# yum install gcc-c++

Remember to use the root user to handle these operations. Y is selected by default here

2.2 Redis installation

2.2. 1. Use SecureFXPortable to upload the Redis installation package to the Linux directory

2.2. 2. Upload Redis installation files to your designated directory. I chose / mysoft here

2.2. 3. Enter the directory and unzip the file

[root@localhost mysoft]# tar -zxvf redis-5.0.5.tar.gz

2.2. 4. Compile Redis file (compile. c file into. o file)

[root@localhost mysoft]# cd redis-5.0.5
[root@localhost redis-5.0.5]# make

Note: if there is an error in the compilation process, first delete the installation file directory, then decompress and recompile.

2.2. 5. Installation

[root@localhost redis-5.0.5]# make PREFIX=/home/admin/myapps/redis install

2.2. 6. Introduction to the bin directory after installation

[root@localhost redis]cd /home/admin/myapps/redis/bin

These documents are introduced:

redis-benchmark:Performance test tool
redis-check-aof:AOF File repair tool
redis-check-rdb:RDB Document checking tool
redis-cli:Command line client
redis-server: redis Server start command

2.2.7 Copy files

Redis needs a configuration file to start. You can modify the port number information. Extract redis from the folder Copy the conf file to the installation directory.

2.3 redis startup

2.3. 1. Redis front-end mode startup

Running bin / redis server directly will start the front-end mode. The disadvantage of starting the front-end mode is that no other operations can be carried out after the start. If you want to operate, you must use ctrl+c, and the redis server program ends. Therefore, this method is not recommended.

[root@localhost bin]# ./redis-server

2.3. 2. Redis backend startup

Modify redis Conf configuration file, set daemon yes, and then you can start using the back-end mode.

At startup, specify the configuration file.

[root@localhost redis]# ./bin/redis-server ./redis.conf

Redis default port: 6379, which can be viewed through the current service

[root@localhost redis]# ./bin/redis-server ./redis.conf 
[root@localhost redis]# ps -ef | grep -i redis

2.3. 3 client access to redis

If you want to operate redis through instructions, you can use the redis client.

Run redis cli in the bin folder. The default connection of this instruction is 127.0 0.1, the port number is 6379.

[root@localhost bin]# ./redis-cli
127.0.0.1:6379>

If you want to connect the specified ip address and port number, you need to follow the syntax structure of redis cli - H ip address - p port number.

2.3. 4 send commands to Redis server

Ping: test whether the connection between the client and Redis is normal. If the connection is normal, recycle to pong.

127.0.0.1:6379> ping
PONG

2.3. 5 exit client

127.0.0.1:6379> quit

2.3.6 Redis stop

(1) Force the end of the program. Forced termination of the redis process may result in the loss of redis persistent data.

kill -9 pid
pid Get query for: ps aux | grep -i redis

(2) Stop correctly. The correct way to stop Redis is to send the SHUTDOWN command to Redis. The method is (close the default port)

[root@localhost redis]# ./bin/redis-cli shutdown

2.4 introduce the third-party tool operation redis

Redis desktop manager connection:

2.4. 1. Connect the ip address of the linux virtual machine

Fill in the user-defined name in the first line; Fill in the host address of redis in the second line. The default is 127.0 0.1.

Note: first, close the linux firewall and modify redis The bind parameter in the conf file.

bind linux of ip address

Finally, when accessing, enter as shown in the figure above.

[root@localhost bin]# ./redis-cli -h 192.168.91.129 -p 6379

Fill in your own ip address.

Finally, the installation of Redis under linux is basically completed.

Topics: Java Linux Database Redis