LoginSignup
14
14

More than 5 years have passed since last update.

Apache Spark ドキュメント和訳 - Submitting Applications

Last updated at Posted at 2014-06-11

最初に

Apache Sparkのドキュメントの日本語訳です。
他のページも翻訳していますのでご確認ください。

翻訳におかしなところを見つけたらコメントかfacebookでお知らせください。

Submitting Applications

The spark-submit script in Spark’s bin directory is used to launch applications on a cluster. It can use all of Spark’s supported cluster managers through a uniform interface so you don’t have to configure your application specially for each one.

Sparkのbinディレクトリ内にあるspark-submitスクリプトはアプリケーションをクラスタ上で開始するために使います。これはSparkがサポートする全てのスラスタマネージャで、アプリケーションで特別に設定することなく利用できます。

Bundling Your Application’s Dependencies - 依存性をビルドする

If your code depends on other projects, you will need to package them alongside your application in order to distribute the code to a Spark cluster. To do this, to create an assembly jar (or “uber” jar) containing your code and its dependencies. Both sbt and Maven have assembly plugins. When creating assembly jars, list Spark and Hadoop as provided dependencies; these need not be bundled since they are provided by the cluster manager at runtime. Once you have an assembled jar you can call the bin/spark-submit script as shown here while passing your jar.

もしあなたのコードが他のプロジェクトに依存しているなら、Sparkに配備する為にそれらも一緒にパッケージ化する必要があります。
このため、依存関係も含めてあなたのコードを単一で実行可能に集約されたjar(または"uber" jar)を生成します。sbtもMavenも集約するためのプラグインを持っています。
アセンブリjarを生成するときに, SparkとHadoopも依存関係としてリストにされます。これらはランタイムのクラスタマネージャーから提供されるためバンドルする必要はありません。
一度あなたはjarを集約すれば、bin/spark-submitスクリプトをここで紹介している通りに呼び出すことができます。

For Python, you can use the --py-files argument of spark-submit to add .py, .zip or .egg files to be distributed with your application. If you depend on multiple Python files we recommend packaging them into a .zip or .egg.

Pythonで.py,.zip,.eggファイルをあなたのアプリケーションと一緒に配備するためにspark-submitスクリプトに--py-files引数が用意されています。
あなたがいくつかのPythonファイルに依存しているなら、それらをひとつのzipやeggファイルにすることをお勧めします。

Launching Applications with spark-submit - spark-submitで起動する

Once a user application is bundled, it can be launched using the bin/spark-submit script. This script takes care of setting up the classpath with Spark and its dependencies, and can support different cluster managers and deploy modes that Spark supports:

一度ユーザアプリケーションがバンドルされるとbin/spark-submitスクリプトで起動できます。このスクリプトはSparkとその依存関係のクラスパスをケアします。そして異なるクラスタマネージャーとSparkがサポートしているでプロモードをサポートします。

./bin/spark-submit \
  --class <main-class>
  --master <master-url> \
  --deploy-mode <deploy-mode> \
  ... # other options
  <application-jar> \
  [application-arguments]

Some of the commonly used options are:

いくつかの汎用的なオプションは

--class: The entry point for your application (e.g. org.apache.spark.examples.SparkPi)

--class: アプリケーションのエントリーポイント(クラス名:e.g. org.apache.spark.examples.SparkPi)

