-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4_spark_install.sh
executable file
·64 lines (56 loc) · 1.94 KB
/
4_spark_install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
logPrefix="spark-install"
location=$(pwd)
sparkTar="spark-1.5.1-bin-hadoop2.6.tar"
sparkPath="tar/$sparkTar"
RETVAL=0
loggerInfo() {
printf "%s %s %s : %s\n" `date +%Y%m%d-%H:%M:%S` $logPrefix "INFO" "$1"
}
loggerError() {
printf "%s %s %s : %s\n" `date +%Y%m%d-%H:%M:%S` $logPrefix "ERROR" "$1"
}
sparkInstall() {
if [[ ! -f /opt/.spark-install ]]; then
tar xvf $sparkPath -C /opt/
mv /opt/spark-1.5.1-bin-hadoop2.6 /opt/spark
loggerInfo "Start to set SPARK_HOME append to PATH"
sed -i '/export HIVE_HOME=\/opt\/hive/a export SPARK_HOME=\/opt\/spark' /etc/profile
sed -i '/^export PATH=/ s/$/:\$SPARK_HOME\/bin/' /etc/profile
if [[ $? -eq 0 ]]; then
source /etc/profile
# upload spark-assembly.jar to reduce running time
hdfs dfs -mkdir -p /user/spark/share/lib
hdfs dfs -put /opt/spark/lib/spark-assembly-1.5.1-hadoop2.6.0.jar /user/spark/share/lib/spark-assembly.jar
echo "export SPARK_JAR=hdfs://master1:8020/user/spark/share/lib/spark-assembly.jar" >> /etc/profile
loggerInfo "Spark installation is finished."
touch /opt/.spark-install
fi
else
loggerInfo "Spark has been installed."
fi
}
sparkWithHive() {
loggerInfo "Start to integrate SparkSQL with Hive."
cp /opt/hive/conf/hive-site.xml /opt/spark/conf/
}
#hiveOnSpark() {
# # Reference from: https://cwiki.apache.org/confluence/display/Hive/Hive+on+Spark%3A+Getting+Started
# loggerInfo "Start to integrate Spark and Hive."
# hive -e "set spark.home=/opt/spark;"
# ln -s /opt/spark/lib/spark-assembly-1.5.1-hadoop2.6.0.jar /opt/hive/lib/spark-assembly-1.5.1-hadoop2.6.0.jar
# hive -e "set hive.execution.engine=spark;"
#}
start() {
sparkInstall
sparkWithHive
}
case "$1" in
start)
start
;;
*)
echo $"Usage: $logPrefix {start}"
RETVAL=3
esac
exit $RETVAL