以下在系统CentOS 6.3 x86_64上操作
1.试图运行程序,提示"libc.so.6: version `GLIBC_2.14' not found",原因是系统的glibc版本太低,软件编译时使用了较高版本的glibc引起的:
[work@zc-mc-face01 src]$ ./redis-server
./redis-server: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by ./redis-server)
2.查看系统glibc支持的版本:
[work@zc-mc-face01 src]$ strings /lib64/libc.so.6 | grep GLIBC_
GLIBC_2.2.5
GLIBC_2.2.6
GLIBC_2.3
GLIBC_2.3.2
GLIBC_2.3.3
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.5
GLIBC_2.6
GLIBC_2.7
GLIBC_2.8
GLIBC_2.9
GLIBC_2.10
GLIBC_2.11
GLIBC_2.12
GLIBC_PRIVATE
[work@zc-mc-face01 src]$ rpm -qa | grep glibc
glibc-common-2.12-1.80.el6_3.6.x86_64
glibc-2.12-1.80.el6_3.6.x86_64
glibc-headers-2.12-1.80.el6_3.6.x86_64
glibc-devel-2.12-1.80.el6_3.6.x86_64
3.可以看到当前系统最高只支持2.12版本,所以需要安装新版本来解决这个问题:
编译安装步骤如下:
a. 到http://www.gnu.org/software/libc/下载最新版本,我这里下载了glibc-2.14.tar.gz 这个版本,解压到任意目录准备编译
wget http://ftp.gnu.org/gnu/glibc/glibc-2.14.tar.gz
b.这里解压到~/glibc-2.14/
[work@zc-mc-face01 src]# cd /home/work/glibc-2.14/
[work@zc-mc-face01 glibc-2.14]# ls
BUGS ChangeLog.2 NAMESPACE bits elf libidn po string
CANCEL-FCT-WAIVE ChangeLog.3 NEWS build extra-lib.mk libio posix sunrpc
CANCEL-FILE-WAIVE ChangeLog.4 NOTES catgets extra-modules.mk locale pwd sysdeps
CONFORMANCE ChangeLog.5 PROJECTS conf gmon localedata resolv sysvipc
COPYING ChangeLog.6 README config.h.in gnulib login resource termios
COPYING.LIB ChangeLog.7 README.libm config.make.in grp mach rt test-skeleton.c
ChangeLog ChangeLog.8 Rules configure gshadow malloc scripts time
ChangeLog.1 ChangeLog.9 Versions.def configure.in hesiod manual setjmp timezone
ChangeLog.10 FAQ WUR-REPORT conform hurd math shadow tls.make.c
ChangeLog.11 FAQ.in abi-tags cppflags-iterator.mk iconv misc shlib-versions version.h
ChangeLog.12 INSTALL abilist crypt iconvdata nis signal wcsmbs
ChangeLog.13 LICENSES aclocal.m4 csu include nptl socket wctype
ChangeLog.14 Makeconfig aout ctype inet nptl_db soft-fp
ChangeLog.15 Makefile argp debug intl nscd stdio-common
ChangeLog.16 Makefile.in assert dirent io nss stdlib
ChangeLog.17 Makerules autom4te.cache dlfcn libc-abis o-iterator.mk streams
c.在glibc源码目录建立构建目录,并cd进入构建目录
[work@zc-mc-face01 glibc-2.14]# mkdir build
[work@zc-mc-face01 glibc-2.14]# cd build
d.运行configure配置,make && sudo make install
1. [work@zc-mc-face01 build]# ../configure --prefix=/opt/glibc-2.14
这一步如果config失败,显示错误如下:
checking whether ranlib is necessary... no
checking LD_LIBRARY_PATH variable... contains current directory
configure: error:
*** LD_LIBRARY_PATH shouldn't contain the current directory when
*** building glibc. Please change the environment variable
*** and run configure again.
此时首先查看LD_LIBRARY_PATH:
echo $LD_LIBRARY_PATH
/opt/soft/jdk/jre/lib/amd64/server:
而实际上这个路径的设置是有限制的:
# Test if LD_LIBRARY_PATH contains the notation for the current directory
# since this would lead to problems installing/building glibc.
# LD_LIBRARY_PATH contains the current directory if one of the following
# is true:
# - one of the terminals (":" and ";") is the first or last sign
# - two terminals occur directly after each other
# - the path contains an element with a dot in it
所以这里我们只需要去掉 LD_LIBRARY_PATH 最后的那个路径分隔符':'即可:
export LD_LIBRARY_PATH=/opt/soft/jdk/jre/lib/amd64/server
接下来继续运行
2. [work@zc-mc-face01 build]# make -j4
3. [work@zc-mc-face01 build]# sudo make install
4.临时修改环境变量
[work@zc-mc-face01 build]# export LD_LIBRARY_PATH=/opt/glibc-2.14/lib:$LD_LIBRARY_PATH
5.接下来就可以正常启动redis了
[work@zc-mc-face01 build]# cd ~/app/redis-2.8.13/src
[work@zc-mc-face01 src]# ./redis-server