centos7 升級glibc內核2.17到2.34
把自己實踐過的記錄整理下來,時間久了可能不一定很準確,還是應該當時剛做完就記錄的,也不是沒時間,還是太懶了,沒養成隨時記錄筆記的好習慣。
[root@iZf8z4cfpxgbggro9k9blwZ ~]# ldd --version ldd (GNU libc) 2.34 Copyright (C) 2021 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. Written by Roland McGrath and Ulrich Drepper. [root@iZf8z4cfpxgbggro9k9blwZ ~]#
現在已經是升級成功之后的顯示,之前2.17安裝nodejs18的一個庫總是報錯,升級之后,也主要是為了使用高版本的nodejs
[root@iZf8z4cfpxgbggro9k9blwZ ~]# node --version v22.14.0 [root@iZf8z4cfpxgbggro9k9blwZ ~]# npm -v 10.9.2
接下來進入正式步驟,主要參考這2篇:
- 下載新glibc2.34,并檢查安裝要求
先看個全覽,新建了一個/opt文件夾,存放升級需要的文件包:
[root@iZf8z4cfpxgbggro9k9blwZ ~]# cd /opt [root@iZf8z4cfpxgbggro9k9blwZ opt]# ls containerd gcc-9.3.0 gdb-7.8.2 glibc-2.34 make-4.3 node-v22.14 termcap-1.3.1 [root@iZf8z4cfpxgbggro9k9blwZ opt]#
1、下載glibc2.34
cd /opt wget https://mirrors.aliyun.com/gnu/glibc/glibc-2.34.tar.gz tar -zxvf glibc-2.34.tar.gz //可以添加參數-C指定存放目錄
2、查看安裝要求
cd glibc-2.34 cat INSTALL | grep -E "later|newer" * 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
可以挨著檢查一下自己的系統相關軟件目前版本是否符合要求:如:
[root@iZf8z4cfpxgbggro9k9blwZ upglibc]# python --version Python 2.7.5 [root@iZf8z4cfpxgbggro9k9blwZ upglibc]# python3 --version Python 3.6.8 [root@iZf8z4cfpxgbggro9k9blwZ upglibc]# gcc --version gcc (GCC) 9.3.0 Copyright ? 2019 Free Software Foundation, Inc. [root@iZf8z4cfpxgbggro9k9blwZ upglibc]# bison --version bison (GNU Bison) 3.0.4 Written by Robert Corbett and Richard Stallman. [root@iZf8z4cfpxgbggro9k9blwZ upglibc]# 注意的是binutils的版本檢查,可以使用ld --version as --version 以上都是升級之后的了
看一下我下載的相關升級包:
[root@iZf8z4cfpxgbggro9k9blwZ home]# cd upglibc/ [root@iZf8z4cfpxgbggro9k9blwZ upglibc]# ls gcc-9.3.0.tar.gz gdb-7.8.2.tar.xz gmp-6.1.0.tar.bz2 make-4.3.tar.gz mpfr-3.1.4.tar.bz2 gdb-7.8.2.tar glibc-2.34.tar.gz isl-0.18.tar.bz2 mpc-1.0.3.tar.gz termcap-1.3.1.tar.gz
- 開始一個個升級
- 升級python3
- 升級make
- 升級gcc需要的依賴
- 升級gcc
- 升級gdb
- 升級glibc
1、升級python3
`yum install python3 python3 --version `
2、升級make
`wget https://mirrors.aliyun.com/gnu/make/make-4.3.tar.gz tar -xzvf make-4.3.tar.gz -C /opt cd /opt/make-4.3/ mkdir build cd build ../configure --prefix=/usr && make && make install `3、升級gcc依賴
`wget ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2 wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2 wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz wget https://gcc.gnu.org/pub/gcc/infrastructure/isl.0.18.tar.bz2 ` 或者在gcc目錄下,通過執行./contrib/download_prerequisites下載(可能失?。?有些文章寫的好像還解壓make了這4個前置依賴安裝包,但是好像并不需要,下載包和gcc在同一目錄,那就行了4、升級gcc
`mkdir build cd build ../configure --enable-checking=release --enable-language=c,c++ --disable-multilib --prefix=/usr ` 然后make編譯,這一步非常慢,1個小時左右,我的是2核cpu所有是j2,cat /proc/cpuinfo| grep "processor"| wc -l查看; `make -j2 //1個小時…… make install gcc --version `5、升級gdb
`gdb --version wget https://gcc.gnu.org/pub/gdb/releases/gdb-7.8.2.tar.xz xz -dk gdb-7.8.2.tar.xz tar -xvf gdb-7.8.2.tar -C /opt mkdir build cd build ../configure --prefix=/usr//自動配置環境變量,否則gdb --version 還是原來的版本; ` 可能會提升安裝textinfo,wget https://mirrors.aliyun.com/gnu/termcap/termcap-1.3.1.tar.gz6、最后關鍵的一步,升級glibc
strings /lib64/libc.so.6 | grep GLIBC//查看一下當前的glibc; `wget https://mirrors.aliyun.com/gnu/glibc/glibc-2.34.tar.gz tar -xzvf glibc-2.34.tar.gz -C /opt cd /opt/glibc-2.34/ mkdir build ../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin --disable-sanity-checks --disable-werror make -j2//時間比較慢 make install `
- 遇到的問題
1. 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
解決辦法,原文鏈接:https://blog.csdn.net/chenhz2284/article/details/139584458:
LD_PRELOAD=/lib64/libc-2.17.so sln /opt/glibc-2.34/build/libc.so.6 /lib64/libc.so.6 LD_PRELOAD=/lib64/libc-2.17.so sln /opt/glibc-2.34/build/dlfcn/libdl.so.2 /lib64/libdl.so.2 LD_PRELOAD=/lib64/libc-2.17.so sln /opt/glibc-2.34/build/nptl/libpthread.so.0 /lib64/libpthread.so.0 LD_PRELOAD=/lib64/libc-2.17.so sln /opt/glibc-2.34/build/elf/ld-linux-x86-64.so.2 /usr/lib64/ld-linux-x86-64.so.2
2.錯誤信息: /usr/bin/ld: cannot find -lnss_test2 collect2: error: ld returned 1 exit status
解決辦法:
修改glibc-2.28/scripts/test-installation.pl, 將第128行:
&& $name ne “nss_test1” && $name ne “libgcc_s”) {
修改成:
&& $name ne “nss_test1” && $name ne “nss_test2” && $name ne “nss_nis” && $name ne “nss_nisplus” && $name ne “libgcc_s”) {
原文鏈接:https://blog.csdn.net/freflying1119/article/details/141937402
3.重新本地化環境 //重新生成本地化環境 localedef -c -i en_US -f UTF-8 en_US.UTF-8 locale
strings /lib64/libc.so.6 | grep GLIBC//再查看一下當前的glibc,是否升級成功;
浙公網安備 33010602011771號