JIYIK CN >

Current Location:Home > Learning > DATABASE > Redis >

Redis installation method and common problem solving under centos

Author:JIYIK Last Updated:2025/04/09 Views:

In this article, we will introduce how to install redis under CentOS. In fact, the installation steps are very simple, but there may be some problems in the middle, which is worthy of our attention.

Let's take a look at how to install it.

First download the redis installation package

# wget http://download.redis.io/releases/redis-4.0.1.tar.gz

Then unzip and install

# tar -zxvf redis-4.0.1.tar.gz -C /usr/local/
# cd /usr/local/redis-4.0.1
# make

After the above commands run successfully, the commands in src can be used

# src/redis-server   //开启redis服务

Similarly, we can use the command in src to connect to the service

# src/redis-cli
> set onmpw bar
OK
> get onmpw
bar

Isn’t it very simple? Yes, it is very simple, so simple that we begin to doubt our lives.

However, the actual situation is not as we think, and problems often occur in actual operations. During the installation process, when we execute the make command, the following error is reported in some cases

zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory
#include <jemalloc/jemalloc.h>
                               ^
compilation terminated.
make[1]: *** [adlist.o] Error 1
make[1]: Leaving directory `/software/redis-4.0.1/src'
make: *** [all] Error 2

What does this error mean? In fact, if we read the README carefully, we will find the following paragraph:

Allocator
---------
 
Selecting a non-default memory allocator when building Redis is done by setting
the `MALLOC` environment variable. Redis is compiled and linked against libc
malloc by default, with the exception of jemalloc being the default on Linux
systems. This default was picked because jemalloc has proven to have fewer
fragmentation problems than libc malloc.
 
To force compiling against libc malloc, use:
 
    % make MALLOC=libc
 
To compile against jemalloc on Mac OS X systems, use:
    
    % make MALLOC=jemalloc

The above paragraph means that if there is an environment variable MALLOC, redis will be built with this environment variable. In addition to using jemalloc by default, Redis will also use libc for compilation on Linux systems. By default, jemalloc will be used for compilation first, because tests have shown that jemalloc will have fewer problems than libc.

Of course, if there is no jemalloc on our system, we can specify to compile with libc through the MALLOC environment variable.

So we can use the following command to compile.

# make MALLOC=libc

This way we can compile normally.

Generally, after make is executed successfully, redis will remind you to test the function.

# make test

This problem comes again, unfortunately the following error will be reported

You need tcl 8.5 or newer in order to run the Redis test
make: *** [test] Error 1

This is easy to understand, that is, the tcl version is too low or tcl does not exist in our system at all. It's very simple, we just install a higher version of tcl.

# wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz
# tar xzvf tcl8.6.1-src.tar.gz  -C /usr/local/
# cd /usr/local/tcl8.6.1/unix/
# ./configure
# make && make install

After the installation is complete, we go to the redis installation directory and execute

# make test

The test can now be performed normally.

At this point, we can use our redis normally. However, we found that when using the redis command, we need to enter the directory where the command is located

# src/redis-cli

Or go into the src directory

# cd src
# ./redis-cli

This is very inconvenient to use. It is also very simple to solve this problem.

# cd redis   //进入redis安装目录。
# make install

Then we can use redis commands directly anywhere.

For reprinting, please send an email to 1244347461@qq.com for approval. After obtaining the author's consent, kindly include the source as a link.

Article URL:

Related Articles

Updating PHP 7.x to 7.4 on CentOS

Publish Date:2025/04/13 Views:131 Category:PHP

This article shows the steps to update the PHP version from 7.x version to 7.4 in CentOS. How to Update PHP from 7.X to 7.4 in CentOS Update operating system packages. yum update -y Check your PHP version in CentOS. php -v Prints a list of

Redis password verification command AUTH

Publish Date:2025/04/09 Views:78 Category:Redis

Redis has not made much optimization in terms of security, but has made great efforts in terms of performance and ease of use. A very simple security method for Redis is password verification, which requires the use of the AUTH command. Let

How to use clion to debug redis source code on mac system

Publish Date:2025/04/09 Views:172 Category:Redis

clion mainly uses cmake + make for compilation. So for redis4, the main thing is to write the CMakeLists.txt file first. CmakeLists.txt file redis4/CMakeLists.txt cmake_minimum_required (VERSION 3.15 ) project (redis4) set (CMAKE_BUILD_TYPE

Mac system uses clion to remotely debug redis4 source code

Publish Date:2025/04/09 Views:129 Category:Redis

The remote host uses the Linux system. The first step is definitely to establish a code synchronization mechanism on the local and remote hosts - sftp is the first choice. The second step is to write the CMakeLists.txt file of redis4. There

How to install manpage in centos

Publish Date:2025/04/07 Views:117 Category:OPERATING SYSTEM

Usually, centos system comes with man commands, which can be used to view the details of commonly used commands. However, sometimes we need to view some functions, and using only the default man functions cannot meet the needs. At this time

Installing and configuring Redis on Mac OS X via Homebrew

Publish Date:2025/04/07 Views:108 Category:OPERATING SYSTEM

By using Homebrew, you can greatly reduce the cost of setting up and configuring a development environment on Mac OS X. Let's install Redis. $ brew install redis After installation, we will see some notifications about configuration conside

How to install GrayLog on centos

Publish Date:2025/04/06 Views:122 Category:OPERATING SYSTEM

Installing Graylog on CentOS requires the following steps: 1. Add EPEL and MongoDB repositories: sudo yum install epel-release -y sudo rpm -Uvh https://repo.mongodb.org/yum/redhat/7/mongodb-org/4.4/x86_64/RPMS/mongodb-org-server-4.4.4-1.el7

How to install Elasticsearch on CentOS

Publish Date:2025/04/06 Views:157 Category:OPERATING SYSTEM

Elasticsearch is an open source search engine developed based on Java, so you need to install the Java runtime environment to run it properly. Specifically, Elasticsearch is a distributed search engine built on Apache Lucene. It uses Java t

Scan to Read All Tech Tutorials

Social Media
  • https://www.github.com/onmpw
  • qq:1244347461

Recommended

Tags

Scan the Code
Easier Access Tutorial