三三世界-百宝箱

文章 分类 标签
130 9 247

公告

暂无站点公告

CentOS7中安装redis5.0

三三 2022-03-04 1430 0条评论 Linux使用 CentOS7redis5

首页 / 正文

1. 环境介绍
CentOS7 (未安装Development Tools)
2. 下载Redis5.0-rc3
具体的版本下载地址可以参考:

http://download.redis.io/releases/ /*所有版本的目录
http://download.redis.io/releases/redis-5.0.14.tar.gz /*5.x的最新版本是5.0.14

wget -O redis-5.0-rc3.tar.gz https://github.com/antirez/redis/archive/5.0-rc3.tar.gz

3. 解压redis

tar -zxvf redis-5.0-rc3.tar.gz -C /usr/local

4. 编译并安装

cd /usr/local/redis-5.0-rc3
make

此时会出错:

compilation terminated.
make[1]: *** [adlist.o] Error 1
make[1]: Leaving directory `/usr/local/redis-5.0-rc3/src'
make: *** [all] Error 2

安装Development Tools

yum groupinstall 'Development Tools'

再次执行,还会报错

make
cd src && make all
make[1]: Entering directory `/usr/local/redis-5.0-rc3/src'
    CC adlist.o
In file included from adlist.c:34:0:
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 `/usr/local/redis-5.0-rc3/src'
make: *** [all] Error 2

最后解决方案如下:

cd /usr/local/redis-5.0-rc3/deps; make hiredis lua jemalloc linenoise

编译完成后再次在/usr/local/redis-5.0-rc3中执行make命令

cd /usr/local/redis-5.0-rc3
make

出现如下即编译成功

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

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

然后在/usr/local/redis-5.0-rc3/src中执行安装命令:

cd /usr/local/redis-5.0-rc3/src
make install

会出现如下日志信息

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

    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install

5. 修改redis.conf配置文件

vim /usr/local/redis-5.0-rc3/redis.conf

只需要调整如下几个即可

protected-mode no # 关闭保护模式
daemonize yes     # 守护进程模式开启

6. 启动redis5.0

/usr/local/redis-5.0-rc3/src/redis-server /usr/local/redis-5.0-rc3/redis.conf

其实我们在执行make install的时候会将src下面的几个命令复制到/usr/local/bin/下面去,也可以执行如下命令启动redis5.0

/usr/local/bin/redis-server /usr/local/redis-5.0-rc3/redis.conf

检查端口

netstat -ltnp |grep 6379

如果有端口监听,说明redis已经启动成功。

连接下试试

redis-cli
127.0.0.1:6379> info
# Server
redis_version:4.9.103
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:207f31cf830c081e
redis_mode:standalone
os:Linux 3.10.0-693.17.1.el7.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:4.8.5
process_id:20361
run_id:4835668974ad86f1db9b3c8b98e02be1a87a7b9b
tcp_port:6379
uptime_in_seconds:689
uptime_in_days:0
hz:10
lru_clock:3944003

为什么能在任意目录执行redis-cli命令呢,因为redis-cli命令在/usr/local/bin目录里面,而该目录又配置在PATH中,所以你可以向执行ls、mkdir等命令的方式去执行redis-cli或者redis-server等命令。

一般我们在安装完redis后就会将其安装包给删除,那么我们只需要将redis.conf配置文件移动的其他目录,比如:/etc/redis/redis.conf中,具体位置在哪请按照自己的习惯或者规范放置即可。

评论(0)

当前没有评论,还不快来留下第一个脚印吧


Copyright 2021 三三世界-百宝箱. All Rights Reserved.

最新评论

  • 三三

    @Doug Shume it's ok for me , you can post here.

  • refugiaguenther

    Saved as a favorite, I like your website!

  • josefa

    If some one wishes to be updated with hottest technologies after that he must be visit this site and be up to date daily.

  • Penzu

    Heello would you mind sharing which blog platform you're using? I'm planning to start my own blog in the near future but I'm having a tough time making a decision between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your layout seems different then moost blogs and I'm looking for something completely unique. P.S Apologies forr being off-topic butt I had to ask!

  • Yupoo Fendi

    Thanks to my father who shared with me regarding this webpage, this website is genuinely amazing.

  • Doug Shume

    Hi, I have an overflow of customers that I'd like to send to you but I want to make sure you can handle more leads, let me know if you'd like me to send you more info.

  • SuperWind

    zh.us.to 有效
    kms.03k.org 有效
    kms.chinancce.com
    kms.shuax.com 有效
    kms.dwhd.org 有效
    kms.luody.info 有效
    kms.digiboy.ir 有效
    kms.lotro.cc 有效
    www.zgbs.cc 有效
    cy2617.jios.org 有效

  • 三三

    @         权限问题,试试sudo 再加命令。

  •         

    你好提示Permission denied 怎么办啊

日历

2024年05月

   1234
567891011
12131415161718
19202122232425
262728293031 

文章目录

上一张 下一张