Linux installation Redis implementation process and error solution

Linux installation Redis implementation process and error solution

I installed redis today and some errors occurred that had not occurred before. I will record them here.

1. Install redis and errors

First download redis, the official download address page: https://redis.io/download

We choose the stable version 6.0.1 here

The normal installation steps are as follows:

[root@localhost ~]# yum install gcc
[root@localhost ~]# cd /usr/local
[root@localhost local]# wget http://download.redis.io/releases/redis-6.0.1.tar.gz
[root@localhost local]# tar -xvf redis-6.0.1.tar.gz
[root@localhost local]# cd /usr/local/redis-6.0.1/
[root@localhost redis-6.0.1]# make PREFIX=/usr/local/redis install

The following error is reported here

make[1]: *** [server.o] Error 1
make[1]: Leaving directory "/usr/redis-6.0.1/src"
make: *** [all] Error 2

server.c:2402:11: error: 'struct redisServer' has no member named 'assert_file'
server.assert_file = "<no file>";
^
server.c:2403:11: error: 'struct redisServer' has no member named 'assert_line'
server.assert_line = 0;
^
server.c:2404:11: error: 'struct redisServer' has no member named 'bug_report_start'
server.bug_report_start = 0;
^
server.c:2405:11: error: 'struct redisServer' has no member named 'watchdog_period'
server.watchdog_period = 0;
^
server.c:2411:11: error: 'struct redisServer' has no member named 'lua_always_replicate_commands'
server.lua_always_replicate_commands = 1;
^
server.c: In function 'restartServer':
server.c:2464:32: error: 'struct redisServer' has no member named 'maxclients'
for (j = 3; j < (int)server.maxclients + 1024; j++) {
^
server.c: In function 'adjustOpenFilesLimit':
server.c:2491:29: error: 'struct redisServer' has no member named 'maxclients'
rlim_t maxfiles = server.maxclients+CONFIG_MIN_RESERVED_FDS;
^
server.c:2497:15: error: 'struct redisServer' has no member named 'maxclients'
server.maxclients = 1024 - CONFIG_MIN_RESERVED_FDS;
^
server.c:2529:53: error: 'struct redisServer' has no member named 'maxclients'
unsigned int old_maxclients = server.maxclients;
^
server.c:2530:23: error: 'struct redisServer' has no member named 'maxclients'
server.maxclients = bestlimit-CONFIG_MIN_RESERVED_FDS;
^
server.c:2554:59: error: 'struct redisServer' has no member named 'maxclients'
(unsigned long long) bestlimit, server.maxclients);
^
server.c: In function 'checkTcpBacklogSettings':
server.c:2574:48: error: 'struct redisServer' has no member named 'tcp_backlog'
if (somaxconn > 0 && somaxconn < server.tcp_backlog) {
^
server.c:2575:171: error: 'struct redisServer' has no member named 'tcp_backlog'
serverLog(LL_WARNING,"WARNING: The TCP backlog setting of %d cannot be enforced because /proc/sys/net /core/somaxconn is set to the lower value of %d.", server.tcp_backlog, somaxconn);

Solution: Upgrade the gcc version

[root@localhost redis-6.0.1]# gcc -v # View gcc version
[root@localhost redis-6.0.1]# yum -y install centos-release-scl # Upgrade to version 9.1
[root@localhost redis-6.0.1]# yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
[root@localhost redis-6.0.1]# scl enable devtoolset-9 bash
The above is for temporary use. If you want to use gcc 9.1 for a long time:
[root@localhost redis-6.0.1]# echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile

Then compile:

[root@mmjredis redis-6.0.1]# make PREFIX=/usr/local/redis install

If the installation is successful, the following message will appear: Hint: It's a good idea to run 'make test' 😉

Let's execute make test to test it.

The following error occurred:

[root@localhost redis-6.0.1]# make test
cd src && make test
make[1]: Enter directory "/usr/redis-6.0.1/src"
CC Makefile.dep
make[1]: Leaving directory "/usr/redis-6.0.1/src"
make[1]: Enter directory "/usr/redis-6.0.1/src"
You need tcl 8.5 or newer in order to run the Redis test
make[1]: *** [test] Error 1
make[1]: Leaving directory "/usr/redis-6.0.1/src"
make: *** [test] Error 2

Solution:

[root@localhost redis-6.0.1]# yum install tcl[root@localhost redis-6.0.1]# make test

The test succeeded as follows:

Run redis first and try it:

[root@localhost redis-6.0.1]# /usr/local/redis-6.0.1/src/redis-server /usr/local/redis-6.0.1/redis.conf
32101:C 13 May 2020 17:01:48.248 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
32101:C 13 May 2020 17:01:48.248 # Redis version=6.0.1, bits=64, commit=00000000, modified=0, pid=32101, just started
32101:C 13 May 2020 17:01:48.248 # Configuration loaded
32101:M 13 May 2020 17:01:48.249 * Increased maximum number of open files to 10032 (it was originally set to 1024).
        _._
      _.-``__ ''-._
   _.-`` `. `_. ''-._ Redis 6.0.1 (00000000/0) 64 bit
 .-`` .-```. ```\/ _.,_ ''-._
 ( ' , .-` | `, ) Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
 | `-._ `._ / _.-' | PID: 32101
 `-._ `-._ `-./ _.-' _.-'
 |`-._`-._ `-.__.-' _.-'_.-'|
 | `-._`-._ _.-'_.-' | http://redis.io
 `-._ `-._`-.__.-'_.-' _.-'
 |`-._`-._ `-.__.-' _.-'_.-'|
 | `-._`-._ _.-'_.-' |
 `-._ `-._`-.__.-'_.-' _.-'
   `-._ `-.__.-' _.-'
     `-._ _.-'
       `-.__.-' 

2. Background startup

Simple modification of background startup

[root@localhost redis-6.0.1]# vim redis.conf

Change daemonize no to daemonize yes

Run it again

[root@localhost redis-6.0.1]# /usr/redis-6.0.1/src/redis-server /usr/redis-6.0.1/redis.conf
30385:C 13 May 2020 16:57:58.918 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
30385:C 13 May 2020 16:57:58.918 # Redis version=6.0.1, bits=64, commit=00000000, modified=0, pid=30385, just started
30385:C 13 May 2020 16:57:58.918 # Configuration loaded

The background operation is successful, let's check it and terminate the program

[root@localhost redis-6.0.1]# ps -aux|grep redis| grep -v grep
root 29836 0.0 0.0 162416 7912 ? Ssl 16:56 0:00 /usr/redis-6.0.1/src/redis-server 127.0.0.1:6379
[root@localhost redis-6.0.1]# kill -9 29836

What we use here is to start redis with background systemctl

First, add redis to the service service

vim /lib/systemd/system/redis.service

Write

[Unit]
Description=redis
After=network.target

[Service]
Type=forking
PIDFile=/var/run/redis_6379.pid
ExecStart=/usr/local/redis-6.0.1/src/redis-server /usr/local/redis-6.0.1/etc/redis.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

Note the path problem, and the path of PIDFile corresponds to the PIDFile in redis-6.0.1/src/redis-server

wq save and exit

Then run the following

[root@localhost redis-6.0.1]# systemctl enable redis.service # Add to boot

[root@localhost redis-6.0.1]# systemctl is-enabled redis.service # Check whether the boot is successful
enabled

[root@localhost redis-6.0.1]# systemctl start redis #Start redis service

[root@localhost redis-6.0.1]# systemctl status redis //View the running status of redis

If there is a problem with startup, you can view the log and fix it through systemctl status redis

As shown in the figure, it has been successfully started

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • About Linux redis installation and installation problems
  • Installation process and configuration method of redis5.0.5 under Linux
  • Redis Overview and Detailed Tutorial on Installing Redis on Linux
  • Detailed steps to install redis under Linux

<<:  Mysql accidental deletion of data solution and kill statement principle

>>:  JS implements user registration interface function

Recommend

Detailed explanation of how to pass password to ssh/scp command in bash script

Install SSHPASS For most recent operating systems...

Comprehensive explanation of CocosCreator hot update

Table of contents Preface What is Hot Change Coco...

Use scripts to package and upload Docker images with one click

The author has been working on a micro-frontend p...

MySQL log settings and viewing methods

MySQL has the following logs: Error log: -log-err...

How to install Composer in Linux

1. Download the installation script - composer-se...

Docker starts in Exited state

After docker run, the status is always Exited Sol...

CSS navigation bar menu with small triangle implementation code

Many web pages have small triangles in their navi...

Docker and portainer configuration methods under Linux

1. Install and use Docer CE This article takes Ce...

How to install ELK in Docker and implement JSON format log analysis

What is ELK? ELK is a complete set of log collect...

Detailed explanation of Jquery datagrid query

Table of contents Add code to the Tree item; 1. S...

About the pitfalls of implementing specified encoding in MySQL

Written in front Environment: MySQL 5.7+, MySQL d...

Share the problem of Ubuntu 19 not being able to install docker source

According to major websites and personal habits, ...

Docker adds a bridge and sets the IP address range

I don't know if it's because the binary d...

How to remove carriage return characters from text in Linux

When the carriage return character ( Ctrl+M ) mak...

How to install Docker and configure Alibaba Cloud Image Accelerator

Docker Installation There is no need to talk abou...