CentOS 安装redis2.8.13 提醒"libc.so.6: version `GLIBC_2.14' not found"系统的glibc版本太低

时间:2023-02-04 08:54:27

以下在系统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.: version `GLIBC_2.' not found (required by ./redis-server)

2.查看系统glibc支持的版本:

[work@zc-mc-face01 src]$ strings /lib64/libc.so. | grep GLIBC_
GLIBC_2.2.5
GLIBC_2.2.6
GLIBC_2.
GLIBC_2.3.2
GLIBC_2.3.3
GLIBC_2.3.4
GLIBC_2.
GLIBC_2.
GLIBC_2.
GLIBC_2.
GLIBC_2.
GLIBC_2.
GLIBC_2.
GLIBC_2.
GLIBC_2.
GLIBC_PRIVATE
[work@zc-mc-face01 src]$ rpm -qa | grep glibc
glibc-common-2.12-1.80.el6_3..x86_64
glibc-2.12-1.80.el6_3..x86_64
glibc-headers-2.12-1.80.el6_3..x86_64
glibc-devel-2.12-1.80.el6_3..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. NAMESPACE bits elf libidn po string
CANCEL-FCT-WAIVE ChangeLog. NEWS build extra-lib.mk libio posix sunrpc
CANCEL-FILE-WAIVE ChangeLog. NOTES catgets extra-modules.mk locale pwd sysdeps
CONFORMANCE ChangeLog. PROJECTS conf gmon localedata resolv sysvipc
COPYING ChangeLog. README config.h.in gnulib login resource termios
COPYING.LIB ChangeLog. README.libm config.make.in grp mach rt test-skeleton.c
ChangeLog ChangeLog. Rules configure gshadow malloc scripts time
ChangeLog. ChangeLog. Versions.def configure.in hesiod manual setjmp timezone
ChangeLog. FAQ WUR-REPORT conform hurd math shadow tls.make.c
ChangeLog. FAQ.in abi-tags cppflags-iterator.mk iconv misc shlib-versions version.h
ChangeLog. INSTALL abilist crypt iconvdata nis signal wcsmbs
ChangeLog. LICENSES aclocal.m4 csu include nptl socket wctype
ChangeLog. Makeconfig aout ctype inet nptl_db soft-fp
ChangeLog. Makefile argp debug intl nscd stdio-common
ChangeLog. Makefile.in assert dirent io nss stdlib
ChangeLog. 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

  接下来继续运行

. [work@zc-mc-face01 build]# make -j4
. [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./src
[work@zc-mc-face01 src]# ./redis-server