Redis源码编译安装

1)下载Redis安装包(下载链接从Redis官网获取,直接搜索redis进入官网)

[xiaokang@localhost redis-5.0.5]$ cd ~
[xiaokang@localhost ~]$ cd /tmp

# 下载redis源码安装包
[xiaokang@localhost tmp]$ wget http://download.redis.io/releases/redis-5.0.5.tar.gz

 # 可以看到已经下载好redis-5.0.5.tar.gz
[xiaokang@localhost tmp]$ ls 
general.log                                 redis-5.0.5.tar.gz
mysql80-community-release-el7-3.noarch.rpm  yum_save_tx.2019-06-16.22-49.ffNk4E.yumtx

2)解压Redis安装包

 

[xiaokang@localhost tmp]$ tar -xzvf  redis-5.0.5.tar.gz  # 解压安装包
[xiaokang@localhost tmp]$ ls
general.log                                 redis-5.0.5.tar.gz
mysql80-community-release-el7-3.noarch.rpm  yum_save_tx.2019-06-16.22-49.ffNk4E.yumtx
redis-5.0.5
[xiaokang@localhost tmp]$ cd redis-5.0.5  # 切换到解压的文件夹中

3)先通过make命令编译,直到不出现错误

make[3]: gcc: Command not found      # (报错gcc不存在)
make[3]: *** [net.o] Error 127
make[3]: Leaving directory `/tmp/redis-5.0.5/deps/hiredis'
make[2]: *** [hiredis] Error 2
make[2]: Leaving directory `/tmp/redis-5.0.5/deps'
make[1]: [persist-settings] Error 2 (ignored)
    CC adlist.o
/bin/sh: cc: command not found
make[1]: *** [adlist.o] Error 127
make[1]: Leaving directory `/tmp/redis-5.0.5/src'
make: *** [all] Error 2     # 可以看到编译出现两个错误

  ① 解决gcc命令不存在错误

 # 安装gcc,解决gcc命令不存在
[xiaokang@localhost redis-5.0.5]$ sudo yum install gcc   

   再次编译

[xiaokang@localhost redis-5.0.5]$ make  # 再次编译
cd src && make all
make[1]: Entering directory `/tmp/redis-5.0.5/src'
    CC Makefile.dep
make[1]: Leaving directory `/tmp/redis-5.0.5/src'
make[1]: Entering directory `/tmp/redis-5.0.5/src'
    CC adlist.o
In file included from adlist.c:34:0:

 #  ( 报错没有找到jemalloc/jemalloc.h文件 )
zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory
 #include 
  .......................

   ② 解决文件不存错误

  # 解决文件不存在问题
 [xiaokang@localhost redis-5.0.5]$ make MALLOC=libc   
 Hint: It's a good idea to run 'make test' ;)
make[1]: Leaving directory `/tmp/redis-5.0.5/src'
   ....................

 #  表示编译完成
   Hint: It's a good idea to run 'make test' ;)   
make[1]: Leaving directory `/tmp/redis-5.0.5/src'

 

4)安装编译完成软件

[xiaokang@localhost redis-5.0.5]$ sudo make install  # 安装编译完软件
cd src && make install
make[1]: Entering directory `/tmp/redis-5.0.5/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 `/tmp/redis-5.0.5/src'

 

以上为Linux下Redis源码编译安装过程

 

 

你可能感兴趣的:(Linux系统)