【debug】centos7
場景
centos7服務器使用nvm安裝的node之後,只要使用npm或者node,均會出現以下問題
xxxxxxxxxx
[root@172 ~]# 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)
原因
查看系統內安裝的glibc版本
然後再根據分析可得知新版的node v18開始都需要GLIBC_2.27支持,可是目前系統內卻沒有那麼高的版本
xxxxxxxxxx
[root@172 glibc-2.28]# strings /lib64/libc.so.6 |grep GLIBC_
GLIBC_2.2.5
...
GLIBC_2.17
....
解決辦法
更新glibc
根據提示安裝所需要的glibc-2.28
xxxxxxxxxx
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問題
xxxxxxxxxx
configure: error:
*** These critical programs are missing or too old: make bison compiler
*** Check the INSTALL file for required versions.
解決辦法:升級gcc與make
xxxxxxxxxx
# 升级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即可
xxxxxxxxxx
cd /root/glibc-2.28/build
../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
我的依舊報錯:bison太老舊
xxxxxxxxxx
configure: error:
*** These critical programs are missing or too old: bison
*** Check the INSTALL file for required versions.
看看我的bison版本多少
xxxxxxxxxx
[root@172 ~]# bison -v
-bash: bison: 未找到命令
bison問題
嗨,沒裝啊。裝一下唄
xxxxxxxxxx
yum install -y bison
這時所有的問題真的真的都已經解決完畢再重新執行上一步更新glibc即可
xxxxxxxxxx
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中就是安裝軟件的意思簡單這麼理解就好。
這個過程較長,大約半小時左右,建議打一局遊戲就好了。
xxxxxxxxxx
make && make install
``
验证下 是不是好了
```shell
npm -v