Detailed graphic steps for installation and deployment of Redis 6.2.6 under Linux

Redis (Remote Dictionary Server), the remote dictionary service, is an open source log-type, Key-Value database written in ANSI C language, supports the network, can be memory-based and persistent, and provides APIs in multiple languages. Redis 6.0 introduces SSL, new RESP3 protocol, ACL, client cache, diskless replicas, I/O threads, faster RDB loading, new module API and more improvements.

1. Download the redis6.2.6 installation package

Visit the https://redis.io/download address to download from the official website. This article demonstrates the installation and configuration of the latest version of redis6.2.6.

Insert image description here
Just click the download button in the red box in the picture above, and then upload it to the server through the remote tool, or download it through the wget command.

[root@Java-JingXuan home]# wget https://download.redis.io/releases/redis-6.2.6.tar.gz
--2022-01-16 22:09:18--  https://download.redis.io/releases/redis-6.2.6.tar.gz
Resolving download.redis.io (download.redis.io)... 45.60.125.1
Connecting to download.redis.io (download.redis.io)|45.60.125.1|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2476542 (2.4M) [application/octet-stream]
Saving to: ‘redis-6.2.6.tar.gz’

100%[================================================================================================================================================>] 2,476,542   53.1KB/s   in 40s    

2022-01-16 22:10:00 (61.0 KB/s) - ‘redis-6.2.6.tar.gz’ saved [2476542/2476542]

2. Unzip the compressed file

Decompress the redis-6.2.6.tar.gz file and execute the tar -xvf redis-6.2.6.tar.gz command.

[root@Java-JingXuan home]# tar -xvf redis-6.2.6.tar.gz
...
redis-6.2.6/utils/srandmember/README.md
redis-6.2.6/utils/srandmember/showdist.rb
redis-6.2.6/utils/srandmember/showfreq.rb
redis-6.2.6/utils/[email protected]
redis-6.2.6/utils/systemd-redis_server.service
redis-6.2.6/utils/tracking_collisions.c
redis-6.2.6/utils/whatisdoing.sh

3. Rename and move files

Here, the installation directory is moved to the /usr/local/ directory, redis-6.2.6 is renamed to the redis directory, and the mv /home/redis-6.2.6 /usr/local/redis command is used, so the following operations are performed.

[root@Java-JingXuan home]# mv /home/redis-6.2.6 /usr/local/redis
[root@Java-JingXuan home]# cd /usr/local/redis
[root@Java-JingXuan redis]# ll
total 240
-rw-rw-r--  1 root root 33624 Oct  4 18:59 00-RELEASENOTES
-rw-rw-r--  1 root root    51 Oct  4 18:59 BUGS
-rw-rw-r--  1 root root  5026 Oct  4 18:59 CONDUCT
-rw-rw-r--  1 root root  3384 Oct  4 18:59 CONTRIBUTING
-rw-rw-r--  1 root root  1487 Oct  4 18:59 COPYING
drwxrwxr-x  7 root root  4096 Oct  4 18:59 deps
-rw-rw-r--  1 root root    11 Oct  4 18:59 INSTALL
-rw-rw-r--  1 root root   151 Oct  4 18:59 Makefile
-rw-rw-r--  1 root root  6888 Oct  4 18:59 MANIFESTO
-rw-rw-r--  1 root root 21567 Oct  4 18:59 README.md
-rw-rw-r--  1 root root 93724 Oct  4 18:59 redis.conf
-rwxrwxr-x  1 root root   275 Oct  4 18:59 runtest
-rwxrwxr-x  1 root root   279 Oct  4 18:59 runtest-cluster
-rwxrwxr-x  1 root root  1079 Oct  4 18:59 runtest-moduleapi
-rwxrwxr-x  1 root root   281 Oct  4 18:59 runtest-sentinel
-rw-rw-r--  1 root root 13768 Oct  4 18:59 sentinel.conf
drwxrwxr-x  3 root root  4096 Oct  4 18:59 src
drwxrwxr-x 11 root root  4096 Oct  4 18:59 tests
-rw-rw-r--  1 root root  3055 Oct  4 18:59 TLS.md
drwxrwxr-x  9 root root  4096 Oct  4 18:59 utils

4. Redis compilation and installation

1) Compile redis and execute the make command.

[root@Java-JingXuan redis]# make
cd src && make all
make[1]: Entering directory `/usr/local/redis/src'
    CC Makefile.dep
...
    LINK redis-benchmark
    INSTALL redis-check-rdb
    INSTALL redis-check-aof

Hint: It's a good idea to run 'make test' ;)

make[1]: Leaving directory `/usr/local/redis/src'

2) Execute the make install command for redis installation.

