快捷导航
-
3、关注公众号获取最新推文:
正题
一、如何安装高版本的gcc 🚀
方法一:通过常规方式安装高版本的 gcc
🛠️
-
启用 CentOS SCLo 仓库 🔧 使用 Software Collections (SCL) 来安装较新版本的
gcc
,首先启用 SCL 仓库:sudo yum install centos-release-scl
-
安装 devtoolset-7 ⚙️ 启用仓库后,安装高版本
gcc
和gcc-c++
:sudo yum install devtoolset-7-gcc devtoolset-7-gcc-c++
-
启用 devtoolset-7 环境 🎯 通过以下命令启用 devtoolset 环境:
scl enable devtoolset-7 bash
检查
gcc
版本是否更新:gcc --version
-
永久启用 devtoolset-7 📝 将命令添加到
.bashrc
文件中,实现自动启用:echo "source scl_source enable devtoolset-7" >> ~/.bashrc
方法二:通过 Nexus 私服安装高版本的 gcc
🔐
-
在 Nexus 上配置阿里云 yum 仓库 💻
# 填写下述地址 https://mirrors.aliyun.com/centos/
Step1 新增 proxy源
Step2 把刚才的proxy加入到group中
Step3 使用中看到如下效果
-
代理的 yum 源为阿里云。以下是私服配置的
repo
文件:# 编辑一个自定义源头 vim /etc/yum.repos.d/yum-public.repo # 因为我所有的源都指向一个 yum 所以 我删除了 Centos*.repo文件 填入以下内容
[yum-public-base] name=YUM Public Repository baseurl=http://172.20.0.2:8081/repository/yum-public/$releasever/os/$basearch/ enabled=1 gpgcheck=0 [yum-public-update] name=YUM Public Repository baseurl=http://172.20.0.2:8081/repository/yum-public/$releasever/updates/$basearch/ enabled=1 gpgcheck=0 [yum-public-extras] name=YUM Public Repository baseurl=http://172.20.0.2:8081/repository/yum-public/$releasever/extras/$basearch/ enabled=1 gpgcheck=0 [yum-public-centosplus] name=YUM Public Repository baseurl=http://172.20.0.2:8081/repository/yum-public/$releasever/centosplus/$basearch/ enabled=1 gpgcheck=0 [yum-public-scl] name=YUM Public Repository baseurl=http://172.20.0.2:8081/repository/yum-public/7.9.2009/sclo/$basearch/sclo/ enabled=1 gpgcheck=0 [yum-public-scl-rh] name=YUM Public Repository baseurl=http://172.20.0.2:8081/repository/yum-public/7.9.2009/sclo/$basearch/rh/ enabled=1 gpgcheck=0 [yum-public-epel] name=YUM Public Repository baseurl=http://172.20.0.2:8081/repository/yum-public/$releasever/$basearch/ enabled=1 gpgcheck=0 [yum-public-mariadb] name=YUM Public Repository baseurl=http://172.20.0.2:8081/repository/yum-public/yum/10.11.8/centos7-amd64/ enabled=1 gpgcheck=0
-
安装高版本的
gcc
🔄清理缓存并安装:
sudo yum clean all sudo yum makecache sudo yum install devtoolset-7-gcc devtoolset-7-gcc-c++
-
启用 devtoolset-7 环境 🎯
安装完成后,启用环境:
scl enable devtoolset-7 bash
二、在 Ambari 项目中编译ambari-web报错
2.1 报错日志
[DEBUG] Loading mojo com.github.eirslett:frontend-maven-plugin:1.4:yarn from plugin realm ClassRealm[plugin>com.github.eirslett:frontend-maven-plugin:1.4, parent: sun.misc.Launcher$AppClassLoader@7852e922]
[DEBUG] Configuring mojo execution 'com.github.eirslett:frontend-maven-plugin:1.4:yarn:yarn install' with basic configurator -->
[DEBUG] (f) arguments = install --ignore-engines --pure-lockfile --verbose
[DEBUG] (f) environmentVariables = {npm_config_tmp=/tmp/npm_config_tmp}
[DEBUG] (f) npmRegistryURL = https://registry.npmmirror.com
[DEBUG] (f) project = MavenProject: org.apache.ambari:ambari-web:2.8.0.0.0 @ /opt/modules/ambari/ambari-web/pom.xml
[DEBUG] (f) repositorySystemSession = org.eclipse.aether.DefaultRepositorySystemSession@3c35c345
[DEBUG] (f) session = org.apache.maven.execution.MavenSession@41aaedaa
[DEBUG] (f) skip = false
[DEBUG] (f) skipTests = false
[DEBUG] (f) testFailureIgnore = false
[DEBUG] (f) workingDirectory = /opt/modules/ambari/ambari-web
[DEBUG] (f) yarnInheritsProxyConfigFromMaven = false
[DEBUG] (f) execution = com.github.eirslett:frontend-maven-plugin:1.4:yarn {execution: yarn install}
[DEBUG] -- end configuration --
[INFO] yarn not inheriting proxy config from Maven
[INFO] Running 'yarn install --ignore-engines --pure-lockfile --verbose --registry=https://registry.npmmirror.com/' in /opt/modules/ambari/ambari-web
[DEBUG] Executing command line [/opt/modules/ambari/ambari-web/node/yarn/dist/bin/yarn, install, --ignore-engines, --pure-lockfile, --verbose, --registry=https://registry.npmmirror.com]
[ERROR] node: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by node)
[ERROR] node: /lib64/libc.so.6: version `GLIBC_2.25' not found (required by node)
[ERROR] node: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by node)
[ERROR] node: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by node)
[ERROR] node: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by node)
[ERROR] node: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by node)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.140 s
[INFO] Finished at: 2024-08-20T09:15:00+08:00
[INFO] ------------------------------------------------------------------------
2.2 解决办法
多版本共存方案
需要做的是,加入scl源即可,安装
devtoolset-7-gcc devtoolset-7-gcc-c++