如何安全,高效,优雅的提升linux的glibc版本

如何安全,高效,优雅的提升linux的glibc版本

如何安全,高效,优雅的提升linux的glibc版本

一、发现问题二、升级glibc版本1. 下载对应的软件包2. 解压软件包3. 查看新版本glibc安装要求,并查看自己版本是否符合需求4. 升级python版本4.1 下载软件包4.2 解压4.3 编译4.4 确认更新后的python版本

5. 更新make版本5.1 下载软件包5.2 解压5.3 编译5.4 确认更新后的make版本

6. 更新gcc版本6.1 下载软件包6.2 解压6.3 编译6.4 验证gcc版本6.5 配置全局可用

7. 编译新版本glibc8. 安装9. 检查可用glibc版本

一、发现问题

之前在配置Gorse的时候遇到了下面这个问题:

gorse-in-one: /lib64/libc.so.6: version `GLIBC_2.32' not found (required by gorse-in-one)

gorse-in-one: /lib64/libc.so.6: version `GLIBC_2.34' not found (required by gorse-in-one)

这个问题是没有找到2.32以及2.34的glibc 可以先查看一下目前可用的glibc版本

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_2.16

GLIBC_2.17

GLIBC_PRIVATE

可以看出目前并没有那两个版本的glibc 那么,就进入正题,升级glibc版本

二、升级glibc版本

注:

升级glibc版本存在系统崩溃风险,强烈建议在升级前拍摄系统快照,以便出错时及时恢复此操作建议需要的权限较高,建议root成员进行操作,非root成员建议全程使用sudo操作

1. 下载对应的软件包

wget https://mirrors.aliyun.com/gnu/glibc/glibc-2.34.tar.gz

2. 解压软件包

tar -zxvf glibc-2.34.tar.gz

3. 查看新版本glibc安装要求,并查看自己版本是否符合需求

cd glibc-2.34

cat INSTALL | grep -E "later|newer"

结果如下,主要关注python make gcc 三个版本

this option if you want to compile the GNU C Library with a newer

later. Note that when CET is enabled, the GNU C Library requires

Intel Pentium Pro or newer. With '--enable-cet', it is an error to

