前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >CentOS6.5升级自带glibc-2.12到glibc-2.15的过程解析(无需重启)

CentOS6.5升级自带glibc-2.12到glibc-2.15的过程解析(无需重启)

作者头像
孙杰
发布2019-10-29 18:03:35
3.1K0
发布2019-10-29 18:03:35
举报
文章被收录于专栏:云技术+云运维云技术+云运维

在开发时项目所依赖的包需要更高版本的glibc库支持, 而Centos6.5 中glibc默认版本为2.12, 这样调试时可能会遇到报错。但如果不小心把动态库中的libc.so.6给删了,瞬间所有的非系统命令都将无法使用,使用就报错。因为libc.so.6 是c运行时库glibc的软链接,而系统几乎所有程序都依赖c运行时库。程序启动和运行时,是根据libc.so.6 软链接找到glibc库。删除libc.so.6将导致系统的几乎所有程序不能工作。   每个glibc.so文件有它支持的libc版本,可以通过 strings /lib64/libc.so.6 |grep GLIBC 查看,一定要选择这条命令列出的版本。 [root@test1 ~]# 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_2.13 GLIBC_2.14 GLIBC_2.15 GLIBC_PRIVATE

如果程序编译的时候链接的libc库版本不在程序运行环境下的glibc库支持的libc版本之内,也会报错。于是,系统的所有命令 ls,cp,cd 等等都无法使用了。我们可以到这里找你要的版本,http://ftp.gnu.org/gnu/glibc/,然后解压后安装

一、首先查看下本机的glibc版本 [root@test1 ~]# /lib64/libc.so.6 GNU C Library stable release version 2.12, by Roland McGrath et al. Copyright (C) 2010 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Compiled by GNU CC version 4.4.7 20120313 (Red Hat 4.4.7-4). Compiled on a Linux 2.6.32 system on 2013-11-05. Available extensions: The C stubs add-on version 2.1.2. crypt add-on version 2.1 by Michael Glad and others GNU Libidn by Simon Josefsson Native POSIX Threads Library by Ulrich Drepper et al BIND-8.2.3-T5B RT using linux kernel aio libc ABIs: UNIQUE IFUNC For bug reporting instructions, please see: <http://www.gnu.org/software/libc/bugs.html>;.

二、编译安装 [root@test1 ~]# mkdir -pv /path/to/glibc-2.15/build [root@test1 ~]# cd /path/to/glibc-2.15/ [root@test1 ~]# wget http://ftp.gnu.org/gnu/glibc/glibc-2.15.tar.gz [root@test1 ~]# tar xzvf glibc-2.15.tar.gz [root@test1 ~]# cd /path/to/glibc-2.15/build

[root@test1 build]# ../glibc-2.15/configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin 这一步是关键,一定不要在glibc解压的那个目录执行/configure checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking for gcc... no checking for cc... no checking for cl.exe... no configure: error: in /path/to/glibc-2.15/build':<br/>configure: error: no acceptable C compiler found in $PATH<br/>Seeconfig.log' for more details 这个报错是提示你没有gcc和cc编译包

要安装gcc cc 编译包,使用yum安装即可。然后再make、 make install

三、检查验证

[root@test1 build]# ll /lib64/libc* -rwxr-xr-x 1 root root 1926800 Nov 6 2013 /lib64/libc-2.12.so -rwxr-xr-x 1 root root 9801125 Apr 22 11:19 /lib64/libc-2.15.so lrwxrwxrwx. 1 root root 18 Oct 10 2018 /lib64/libcap-ng.so.0 -> libcap-ng.so.0.0.0 -rwxr-xr-x. 1 root root 18672 Nov 5 2010 /lib64/libcap-ng.so.0.0.0 lrwxrwxrwx. 1 root root 14 Oct 10 2018 /lib64/libcap.so.2 -> libcap.so.2.16 -rwxr-xr-x 1 root root 19016 Aug 23 2011 /lib64/libcap.so.2.16 -rwxr-xr-x. 1 root root 197064 Nov 6 2013 /lib64/libcidn-2.12.so -rwxr-xr-x 1 root root 267972 Apr 22 11:19 /lib64/libcidn-2.15.so lrwxrwxrwx 1 root root 15 Apr 22 11:19 /lib64/libcidn.so.1 -> libcidn-2.15.so lrwxrwxrwx. 1 root root 17 Oct 10 2018 /lib64/libcom_err.so.2 -> libcom_err.so.2.1 -rwxr-xr-x 1 root root 17256 Aug 13 2013 /lib64/libcom_err.so.2.1 -rwxr-xr-x 1 root root 43392 Nov 6 2013 /lib64/libcrypt-2.12.so -rwxr-xr-x 1 root root 142947 Apr 22 11:19 /lib64/libcrypt-2.15.so lrwxrwxrwx. 1 root root 22 Oct 10 2018 /lib64/libcryptsetup.so.1 -> libcryptsetup.so.1.1.0 -rwxr-xr-x 1 root root 97072 Feb 29 2012 /lib64/libcryptsetup.so.1.1.0 lrwxrwxrwx 1 root root 16 Apr 22 11:19 /lib64/libcrypt.so.1 -> libcrypt-2.15.so lrwxrwxrwx 1 root root 12 Apr 22 11:19 /lib64/libc.so.6 -> libc-2.15.so

我们可以看到2.12版本的旧库文件依然存在,而且还多了2.15版本的库文件,而且软链接文件全部指向了2.15版本。

再次确认,发现版本已更新为2.15版了,无需重启。 [root@test1 build]# /lib64/libc.so.6 GNU C Library stable release version 2.15, by Roland McGrath et al. Copyright (C) 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Compiled by GNU CC version 4.4.7 20120313 (Red Hat 4.4.7-23). Compiled on a Linux 2.6.32 system on 2019-04-22. Available extensions: crypt add-on version 2.1 by Michael Glad and others GNU Libidn by Simon Josefsson Native POSIX Threads Library by Ulrich Drepper et al BIND-8.2.3-T5B libc ABIs: UNIQUE IFUNC For bug reporting instructions, please see: <http://www.gnu.org/software/libc/bugs.html>;.

注: 1、不要在 glibc源码包里直接执行 ./configure 指令,否则你就等着被虐吧,假如安装包位置是: /path/to/glibc-2.15,正确的姿势是再建一级目录,在那个目录下执行 ./configure 指令 2、不要将 glibc 安装到默认的目录【/usr/local】或者 【任何自定义的目录】,请务必安装到【/usr】目录,否则你就等着被虐吧。

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019-04-22 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档