--master: The master URL for the cluster (e.g. spark://23.195.26.187:7077)

--master: クラスタにたいするマスターノードのURL

--deploy-mode: Whether to deploy your driver program within the cluster or run it locally as an external client (either cluster or client)

--deploy-mode : ドライバープログラムをクラスタにデプロイするか、ローカルで外部クライアントとしえ実行するかを指定します。(cluster/client)

application-jar: Path to a bundled jar including your application and all dependencies. The URL must be globally visible inside of your cluster, for instance, an hdfs:// path or a file:// path that is present on all nodes.

application-jar: バンドルされたあなたのアプリケーションと全ての依存関係を含むjarファイルのパス。そのURLはあなたのクラスターからインスタンスにグローバルに可視でなければなりません。hdfs://パスまたは、 file://パスのように全てのノードに存在する必要があります。

application-arguments: Arguments passed to the main method of your main class, if any

application-arguments: あなたのメインクラスに渡される引数を自由に記述できます。

For Python applications, simply pass a .py file in the place of instead of a JAR, and add Python .zip, .egg or .py files to the search path with --py-files.

Pythonアプリケーションの場合、JARの代わりに単に.pyファイルを指定し、Python .zip, .eggまたは.pyファイルを--py-filesで指定してください。

To enumerate all options available to spark-submit run it with --help. Here are a few examples of common options:

全てのオプションを確認したい場合は--helpを実行してください。ここではいくつかの一般的な例だけ紹介します。

Run application locally on 8 cores

./bin/spark-submit \
--class org.apache.spark.examples.SparkPi \
--master local[8] \
/path/to/examples.jar \
100

Run on a Spark standalone cluster

./bin/spark-submit \
--class org.apache.spark.examples.SparkPi \
--master spark://207.184.161.138:7077 \
--executor-memory 20G \
--total-executor-cores 100 \
/path/to/examples.jar \
1000

Run on a YARN cluster

export HADOOP_CONF_DIR=XXX
./bin/spark-submit \
--class org.apache.spark.examples.SparkPi \
--master yarn-cluster \ # can also be yarn-client for client mode
--executor-memory 20G \
--num-executors 50 \
/path/to/examples.jar \
1000

Run a Python application on a cluster

./bin/spark-submit \
--master spark://207.184.161.138:7077 \
examples/src/main/python/pi.py \
1000

Master URLs - マスタURL

The master URL passed to Spark can be in one of the following formats:

マスターURLは下記いずれかのフォーマットで利用してください。

  • local
    Run Spark locally with one worker thread (i.e. no parallelism at all).
    1つのワーカースレッドでSparkをローカル実行する。
  • local[K]
    Run Spark locally with K worker threads (ideally, set this to the number of cores on your machine).
    K個のワーカースレッドでSparkをローカル実行する。(この数をあなたのマシンのコア数にするのが理想的)
  • local[*]
    Run Spark locally with as many worker threads as logical cores on your machine.
    あなたのマシンの理論コア数に応じて多くのワーカースレッドでSparkをローカル実行する。
  • spark://HOST:PORT
    Connect to the given Spark standalone cluster master. The port must be whichever one your master is configured to use, which is 7077 by default.
    Sparkスタンドアロンクラスタマスタに接続する。ポート番号はあなたのマスターで設定されたものでなければならない。デフォルトは7077。
  • mesos://HOST:PORT
    Connect to the given Mesos cluster. The port must be whichever one your is configured to use, which is 5050 by default. Or, for a Mesos cluster using ZooKeeper, use mesos://zk://....
    Mesosのクラスタに接続する。ポート番号はあなたが設定したもので、Mesosのデフォルトは5050。ZooKeeperを利用している場合は mesos://sk://...と記述する必要がある。
  • yarn-client
    Connect to a YARN cluster in client mode. The cluster location will be found based on the HADOOP_CONF_DIR variable.
    YARNクラスタにクライアントモードで接続する。クラスタはHADOOP_CONF_DIR変数で定義されたロケーションである必要がある。
  • yarn-cluster
    Connect to a YARN cluster in cluster mode. The cluster location will be found based on HADOOP_CONF_DIR.
    YARNクラスターにクラスターモードで接続する。クラスタはHADOOP_CONF_DIR変数で定義されている必要がある。

Loading Configuration from a File - 設定をファイルから読み込む

The spark-submit script can load default Spark configuration values from a properties file and pass them on to your application. By default it will read options from conf/spark-defaults.conf in the Spark directory. For more detail, see the section on loading default configurations.

spark-submitスクリプトはあなたのアプリケーションのプロパティファイルから設定値を読み込むことができます。デフォルトではオプションをSparkディレクトリ内のconf/spark-defaults.confから読み込みます。
もっと詳しく知りたいならデフォルト設定読み込みのセクションを見てください。

Loading default Spark configurations this way can obviate the need for certain flags to spark-submit. For instance, if the spark.master property is set, you can safely omit the --master flag from spark-submit. In general, configuration values explicitly set on a SparkConf take the highest precedence, then flags passed to spark-submit, then values in the defaults file.

Sparkのデフォルト設定を読み込む方法はいくつものフラグをspark-submitで利用の必要がでてくることを回避できます。インスタンスにとって、spark.masterpropertyがセットされたら安全に--masterフラグをコマンドから省略することができます。一般的に明示的にSparkConfにセットされた設定値は最優先され、それからspark-submitのフラグ、デフォルトファイルの順に優先されます。

If you are ever unclear where configuration options are coming from, you can print out fine-grained debugging information by running spark-submit with the --verbose option.

設定がどこからきたかわからなくなってしまった場合、spark-submitを--verboseオプション付きで実行することで詳細なデバッギングを出力することができます。

Advanced Dependency Management - 高度な依存性管理

When using spark-submit, the application jar along with any jars included with the --jars option will be automatically transferred to the cluster. Spark uses the following URL scheme to allow different strategies for disseminating jars:

spark-submitを利用する時に、アプリケーションjarの--jarsオプションに含まれるものは自動的にクラスタに転送されます。Sparkは解決できないjarについて異なる方法を許可するために下記のURLスキームを使います。

file: - Absolute paths and file:/ URIs are served by the driver’s HTTP file server, and every executor pulls the file from the driver HTTP server.

file: ドライバのHTTPファイルサーバから提供される完全なパスのURI、それぞれのexecuterはドライバHTTPサーバーからファイルを取得します。

hdfs:, http:, https:, ftp: - these pull down files and JARs from the URI as expected

hdf:, http:, https:, ftpは
URIで期待される場所からファイルやJARを取得します。

local: - a URI starting with local:/ is expected to exist as a local file on each worker node. This means that no network IO will be incurred, and works well for large files/JARs that are pushed to each worker, or shared via NFS, GlusterFS, etc.

local: local:/からスタートするURIはそれぞれのワーカーノードのローカルファイルとして存在することを期待されます。これはネットワークIOが不要であることを意味し、既にそれぞれのワーカーにプシュされたりNFSやGlusterFSなどを利用してシェアされている大きなファイルやJARの場合により良い動作を期待できます。

Note that JARs and files are copied to the working directory for each SparkContext on the executor nodes. This can use up a significant amount of space over time and will need to be cleaned up. With YARN, cleanup is handled automatically, and with Spark standalone, automatic cleanup can be configured with the spark.worker.cleanup.appDataTtl property.

JARとファイル群はそれぞれのexecutorノードのSparkContextのワーキングディレクトリにコピーされます。これは深刻な量の領域を長時間確保するためクリーンアップする必要があるでしょう。YARNの場合、クリーンアップは自動的にハンドリングされます。Sparkスタンドアロンの場合spark.worker.cleanup.appDataTtlプロパティで自動クリーンアップを設定できます。

For python, the equivalent --py-files option can be used to distribute .egg, .zip and .py libraries to executors.

Pythonの場合は同等の機能 --py-filesオプションが.egg, .zip, .pyライブラリをexecuterに配送します。

More Information

Once you have deployed your application, the cluster mode overview describes the components involved in distributed execution, and how to monitor and debug applications.

あなたのアプリケーションをデプロイしたら、クラスタモードオーバービューで実行中の難解なコンポーネント、どのようにモニターするか、どのようにアプリケーションをデバッグするかを記述しています。

原文)cluster mode overview
http://spark.apache.org/docs/latest/cluster-overview.html
翻訳)
http://qiita.com/mychaelstyle/items/610b432a1ef1a7e3d2a0

My Facebook
https://www.facebook.com/masanori.nakashima

14
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
14