to build without this option (for example, if building with a newer

The tests (and later installation) use some pre-existing files of the

* GNU 'make' 4.0 or newer

* GCC 6.2 or newer

building the GNU C Library, as newer compilers usually produce

of release, this implies GCC 7.4 and newer (excepting GCC 7.5.0,

* GNU 'binutils' 2.25 or later

binutils 2.26 or newer.

* GNU 'texinfo' 4.7 or later

* GNU 'bison' 2.7 or later

* GNU 'sed' 3.02 or newer

* Python 3.4 or later

* GDB 7.8 or later with support for Python 2.7/3.4 or later

* GNU 'gettext' 0.10.36 or later

to have the header files from a 3.2 or newer kernel around for

reference. (For the ia64 architecture, you need version 3.2.18 or newer

python -V

gcc -v

make -v

Python 2.7.5

gcc 版本 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)

GNU Make 3.82

4. 升级python版本

如果不执行这步,直接进行升级会出现如下报错

configure: error:

*** These critical programs are missing or too old: make compiler python

*** Check the INSTALL file for required versions.

4.1 下载软件包

wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz

4.2 解压

tar -zxf Python-3.8.0.tgz

4.3 编译

依次执行下列命令

mkdir /usr/local/python3

cd Python-3.8.0

mkdir build

../configure --prefix=/usr/local/python3

make -j 4

make install

4.4 确认更新后的python版本

python3 -V

5. 更新make版本

如果不执行这步,直接进行升级会出现如下报错

configure: error:

*** These critical programs are missing or too old: make compiler

*** Check the INSTALL file for required versions.

5.1 下载软件包

wget http://ftp.gnu.org/pub/gnu/make/make-4.3.tar.gz

5.2 解压

tar -zxvf make-4.3.tar.gz

5.3 编译

cd make-4.3

./configure --prefix=/usr

type make

make check

# 可能会报一些错误,不过不影响后面的install

make install

这几步稍有点慢,耐心等待

5.4 确认更新后的make版本

make -v

GNU Make 4.3

为 x86_64-pc-linux-gnu 编译

Copyright (C) 1988-2020 Free Software Foundation, Inc.

许可证:GPLv3+:GNU 通用公共许可证第 3 版或更新版本

本软件是自由软件:您可以自由修改和重新发布它。

在法律允许的范围内没有其他保证。

6. 更新gcc版本

如果不执行这步,直接进行升级会出现如下报错

configure: error:

*** These critical programs are missing or too old: compiler

*** Check the INSTALL file for required versions.

6.1 下载软件包

wget http://ftp.gnu.org/gnu/gcc/gcc-11.2.0/gcc-11.2.0.tar.gz

6.2 解压

tar -zxvf gcc-11.2.0.tar.gz

6.3 编译

mkdir build

cd build/

../configure -enable-checking=release -enable-languages=c,c++ -disable-multilib

make -j 4

# 这一步时间非常长

yum -y remove gcc g++

# 删除旧版本

make install

# 安装

非常慢,耐心等待

6.4 验证gcc版本

gcc -v

Using built-in specs.

COLLECT_GCC=/usr/local/bin/gcc

COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/11.2.0/lto-wrapper

Target: x86_64-pc-linux-gnu

Configured with: ../configure -enable-checking=release -enable-languages=c,c++ -disable-multilib

Thread model: posix

Supported LTO compression algorithms: zlib

gcc version 11.2.0 (GCC)

6.5 配置全局可用

ln -s /usr/local/bin/gcc /usr/bin/gcc

ln -s /usr/local/bin/g++ /usr/bin/g++

# 更新动态库

rm -f /usr/lib64/libstdc++.so.6

ln -s /usr/local/lib64/libstdc++.so.6.0.29 /usr/lib64/libstdc++.so.6

7. 编译新版本glibc

cd glibc-2.34

mkdir build

cd build

../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin

8. 安装

这步请务必确保当前用户拥有权限,非root用户请使用sudo运行

make && make install

接下来大概率会报这样的错误

gcc: relocation error: /lib64/libc.so.6: symbol __tunable_get_val, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference

make[1]: *** [Makerules:1041: /home/luolong/glibc-2.35/build/format.lds] Error 127

make[1]: Leaving directory '/home/luolong/glibc-2.35'

make: *** [Makefile:12: install] Error 2

这时候应该SSH的链接也断开了,很多基础命令也无法使用了 如使用ls命令

ls: relocation error: /lib64/libpthread.so.0: symbol __libc_dl_error_tsd, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference

这是正常现象,请键入如下命令

LD_PRELOAD=/lib64/libc-2.34.so sln /root/glibc-2.34/build/libc.so.6 /lib64/libc.so.6

LD_PRELOAD=/lib64/libc-2.34.so sln /root/glibc-2.34/build/dlfcn/libdl.so.2 /lib64/libdl.so.2

LD_PRELOAD=/lib64/libc-2.34.so sln /root/glibc-2.34/build/nptl/libpthread.so.0 /lib64/libpthread.so.0

LD_PRELOAD=/lib64/libc-2.34.so sln /root/glibc-2.34/build/elf/ld-linux-x86-64.so.2 /usr/lib64/ld-linux-x86-64.so.2

PS:如果你并不是root用户,请将[/root/glibc-2.34/build] 改成自己的位置

此时,再次执行

make install

9. 检查可用glibc版本

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_2.16

GLIBC_2.17

GLIBC_2.18

GLIBC_2.22

GLIBC_2.23

GLIBC_2.24

GLIBC_2.25

GLIBC_2.26

GLIBC_2.27

GLIBC_2.28

GLIBC_2.29

GLIBC_2.30

GLIBC_2.31

GLIBC_2.32

GLIBC_2.33

GLIBC_2.34

GLIBC_PRIVATE

成功!!!

相关推荐

小米手机下单后多久发货
日博365邮箱

小米手机下单后多久发货

📅 07-14 👁️ 999
视频剪切器软件有哪些 十款常用视频剪切器软件排行榜
beat365在线登录app

视频剪切器软件有哪些 十款常用视频剪切器软件排行榜

📅 06-29 👁️ 3371
建行网站注销
日博365邮箱

建行网站注销

📅 07-22 👁️ 4761

友情链接