码迷,mamicode.com
首页 > 其他好文 > 详细

阿里云64位centos6.3系统上编译安装redis

时间:2014-05-12 09:27:33      阅读:510      评论:0      收藏:0      [点我收藏+]

标签:style   blog   class   code   java   tar   

环境

系统:阿里云64位centos 6.3

bubuko.com,布布扣
[rao@AY~]$ cat /etc/issue
CentOS release 6.3 (Final)
Kernel \r on an \m

[rao@AY~]$ uname -a
Linux AY1404062027584053a1Z 2.6.32-358.6.2.el6.x86_64 #1 SMP Thu May 16 20:59:36 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
bubuko.com,布布扣

 

下载最新版redis:

[rao@~Packages]$ wget http://download.redis.io/releases/redis-2.8.9.tar.gz
[rao@~Packages]$ tar zxvf redis-2.8.9.tar.gz

 

编译redis:

[rao@~ Packages]$ tar zxvf redis-2.8.9.tar.gz
[rao@~ Packages]$ cd redis-2.8.9
[rao@~ redis-2.8.9]$ make

 

报错:

bubuko.com,布布扣
cd src && make all
make[1]: Entering directory `/home/rao/Packages/redis-2.8.9/src    CC adlist.o
在包含自 /usr/include/features.h:385 的文件中,
                 从 /usr/include/stdlib.h:25,
                 从 adlist.c:32:
/usr/include/gnu/stubs.h:7:27: 错误:gnu/stubs-32.h:没有那个文件或目录
make[1]: *** [adlist.o] 错误 1
make[1]: Leaving directory `/home/rao/Packages/redis-2.8.9/srcmake: *** [all] 错误 2
bubuko.com,布布扣

 

redis的README中有说明:

In case of build errors when trying to build a 32 bit binary of Redis, try
the following steps:

* Install the packages libc6-dev-i386 (also try g++-multilib).

但是centos中并没有libc6-dev-i386这个包,查了一下需要的头文件在glibc-devel这个包中。

 

安装glibc-devel:

bubuko.com,布布扣
[rao@~ Packages]$ sudo yum install glibc-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package glibc-devel.x86_64 0:2.12-1.107.el6_4.2 will be updated
---> Package glibc-devel.x86_64 0:2.12-1.132.el6 will be an update
--> Processing Dependency: glibc-headers = 2.12-1.132.el6 for package: glibc-devel-2.12-1.132.el6.x86_64
--> Processing Dependency: glibc = 2.12-1.132.el6 for package: glibc-devel-2.12-1.132.el6.x86_64
--> Running transaction check
---> Package glibc.x86_64 0:2.12-1.107.el6_4.2 will be updated
--> Processing Dependency: glibc = 2.12-1.107.el6_4.2 for package: nscd-2.12-1.107.el6_4.2.x86_64
--> Processing Dependency: glibc = 2.12-1.107.el6_4.2 for package: glibc-common-2.12-1.107.el6_4.2.x86_64
---> Package glibc.x86_64 0:2.12-1.132.el6 will be an update
---> Package glibc-headers.x86_64 0:2.12-1.107.el6_4.2 will be updated
---> Package glibc-headers.x86_64 0:2.12-1.132.el6 will be an update
--> Running transaction check
---> Package glibc-common.x86_64 0:2.12-1.107.el6_4.2 will be updated
---> Package glibc-common.x86_64 0:2.12-1.132.el6 will be an update
---> Package nscd.x86_64 0:2.12-1.107.el6_4.2 will be updated
---> Package nscd.x86_64 0:2.12-1.132.el6 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================
 Package                        Arch                    Version                           Repository             Size
======================================================================================================================
Updating:
 glibc-devel                    x86_64                  2.12-1.132.el6                    base                  978 k
Updating for dependencies:
 glibc                          x86_64                  2.12-1.132.el6                    base                  3.8 M
 glibc-common                   x86_64                  2.12-1.132.el6                    base                   14 M
 glibc-headers                  x86_64                  2.12-1.132.el6                    base                  608 k
 nscd                           x86_64                  2.12-1.132.el6                    base                  219 k

Transaction Summary
======================================================================================================================
Upgrade       5 Package(s)

Total download size: 20 M
Is this ok [y/N]: y
Downloading Packages:
(1/5): glibc-2.12-1.132.el6.x86_64.rpm                                                         | 3.8 MB     00:00     
(2/5): glibc-common-2.12-1.132.el6.x86_64.rpm                                                  |  14 MB     00:02     
(3/5): glibc-devel-2.12-1.132.el6.x86_64.rpm                                                   | 978 kB     00:00     
(4/5): glibc-headers-2.12-1.132.el6.x86_64.rpm                                                 | 608 kB     00:00     
(5/5): nscd-2.12-1.132.el6.x86_64.rpm                                                          | 219 kB     00:00     
----------------------------------------------------------------------------------------------------------------------
Total                                                                                 5.7 MB/s |  20 MB     00:03     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : glibc-common-2.12-1.132.el6.x86_64                                                                1/10 
  Updating   : glibc-2.12-1.132.el6.x86_64                                                                       2/10 
  Updating   : glibc-headers-2.12-1.132.el6.x86_64                                                               3/10 
  Updating   : glibc-devel-2.12-1.132.el6.x86_64                                                                 4/10 
  Updating   : nscd-2.12-1.132.el6.x86_64                                                                        5/10 
warning: /etc/nscd.conf created as /etc/nscd.conf.rpmnew
  Cleanup    : glibc-devel-2.12-1.107.el6_4.2.x86_64                                                             6/10 
  Cleanup    : glibc-headers-2.12-1.107.el6_4.2.x86_64                                                           7/10 
  Cleanup    : nscd-2.12-1.107.el6_4.2.x86_64                                                                    8/10 
  Cleanup    : glibc-common-2.12-1.107.el6_4.2.x86_64                                                            9/10 
  Cleanup    : glibc-2.12-1.107.el6_4.2.x86_64                                                                  10/10 
  Verifying  : glibc-2.12-1.132.el6.x86_64                                                                       1/10 
  Verifying  : glibc-devel-2.12-1.132.el6.x86_64                                                                 2/10 
  Verifying  : glibc-common-2.12-1.132.el6.x86_64                                                                3/10 
  Verifying  : nscd-2.12-1.132.el6.x86_64                                                                        4/10 
  Verifying  : glibc-headers-2.12-1.132.el6.x86_64                                                               5/10 
  Verifying  : glibc-common-2.12-1.107.el6_4.2.x86_64                                                            6/10 
  Verifying  : glibc-2.12-1.107.el6_4.2.x86_64                                                                   7/10 
  Verifying  : glibc-devel-2.12-1.107.el6_4.2.x86_64                                                             8/10 
  Verifying  : glibc-headers-2.12-1.107.el6_4.2.x86_64                                                           9/10 
  Verifying  : nscd-2.12-1.107.el6_4.2.x86_64                                                                   10/10 

Updated:
  glibc-devel.x86_64 0:2.12-1.132.el6                                                                                 

Dependency Updated:
  glibc.x86_64 0:2.12-1.132.el6     glibc-common.x86_64 0:2.12-1.132.el6     glibc-headers.x86_64 0:2.12-1.132.el6    
  nscd.x86_64 0:2.12-1.132.el6     

Complete!
bubuko.com,布布扣

 

继续make,还是报同样的错误。但是明明已经安装了glibc-devel包啊?

[rao@~ redis-2.8.9]$ ls /usr/include/gnu/
libc-version.h  lib-names.h     stubs-64.h      stubs.h  

确实没有所需要的头文件“gnu/stubs-32.h”。

 

