CentOS 7 平台下Redis 4.0下载与安装全纪录

1、下载

下载地址:http://redis.io/download 当前最新稳定版是4.0,下载链接是http://download.redis.io/releases/redis-4.0.2.tar.gz

[root@node3 ~]# wget http://download.redis.io/releases/redis-4.0.2.tar.gz
--2017-10-28 08:06:18--  http://download.redis.io/releases/redis-4.0.2.tar.gz
Resolving download.redis.io (download.redis.io)... 109.74.203.151
Connecting to download.redis.io (download.redis.io)|109.74.203.151|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1713990 (1.6M) [application/x-gzip]
Saving to: ‘redis-4.0.2.tar.gz’

100%[==============================================================================================>] 1,713,990    237KB/s   in 7.3s   

2017-10-28 08:06:26 (228 KB/s) - ‘redis-4.0.2.tar.gz’ saved [1713990/1713990]

[root@node3 ~]# 

2、编译安装

(1)解压缩

[root@node3 ~]# tar -zxvf redis-4.0.2.tar.gz

(2)进入redis根目录

[root@node3 ~]# cd redis-4.0.2

(3)开始编译

[root@node3 redis-4.0.2]# make -j 4
cd src && make all
make[1]: Entering directory `/root/redis-4.0.2/src'
    CC Makefile.dep
make[1]: Leaving directory `/root/redis-4.0.2/src'
make[1]: Entering directory `/root/redis-4.0.2/src'
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-rdb redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html Makefile.dep dict-benchmark
(cd ../deps && make distclean)
make[2]: Entering directory `/root/redis-4.0.2/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
make[2]: Leaving directory `/root/redis-4.0.2/deps'
(rm -f .make-*)
echo STD=-std=c99 -pedantic -DREDIS_STATIC='' >> .make-settings
echo WARN=-Wall -W -Wno-missing-field-initializers >> .make-settings
echo OPT=-O2 >> .make-settings
echo MALLOC=jemalloc >> .make-settings
echo CFLAGS= >> .make-settings
echo LDFLAGS= >> .make-settings
echo REDIS_CFLAGS= >> .make-settings
echo REDIS_LDFLAGS= >> .make-settings
echo PREV_FINAL_CFLAGS=-std=c99 -pedantic -DREDIS_STATIC='' -Wall -W -Wno-missing-field-initializers -O2 -g -ggdb   -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -DUSE_JEMALLOC -I../deps/jemalloc/include >> .make-settings
echo PREV_FINAL_LDFLAGS=  -g -ggdb -rdynamic >> .make-settings
(cd ../deps && make hiredis linenoise lua jemalloc)
make[2]: Entering directory `/root/redis-4.0.2/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
(echo "" > .make-cflags)
(echo "" > .make-ldflags)
MAKE hiredis
cd hiredis && make static
MAKE linenoise
cd linenoise && make
make[3]: Entering directory `/root/redis-4.0.2/deps/linenoise'
cc  -Wall -Os -g  -c linenoise.c
MAKE lua
cd lua/src && make all CFLAGS="-O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' " MYLDFLAGS="" AR="ar rcu"
make[3]: cc: Command not found
make[3]: *** [linenoise.o] Error 127
make[3]: Leaving directory `/root/redis-4.0.2/deps/linenoise'
make[2]: *** [linenoise] Error 2
make[2]: *** Waiting for unfinished jobs....
make[3]: Entering directory `/root/redis-4.0.2/deps/hiredis'
gcc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  net.c
make[3]: Entering directory `/root/redis-4.0.2/deps/lua/src'
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lapi.o lapi.c
make[3]: gcc: Command not found
make[3]: *** [net.o] Error 127
make[3]: Leaving directory `/root/redis-4.0.2/deps/hiredis'
make[2]: *** [hiredis] Error 2
make[3]: cc: Command not found
make[3]: *** [lapi.o] Error 127
make[3]: Leaving directory `/root/redis-4.0.2/deps/lua/src'
make[2]: *** [lua] Error 2
make[2]: Leaving directory `/root/redis-4.0.2/deps'
make[1]: [persist-settings] Error 2 (ignored)
    CC adlist.o
/bin/sh: cc: command not found
    CC quicklist.o
make[1]: *** [adlist.o] Error 127
make[1]: *** Waiting for unfinished jobs....
/bin/sh: cc: command not found
make[1]: *** [quicklist.o] Error 127
make[1]: Leaving directory `/root/redis-4.0.2/src'
make: *** [all] Error 2
[root@node3 redis-4.0.2]

(4)解决依赖关系 由于新安装的Linux系统没有安装gcc环境

[root@node3 redis-4.0.2]# yum install -y gcc
[root@node3 redis-4.0.2]# make -j 4
cd src && make all
make[1]: Entering directory `/root/redis-4.0.2/src'
    CC Makefile.dep
make[1]: Leaving directory `/root/redis-4.0.2/src'
make[1]: Entering directory `/root/redis-4.0.2/src'
    CC adlist.o
    CC quicklist.o
    CC ae.o
    CC anet.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.
In file included from quicklist.c:33:0:
zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory
 #include <jemalloc/jemalloc.h>
                               ^
compilation terminated.
In file included from ae.c:44: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]: *** Waiting for unfinished jobs....
make[1]: *** [quicklist.o] Error 1
make[1]: *** [ae.o] Error 1
make[1]: Leaving directory `/root/redis-4.0.2/src'
make: *** [all] Error 2
[root@node3 redis-4.0.2]# 
[root@node3 redis-4.0.2]# yum install -y jemalloc-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
No package jemalloc-devel available.
Error: Nothing to do
[root@node3 redis-4.0.2]#

