* add `-Dlog4j.configuration=<location of configuration file>` to `spark.driver.extraJavaOptions` (for the driver) or `spark.executor.extraJavaOptions` (for executors). Note that if using a file, the `file:` protocol should be explicitly provided, and the file needs to exist locally on all the nodes.
@@ -141,4 +141,4 @@ To use a custom metrics.properties for the application master and executors, upd
| --- | --- | --- |
| `spark.yarn.shuffle.stopOnFailure` | `false` | 是否在 Spark Shuffle Service 初始化出现故障时停止 NodeManager。This prevents application failures caused by running containers on NodeManagers where the Spark Shuffle Service is not running. |
## 用 Apache Oozie 来运行应用程序 Apache Oozie 可以将启动 Spark 应用程序作为工作流的一部分。在安全集群中,启动的应用程序将需要相关的 tokens 来访问集群的服务。如果 Spark 使用 keytab 启动,这是自动的。但是,如果 Spark 在没有 keytab 的情况下启动,则设置安全性的责任必须移交给 Oozie。有关配置 Oozie 以获取安全集群和获取作业凭据的详细信息,请参阅 [Oozie web site](http://oozie.apache.org/) 上特定版本文档的 “Authentication” 部分。对于 Spark 应用程序,必须设置 Oozie 工作流以使 Oozie 请求应用程序需要的所有 tokens,包括: - The YARN resource manager. - The local Hadoop filesystem. - Any remote Hadoop filesystems used as a source or destination of I/O. - Hive —if used. - HBase —if used. - The YARN timeline server, if the application interacts with this. 为了避免 Spark 尝试 - 然后失败 - 要获取 Hive,HBase 和远程的 HDFS 令牌,必须将 Spark 配置收集这些服务 tokens 的选项设置为禁用。Spark 配置必须包含以下行: ``` spark.yarn.security.credentials.hive.enabled false spark.yarn.security.credentials.hbase.enabled false ``` 必须取消设置配置选项`spark.yarn.access.hadoopFileSystems`. ## Kerberos 故障排查 调试 Hadoop/Kerberos 问题可能是 “difficult 困难的”。一个有用的技术是通过设置 `HADOOP_JAAS_DEBUG` 环境变量在 Hadoop 中启用对 Kerberos 操作的额外记录。```bash export HADOOP_JAAS_DEBUG=true ``` JDK 类可以配置为通过系统属性 `sun.security.krb5.debug` 和 `sun.security.spnego.debug=true` 启用对 Kerberos 和 SPNEGO/REST 认证的额外日志记录。``` -Dsun.security.krb5.debug=true -Dsun.security.spnego.debug=true ``` 所有这些选项都可以在 Application Master 中启用: ``` spark.yarn.appMasterEnv.HADOOP_JAAS_DEBUG true spark.yarn.am.extraJavaOptions -Dsun.security.krb5.debug=true -Dsun.security.spnego.debug=true ``` 最后,如果 `org.apache.spark.deploy.yarn.Client` 的日志级别设置为 `DEBUG`,日志将包括获取的所有 tokens 的列表,以及它们的到期详细信息。## 使用 Spark History Server 来替换 Spark Web UI 当应用程序 UI 被禁用时的应用程序,可以使用 Spark History Server 应用程序页面作为运行程序用于跟踪的 URL。这在 secure clusters(安全的集群)中是适合的,或者减少 Spark driver 的内存使用量。要通过 Spark History Server 设置跟踪,请执行以下操作: - 在 application(应用)方面,在 Spark 的配置中设置 `spark.yarn.historyServer.allowTracking=true`. 在 application's UI 是禁用的情况下,这将告诉 Spark 去使用 history server's URL 作为 racking URL。- 在 Spark History Server 方面,添加 `org.apache.spark.deploy.yarn.YarnProxyRedirectFilter` 到 `spark.ui.filters` 配置的中的 filters 列表中去。请注意,history server 信息可能不是应用程序状态的最新信息。
\ No newline at end of file
## 用 Apache Oozie 来运行应用程序 Apache Oozie 可以将启动 Spark 应用程序作为工作流的一部分。在安全集群中,启动的应用程序将需要相关的 tokens 来访问集群的服务。如果 Spark 使用 keytab 启动,这是自动的。但是,如果 Spark 在没有 keytab 的情况下启动,则设置安全性的责任必须移交给 Oozie。有关配置 Oozie 以获取安全集群和获取作业凭据的详细信息,请参阅 [Oozie web site](http://oozie.apache.org/) 上特定版本文档的 “Authentication” 部分。对于 Spark 应用程序,必须设置 Oozie 工作流以使 Oozie 请求应用程序需要的所有 tokens,包括:- The YARN resource manager. - The local Hadoop filesystem. - Any remote Hadoop filesystems used as a source or destination of I/O. - Hive —if used. - HBase —if used. - The YARN timeline server, if the application interacts with this. 为了避免 Spark 尝试 - 然后失败 - 要获取 Hive,HBase 和远程的 HDFS 令牌,必须将 Spark 配置收集这些服务 tokens 的选项设置为禁用。Spark 配置必须包含以下行:``` spark.yarn.security.credentials.hive.enabled false spark.yarn.security.credentials.hbase.enabled false ``` 必须取消设置配置选项`spark.yarn.access.hadoopFileSystems`. ## Kerberos 故障排查 调试 Hadoop/Kerberos 问题可能是 “difficult 困难的”。一个有用的技术是通过设置 `HADOOP_JAAS_DEBUG` 环境变量在 Hadoop 中启用对 Kerberos 操作的额外记录。```bash export HADOOP_JAAS_DEBUG=true ``` JDK 类可以配置为通过系统属性 `sun.security.krb5.debug` 和 `sun.security.spnego.debug=true` 启用对 Kerberos 和 SPNEGO/REST 认证的额外日志记录。``` -Dsun.security.krb5.debug=true -Dsun.security.spnego.debug=true ``` 所有这些选项都可以在 Application Master 中启用:``` spark.yarn.appMasterEnv.HADOOP_JAAS_DEBUG true spark.yarn.am.extraJavaOptions -Dsun.security.krb5.debug=true -Dsun.security.spnego.debug=true ``` 最后,如果 `org.apache.spark.deploy.yarn.Client` 的日志级别设置为 `DEBUG`,日志将包括获取的所有 tokens 的列表,以及它们的到期详细信息。## 使用 Spark History Server 来替换 Spark Web UI 当应用程序 UI 被禁用时的应用程序,可以使用 Spark History Server 应用程序页面作为运行程序用于跟踪的 URL。这在 secure clusters(安全的集群)中是适合的,或者减少 Spark driver 的内存使用量。要通过 Spark History Server 设置跟踪,请执行以下操作:- 在 application(应用)方面,在 Spark 的配置中设置 `spark.yarn.historyServer.allowTracking=true`. 在 application's UI 是禁用的情况下,这将告诉 Spark 去使用 history server's URL 作为 racking URL。- 在 Spark History Server 方面,添加 `org.apache.spark.deploy.yarn.YarnProxyRedirectFilter` 到 `spark.ui.filters` 配置的中的 filters 列表中去。请注意,history server 信息可能不是应用程序状态的最新信息。
Once created, the distributed dataset (`distData`) can be operated on in parallel. For example, we can call `distData.reduce(lambda a, b: a + b)` to add up the elements of the list. We describe operations on distributed datasets later on.
并行集合中一个很重要参数是 _partitions_(分区)的数量,它可用来切割 dataset(数据集)。Spark 将在集群中的每一个分区上运行一个任务。通常您希望群集中的每一个 CPU 计算 2-4 个分区。一般情况下,Spark 会尝试根据您的群集情况来自动的设置的分区的数量。当然,您也可以将分区数作为第二个参数传递到 `parallelize` (e.g. `sc.parallelize(data, 10)`) 方法中来手动的设置它。注意: 代码中的一些地方会使用 term slices (a synonym for partitions) 以保持向后兼容.
并行集合中一个很重要参数是 _partitions_(分区)的数量,它可用来切割 dataset(数据集)。Spark 将在集群中的每一个分区上运行一个任务。通常您希望群集中的每一个 CPU 计算 2-4 个分区。一般情况下,Spark 会尝试根据您的群集情况来自动的设置的分区的数量。当然,您也可以将分区数作为第二个参数传递到 `parallelize` (e.g. `sc.parallelize(data, 10)`) 方法中来手动的设置它。注意:代码中的一些地方会使用 term slices (a synonym for partitions) 以保持向后兼容.
## 外部 Datasets(数据集)
...
...
@@ -314,7 +314,7 @@ distFile: org.apache.spark.rdd.RDD[String] = data.txt MapPartitionsRDD[10] at te
在创建后,`distFile` 可以使用 dataset(数据集)的操作。例如,我们可以使用下面的 map 和 reduce 操作来合计所有行的数量: `distFile.map(s => s.length).reduce((a, b) => a + b)`。
在创建后,`distFile` 可以使用 dataset(数据集)的操作。例如,我们可以使用下面的 map 和 reduce 操作来合计所有行的数量:`distFile.map(s => s.length).reduce((a, b) => a + b)`。
使用 Spark 读取文件时需要注意:
...
...
@@ -460,7 +460,7 @@ See the [Python examples](https://github.com/apache/spark/tree/master/examples/s
DataFrames 提供了一个特定的语法用在 [Scala](api/scala/index.html#org.apache.spark.sql.Dataset),[Java](api/java/index.html?org/apache/spark/sql/Dataset.html),[Python](api/python/pyspark.sql.html#pyspark.sql.DataFrame) and [R](api/R/SparkDataFrame.html)中机构化数据的操作.
* Column 统计信息的收集: Spark SQL does not piggyback scans to collect column statistics at the moment and only supports populating the sizeInBytes field of the hive metastore.
* Column 统计信息的收集:Spark SQL does not piggyback scans to collect column statistics at the moment and only supports populating the sizeInBytes field of the hive metastore.