【debug】centos7
場景
centos7服務器使用nvm安裝的node之後,只要使用npm或者node,均會出現以下問題
xxxxxxxxxx
1
[root@172 ~]# npm -v
2
node: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by node)
3
node: /lib64/libc.so.6: version `GLIBC_2.25' not found (required by node)
4
node: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by node)
5
node: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by node)
6
node: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by node)
7
node: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by node)
8
原因
查看系統內安裝的glibc版本
然後再根據分析可得知新版的node v18開始都需要GLIBC_2.27支持,可是目前系統內卻沒有那麼高的版本
xxxxxxxxxx
1
[root@172 glibc-2.28]# strings /lib64/libc.so.6 |grep GLIBC_
2
GLIBC_2.2.5
3
...
4
GLIBC_2.17
5
....
6
解決辦法
更新glibc
根據提示安裝所需要的glibc-2.28
xxxxxxxxxx
1
wget http://ftp.gnu.org/gnu/glibc/glibc-2.28.tar.gz
2
tar xf glibc-2.28.tar.gz
3
cd glibc-2.28/ && mkdir build && cd build
4
../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
5
可能出現的錯誤
上步更新glibc 可能會發生錯誤。
如果沒有錯誤下邊這一步不用看。
make問題
xxxxxxxxxx
1
configure: error:
2
*** These critical programs are missing or too old: make bison compiler
3
*** Check the INSTALL file for required versions.
4
解決辦法:升級gcc與make
xxxxxxxxxx
1
# 升级GCC(默认为4 升级为8)
2
yum install -y centos-release-scl
3
yum install -y devtoolset-8-gcc*
4
mv /usr/bin/gcc /usr/bin/gcc-4.8.5
5
ln -s /opt/rh/devtoolset-8/root/bin/gcc /usr/bin/gcc
6
mv /usr/bin/g++ /usr/bin/g++-4.8.5
7
ln -s /opt/rh/devtoolset-8/root/bin/g++ /usr/bin/g++
8
9
# 升级 make(默认为3 升级为4)
10
wget http://ftp.gnu.org/gnu/make/make-4.3.tar.gz
11
tar -xzvf make-4.3.tar.gz && cd make-4.3/
12
./configure --prefix=/usr/local/make
13
make && make install
14
cd /usr/bin/ && mv make make.bak
15
ln -sv /usr/local/make/bin/make /usr/bin/make
16
這時所有的問題都已經解決完畢再重新執行上一步更新glibc即可
xxxxxxxxxx
1
cd /root/glibc-2.28/build
2
../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
3
我的依舊報錯:bison太老舊
xxxxxxxxxx
1
configure: error:
2
*** These critical programs are missing or too old: bison
3
*** Check the INSTALL file for required versions.
4
看看我的bison版本多少
xxxxxxxxxx
1
[root@172 ~]# bison -v
2
-bash: bison: 未找到命令
3
bison問題
嗨,沒裝啊。裝一下唄
xxxxxxxxxx
1
yum install -y bison
2
這時所有的問題真的真的都已經解決完畢再重新執行上一步更新glibc即可
xxxxxxxxxx
1
cd /root/glibc-2.28/build
2
../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
3
繼續更新glibc
make 和make install在linux中就是安裝軟件的意思簡單這麼理解就好。
這個過程較長,大約半小時左右,建議打一局遊戲就好了。
xxxxxxxxxx
1
make && make install
2
``
3
4
验证下 是不是好了
5
```shell
6
npm -v
7