【Ambari编译】打包需要的多版本gcc环境

快捷导航

正题


一、如何安装高版本的gcc 🚀

方法一:通过常规方式安装高版本的 gcc 🛠️
  1. 启用 CentOS SCLo 仓库 🔧 使用 Software Collections (SCL) 来安装较新版本的 gcc,首先启用 SCL 仓库:

    sudo yum install centos-release-scl
    
  2. 安装 devtoolset-7 ⚙️ 启用仓库后,安装高版本 gccgcc-c++

    sudo yum install devtoolset-7-gcc devtoolset-7-gcc-c++
    
  3. 启用 devtoolset-7 环境 🎯 通过以下命令启用 devtoolset 环境:

    scl enable devtoolset-7 bash
    

    检查 gcc 版本是否更新:

    gcc --version
    
  4. 永久启用 devtoolset-7 📝 将命令添加到 .bashrc 文件中,实现自动启用:

    echo "source scl_source enable devtoolset-7" >> ~/.bashrc
    
方法二:通过 Nexus 私服安装高版本的 gcc 🔐
  1. 在 Nexus 上配置阿里云 yum 仓库 💻

    # 填写下述地址
    https://mirrors.aliyun.com/centos/
    

    Step1 新增 proxy源

    在这里插入图片描述

    Step2 把刚才的proxy加入到group中
    在这里插入图片描述

    Step3 使用中看到如下效果

在这里插入图片描述

  1. 代理的 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
    
    
  2. 安装高版本的 gcc 🔄

    清理缓存并安装:

    sudo yum clean all
    sudo yum makecache
    sudo yum install devtoolset-7-gcc devtoolset-7-gcc-c++
    
  3. 启用 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++

在这里插入图片描述

2.3 使用ambari-env 一键解决环境准备问题

项目地址: ambari-env: Ambari+Bigtop 一站式编译和部署解决方案 (gitee.com)

Step1 自动加入并配置统一yum源

在这里插入图片描述

Step2 自动初始化 yum-public.repo文件

在这里插入图片描述

Step3 编译前自动准备环境

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值