前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >[1317]centos7 node: /lib64/libm.so.6: version `GLIBC_2.27‘ not found

[1317]centos7 node: /lib64/libm.so.6: version `GLIBC_2.27‘ not found

作者头像
周小董
发布于 2024-12-29 00:06:30
发布于 2024-12-29 00:06:30
1.4K00
代码可运行
举报
文章被收录于专栏:python前行者python前行者
运行总次数:0
代码可运行
centos7 node: /lib64/libm.so.6: version `GLIBC_2.27‘ not found问题
1、问题

centos7服务器使用nvm安装的node之后,只要使用npm或者node,均会出现以下问题。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
npm -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)
2、原因

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

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
strings /lib64/libc.so.6 |grep GLIBC_
GLIBC_2.2.5
...
GLIBC_2.17
....
3、安装所需要的glibc-2.28

更新glibc 根据提示 安装所需要的glibc-2.28

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
wget http://ftp.gnu.org/gnu/glibc/glibc-2.28.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问题
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
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)
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
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)
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
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即可

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
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版本多少

  • 安装bison
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
bison -v
-bash: bison: 未找到命令
yum install -y bison

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

  • 继续安装glibc-2.28
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
cd /root/glibc-2.28/build
../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin

make 和 make install在linux中就是安装软件的意思 简单这么理解就好。 这个过程较长,大约半小时左右,建议打一局游戏就好了。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
make && make install
# 结果
LD_SO=ld-linux-x86-64.so.2 CC="gcc -B/usr/bin/" /usr/bin/perl scripts/test-installation.pl /opt/module/mysql-lib/glibc-2.28/build/
/usr/bin/ld: cannot find -lnss_test2
collect2: error: ld returned 1 exit status
Execution of gcc -B/usr/bin/ failed!
The script has found some problems with your installation!
Please read the FAQ and the README file and check the following:
- Did you change the gcc specs file (necessary after upgrading from
  Linux libc5)?
- Are there any symbolic links of the form libXXX.so to old libraries?
  Links like libm.so -> libm.so.5 (where libm.so.5 is an old library) are wrong,
  libm.so should point to the newly installed glibc file - and there should be
  only one such link (check e.g. /lib and /usr/lib)
You should restart this script from your build directory after you've
fixed all problems!
Btw. the script doesn't work if you're installing GNU libc not as your
primary library!
make[1]: *** [Makefile:111: install] Error 1
make[1]: Leaving directory '/opt/module/mysql-lib/glibc-2.28'
make: *** [Makefile:12: install] Error 2

# 这上面的问题可以忽略

make install有报错没有关系

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
ls -l /lib64/libc.so.6
strings /lib64/libc.so.6 | grep GLIBC
#查询是否有了2.28
GLIBC_2.27
GLIBC_2.28

验证下 是不是好了

npm -v 如果还是出现下面的问题,要连接新的动态库

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
npm -v
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)
4、 更新lib libstdc++.so.6.0.26
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
wget https://cdn.frostbelt.cn/software/libstdc%2B%2B.so.6.0.26
  • 替换系统中的/usr/lib64
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
cp libstdc++.so.6.0.26 /usr/lib64/

cd /usr/lib64/

ln -snf ./libstdc++.so.6.0.26 libstdc++.so.6

验证

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
node -v
v20.15.0

error was 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的错误"

报错信息:error was 14: curl#6 - “Could not resolve host: mirrorlist.centos.org; 未知的错误”

yum安装失败报错

完整的报错信息

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
[root@localhost ~]#  yum install -y vim
已加载插件:fastestmirror
Determining fastest mirrors
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的错误"
 
 
 One of the configured repositories failed (未知),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:
     1. Contact the upstream for the repository and get them to fix the problem.
     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).
     3. Run the command with the repository temporarily disabled
            yum --disablerepo=<repoid> ...
     4. Disable the repository permanently, so yum won't use it by default. Yum
        will then just ignore the repository until you permanently enable it
        again or use --enablerepo for temporary usage:
 
            yum-config-manager --disable <repoid>
        or
            subscription-manager repos --disable=<repoid>
 
     5. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:
 
            yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true
 
Cannot find a valid baseurl for repo: base/7/x86_64
[root@localhost ~]#
报错处理

注:请先确认网络是否能正常访问,可以正常访问的按照操作进行。

也可以看链接里的在线配置:Linux CentOS7 yum源配置(离线和在线)

  • 下载yum源
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
#安装wget是为了用wget下载yum源,如果安装不了也没事,用url下载yum源也行
yum install -y wget

wget或url下载二选一,这用wget下载。wget没有安装成功的用url下载即可。

  • 备份系统yum源
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
cd /etc/yum.repos.d
 
#创建备份文件夹
mkdir bak
 
#所有的repo文件移动到bak下
mv *.repo bak

注:选择一个下载即可

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
#wget下载
#用阿里云的演示
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
 
#华为云
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.huaweicloud.com/repository/conf/CentOS-7-anon.repo
#url下载
#阿里云
sudo curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
 
#华为云
sudo curl -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.huaweicloud.com/repository/conf/CentOS-7-anon.repo

文件名

作用

适用场景

CentOS-Base.repo

提供 CentOS 系统的核心组件和标准软件包。

基础系统安装和更新。

CentOS-CR.repo

提供下一个小版本更新前的预览包。

测试环境,提前测试新功能。

CentOS-Debuginfo.repo

提供调试信息的 RPM 包(如符号表)。

系统问题排查、开发环境调试。

CentOS-fasttrack.repo

提供比 updates 仓库更快的软件更新包。

获取关键问题的紧急修复。

CentOS-Media.repo

配置从本地媒体(如 DVD、ISO)安装的软件包。

离线安装或光盘安装软件。

CentOS-SCLo-scl.repo

提供 SCL 软件集合,支持多版本共存(社区版)。

同时运行多个版本的软件(如 PHP 5 和 PHP 7)。

CentOS-SCLo-scl-rh.repo

提供 SCL 软件集合,支持多版本共存(Red Hat 官方版)。

需要稳定且官方支持的多版本软件时使用。

CentOS-Sources.repo

提供软件包的源代码(SRPM)。

自定义软件包或研究软件源码。

CentOS-Vault.repo

提供旧版本和历史版本的存档软件包。

维护旧版本系统或兼容旧环境。

CentOS-x86_64-kernel.repo

提供 CentOS 内核相关的软件包更新和测试版本。

内核开发或测试新功能。

  • 更新yum源
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
#清除缓存yum源
sudo yum clean all 
 
#缓存新的yum源
sudo yum makecache
 
#更新新的yum源
sudo yum update
  • 测试
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
yum install -y vim

参考:https://blog.csdn.net/qq_39287495/article/details/139964001 https://blog.csdn.net/weixin_68547003/article/details/144613213 https://www.cnblogs.com/wuchitao/p/18365624 https://blog.csdn.net/ufihsgnawoaix/article/details/143984782 https://yunche.pro/blog/?id=1182

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

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

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

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

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • centos7 node: /lib64/libm.so.6: version `GLIBC_2.27‘ not found问题
  • 1、问题
  • 2、原因
  • 3、安装所需要的glibc-2.28
    • make问题
    • 解决办法:升级gcc与make
  • 4、 更新lib libstdc++.so.6.0.26
  • error was 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的错误"
    • 报错处理
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档