# 【debug】centos7

## 場景

centos7服務器使用nvm安裝的node之後，只要使用npm或者node，均會出現以下問題

<div id="bkmrk-https%3A%2F%2Fwww.cnblogs.">[https://www.cnblogs.com/dingshaohua/p/17103654.html](https://www.cnblogs.com/dingshaohua/p/17103654.html)</div><div data-lang="highlighter-hljs shell" id="bkmrk-%5Broot%40172-%7E%5D%23-npm--v"><textarea style="display: none;">\[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) </textarea><div><div><textarea readonly="readonly" spellcheck="false" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;" tabindex="0"></textarea></div><div><div></div></div><div><div></div></div><div></div><div></div><div><div><div><div><div><div>```
xxxxxxxxxx
```

</div><div></div><div></div><div><div> </div></div><div><div><div aria-hidden="true"><div>1</div></div>```
<span role="presentation" style="padding-right: 0.1px;">[root@172 ~]# npm -v</span>
```

</div><div><div aria-hidden="true"><div>2</div></div>```
<span role="presentation" style="padding-right: 0.1px;">node: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by node)</span>
```

</div><div><div aria-hidden="true"><div>3</div></div>```
<span role="presentation" style="padding-right: 0.1px;">node: /lib64/libc.so.6: version `GLIBC_2.25' not found (required by node)</span>
```

</div><div><div aria-hidden="true"><div>4</div></div>```
<span role="presentation" style="padding-right: 0.1px;">node: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by node)</span>
```

</div><div><div aria-hidden="true"><div>5</div></div>```
<span role="presentation" style="padding-right: 0.1px;">node: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by node)</span>
```

</div><div><div aria-hidden="true"><div>6</div></div>```
<span role="presentation" style="padding-right: 0.1px;">node: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by node)</span>
```

</div><div><div aria-hidden="true"><div>7</div></div>```
<span role="presentation" style="padding-right: 0.1px;">node: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by node)</span>
```

</div><div><div aria-hidden="true"><div>8</div></div>```
<span role="presentation" style="padding-right: 0.1px;">​</span>
```

</div></div></div></div></div></div><div></div><div><div></div></div></div></div></div>## 原因

查看系統內安裝的glibc版本  
然後再根據分析可得知新版的node v18開始都需要GLIBC\_2.27支持，可是目前系統內卻沒有那麼高的版本