[root@Java-JingXuan redis]# make install
cd src && make install
make[1]: Entering directory `/usr/local/redis/src'
    CC Makefile.dep
make[1]: Leaving directory `/usr/local/redis/src'
make[1]: Entering directory `/usr/local/redis/src'

...
Hint: It's a good idea to run 'make test' ;)

    INSTALL redis-server
    INSTALL redis-benchmark
    INSTALL redis-cli
make[1]: Leaving directory `/usr/local/redis/src'

5. redis startup

To facilitate management, move the conf configuration files and common commands in the Redis6.2.6 directory to a unified directory.

Switch to the redis root directory, create bin and etc files, move the redis.conf file to the /usr/local/redis/etc/ directory, and add mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-rdb redis-cli The redis-server file is moved to the /usr/local/redis/bin/ directory.

[root@Java-JingXuan redis]# mkdir etc
[root@Java-JingXuan redis]# mkdir bin
[root@Java-JingXuan redis]# mv redis.conf /usr/local/redis/etc/
[root@Java-JingXuan redis]# cd src/
[root@Java-JingXuan src]# mv mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-server /usr/local/redis/bin/
[root@Java-JingXuan src]# ll ../bin/
total 37524
-rwxrwxr-x 1 root root     735 Oct  4 18:59 mkreleasehdr.sh
-rwxr-xr-x 1 root root 4829472 Jan 16 22:30 redis-benchmark
-rwxr-xr-x 1 root root 9524032 Jan 16 22:30 redis-check-aof
-rwxr-xr-x 1 root root 9524032 Jan 16 22:30 redis-check-rdb
-rwxr-xr-x 1 root root 5003752 Jan 16 22:30 redis-cli
-rwxr-xr-x 1 root root 9524032 Jan 16 22:30 redis-server

Execute the redis-server command to start the redis service.

[root@Java-JingXuan redis]# ./bin/redis-server 
26344:C 16 Jan 2022 22:38:18.616 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
26344:C 16 Jan 2022 22:38:18.617 # Redis version=6.2.6, bits=64, commit=00000000, modified=0, pid=26344, just started
26344:C 16 Jan 2022 22:38:18.617 # Warning: no config file specified, using the default config. In order to specify a config file use ./bin/redis-server /path/to/redis.conf
26344:M 16 Jan 2022 22:38:18.617 * monotonic clock: POSIX clock_gettime
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 6.2.6 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                  
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 26344
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           https://redis.io       
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

26344:M 16 Jan 2022 22:38:18.618 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
26344:M 16 Jan 2022 22:38:18.618 # Server initialized
26344:M 16 Jan 2022 22:38:18.618 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
26344:M 16 Jan 2022 22:38:18.618 * Ready to accept connections

6. Set up background to start redis

Edit the redis.conf file, change the daemonize attribute to yes, and execute the vim /usr/local/redis/etc/redis.conf command.

vim /usr/local/redis/etc/redis.conf

Insert image description here
Execute the ./bin/redis-server /usr/local/redis/etc/redis.conf command to start the redis service.

./bin/redis-server /usr/local/redis/etc/redis.conf

7. Set redis password

Edit the redis.conf file and find the requirepass parameter. If you have not added the requirepass parameter and set the password, refer to the figure below and execute the vim /usr/local/redis/etc/redis.conf command.
Insert image description here
After saving, restart the redis service to take effect.

8. Set up redis service remote access

1. Add port 6379 to the firewall

Make sure the firewall opens port 6379.

2. Modify redis.conf

Modify the following parameters in redis.conf

# 允许任何主机连接、访问
bind 127.0.0.1 改为 bind 0.0.0.0
 
# 关闭保护模式
protected-mode yes 改为 protected-mode no
 
# 允许启动后在后台运行,即关闭命令行窗口后仍能运行
daemonize no 改为 daemonize yes

or
Edit the redis.conf file, find the bind 127.0.0.1 -::1 configuration, and comment it out with the # sign, as shown in the figure below.
Insert image description here

Then execute the ps -ef|grep redis command to find the started redis service, and use the kill command to kill the redis service process. Then execute the ./bin/redis-server /usr/local/redis/etc/redis.conf command to start the redis service.

[root@Java-JingXuan redis]# ps -ef|grep redis
root     27715     1  0 22:45 ?        00:00:00 ./bin/redis-server 127.0.0.1:6379
root     29297 25962  0 22:53 pts/4    00:00:00 grep --color=auto redis
[root@Java-JingXuan redis]# kill -9 27715
[root@Java-JingXuan redis]# ./bin/redis-server /usr/local/redis/etc/redis.conf
[root@Java-JingXuan redis]# ps -ef|grep redis
root     29323     1  0 22:53 ?        00:00:00 ./bin/redis-server *:6379
root     29357 25962  0 22:54 pts/4    00:00:00 grep --color=auto redis

Use the client connection test connected to the redis service. As shown in the figure below, the connection is successful.

Guess you like

Origin blog.csdn.net/csl12919/article/details/131435112