百度一下,有网友说可以这样解决make MALLOC=libc,下面试试

[root@node3 redis-4.0.2]# make -j 4 MALLOC=libc
....

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

make[1]: Leaving directory `/root/redis-4.0.2/src'
[root@node3 redis-4.0.2]# 

编译完成。

[root@node3 redis-4.0.2]# make test
cd src && make test
make[1]: Entering directory `/root/redis-4.0.2/src'
You need tcl 8.5 or newer in order to run the Redis test
make[1]: *** [test] Error 1
make[1]: Leaving directory `/root/redis-4.0.2/src'
make: *** [test] Error 2
[root@node3 redis-4.0.2]#

提示需要安装tcl

[root@node3 redis-4.0.2]# yum install -y tcl

再次测试

[root@node3 redis-4.0.2]# make test
...

  167 seconds - unit/obuf-limits

\o/ All tests passed without errors!

Cleanup: may take some time... OK
make[1]: Leaving directory `/root/redis-4.0.2/src'
[root@node3 redis-4.0.2]# 

最终编译完成。

编译总结:

  • 编译前需要安装依赖 yum install -y gcc tcl
  • 然后再编译 make -j 4 MALLOC=libc
[root@node3 redis-4.0.2]# make install
cd src && make install
make[1]: Entering directory `/root/redis-4.0.2/src'

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

    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
make[1]: Leaving directory `/root/redis-4.0.2/src'
[root@node3 redis-4.0.2]# 

3、配置

Redis外部访问

[root@node3 redis-4.0.2]# vi redis.conf

修改3处:

  • 注释掉 #bind 127.0.0.1
  • 设置守护进程 daemonize yes
  • 禁用保护模式 protected-mode no

4、启动服务

编译后,在src目录下将出现一个redis服务程序redis-server

使用下面命令启动,通过启动参数告诉redis使用指定配置文件

[root@node3 redis-4.0.2]# src/redis-server redis.conf 
7311:C 28 Oct 08:49:25.126 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
7311:C 28 Oct 08:49:25.126 # Redis version=4.0.2, bits=64, commit=00000000, modified=0, pid=7311, just started
7311:C 28 Oct 08:49:25.126 # Configuration loaded
[root@node3 redis-4.0.2]# ps -aux|grep redis
root       7312  0.0  0.1 141768  1964 ?        Ssl  08:49   0:00 src/redis-server *:6379
root       7317  0.0  0.0 112660   964 pts/0    S+   08:49   0:00 grep --color=auto redis
[root@node3 redis-4.0.2]# 

5、使用redis-cli访问redis

[root@node3 redis-4.0.2]# src/redis-cli 
127.0.0.1:6379> set "hadron" "chengyuqiang"
OK
127.0.0.1:6379> get "hadron"
"chengyuqiang"
127.0.0.1:6379> 

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏along的开发之旅

Mac os 下打开java内存分析工具 mat

版权声明:欢迎传播,请标明出处。 https://blog.csdn.net/u201011221/article/details/8305...

633
来自专栏跟着阿笨一起玩NET

ASP.NET datable导出excel

本文转载:http://www.cnblogs.com/chwkai/archive/2005/10/08/250426.html

532
来自专栏前端架构

flash上传文件的actionscript代码

634
来自专栏deepcc

微信图片上传,遇到一个神奇的jgp

3569
来自专栏沈唁志

USpider~一只超级污的司机蜘蛛

之前就看到了狂放小朋友的PHP版本的污言爬虫,然后我就征求了一下小朋友的意见,就改成了Python版本的爬虫,也算是当做练手了

982
来自专栏向治洪

butternife Zelezny自动注入插件

插件地址:http://plugins.jetbrains.com/plugin/7369 Products: IntelliJ IDEA, RubyMine...

1798
来自专栏开源项目

精选国产 IntelliJ IDEA 优秀插件 | 码云周刊第 50 期

IntelliJ IDEA 在业界被公认为最好的 Java 开发平台之一,在智能代码助手、代码自动提示、J2EE 支持、Ant、JUnit、代码审查等方面都有不...

3535
来自专栏码匠的流水账

聊聊reactive streams的processors

processors既是Publisher也是Subscriber。在project reactor中processor有诸多实现,他们的分类大致如下:

561
来自专栏为数不多的Android技巧

无需Root也能使用Xposed!

Xposed是Android系统上久负盛名的一个框架,它给了普通用户任意 DIY 系统的能力;比如典型的微信防撤回、自动抢红包、修改主题字体,以及模拟位置等等等...

672
来自专栏企鹅号快讯

无需 Root 也能使用 Xposed!

Xposed是Android系统上久负盛名的一个框架,它给了普通用户任意 DIY 系统的能力;比如典型的微信防撤回、自动抢红包、修改主题字体,以及模拟位置等等等...

46410

扫码关注云+社区