CentOS7 升级glibc

【glibc说明】

glibc: glibc是GNU发布的libc库,即c运行库。
glibc是linux系统中最底层的api,几乎其它任何运行库都会依赖于glibc。
glibc除了封装linux操作系统所提供的系统服务外,它本身也提供了许多其它一些必要功能服务的实现。
由于glibc囊括了几平所有的UNIX通行的标准,可以想见其内容包罗万象。
而就像其他的 UNIX系统一样,其内含的档案群分散于系统的树状目录结构中,像一个支架一般撑起整个操作系统。
在 GNU/Linux 系统中,其C函式库发展史点出了GNU/inux 演进的几个重要里程碑,用 glibc 作为系统的C函式库,是GNU/Linux演进的一个重要里程碑。

【升级前】

[root@server ~]# ldd --version
ldd (GNU libc) 2.17
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.
由 Roland McGrath 和 Ulrich Drepper 编写。
[root@server ~]# rpm -qa |grep glibc
glibc-2.17-326.el7_9.x86_64
compat-glibc-2.12-4.el7.centos.x86_64
compat-glibc-headers-2.12-4.el7.centos.x86_64
glibc-common-2.17-326.el7_9.x86_64
[root@server ~]#

【升级安装】
[root@server ~]# rpm -Uvh -aid --nodeps --force glibc-2.18-11.fc20.x86_64.rpm glibc-common-2.18-11.fc20.x86_64.rpm glibc-devel-2.18-11.fc20.x86_64.rpm glibc-headers-2.18-11.fc20.x86_64.rpm
警告:glibc-2.18-11.fc20.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID 246110c1: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:glibc-common-2.18-11.fc20        ################################# [ 17%]
   2:glibc-2.18-11.fc20               警告:/etc/nsswitch.conf 已建立为 /etc/nsswitch.conf.rpmnew
################################# [ 33%]
   3:glibc-headers-2.18-11.fc20       ################################# [ 50%]
   4:glibc-devel-2.18-11.fc20         ################################# [ 67%]
正在清理/删除...
   5:glibc-common-2.17-326.el7_9      ################################# [ 83%]
   6:glibc-2.17-326.el7_9             ################################# [100%]
[root@server ~]#

【升级后】
[root@server ~]# ldd --version
ldd (GNU libc) 2.18
Copyright (C) 2013 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.
由 Roland McGrath 和 Ulrich Drepper 编写。
[root@server ~]# rpm -qa |grep glibc
glibc-common-2.18-11.fc20.x86_64
compat-glibc-2.12-4.el7.centos.x86_64
glibc-headers-2.18-11.fc20.x86_64
compat-glibc-headers-2.12-4.el7.centos.x86_64
glibc-devel-2.18-11.fc20.x86_64
glibc-2.18-11.fc20.x86_64
[root@server ~]#
[root@server ~]# strings /lib64/libc.so.6 | grep -i '^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_2.16
GLIBC_2.17
GLIBC_2.18
GLIBC_PRIVATE
glibc 2.18
GLIBC_PRIVATE
GLIBC_2.8
GLIBC_2.3
GLIBC_2.5
GLIBC_2.4
GLIBC_2.9
GLIBC_2.7
GLIBC_2.6
GLIBC_2.3.2
GLIBC_2.3.4
GLIBC_2.3.3
GLIBC_2.18
GLIBC_2.15
GLIBC_2.14
GLIBC_2.11
GLIBC_2.16
GLIBC_2.10
GLIBC_2.17
GLIBC_2.12
GLIBC_2.13
GLIBC_2.2.5
GLIBC_2.2.6
[root@server ~]#

编译方式升级glibc

CentOS7 升级Glibc2.17到GLIBC2.23
系统自带的是Glibc2.17版本,由于有项目要使用到Glibc的更高级的版本,所以编译安装glibc。
下载GLIBC2.23压缩包,然后解压
wget http://ftp.gnu.org/gnu/glibc/glibc-2.23.tar.gz
tar -zxvf glibc-2.23.tar.gz

进入文件夹
cd glibc-2.23/
mkdir build
一定要进入这个新建的文件夹内进行后续操作


cd build
../configure --prefix=/usr && make && make install


在make install 时可能会跳出错误(类似的应该是因为软链接的版本不对造成的)
[root@server lib64]#
gawk '/\.gnu\.glibc-stub\./ { \
      sub(/\.gnu\.glibc-stub\./, "", $2); \
      stubs[$2] = 1; } \
    END { for (s in stubs) print "#define __stub_" s }' > /root/glibc-2.23/build/math/stubsT
gawk: error while loading shared libraries: /lib64/libm.so.6: invalid ELF header
make[2]: *** [/root/glibc-2.23/build/math/stubs] Error 127
make[2]: Leaving directory `/root/glibc-2.23/math'
make[1]: *** [math/subdir_install] Error 2
make[1]: Leaving directory `/root/glibc-2.23'
make: *** [install] 错误 2
[root@server build]#
 
解决办法,然后重新编译安装
[root@server lib64]# unlink libm.so.6
[root@server lib64]# ln -s libm-2.23.so libm.so.6
[root@server lib64]# cd /root/glibc-2.23/build/
[root@server build]# ldd --version
ldd (GNU libc) 2.17
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.
由 Roland McGrath 和 Ulrich Drepper 编写。
[root@server build]# make install

进行验证
ldd --version

posted @ 2024-12-19 09:35  花之旭  阅读(1771)  评论(0)    收藏  举报