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

环境

系统:阿里云64位centos 6.3


[[email protected]~]$ cat /etc/issue
CentOS release 6.3 (Final)
Kernel \r on an \m

[[email protected]~]$ 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

下载最新版redis:

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

编译redis:

[[email protected]~ Packages]$ tar zxvf redis-2.8.9.tar.gz
[[email protected]~ Packages]$ cd redis-2.8.9
[[email protected]~ redis-2.8.9]$ make

报错:


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/src‘
make: *** [all] 错误 2

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:


[[email protected]~ 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!

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

[[email protected]~ 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”,解压看看里面有什么文件:


[[email protected]~ 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 块

可以看到里面刚好有我们需要的头文件“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命令手动安装试试看:


[[email protected]~ 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

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

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


[[email protected]~ 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

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


[[email protected]~ 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

可以看到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


[[email protected] 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

果然多了一个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的默认配置,还是阿里云的修改,总之很坑爹,浪费了我一个美好的周末。

时间: 2024-10-25 11:25:10

阿里云64位centos6.3系统上编译安装redis的相关文章

64位的Ubuntu系统上使用汇编nasm和C语言

$ nasm -f elf foo.asm -o foo.o$ gcc -c bar.c -o bar.o$ ld -s  foo.o bar.o -o foobar ld: i386 architecture of input file `foo.o' is incompatible with i386:x86-64 output 意思是nasm 编译产生的是32位的目标代码,gcc 在64位平台上默认产生的是64位的目标代码, 这两者在链接的时候出错,gcc在64位平台上默认以64位的方式链

在CentOS6.7操作系统上编译安装httpd2.4

功能描述: 在CentOS6.7操作系统上,编译安装apache服务,实现定制功能等 一.安装前提 1)安装编译httpd需要的软件包 [[email protected] ~]#  yum -y install wget gcc-c++ ncurses ncurses-devel cmake make perl bison openssl openssl-devel gcc* libxml2 libxml2-devel   curl-devel libjpeg* libpng* freetyp

在Linux系统上编译安装eAccelerator

eAccelerator是一个自由开放源码PHP加速器,优化和动态内容缓存,提高了php脚本的缓存性能,使得PHP脚本在编译的状态下,对服务器的开销几乎完全消除.它还有对脚本起优化作用,以加快其执行效率.使您的PHP程序代码执效率能提高1-10倍. 下载地下:wget http://soft.vpser.net/web/eaccelerator/eaccelerator-eaccelerator-42067ac.tar.gz 或从官方网站下载 http://eaccelerator.net ta

在Windows 64位下为PHP5.6.14安装redis扩展

一.php安装redis扩展 1.使用phpinfo()查看当前版本的信息 2.根据PHP版本号,编译器版本号和CPU架构 选择php_redis-2.2.5-5.6-nts-vc11-x64.zip和php_igbinary-1.2.1-5.5-nts-vc11-x64.zip 下载地址: http://windows.php.net/downloads/pecl/snaps/redis/2.2.5/ http://windows.php.net/downloads/pecl/releases

在CentOS6.7操作系统上编译安装mysql-5.6.31

功能概述: 由于在centos 6.7下通过yum安装的mysql是5.1版本的,不满足需求,因此经常性需要编译安装mysql服务等. 一.安装mysql 1.安装前提 1)安装编译mysql代码所依赖的包 [[email protected] ~]# yum -y install make gcc-c++ cmake bison-devel  ncurses-devel   2)下载mysql-5.5.20源码包 [[email protected] ~]#http://mirrors.soh

最小化安装的64位CentOS6.5上安装Oracle11g R2

安装环境: 操作系统:CentOS6.5 x86_64 安装步骤: 一.按照官方文档安装依赖包,主要包如下: binutils-2.20.51.0.2-5.11.el6 (x86_64) compat-libcap1-1.10-1 (x86_64) compat-libstdc++-33-3.2.3-69.el6 (x86_64) compat-libstdc++-33-3.2.3-69.el6.i686 gcc-4.4.4-13.el6 (x86_64) gcc-c++-4.4.4-13.el

在64位系统上不能安装Matlab notebook的解决方案

在64位系统上不能安装Matlab notebook的解决方案 过程分解 第一步:安装好matlab(附:Matalab R2015a界面) 第二步:在matlab中执行命令 >>notebook -setup  ,完成安装notebook 第三步: 输入命令>>notebook ,启动notebook,弹出如下问题界面(64bit系统安装时) 解决方法:替换下面红色方框内的这段内容 解决方案(拷贝覆盖即可): 添加PtrSafe属性,将: Private Declare  Fun

在阿里云 CentOS 服务器(ECS)上搭建 nginx + mysql + php-fpm 环境

阿里云的云服务器(ECS)可以选择多种操作系统,打算用它运行 Drupal或者 WordPress ,你最好选择 Linux 系统,这篇文章的演示是基于阿里云的 CentOS 操作系统的服务器.我们在上面搭建一个 nginx + mysql + php-fpm 的环境,这就是常说的 LNMP .我们不过多解释什么是什么,而是着重讲流程与方法,想了解具体的细节,去搜索下吧:)这个手册是在阿里云上测试的,不过应该也适用于其它使用 CentOS 系统的服务器. 背景 宁皓网的< CentOS:在阿里云

64位win2003/win2008系统IIS6.0/7.5配置PHP的方法

64位win2003/win2008系统IIS6.0/7.5配置PHP的方法 32位的win2003系统配置PHP,估计很多人都已经驾轻就熟了,不过当遇到64位的系统时,估计又会遇上新的问题了.本文记录了我在64位win2003/win2008系统IIS6.0/7.5配置PHP的方法,第一次配置的人可以参考参考. 64位win2008系统IIS7.5配置PHP环境 用惯IIS6.0的人,对IIS7.5的界面尤为陌生,操作习惯也大不一样,不过这都很容易就上手,就如第一次操作IIS6.0一样. 64