您好,登錄后才能下訂單哦!
51CTO沒有目錄功能么?好難受
========
有任何問題歡迎加企鵝討論^-^
1176738641
========
#用戶目錄下創建五個文件夾
app #存放應用
software #存放應用壓縮包
data #存放測試數據
lib #存放jar包
source #存放源碼
rpm -qa|grep java
# 如果安裝的版本低于1.7,卸載該jdk
rpm -e 軟件包1 軟件包2
tar -zxf jdk-8u131-linux-x64.tar.gz -C ~/app/
~/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都可生效
tar -zxvf apache-maven-3.6.1-bin.tar.gz -C ~/app
~/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>
tar -zxf scala-2.11.8.tgz -C ~/app/
~/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 都可生效
默認為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!
#安裝成功
前期工作終于完事兒了!!!!!
====================累成狗的分割線=========================
其實漫長的編譯之路才剛剛開始
祭出大殺器!===>參考官網
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
我們不使用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
在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源碼包下
[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
完事兒!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。