前言
bigtop大数据组件编译分为三个部分
1.操作系统准备
2.编译工具准备
3.组件编译
本章先说环境准备
操作系统准备
1.操作系统
vm虚拟机安装centos7系列操作系统
2.挂载国内yum源
yum install wget -y
cd /etc/yum.repos.d/
mkdir bak
mv *.repo bak
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all
yum makecache
3.更新和安装基础软件
yum -y groupinstall "Infrastructure Server"
yum -y groupinstall "Compatibility Libraries"
yum -y groupinstall "Development Tools"
yum -y update
4.操作系统其他操作
#关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
#关闭SELINUX
setenforce 0
cp /etc/selinux/config /etc/selinux/config.bak
echo SELINUX=disabled > /etc/selinux/config
echo SELINUXTYPE=targeted >> /etc/selinux/config
#修改limits.conf
cp /etc/security/limits.conf /etc/security/limits.conf.bak
echo "* hard nproc 65535" > /etc/security/limits.conf
echo "* soft nproc 65535" >> /etc/security/limits.conf
echo "* hard nofile 65535" >> /etc/security/limits.conf
echo "* soft nofile 65535" >> /etc/security/limits.conf
#修改时区
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
#重启
reboot
编译工具准备
1.安装Java
yum -y install java-1.8.0-openjdk*
2.安装Scala
wget https://downloads.lightbend.com/scala/2.12.17/scala-2.12.17.rpm
rpm -ivh scala-2.12.17.rpm
3.安装Maven
wget https://repo.huaweicloud.com/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
tar -zxvf apache-maven-3.6.3-bin.tar.gz -C /opt/
ln -s /opt/apache-maven-3.6.3/ /opt/maven
#替换settings.xml
mv /opt/maven/conf/settings.xml /opt/maven/conf/settings.xml.bak
cat > /opt/maven/conf/settings.xml <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 http://maven.apache.org/xsd/settings-1.2.0.xsd">
<pluginGroups></pluginGroups>
<proxies></proxies>
<servers></servers>
<mirrors></mirrors>
<profiles>
<profile>
<id>aliyun</id>
<repositories>
<repository>
<id>aliyun</id>
<url>https://maven.aliyun.com/repository/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>aliyun-plugin-repository</id>
<name>aliyun-plugin-repository</name>
<url>https://maven.aliyun.com/repository/public</url>
</pluginRepository>
</pluginRepositories>
</profile>
<profile>
<id>huaweiyun</id>
<repositories>
<repository>
<id>huaweiyum</id>
<url>https://mirrors.huaweicloud.com/repository/maven/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>huawei-plugin-repository</id>
<name>huawei-plugin-repository</name>
<url>https://mirrors.huaweicloud.com/repository/maven/</url>
</pluginRepository>
</pluginRepositories>
</profile>
<profile>
<id>repo1</id>
<repositories>
<repository>
<id>repo1</id>
<url>https://repo1.maven.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
</profile>
<profile>
<id>repo2</id>
<repositories>
<repository>
<id>repo2</id>
<url>https://repo.maven.apache.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>aliyun</activeProfile>
<activeProfile>repo1</activeProfile>
<activeProfile>repo2</activeProfile>
<activeProfile>huaweiyun</activeProfile>
</activeProfiles>
</settings>
EOF
4.安装Nodejs
wget https://mirrors.aliyun.com/nodejs-release/v12.22.1/node-v12.22.1-linux-x64.tar.gz
tar -zxvf node-v12.22.1-linux-x64.tar.gz -C /opt/
ln -s /opt/node-v12.22.1-linux-x64/ /opt/nodejs
5.安装Gradle
wget https://services.gradle.org/distributions/gradle-7.5.1-bin.zip
unzip -d /opt/ gradle-7.5.1-bin.zip
ln -s /opt/gradle-7.5.1/ /opt/gradle
6.安装Ant
wget https://repo.huaweicloud.com/apache/ant/binaries/apache-ant-1.9.16-bin.tar.gz
wget https://repo.huaweicloud.com/apache/ant/ivy/2.4.0/apache-ivy-2.4.0-bin.tar.gz
tar -zxvf apache-ant-1.9.16-bin.tar.gz -C /opt
tar -zxvf apache-ivy-2.4.0-bin.tar.gz
ln -s /opt/apache-ant-1.9.16/ /opt/ant
cp apache-ivy-2.4.0/ivy-2.4.0.jar /opt/ant/lib/
mkdir ~/.ivy2
cat > ~/.ivy2/ivysettings.xml <<EOF
<ivy-settings>
<!-- path to local maven repo and default maven layout -->
<property name="local-maven2-pattern"
value="~/.m2/repository/[organisation]/[module]/[revision]/[module]-[revision]"
override="false" />
<!-- set resolver chain as default -->
<settings defaultResolver="main" />
<!-- configure caches -->
<caches repositoryCacheDir="~/.ivy2/cache">
<!-- do not cache from local .m2-->
<cache name="nocache" useOrigin="true" />
<cache name="default" />
</caches>
<resolvers>
<chain name="main">
<!-- as this is not cached, even changing SNAPSHOT dependencies
are resolved correctly -->
<filesystem name="local-maven-2" m2compatible="true" local="true"
cache="nocache">
<ivy pattern="\${local-maven2-pattern}.pom" />
<artifact pattern="\${local-maven2-pattern}(-[classifier]).[ext]" />
</filesystem>
<!-- use repository manager as proxy to maven-central
(and all other repositories)-->
<ibiblio name="repomanager" m2compatible="true"
root="http://maven.aliyun.com/nexus/content/groups/public/" cache="default"/>
</chain>
</resolvers>
</ivy-settings>
EOF
7.配置并刷新环境变量
echo "
export JAVA_HOME=/etc/alternatives/java_sdk_1.8.0
export SCALA_HOME=/usr/share/scala
export MAVEN_HOME=/opt/maven
export NODEJS_HOME=/opt/nodejs
export GRADLE_HOME=/opt/gradle
export ANT_HOME=/opt/ant
export PATH=$JAVA_HOME/bin:$SCALA_HOME/bin:$MAVEN_HOME/bin:$NODEJS_HOME/bin:$GRADLE_HOME/bin:$ANT_HOME/bin:$PATH
" >> /etc/profile
source /etc/profile