温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

spark-2.4.2.tgz下载及编译

发布时间:2020-04-09 09:45:52 来源:网络 阅读:1043 作者:Stitch_x 栏目:大数据

51CTO没有目录功能么?好难受

========
有任何问题欢迎加企鹅讨论^-^
1176738641

========

前期准备

文件夹创建

#用户目录下创建五个文件夹
app              #存放应用
software      #存放应用压缩包
data            #存放测试数据
lib               #存放jar包
source       #存放源码

下载需要的软件及版本

  • apache-maven-3.6.1-bin.tar.gz
  • hadoop-2.6.0-cdh6.14.0.tar.gz
  • jdk-8u131-linux-x64.tar.gz
  • scala-2.11.8.tgz

安装jdk8

卸载现有jdk

rpm -qa|grep java
# 如果安装的版本低于1.7,卸载该jdk
rpm -e 软件包1 软件包2

解压jdk到~/app目录下

tar -zxf jdk-8u131-linux-x64.tar.gz -C ~/app/

测试jdk8安装成功

~/app/jdk1.8.0_131/bin/java -version

java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

版本信息正常打印,说明安装成功

配置环境变量

切记 >>为追加!>为覆盖!一定不要打成>

echo "####JAVA_HOME####"
echo "export JAVA_HOME=/home/max/app/jdk1.8.0_131" >> ~/.bash_profile  
echo "export PATH=$JAVA_HOME/bin:$PATH" >> ~/.bash_profile 
# 刷新环境变量
source ~/.bash_profile

此时,在任意目录下,使用java -version都可生效

安装maven

解压到~/app/

tar -zxvf  apache-maven-3.6.1-bin.tar.gz -C ~/app

测试maven安装成功

~/app/apache-maven-3.6.1/bin/mvn -v

Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-04T15:00:29-04:00)
Maven home: /home/max/app/apache-maven-3.6.1
Java version: 1.8.0_131, vendor: Oracle Corporation, runtime: /home/max/app/jdk1.8.0_131/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-358.el6.x86_64", arch: "amd64", family: "unix"

显示出版本信息,说明安装成功

添加环境变量

切记 >>为追加!>为覆盖!一定不要打成>

echo "####MAVEN_HOME####" >> ~/.bash_profile
echo "export MAVEN_HOME=/home/max/app/apache-maven-3.6.1/" >> ~/.bash_profile
echo "export PATH=$MAVEN_HOME/bin:$PATH" >> ~/.bash_profile 

# 刷新环境变量
source ~/.bash_profile 

此时,在任意目录下,使用mvn -v 都可生效

配置本地仓库目录&&远程仓库地址

# 创建本地仓库文件夹
mkdir ~/maven_repo
# 修改settings.xml文件
vim $MAVEN_HOME/conf/settings.xml

注意标签!别与已经存在的标签冲突

  <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->
<localRepository>/home/max/maven_repo</localRepository>

<mirrors>
    <mirror>
    <id>nexus-aliyun</id>
    <mirrorOf>*,!cloudera</mirrorOf>
    <name>Nexus aliyun</name>                     
    <url>
      http://maven.aliyun.com/nexus/content/groups/public
    </url>
</mirror>

安装Scala

解压到~/app/

tar -zxf scala-2.11.8.tgz -C ~/app/

测试scala安装成功

~/app/scala-2.11.8/bin/scala 
scala> [max@hadoop000 scala-2.11.8]$ scala
Welcome to Scala 2.11.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_131).
Type in expressions for evaluation. Or try :help.

scala> 

安装成功

添加环境变量

echo "####SCALA_HOME####" >> ~/.bash_profile
echo "export SCALA_HOME=/home/max/app/scala-2.11.8" >> ~/.bash_profile
echo "export PATH=$SCALA_HOME/bin:$PATH" >> ~/.bash_profile 
# 刷新环境变量
source ~/.bash_profile 

此时,在任意目录下,使用scala 都可生效

安装Git

默认为CentOS用户

sudo yum install git
#自动安装,期间需要按几次y
#显示如下
Installed:
  git.x86_64 0:1.7.1-9.el6_9                                                                          

Dependency Installed:
  perl-Error.noarch 1:0.17015-4.el6                  perl-Git.noarch 0:1.7.1-9.el6_9                 

Dependency Updated:
  openssl.x86_64 0:1.0.1e-57.el6                                                                      

Complete!
#安装成功

前期工作终于完事儿了!!!!!
====================累成狗的分割线=========================
其实漫长的编译之路才刚刚开始
spark-2.4.2.tgz下载及编译

下载&编译Spark源码

祭出大杀器!===>参考官网

下载&解压Spark2.4.2源码

cd ~/source
wget https://archive.apache.org/dist/spark/spark-2.4.2/spark-2.4.2.tgz
#有时候贼慢
[max@hadoop000 source]$ ll
total 15788
-rw-rw-r--. 1 max max 16165557 Apr 28 12:27 spark-2.4.2.tgz

[max@hadoop000 source]$ tar -zxf spark-2.4.2.tgz 

关于Maven

我们不使用mvn这个命令,直接用make-distribution.sh脚本,但是需要修改一下

#spark-2.4.2文件夹下
vim ./dev/make-distribution.sh

