阿里云centos7.3 学生机安装spark

(1)安装包下载与解压

官网下载安装包(下带scala的)

http://spark.apache.org/downloads.html

放置/usr/local/spark,解压tar -xzvf spark-2.4.5-bin-hadoop2.7.tgz
 

(2)配置(jdk和hadoop自行安装,可看我之前博客)

vim /usr/local/spark/spark-2.4.5-bin-hadoop2.7/conf/spark-env.sh
加上

export SPARK_DIST_CLASSPATH=$(/usr/local/hadoop/hadoop-2.7.5/bin/hadoop classpath)
export JAVA_HOME=/usr/local/java/jdk1.8.0_231
export HADOOP_CONF_DIR=/usr/local/hadoop/hadoop-2.7.5/etc/hadoop

编辑vim /usr/local/spark/spark-2.4.5-bin-hadoop2.7/conf/slaves

更改主机名,我的主机名是matser,所以修改为mater,如果没有更改过主机名,默认的localhost就可以了。

除了修改主机名外,如果是多台主机,还需要添加其他主机的主机名。

(3)防火墙设置

systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动

(4)启动

/usr/local/spark/spark-2.4.5-bin-hadoop2.7/sbin/start-all.sh

阿里云centos7.3 学生机安装spark_第1张图片

启动客户端 /usr/local/spark/spark-2.4.5-bin-hadoop2.7/bin/spark-shell

阿里云centos7.3 学生机安装spark_第2张图片

(5)测试

基于standalone(例):

/usr/local/spark/spark-2.4.5-bin-hadoop2.7/bin/spark-submit --master spark://master:7077 --class org.apache.spark.examples.SparkPi /usr/local/spark/spark-2.4.5-bin-hadoop2.7/examples/jars/spark-examples_2.11-2.4.5.jar 1000

阿里云centos7.3 学生机安装spark_第3张图片

基于yarn(例):

/usr/local/spark/spark-2.4.5-bin-hadoop2.7/bin/spark-submit --master yarn --class org.apache.spark.examples.SparkPi /usr/local/spark/spark-2.4.5-bin-hadoop2.7/examples/jars/spark-examples_2.11-2.4.5.jar 1000

命令是这么写,不过好像因为我的服务器配置太低了跑不起来。

 

 

 

你可能感兴趣的:(安装教程)