<div id="bkmrk-"></div><div data-lang="highlighter-hljs shell" id="bkmrk-%5Broot%40172-glibc-2.28"><textarea style="display: none;">\[root@172 glibc-2.28\]# strings /lib64/libc.so.6 |grep GLIBC\_ GLIBC\_2.2.5 ... GLIBC\_2.17 .... </textarea><div><div><textarea readonly="readonly" spellcheck="false" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;" tabindex="0"></textarea></div><div><div></div></div><div><div></div></div><div></div><div></div><div><div><div><div><div><div>```
xxxxxxxxxx
```

</div><div></div><div></div><div><div> </div></div><div><div><div aria-hidden="true"><div>1</div></div>```
<span role="presentation" style="padding-right: 0.1px;">[root@172 glibc-2.28]# strings /lib64/libc.so.6 |grep GLIBC_</span>
```

</div><div><div aria-hidden="true"><div>2</div></div>```
<span role="presentation" style="padding-right: 0.1px;">GLIBC_2.2.5</span>
```

</div><div><div aria-hidden="true"><div>3</div></div>```
<span role="presentation" style="padding-right: 0.1px;">...</span>
```

</div><div><div aria-hidden="true"><div>4</div></div>```
<span role="presentation" style="padding-right: 0.1px;">GLIBC_2.17</span>
```

</div><div><div aria-hidden="true"><div>5</div></div>```
<span role="presentation" style="padding-right: 0.1px;">....</span>
```

</div><div><div aria-hidden="true"><div>6</div></div>```
<span role="presentation" style="padding-right: 0.1px;">​</span>
```

</div></div></div></div></div></div><div></div><div><div></div></div></div></div></div>## 解決辦法

### 更新glibc

根據提示安裝所需要的glibc-2.28

<div id="bkmrk--0"></div><div data-lang="highlighter-hljs shell" id="bkmrk-wget-http%3A%2F%2Fftp.gnu."><textarea style="display: none;">wget http://ftp.gnu.org/gnu/glibc/glibc-2.28.tar.gz tar xf glibc-2.28.tar.gz cd glibc-2.28/ &amp;&amp; mkdir build &amp;&amp; cd build ../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin </textarea><div><div><textarea readonly="readonly" spellcheck="false" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;" tabindex="0"></textarea></div><div><div></div></div><div><div></div></div><div></div><div></div><div><div><div><div><div><div>```
xxxxxxxxxx
```

</div><div></div><div></div><div><div> </div></div><div><div><div aria-hidden="true"><div>1</div></div>```
<span role="presentation" style="padding-right: 0.1px;">wget http://ftp.gnu.org/gnu/glibc/glibc-2.28.tar.gz</span>
```

</div><div><div aria-hidden="true"><div>2</div></div>```
<span role="presentation" style="padding-right: 0.1px;">tar xf glibc-2.28.tar.gz </span>
```

</div><div><div aria-hidden="true"><div>3</div></div>```
<span role="presentation" style="padding-right: 0.1px;">cd glibc-2.28/ && mkdir build  && cd build</span>
```

</div><div><div aria-hidden="true"><div>4</div></div>```
<span role="presentation" style="padding-right: 0.1px;">../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin</span>
```

</div><div><div aria-hidden="true"><div>5</div></div>```
<span role="presentation" style="padding-right: 0.1px;">​</span>
```

</div></div></div></div></div></div><div></div><div><div></div></div></div></div></div>### 可能出現的錯誤

上步更新glibc 可能會發生錯誤。  
如果沒有錯誤下邊這一步不用看。

#### make問題

<div id="bkmrk--1"></div><div data-lang="highlighter-hljs shell" id="bkmrk-configure%3A-error%3A-%2A%2A"><textarea style="display: none;">configure: error: \*\*\* These critical programs are missing or too old: make bison compiler \*\*\* Check the INSTALL file for required versions. </textarea><div><div><textarea readonly="readonly" spellcheck="false" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;" tabindex="0"></textarea></div><div><div></div></div><div><div></div></div><div></div><div></div><div><div><div><div><div><div>```
xxxxxxxxxx
```

</div><div></div><div></div><div><div> </div></div><div><div><div aria-hidden="true"><div>1</div></div>```
<span role="presentation" style="padding-right: 0.1px;">configure: error: </span>
```

</div><div><div aria-hidden="true"><div>2</div></div>```
<span role="presentation" style="padding-right: 0.1px;">*** These critical programs are missing or too old: make bison compiler</span>
```

</div><div><div aria-hidden="true"><div>3</div></div>```
<span role="presentation" style="padding-right: 0.1px;">*** Check the INSTALL file for required versions.</span>
```

</div><div><div aria-hidden="true"><div>4</div></div>```
<span role="presentation" style="padding-right: 0.1px;">​</span>
```

</div></div></div></div></div></div><div></div><div><div></div></div></div></div></div>解決辦法：升級gcc與make

<div id="bkmrk--2"></div><div data-lang="highlighter-hljs shell" id="bkmrk-%23-%E5%8D%87%E7%BA%A7gcc%28%E9%BB%98%E8%AE%A4%E4%B8%BA4-%E5%8D%87%E7%BA%A7%E4%B8%BA8%29-y"><textarea style="display: none;">\# 升级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 &amp;&amp; cd make-4.3/ ./configure --prefix=/usr/local/make make &amp;&amp; make install cd /usr/bin/ &amp;&amp; mv make make.bak ln -sv /usr/local/make/bin/make /usr/bin/make </textarea><div><div><textarea readonly="readonly" spellcheck="false" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;" tabindex="0"></textarea></div><div><div></div></div><div><div></div></div><div></div><div></div><div><div><div><div><div><div>```
xxxxxxxxxx
```

</div><div></div><div></div><div><div> </div></div><div><div><div aria-hidden="true"><div>1</div></div>```
<span role="presentation" style="padding-right: 0.1px;"># 升级GCC(默认为4 升级为8)</span>
```

</div><div><div aria-hidden="true"><div>2</div></div>```
<span role="presentation" style="padding-right: 0.1px;">yum install -y centos-release-scl</span>
```

</div><div><div aria-hidden="true"><div>3</div></div>```
<span role="presentation" style="padding-right: 0.1px;">yum install -y devtoolset-8-gcc*</span>
```

</div><div><div aria-hidden="true"><div>4</div></div>```
<span role="presentation" style="padding-right: 0.1px;">mv /usr/bin/gcc /usr/bin/gcc-4.8.5</span>
```

</div><div><div aria-hidden="true"><div>5</div></div>```
<span role="presentation" style="padding-right: 0.1px;">ln -s /opt/rh/devtoolset-8/root/bin/gcc /usr/bin/gcc</span>
```

</div><div><div aria-hidden="true"><div>6</div></div>```
<span role="presentation" style="padding-right: 0.1px;">mv /usr/bin/g++ /usr/bin/g++-4.8.5</span>
```

</div><div><div aria-hidden="true"><div>7</div></div>```
<span role="presentation" style="padding-right: 0.1px;">ln -s /opt/rh/devtoolset-8/root/bin/g++ /usr/bin/g++</span>
```

</div><div><div aria-hidden="true"><div>8</div></div>```
<span role="presentation" style="padding-right: 0.1px;">​</span>
```

</div><div><div aria-hidden="true"><div>9</div></div>```
<span role="presentation" style="padding-right: 0.1px;"># 升级 make(默认为3 升级为4)</span>
```

</div><div><div aria-hidden="true"><div>10</div></div>```
<span role="presentation" style="padding-right: 0.1px;">wget http://ftp.gnu.org/gnu/make/make-4.3.tar.gz</span>
```

</div><div><div aria-hidden="true"><div>11</div></div>```
<span role="presentation" style="padding-right: 0.1px;">tar -xzvf make-4.3.tar.gz && cd make-4.3/</span>
```

</div><div><div aria-hidden="true"><div>12</div></div>```
<span role="presentation" style="padding-right: 0.1px;">./configure  --prefix=/usr/local/make</span>
```

</div><div><div aria-hidden="true"><div>13</div></div>```
<span role="presentation" style="padding-right: 0.1px;">make && make install</span>
```

</div><div><div aria-hidden="true"><div>14</div></div>```
<span role="presentation" style="padding-right: 0.1px;">cd /usr/bin/ && mv make make.bak</span>
```

</div><div><div aria-hidden="true"><div>15</div></div>```
<span role="presentation" style="padding-right: 0.1px;">ln -sv /usr/local/make/bin/make /usr/bin/make</span>
```

</div><div><div aria-hidden="true"><div>16</div></div>```
<span role="presentation" style="padding-right: 0.1px;">​</span>
```

</div></div></div></div></div></div><div></div><div><div></div></div></div></div></div>這時所有的問題都已經解決完畢再重新執行上一步更新glibc即可

<div id="bkmrk--3"></div><div data-lang="highlighter-hljs shell" id="bkmrk-cd-%2Froot%2Fglibc-2.28%2F"><textarea style="display: none;">cd /root/glibc-2.28/build ../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin </textarea><div><div><textarea readonly="readonly" spellcheck="false" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;" tabindex="0"></textarea></div><div><div></div></div><div><div></div></div><div></div><div></div><div><div><div><div><div><div>```
xxxxxxxxxx
```

</div><div></div><div></div><div><div> </div></div><div><div><div aria-hidden="true"><div>1</div></div>```
<span role="presentation" style="padding-right: 0.1px;">cd /root/glibc-2.28/build</span>
```

</div><div><div aria-hidden="true"><div>2</div></div>```
<span role="presentation" style="padding-right: 0.1px;">../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin</span>
```

</div><div><div aria-hidden="true"><div>3</div></div>```
<span role="presentation" style="padding-right: 0.1px;">​</span>
```

</div></div></div></div></div></div><div></div><div><div></div></div></div></div></div>我的依舊報錯：bison太老舊

<div id="bkmrk--4"></div><div data-lang="highlighter-hljs shell" id="bkmrk-configure%3A-error%3A-%2A%2A-0"><textarea style="display: none;">configure: error: \*\*\* These critical programs are missing or too old: bison \*\*\* Check the INSTALL file for required versions. </textarea><div><div><textarea readonly="readonly" spellcheck="false" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;" tabindex="0"></textarea></div><div><div></div></div><div><div></div></div><div></div><div></div><div><div><div><div><div><div>```
xxxxxxxxxx
```

</div><div></div><div></div><div><div> </div></div><div><div><div aria-hidden="true"><div>1</div></div>```
<span role="presentation" style="padding-right: 0.1px;">configure: error: </span>
```

</div><div><div aria-hidden="true"><div>2</div></div>```
<span role="presentation" style="padding-right: 0.1px;">*** These critical programs are missing or too old: bison</span>
```

</div><div><div aria-hidden="true"><div>3</div></div>```
<span role="presentation" style="padding-right: 0.1px;">*** Check the INSTALL file for required versions.</span>
```

</div><div><div aria-hidden="true"><div>4</div></div>```
<span role="presentation" style="padding-right: 0.1px;">​</span>
```

</div></div></div></div></div></div><div></div><div><div></div></div></div></div></div>看看我的bison版本多少

<div id="bkmrk--5"></div><div data-lang="highlighter-hljs shell" id="bkmrk-%5Broot%40172-%7E%5D%23-bison-"><textarea style="display: none;">\[root@172 ~\]# bison -v -bash: bison: 未找到命令 </textarea><div><div><textarea readonly="readonly" spellcheck="false" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;" tabindex="0"></textarea></div><div><div></div></div><div><div></div></div><div></div><div></div><div><div><div><div><div><div>```
xxxxxxxxxx
```

</div><div></div><div></div><div><div> </div></div><div><div><div aria-hidden="true"><div>1</div></div>```
<span role="presentation" style="padding-right: 0.1px;">[root@172 ~]# bison -v</span>
```

</div><div><div aria-hidden="true"><div>2</div></div>```
<span role="presentation" style="padding-right: 0.1px;">-bash: bison: 未找到命令</span>
```

</div><div><div aria-hidden="true"><div>3</div></div>```
<span role="presentation" style="padding-right: 0.1px;">​</span>
```

</div></div></div></div></div></div><div></div><div><div></div></div></div></div></div>#### bison問題

嗨，沒裝啊。裝一下唄

<div id="bkmrk--6"></div><div data-lang="highlighter-hljs shell" id="bkmrk-yum-install--y-bison"><textarea style="display: none;">yum install -y bison </textarea><div><div><textarea readonly="readonly" spellcheck="false" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;" tabindex="0"></textarea></div><div><div></div></div><div><div></div></div><div></div><div></div><div><div><div><div><div><div>```
xxxxxxxxxx
```

</div><div></div><div></div><div><div> </div></div><div><div><div aria-hidden="true"><div>1</div></div>```
<span role="presentation" style="padding-right: 0.1px;">yum install -y bison</span>
```

</div><div><div aria-hidden="true"><div>2</div></div>```
<span role="presentation" style="padding-right: 0.1px;">​</span>
```

</div></div></div></div></div></div><div></div><div><div></div></div></div></div></div>這時所有的問題真的真的都已經解決完畢再重新執行上一步更新glibc即可

<div id="bkmrk--7"></div><div data-lang="highlighter-hljs shell" id="bkmrk-cd-%2Froot%2Fglibc-2.28%2F-0"><textarea style="display: none;">cd /root/glibc-2.28/build ../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin </textarea><div><div><textarea readonly="readonly" spellcheck="false" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;" tabindex="0"></textarea></div><div><div></div></div><div><div></div></div><div></div><div></div><div><div><div><div><div><div>```
xxxxxxxxxx
```

</div><div></div><div></div><div><div> </div></div><div><div><div aria-hidden="true"><div>1</div></div>```
<span role="presentation" style="padding-right: 0.1px;">cd /root/glibc-2.28/build</span>
```

</div><div><div aria-hidden="true"><div>2</div></div>```
<span role="presentation" style="padding-right: 0.1px;">../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin</span>
```

</div><div><div aria-hidden="true"><div>3</div></div>```
<span role="presentation" style="padding-right: 0.1px;">​</span>
```

</div></div></div></div></div></div><div></div><div><div></div></div></div></div></div>### 繼續更新glibc

make 和make install在linux中就是安裝軟件的意思簡單這麼理解就好。  
這個過程較長，大約半小時左右，建議打一局遊戲就好了。

<div id="bkmrk--8"></div><div data-lang="highlighter-hljs shell" id="bkmrk-make-%26%26-make-install"><textarea style="display: none;">make &amp;&amp; make install `` 验证下 是不是好了 ```shell npm -v </textarea><div><div><textarea readonly="readonly" spellcheck="false" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;" tabindex="0"></textarea></div><div><div></div></div><div><div></div></div><div></div><div></div><div><div><div><div><div><div>```
xxxxxxxxxx
```

</div><div></div><div></div><div><div> </div></div><div><div><div aria-hidden="true"><div>1</div></div>```
<span role="presentation" style="padding-right: 0.1px;">make && make install</span>
```

</div><div><div aria-hidden="true"><div>2</div></div>```
<span role="presentation" style="padding-right: 0.1px;">``</span>
```

</div><div><div aria-hidden="true"><div>3</div></div>```
<span role="presentation" style="padding-right: 0.1px;">​</span>
```

</div><div><div aria-hidden="true"><div>4</div></div>```
<span role="presentation" style="padding-right: 0.1px;">验证下 是不是好了</span>
```

</div><div><div aria-hidden="true"><div>5</div></div>```
<span role="presentation" style="padding-right: 0.1px;">```shell</span>
```