#将这些行注释掉    此处为最佳实践,为的是通过指定版本号减少编译时间
#VERSION=$("$MVN" help:evaluate -Dexpression=project.version $@ 2>/dev/null\
#    | grep -v "INFO"\
#    | grep -v "WARNING"\
#    | tail -n 1)
#SCALA_VERSION=$("$MVN" help:evaluate -Dexpression=scala.binary.version $@ 2>/dev/null\
#    | grep -v "INFO"\
#    | grep -v "WARNING"\
#    | tail -n 1)
#SPARK_HADOOP_VERSION=$("$MVN" help:evaluate -Dexpression=hadoop.version $@ 2>/dev/null\
#    | grep -v "INFO"\
#    | grep -v "WARNING"\
#    | tail -n 1)
#SPARK_HIVE=$("$MVN" help:evaluate -Dexpression=project.activeProfiles -pl sql/hive $@ 2>/dev/null\
#    | grep -v "INFO"\
#    | grep -v "WARNING"\
#    | fgrep --count "<id>hive</id>";\
#    # Reset exit status to 0, otherwise the script stops here if the last grep finds nothing\
#    # because we use "set -o pipefail"
#    echo -n)

##添加一下参数,注意,版本号要对应自己想要的生产环境
VERSION=2.4.2
SCALA_VERSION=2.11
SPARK_HADOOP_VERSION=hadoop-2.6.0-cdh6.14.0
SPARK_HIVE=1

修改pom.xml

在maven默认的库里默认只有apache版本的Hadoop依赖,但由于我们hadoop版本是hadoop-2.6.0-cdh6.14.0,我们需要在pom文件里添加CDH仓库

#spark-2.4.2文件夹下
vim pom.xml
<repositories>
    <!--<repositories>
     This should be at top, it makes maven try the central repo first and then others
and hence faster dep resolution
    <repository>
        <id>central</id>
        <name>Maven Repository</name>
        <url>https://repo.maven.apache.org/maven2</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
-->
    <repository>
        <id>central</id>
        <url>http://maven.aliyun.com/nexus/content/groups/public//</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
            <checksumPolicy>fail</checksumPolicy>
        </snapshots>
    </repository>
    <repository>
        <id>cloudera</id>
        <url>https://repository.cloudera.com/artifactory/cloudera-repos/</url>
    </repository>
</repositories>

开始编译

./dev/make-distribution.sh \
--name hadoop-2.6.0-cdh6.14.0  \
--tgz \
-Phadoop-2.6 \
-Dhadoop.version=2.6.0-cdh6.14.0 \
-Phive -Phive-thriftserver  \
-Pyarn \
-Pkubernetes

第一次大约需要编译 1h,我是阿里云镜像
再次编译大约就需要10min

注:报错的话一定要学会看报错日志!

##编译完成

#编译成功最后一部分日志
+ mkdir /home/max/source/spark-2.4.2/dist/conf
+ cp /home/max/source/spark-2.4.2/conf/docker.properties.template /home/max/source/spark-2.4.2/conf/fairscheduler.xml.template /home/max/source/spark-2.4.2/conf/log4j.properties.template /home/max/source/spark-2.4.2/conf/metrics.properties.template /home/max/source/spark-2.4.2/conf/slaves.template /home/max/source/spark-2.4.2/conf/spark-defaults.conf.template /home/max/source/spark-2.4.2/conf/spark-env.sh.template /home/max/source/spark-2.4.2/dist/conf
+ cp /home/max/source/spark-2.4.2/README.md /home/max/source/spark-2.4.2/dist
+ cp -r /home/max/source/spark-2.4.2/bin /home/max/source/spark-2.4.2/dist
+ cp -r /home/max/source/spark-2.4.2/python /home/max/source/spark-2.4.2/dist
+ '[' false == true ']'
+ cp -r /home/max/source/spark-2.4.2/sbin /home/max/source/spark-2.4.2/dist
+ '[' -d /home/max/source/spark-2.4.2/R/lib/SparkR ']'
+ '[' true == true ']'
+ TARDIR_NAME=spark-2.4.2-bin-hadoop-2.6.0-cdh6.14.0
+ TARDIR=/home/max/source/spark-2.4.2/spark-2.4.2-bin-hadoop-2.6.0-cdh6.14.0
+ rm -rf /home/max/source/spark-2.4.2/spark-2.4.2-bin-hadoop-2.6.0-cdh6.14.0
+ cp -r /home/max/source/spark-2.4.2/dist /home/max/source/spark-2.4.2/spark-2.4.2-bin-hadoop-2.6.0-cdh6.14.0
+ tar czf spark-2.4.2-bin-hadoop-2.6.0-cdh6.14.0.tgz -C /home/max/source/spark-2.4.2 spark-2.4.2-bin-hadoop-2.6.0-cdh6.14.0
+ rm -rf /home/max/source/spark-2.4.2/spark-2.4.2-bin-hadoop-2.6.0-cdh6.14.0

由此可以看出编译后的包在spark源码包下
spark-2.4.2.tgz下载及编译

解压

[max@hadoop000 spark-2.4.2]$ tar -zxf spark-2.4.2-bin-hadoop-2.6.0-cdh6.14.0.tgz -C ~/app/
[max@hadoop000 spark-2.4.2]$ cd ~/app/
[max@hadoop000 app]$ ll
total 16
drwxrwxr-x.  6 max max 4096 Apr 28 17:02 apache-maven-3.6.1
drwxr-xr-x.  8 max max 4096 Mar 15  2017 jdk1.8.0_131
drwxrwxr-x.  6 max max 4096 Mar  4  2016 scala-2.11.8
drwxrwxr-x. 11 max max 4096 Apr 28 21:20 spark-2.4.2-bin-hadoop-2.6.0-cdh6.14.0

完事儿!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI