redis7.0.12 安装时报错


​ 好久没安装redis了,开发需求安装redis7,下载了redis7.0.12tar包开始编译,机器环境已经安装过gcc version 8.3.1 20190311 (Red Hat 8.3.1-3) (GCC) 和gcc version 8.3.1 20190311 (Red Hat 8.3.1-3) (GCC) ,在make时出错:

make[1]: [Makefile:355: persist-settings] Error 2 (ignored)

CC adlist.o

In file included from adlist.c:34:

zmalloc.h:50:10: fatal error: jemalloc/jemalloc.h: No such file or directory

#include <jemalloc/jemalloc.h>

网上查找一番,sudo make MALLOC=libc

make distclean 清除之前编译的文件及配置文件再重新make

执行以上命令继续报错:

cc: error: ../deps/hdr_histogram/libhdrhistogram.a: No such file or directory

make[1]: *** [Makefile:374: redis-server] Error 1

make[1]: Leaving directory ‘/data/redis/src’

make: *** [Makefile:6: all] Error 2

cd /data/redis-7.0.12/deps/hdr_histogram

make

-rw-r–r– 1 root root 74296 Sep 10 14:34 hdr_histogram.o

-rwxrwxrwx 1 root root 300 Jul 18 2022 hdr_redis_malloc.h

-rwxrwxrwx 1 root root 631 Jul 18 2022 hdr_tests.h

-rw-r–r– 1 root root 75482 Sep 10 14:34 libhdrhistogram.a

生成libhdrhistogram.a文件,退回到安装目录,make, make install

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

​ INSTALL redis-server

​ INSTALL redis-benchmark

​ INSTALL redis-cli

开机自动启:

vim /etc/systemd/system/redis.service

[Unit]

Description=redis-service

After=syslog.target network.target

 

[Service]

Type=forking

ExecStart=/data/redis/src/redis-server /data/redis/redis.conf

PrivateTmp=true

\#startExecStop=/etc/init.d/redis_6379 

[Install]

WantedBy=multi-user.target

   

systemctl start redis && systemctl enable redis

有时候gcc环境没设置好会有乱七八糟编译报错,再简单一点就是yum 安装:

更新系统软件包:sudo yum update

安装redis依赖库:#sudo yum install epel-release yum-utils

​ #sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

​ #sudo yum-config-manager –enable remi

​ #sudo yum install redis

启动Redis服务:sudo systemctl start redis

设置Redis开机自启动:sudo systemctl enable redis

验证Redis是否成功安装:redis-cli ping,如果返回 “PONG”,则表示Redis安装成功。

安装完成后,你可以根据需要对Redis进行配置和使用。以下是一些常用的Redis配置文件和命令:

· 配置文件路径:/etc/redis.conf

· Redis启动命令:sudo systemctl start/stop/restart/status redis
· Redis配置文件重新加载命令:sudo systemctl reload redis


文章作者: 云上的小雨滴
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 云上的小雨滴 !
评论
  目录