场景

cent os7服务器jenkins使用高版本得Node 18以上版本,,均会出现以下问题


[root@172 ~]# node -v
node: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by node)
node: /lib64/libc.so.6: version `GLIBC_2.25' not found (required by node)
node: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by node)
node: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by node)
node: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by node)
node: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by node)

原因

查看系统内安装的glibc版本 然后再根据分析可得知 新版的node v18开始都需要GLIBC_2.27支持,可是目前系统内却没有那么高的版本

[root@172 glibc-2.28]# strings /lib64/libc.so.6 |grep GLIBC_
GLIBC_2.2.5
...
GLIBC_2.17
....

解决办法

更新glibc 根据提示 安装所需要的glibc-2.28
注意:
升级glibc版本存在系统崩溃风险,强烈建议在升级前拍摄系统快照,以便出错时及时恢复
此操作建议需要的权限较高,建议root成员进行操作,非root成员建议全程使用sudo操作

wget http://ftp.gnu.org/gnu/glibc/glibc-2.28.tar.gz
#或者 wget https://mirrors.aliyun.com/gnu/glibc/glibc-2.34.tar.gz

tar xf glibc-2.28.tar.gz 
cd glibc-2.28/ && mkdir build  && cd build
../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin

可能出现的错误 上步更新glibc 可能会发生错误。 如果没有错误 下边这一步 不用看。
make问题 configure: error:
*** These critical programs are missing or too old: make bison compiler
*** Check the INSTALL file for required versions. 解决办法:升级gcc与make

升级GCC(默认为4 升级为8)

yum install -y centos-release-scl
yum install -y devtoolset-8-gcc*
mv /usr/bin/gcc /usr/bin/gcc-4.8.5
ln -s /opt/rh/devtoolset-8/root/bin/gcc /usr/bin/gcc
mv /usr/bin/g++ /usr/bin/g++-4.8.5
ln -s /opt/rh/devtoolset-8/root/bin/g++ /usr/bin/g++

升级 make(默认为3 升级为4)

wget http://ftp.gnu.org/gnu/make/make-4.3.tar.gz
tar -xzvf make-4.3.tar.gz && cd make-4.3/
./configure  --prefix=/usr/local/make
make && make install
cd /usr/bin/ && mv make make.bak
ln -sv /usr/local/make/bin/make /usr/bin/make

这时 所有的问题 都已经解决完毕 再重新执行上一步 更新glibc即可

cd /root/glibc-2.28/build
../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin

我的依旧报错:bison太老旧
configure: error:
*** These critical programs are missing or too old: bison
*** Check the INSTALL file for required versions. 看看我的bison版本多少

[root@172 ~]# bison -v

-bash: bison: 未找到命令 bison问题

yum install -y bison

这时 所有的问题 真的真的都已经解决完毕 再重新执行上一步 更新glibc即可

cd /root/glibc-2.28/build
../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin

继续更新glibc make 和 make install在linux中就是安装软件的意思 简单这么理解就好。

这个过程较长,大约半小时左右,建议打一局游戏就好了。

make && make install

验证下 是不是好了

node -v

另一种方式

可以先查看一下目前可用的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版本

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

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

cd glibc-2.34
cat INSTALL | grep -E  "later|newer"

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,gcc,make

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

升级python版本

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

configure: error: 
*** These critical programs are missing or too old: make compiler python
*** Check the INSTALL file for required versions.
wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz
tar -zxf Python-3.8.0.tgz 

#开始安装
mkdir /usr/local/python3
cd Python-3.8.0
mkdir build
../configure --prefix=/usr/local/python3
make -j 4
make install

#确认版本
python3 -V

更新make版本

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

configure: error: 
*** These critical programs are missing or too old: make compiler
*** Check the INSTALL file for required versions.
wget http://ftp.gnu.org/pub/gnu/make/make-4.3.tar.gz
tar -zxvf make-4.3.tar.gz

#进行安装
cd make-4.3
./configure --prefix=/usr
type make
make check
# 可能会报一些错误,不过不影响后面的install
make install

#确认版本
make -v

更新gcc版本

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

configure: error: 
*** These critical programs are missing or too old: compiler
*** Check the INSTALL file for required versions.

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

#开始安装
mkdir build
cd build/
../configure -enable-checking=release -enable-languages=c,c++ -disable-multilib
make -j 4
# 这一步时间非常长
yum -y remove gcc g++
# 删除旧版本
make install
# 安装

#验证版本
gcc -v

配置gcc全局可用

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

正式开始编译新版本glibc

cd glibc-2.34
mkdir bulid
cd bulid
../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin

进行安装,必须root

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

再次执行及可正常

make install

#检查新版本
strings /lib64/libc.so.6 | grep GLIBC

文章作者: 刘同学
本文链接:
版权声明: 本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 刘同学的小站
中间件 devops Linux
喜欢就支持一下吧