目录
1.修改spark-default.conf.template名称
2.修改spark-default.conf文件,开启Log:
spark-2.1.1-bin-hadoop2.7.tgz,官网下载
[root@hadoop01 software]# tar -zxvf spark-2.1.1-bin-hadoop2.7.tgz -C /opt/module/
- [root@hadoop01 module]# mv spark-2.1.1-bin-hadoop2.7 spark
- [root@hadoop01 conf]# mv slaves.template slaves
- [root@hadoop01 conf]# vim slaves
-
- #
- # Licensed to the Apache Software Foundation (ASF) under one or more
- # contributor license agreements. See the NOTICE file distributed with
- # this work for additional information regarding copyright ownership.
- # The ASF licenses this file to You under the Apache License, Version 2.0
- # (the "License"); you may not use this file except in compliance with
- # the License. You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- #
-
- # A Spark Worker will be started on each of the machines listed below.
- hadoop01
- hadoop02
- hadoop03
- [root@hadoop01 conf]# vim spark-env.sh
- SPARK_MASTER_HOST=hadoop01
- SPARK_MASTER_PORT=7077
- [root@hadoop01 sbin]# vim spark-config.sh
- export JAVA_HOME=/opt/module/jdk1.8.0_144
[root@hadoop01 module]$ xsync spark/
- [root@hadoop01 spark]$ sbin/start-all.sh
- [root@hadoop01 spark]$ util.sh
- ================root@hadoop01================
- 3330 Jps
- 3238 Worker
- 3163 Master
- ================root@hadoop02================
- 2966 Jps
- 2908 Worker
- ================root@hadoop03================
- 2978 Worker
- 3036 Jps

[root@hadoop01 conf]$ mv spark-defaults.conf.template spark-defaults.conf
注意:HDFS上的目录需要提前存在。
没有就创建目录
[root@hadoop01 conf]# hdfs dfs -mkdir directory
- [root@hadoop01 conf]# vim spark-defaults.conf
-
- #
- # Licensed to the Apache Software Foundation (ASF) under one or more
- # contributor license agreements. See the NOTICE file distributed with
- # this work for additional information regarding copyright ownership.
- # The ASF licenses this file to You under the Apache License, Version 2.0
- # (the "License"); you may not use this file except in compliance with
- # the License. You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- #
-
- # Default system properties included when running spark-submit.
- # This is useful for setting default environmental settings.
-
- # Example:
- # spark.master spark://master:7077
- # spark.eventLog.enabled true
- # spark.eventLog.dir hdfs://namenode:8021/directory
- # spark.serializer org.apache.spark.serializer.KryoSerializer
- # spark.driver.memory 5g
- # spark.executor.extraJavaOptions -XX:+PrintGCDetails -Dkey=value -Dnumbers="one two three"
- spark.eventLog.enabled true
- spark.eventLog.dir hdfs://hadoop01:9000/directory
- [root@hadoop01 conf]# vim spark-env.sh
- export SPARK_HISTORY_OPTS="-Dspark.history.ui.port=18080
- -Dspark.history.retainedApplications=30
- -Dspark.history.fs.logDirectory=hdfs://hadoop01:9000/directory"
[root@hadoop01 conf]# xsync /opt/module/spark/conf
[root@hadoop01 spark]# sbin/start-history-server.sh
- [root@hadoop102 spark]$ bin/spark-submit \
- --class org.apache.spark.examples.SparkPi \
- --master spark://hadoop102:7077 \
- --executor-memory 1G \
- --total-executor-cores 2 \
- ./examples/jars/spark-examples_2.11-2.1.1.jar \
- 100
