linux 发行版 Centos 7 安装redis 6.0.4


Centos 7安装Redis 6.0.4

  • 安装前准备
  • 第一步 下载
  • 第二步 解压
  • 第三步 编译
  • 第四步 启动
  • 第五步 退出
  • 参考资料

安装前准备
  1. 一个网络OK的Centos 7环境。这里我们选择在window上安装,VMWare的虚拟机。
  2. 远程操作linux的工具,这里我们选择比较简单的 SecureCRT
第一步 下载 进入到 /usr/local/ 目录下执行下载指令:
$ wget http://download.redis.io/releases/redis-6.0.4.tar.gz

第二步 解压
$ tar xzf redis-6.0.4.tar.gz

第三步 编译 因为我们下载的是redis的源代码,用C语言编写的,需要编译后才可以在操作系统上安装。
$ cd redis-6.0.4 $ make

eg:这里有个坑
编译报错如下:
server.c:5099:19: error: ‘struct redisServer’ has no member named ‘ipfd_count’ if (server.ipfd_count > 0 || server.tlsfd_count > 0) ^ server.c:5099:44: error: ‘struct redisServer’ has no member named ‘tlsfd_count’ if (server.ipfd_count > 0 || server.tlsfd_count > 0) ^ server.c:5101:19: error: ‘struct redisServer’ has no member named ‘sofd’ if (server.sofd > 0) ^ server.c:5102:94: error: ‘struct redisServer’ has no member named ‘unixsocket’ serverLog(LL_NOTICE,"The server is now ready to accept connections at %s", server.unixsocket); ^ server.c:5103:19: error: ‘struct redisServer’ has no member named ‘supervised_mode’ if (server.supervised_mode == SUPERVISED_SYSTEMD) { ^ server.c:5104:24: error: ‘struct redisServer’ has no member named ‘masterhost’ if (!server.masterhost) { ^ server.c:5117:15: error: ‘struct redisServer’ has no member named ‘maxmemory’ if (server.maxmemory > 0 && server.maxmemory < 1024*1024) { ^ server.c:5117:39: error: ‘struct redisServer’ has no member named ‘maxmemory’ if (server.maxmemory > 0 && server.maxmemory < 1024*1024) { ^ server.c:5118:176: error: ‘struct redisServer’ has no member named ‘maxmemory’ serverLog(LL_WARNING,"WARNING: You specified a maxmemory value that is less than 1MB (current value is %llu bytes). Are you sure this is what you really want?", server.maxmemory); ^ server.c: In function ‘hasActiveChildProcess’: server.c:1476:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ server.c: In function ‘allPersistenceDisabled’: server.c:1482:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ server.c: In function ‘writeCommandsDeniedByDiskError’: server.c:3747:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ server.c: In function ‘iAmMaster’: server.c:4914:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ make[1]: *** [server.o] Error 1 make[1]: Leaving directory `/usr/local/redis-6.0.1/src' make: *** [all] Error 2

解决办法:
查看gcc版本是否在5.3以上,CentOS7默认安装4.8.5。
升级gcc到5.3以上版本,升级到gcc 9
具体可以参考这位大佬的 文章.
第四步 启动
$ src/redis-server

如下图,就说明成功启动了
linux 发行版 Centos 7 安装redis 6.0.4
文章图片

第五步 退出 采用客户端连接到服务端,执行shutdown命令的这种方式退出
$ ./redis-cli 127.0.0.1:6379> shutdown nosave

参考资料 【linux 发行版 Centos 7 安装redis 6.0.4】1.https://www.cnblogs.com/sanduzxcvbnm/p/12955145.html
2.https://www.cnblogs.com/codexj/p/12606037.html
3.https://blog.csdn.net/july_young/article/details/81675693
4.https://blog.csdn.net/xnlay/article/details/79048508
5.https://www.cnblogs.com/zuidongfeng/p/8032505.html
6.https://redis.io/download

    推荐阅读