再检查安装glibc-devel包的过程,其安装的包名称是“glibc-devel-2.12-1.132.el6.x86_64.rpm”,从yum的源(http://mirrors.163.com/centos/6/os/x86_64/Packages/)中下载该rpm包,解压察看发现:该rpm包中确实没有头文件“gnu/stubs-32.h”。

也就是说:通过“sudo yum install glibc-devel”命令安装的“glibc-devel-2.12-1.132.el6.x86_64.rpm”中并不是我们需要的rpm包?

 

那么到底需要安装哪个rpm包呢?

刚才在yum的源中,注意到存在两个版本号相同的glibc-devel:

glibc-devel-2.12-1.132.el6.i686.rpm 25-Nov-2013 03:29 1001468
glibc-devel-2.12-1.132.el6.x86_64.rpm 25-Nov-2013 03:31 1001012

第二个就是刚才通过“sudo yum install glibc-devel”命令安装的包,从名字看是64位系统的,那么第一个就应该是32位的。

 

下载第一个包“glibc-devel-2.12-1.132.el6.i686.rpm”,解压看看里面有什么文件:

bubuko.com,布布扣
[rao@~ Packages]$ rpm2cpio glibc-devel-2.12-1.132.el6.i686.rpm | cpio -div
./usr/include/gnu/stubs-32.h
./usr/lib/Mcrt1.o
./usr/lib/Scrt1.o
./usr/lib/crt1.o
./usr/lib/crti.o
./usr/lib/crtn.o
./usr/lib/gcrt1.o
./usr/lib/libBrokenLocale.so
./usr/lib/libanl.so
./usr/lib/libbsd-compat.a
./usr/lib/libbsd.a
./usr/lib/libc.so
./usr/lib/libc_nonshared.a
./usr/lib/libcidn.so
./usr/lib/libcrypt.so
./usr/lib/libdl.so
./usr/lib/libg.a
./usr/lib/libieee.a
./usr/lib/libm.so
./usr/lib/libmcheck.a
./usr/lib/libnsl.so
./usr/lib/libnss_compat.so
./usr/lib/libnss_dns.so
./usr/lib/libnss_files.so
./usr/lib/libnss_hesiod.so
./usr/lib/libnss_nis.so
./usr/lib/libnss_nisplus.so
./usr/lib/libpthread.so
./usr/lib/libpthread_nonshared.a
./usr/lib/libresolv.so
./usr/lib/librpcsvc.a
./usr/lib/librt.so
./usr/lib/libthread_db.so
./usr/lib/libutil.so
./usr/share/info/libc.info-1.gz
./usr/share/info/libc.info-10.gz
./usr/share/info/libc.info-11.gz
./usr/share/info/libc.info-2.gz
./usr/share/info/libc.info-3.gz
./usr/share/info/libc.info-4.gz
./usr/share/info/libc.info-5.gz
./usr/share/info/libc.info-6.gz
./usr/share/info/libc.info-7.gz
./usr/share/info/libc.info-8.gz
./usr/share/info/libc.info-9.gz
./usr/share/info/libc.info.gz
1920
bubuko.com,布布扣

可以看到里面刚好有我们需要的头文件“gnu/stubs-32.h”。

 

那么执行“sudo yum install glibc-devel”命令为什么安装的是“glibc-devel-2.12-1.132.el6.x86_64.rpm”而不是我们需要的“glibc-devel-2.12-1.132.el6.i686.rpm”包呢?

 

我猜是在64位系统中,yum在安装时发现同一个包存在两个版本时,默认优先安装64位的rpm包。

那该怎么让yum安装“glibc-devel-2.12-1.132.el6.i686.rpm”呢?

 

既然我已经下载了该包,就用rpm命令手动安装试试看:

bubuko.com,布布扣
[rao@~ redis-2.8.9]$ sudo rpm -ivh glibc-devel-2.12-1.132.el6.i686.rpm 
error: Failed dependencies:
    libBrokenLocale.so.1 is needed by glibc-devel-2.12-1.132.el6.i686
    libanl.so.1 is needed by glibc-devel-2.12-1.132.el6.i686
    libcidn.so.1 is needed by glibc-devel-2.12-1.132.el6.i686
    libcrypt.so.1 is needed by glibc-devel-2.12-1.132.el6.i686
    libdl.so.2 is needed by glibc-devel-2.12-1.132.el6.i686
    libm.so.6 is needed by glibc-devel-2.12-1.132.el6.i686
    libnsl.so.1 is needed by glibc-devel-2.12-1.132.el6.i686
    libnss_compat.so.2 is needed by glibc-devel-2.12-1.132.el6.i686
    libnss_dns.so.2 is needed by glibc-devel-2.12-1.132.el6.i686
    libnss_files.so.2 is needed by glibc-devel-2.12-1.132.el6.i686
    libnss_hesiod.so.2 is needed by glibc-devel-2.12-1.132.el6.i686
    libnss_nis.so.2 is needed by glibc-devel-2.12-1.132.el6.i686
    libnss_nisplus.so.2 is needed by glibc-devel-2.12-1.132.el6.i686
    libresolv.so.2 is needed by glibc-devel-2.12-1.132.el6.i686
    librt.so.1 is needed by glibc-devel-2.12-1.132.el6.i686
    libthread_db.so.1 is needed by glibc-devel-2.12-1.132.el6.i686
    libutil.so.1 is needed by glibc-devel-2.12-1.132.el6.i686
bubuko.com,布布扣

看来不行,缺少一堆依赖文件。

 

网上查到可以通过"yum install glibc-devel.i686"命令安装32位的glibc-devel:

bubuko.com,布布扣
[rao@~ redis-2.8.9]$ sudo yum install glibc-devel.i686
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
Setting up Install Process
No package glibc-devel.i686 available.
Error: Nothing to do
bubuko.com,布布扣

找不到?明明有这个包啊。。。。

 

bubuko.com,布布扣
[rao@~ redis-2.8.9]$ yum list|grep libc
glibc.x86_64                              2.12-1.132.el6                @base   
glibc-common.x86_64                       2.12-1.132.el6                @base   
glibc-devel.x86_64                        2.12-1.132.el6                @base   
glibc-headers.x86_64                      2.12-1.132.el6                @base   
libcap.x86_64                             2.16-5.5.el6                  @anaconda-CentOS-201207061011.x86_64/6.3
libcap-ng.x86_64                          0.6.4-3.el6_0.1               @anaconda-CentOS-201207061011.x86_64/6.3
libcom_err.x86_64                         1.41.12-18.el6                @base   
libcom_err-devel.x86_64                   1.41.12-18.el6                @base   
libcurl.x86_64                            7.19.7-26.el6_2.4             @anaconda-CentOS-201207061011.x86_64/6.3
compat-glibc.x86_64                       1:2.5-46.2                    base    
compat-glibc-headers.x86_64               1:2.5-46.2                    base    
compat-libcap1.x86_64                     1.10-1                        base    
glibc-static.x86_64                       2.12-1.132.el6                base    
glibc-utils.x86_64                        2.12-1.132.el6                base    
libc-client.x86_64                        2007e-11.el6                  base    
libc-client-devel.x86_64                  2007e-11.el6                  base    
libcacard.x86_64                          0.15.0-2.el6                  base    
libcacard-devel.x86_64                    0.15.0-2.el6                  base    
libcacard-tools.x86_64                    0.15.0-2.el6                  base    
libcanberra.x86_64                        0.22-1.el6.centos             base    
libcanberra-devel.x86_64                  0.22-1.el6.centos             base    
libcanberra-gtk2.x86_64                   0.22-1.el6.centos             base    
libcap-devel.x86_64                       2.16-5.5.el6                  base    
libcap-ng-devel.x86_64                    0.6.4-3.el6_0.1               base    
libcap-ng-python.x86_64                   0.6.4-3.el6_0.1               base    
libcap-ng-utils.x86_64                    0.6.4-3.el6_0.1               base    
libcdio.x86_64                            0.81-3.1.el6                  base    
libcdio-devel.x86_64                      0.81-3.1.el6                  base    
libcgroup.x86_64                          0.40.rc1-5.el6_5.1            updates 
libcgroup-devel.x86_64                    0.40.rc1-5.el6_5.1            updates 
libcgroup-pam.x86_64                      0.40.rc1-5.el6_5.1            updates 
libchewing.x86_64                         0.3.2-27.el6                  base    
libchewing-devel.x86_64                   0.3.2-27.el6                  base    
libchewing-python.x86_64                  0.3.2-27.el6                  base    
libcmpiCppImpl0.x86_64                    2.0.1-5.el6                   base    
libcmpiutil.x86_64                        0.5.6-1.el6                   base    
libcmpiutil-devel.x86_64                  0.5.6-1.el6                   base    
libcollection.x86_64                      0.6.0-9.el6                   base    
libcollection-devel.x86_64                0.6.0-9.el6                   base    
libconfig.x86_64                          1.3.2-1.1.el6                 base    
libconfig-devel.x86_64                    1.3.2-1.1.el6                 base    
libcroco.x86_64                           0.6.2-5.el6                   base    
libcroco-devel.x86_64                     0.6.2-5.el6                   base    
libcurl.x86_64                            7.19.7-37.el6_4               base    
libcurl-devel.x86_64                      7.19.7-37.el6_4               base    
libcxgb3.x86_64                           1.3.1-1.el6                   base    
libcxgb3-static.x86_64                    1.3.1-1.el6                   base    
libcxgb4.x86_64                           1.2.0-1.el6                   base    
libcxgb4-static.x86_64                    1.2.0-1.el6                   base    
bubuko.com,布布扣

可以看到yum命令确实只能找到64位的rpm包,但yum的源中又确实有32位的rpm包啊。。。问题处在哪呢?

 

打开yum的配置文件/etc/yum.conf看看,发现一行可疑的配置:

exclude=*.i?86 kernel kernel-xen kernel-debug

从内容看,似乎yum刻意忽略了32位的rpm包?

 

不管三七二十一,去掉试试看,修改成如下:

exclude= kernel kernel-xen kernel-debug

 

bubuko.com,布布扣
[rao@AY1404062027584053a1Z etc]$ yum list |grep glibc
glibc.x86_64                           2.12-1.132.el6                    @base  
glibc-common.x86_64                    2.12-1.132.el6                    @base  
glibc-devel.x86_64                     2.12-1.132.el6                    @base  
glibc-headers.x86_64                   2.12-1.132.el6                    @base  
compat-glibc.x86_64                    1:2.5-46.2                        base   
compat-glibc-headers.x86_64            1:2.5-46.2                        base   
glibc.i686                             2.12-1.132.el6                    base   
glibc-devel.i686                       2.12-1.132.el6                    base   
glibc-static.i686                      2.12-1.132.el6                    base   
glibc-static.x86_64                    2.12-1.132.el6                    base   
glibc-utils.x86_64                     2.12-1.132.el6                    base   
bubuko.com,布布扣

果然多了一个32位的rpm包,看来有戏。

 

再执行命令”sudo yum install glibc-devel.i686",终于安装成功了。

再继续编译redis,很快就搞定了。

 

 

总结:

原因:阿里云64位centos6.3上,默认的yum配置不安装32位的rpm包,导致编译redis需要的“glibc-devel.i686”无法被安装。

解决办法:修改yum的配置文件/etc/yum.conf,将”exclude=*.i?86 kernel kernel-xen kernel-debug“改成”exclude= kernel kernel-xen kernel-debug“即可。

不确定这个配置是centos的默认配置,还是阿里云的修改,总之很坑爹,浪费了我一个美好的周末。

阿里云64位centos6.3系统上编译安装redis,布布扣,bubuko.com

阿里云64位centos6.3系统上编译安装redis

标签:style   blog   class   code   java   tar   

原文地址:http://www.cnblogs.com/chutianyao/p/3720723.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!