在使用阿里云的Linux服务器(Alibaba Cloud Linux 2.1903 LTS 64位)时,按照教程安装的是nodejs的V14版本。如果升级了npm到最新的版本,之后使用npm时会提示
ERROR: npm v10.2.4 is known not to run on Node.js v14.0.0. This version of npm supports the following node versions: `^18.17.0 || >=20.5.0`. You can find the latest version at https://nodejs.org/.
那么需要升级nodejs,在升级了nodejs到v21版本后,会提示
[root@iZ2vcim9enkbf26jy2jyinZ ~]# 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_2.28
[root@iZ2vcim9enkbf26jy2jyinZ ~]# 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.
Written by Roland McGrath and Ulrich Drepper.
当前版本为2.17
//下载
wget http://ftp.gnu.org/gnu/glibc/glibc-2.28.tar.gz
//解压
tar xf glibc-2.28.tar.gz
//创建并进入build目录
cd glibc-2.28/ && mkdir build && cd build
//设置编译参数
../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
在设置了编译参数之后,可能会出现以下的错误,需要升级gcc与make
configure: error:
*** These critical programs are missing or too old: make bison compiler
*** Check the INSTALL file for required versions.
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++
这里安装centos-release-scl时可能会出现No package centos-release-scl available,用这两条命令,之后再次安装。
rpm -ivh https://cbs.centos.org/kojifiles/packages/centos-release-scl-rh/2/3.el7.centos/noarch/centos-release-scl-rh-2-3.el7.centos.noarch.rpm
rpm -ivh https://cbs.centos.org/kojifiles/packages/centos-release-scl/2/3.el7.centos/noarch/centos-release-scl-2-3.el7.centos.noarch.rpm
安装后,查看gcc的版本为8.3.1
[root@iZ2vcim9enkbf26jy2jyinZ ~]# gcc --version
gcc (GCC) 8.3.1 20190311 (Red Hat 8.3.1-3)
Copyright (C) 2018 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.
//下载
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
查看make的版本,为4.3
[root@iZ2vcim9enkbf26jy2jyinZ ~]# make --version
GNU Make 4.3
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later //gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
接1中,在build目录下再次设置编译参数,没有报错后,执行make && make install
//设置编译参数
../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
//编译
make && make install
可能会有以下报错,对应解决后,删除build下的内容,重新编译。
1)报错/usr/bin/ld: cannot find -lnss_test2
#修改glibc-2.28的test-installation.pl文件大概128行
vim '相对目录'/glibc-2.28/scripts/test-installation.pl
#将 && $name ne "nss_test1" && $name ne "libgcc_s"
#改为:
&& $name ne "nss_test1" && $name ne "libgcc_s" && $name ne "nss_test2"
2)undefined reference to ‘_nsl_default_nss@GLIBC_PRIVATE’
在编译选项中加上 --enable-obsolete-nsl,删除build下的内容,再次编译
../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin --enable-obsolete-nsl
之后如果成功编译安装了,查看glibc版本,为2.28
[root@iZ2vcim9enkbf26jy2jyinZ ~]# ldd --version
ldd (GNU libc) 2.28
Copyright (C) 2018 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.
glibc2.28已经安装好了,但是运行node -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)
处理方式参考解决nvm升级node v18.14.0时/lib64/libm.so.6: version ‘GLIBC_2.27’ not found (required by node)问题
yum whatprovides libstdc++.so.6
yum update -y libstdc++.x86_64
sudo wget http://www.vuln.cn/wp-content/uploads/2019/08/libstdc.so_.6.0.26.zip
unzip libstdc.so_.6.0.26.zip
cp libstdc++.so.6.0.26 /lib64/
cd /lib64
# 把原来的命令做备份
cp libstdc++.so.6 libstdc++.so.6.bak
rm -f libstdc++.so.6
# 重新链接
ln -s libstdc++.so.6.0.26 libstdc++.so.6
之后node -v能够正确执行
[root@iZ2vcim9enkbf26jy2jyinZ ~]# node -v
v21.0.0
1、解决nvm升级node v18.14.0时/lib64/libm.so.6: version ‘GLIBC_2.27’ not found (required by node)问题
2、MySQL8(glibc2.28)二进制安装
3、centos7 update glibc to 2.27