</div><div><div aria-hidden="true"><div>6</div></div>```
<span role="presentation" style="padding-right: 0.1px;">npm -v</span>
```

</div><div><div aria-hidden="true"><div>7</div></div>```
<span role="presentation" style="padding-right: 0.1px;">​</span>
```

</div></div></div></div></div></div><div></div><div><div></div></div></div></div></div><div id="bkmrk-%E5%A0%B4%E6%99%AF-%E5%8E%9F%E5%9B%A0-%E8%A7%A3%E6%B1%BA%E8%BE%A6%E6%B3%95-%C2%A0%C2%A0%C2%A0%C2%A0%E6%9B%B4%E6%96%B0gli"><nav class="articleDirectoryFixed" id="bkmrk-%E5%A0%B4%E6%99%AF%E5%8E%9F%E5%9B%A0%E8%A7%A3%E6%B1%BA%E8%BE%A6%E6%B3%95%C2%A0%C2%A0%C2%A0%C2%A0%E6%9B%B4%E6%96%B0glibc%C2%A0-0">- [場景](https://www.cnblogs.com/dingshaohua/p/17103654.html#%E5%9C%BA%E6%99%AF)
- [原因](https://www.cnblogs.com/dingshaohua/p/17103654.html#%E5%8E%9F%E5%9B%A0)
- [解決辦法](https://www.cnblogs.com/dingshaohua/p/17103654.html#%E8%A7%A3%E5%86%B3%E5%8A%9E%E6%B3%95)
- [ 更新glibc](https://www.cnblogs.com/dingshaohua/p/17103654.html#%E6%9B%B4%E6%96%B0glibc)
- [ 可能出現的錯誤](https://www.cnblogs.com/dingshaohua/p/17103654.html#%E5%8F%AF%E8%83%BD%E5%87%BA%E7%8E%B0%E7%9A%84%E9%94%99%E8%AF%AF)
- [ make問題](https://www.cnblogs.com/dingshaohua/p/17103654.html#make%E9%97%AE%E9%A2%98)
- [ bison問題](https://www.cnblogs.com/dingshaohua/p/17103654.html#bison%E9%97%AE%E9%A2%98)
- [ 繼續更新glibc](https://www.cnblogs.com/dingshaohua/p/17103654.html#%E7%BB%A7%E7%BB%AD%E6%9B%B4%E6%96%B0glibc)

</nav></div>