Yandex Cloud
Search
Contact UsGet started
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • AI for business
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
© 2025 Direct Cursus Technology L.L.C.
Tutorials
    • All tutorials
    • Unassisted deployment of the Apache Kafka® web interface
    • Upgrading a Managed Service for Apache Kafka® cluster to migrate from ZooKeeper to KRaft
    • Migrating a database from a third-party Apache Kafka® cluster to Managed Service for Apache Kafka®
    • Moving data between Managed Service for Apache Kafka® clusters using Data Transfer
    • Delivering data from Managed Service for MySQL® to Managed Service for Apache Kafka® using Data Transfer
    • Delivering data from Managed Service for MySQL® to Managed Service for Apache Kafka® using Debezium
    • Delivering data from Managed Service for PostgreSQL to Managed Service for Apache Kafka® using Data Transfer
    • Delivering data from Managed Service for PostgreSQL to Managed Service for Apache Kafka® using Debezium
    • Delivering data from Managed Service for YDB to Managed Service for Apache Kafka® using Data Transfer
    • Delivering data from Managed Service for Apache Kafka® to Managed Service for ClickHouse® using Data Transfer
    • Delivering data from Managed Service for Apache Kafka® to Yandex MPP Analytics for PostgreSQL using Data Transfer
    • Delivering data from Managed Service for Apache Kafka® to Yandex StoreDoc using Data Transfer
    • Delivering data from Managed Service for Apache Kafka® to Managed Service for MySQL® using Data Transfer
    • Delivering data from Managed Service for Apache Kafka® to Managed Service for OpenSearch using Data Transfer
    • Delivering data from Managed Service for Apache Kafka® to Managed Service for PostgreSQL using Data Transfer
    • Delivering data from Managed Service for Apache Kafka® to Managed Service for YDB using Data Transfer
    • Delivering data from Managed Service for Apache Kafka® to Data Streams using Data Transfer
    • Delivering data from Data Streams to Managed Service for YDB using Data Transfer
    • Delivering data from Data Streams to Managed Service for Apache Kafka® using Data Transfer
    • YDB change data capture and delivery to YDS
    • Configuring Kafka Connect to work with a Managed Service for Apache Kafka® cluster
    • Synchronizing Apache Kafka® topics in Object Storage with no web access
    • Monitoring message loss in an Apache Kafka® topic
    • Automating Query tasks with Managed Service for Apache Airflow™
    • Sending requests to the Yandex Cloud API via the Yandex Cloud Python SDK
    • Configuring an SMTP server to send e-mail notifications
    • Adding data to a ClickHouse® DB
    • Migrating data to Managed Service for ClickHouse® using ClickHouse® tools
    • Migrating data to Managed Service for ClickHouse® using Data Transfer
    • Delivering data from Managed Service for MySQL® to Managed Service for ClickHouse® using Data Transfer
    • Asynchronously replicating data from PostgreSQL to ClickHouse®
    • Exchanging data between Managed Service for ClickHouse® and Yandex Data Processing
    • Configuring Managed Service for ClickHouse® for Graphite
    • Fetching data from Managed Service for Apache Kafka® to Managed Service for ClickHouse®
    • Fetching data from Managed Service for Apache Kafka® to ksqlDB
    • Fetching data from RabbitMQ to Managed Service for ClickHouse®
    • Saving a data stream from Data Streams to Managed Service for ClickHouse®
    • Asynchronous replication of data from Yandex Metrica to ClickHouse® using Data Transfer
    • Using hybrid storage in Managed Service for ClickHouse®
    • Sharding Managed Service for ClickHouse® tables
    • Loading data from Yandex Direct to a Managed Service for ClickHouse® data mart using Cloud Functions, Object Storage, and Data Transfer
    • Loading data from Object Storage to Managed Service for ClickHouse® using Data Transfer
    • Migrating data with change of storage from Managed Service for OpenSearch to Managed Service for ClickHouse® using Data Transfer
    • Loading data from Managed Service for YDB to Managed Service for ClickHouse® using Data Transfer
    • Yandex Managed Service for ClickHouse® integration with Microsoft SQL Server via ClickHouse® JDBC Bridge
    • Migrating databases from Google BigQuery to Managed Service for ClickHouse®
    • Yandex Managed Service for ClickHouse® integration with Oracle via ClickHouse® JDBC Bridge
    • Configuring Cloud DNS to access a Managed Service for ClickHouse® cluster from other cloud networks
    • Migrating a Yandex Data Processing HDFS cluster to a different availability zone
    • Importing data from Managed Service for MySQL® to Yandex Data Processing using Sqoop
    • Importing data from Managed Service for PostgreSQL to Yandex Data Processing using Sqoop
    • Mounting Object Storage buckets to the file system of Yandex Data Processing hosts
    • Working with Apache Kafka® topics using Yandex Data Processing
    • Automating operations with Yandex Data Processing using Managed Service for Apache Airflow™
    • Shared use of Yandex Data Processing tables through Apache Hive™ Metastore
    • Transferring metadata across Yandex Data Processing clusters using Apache Hive™ Metastore
    • Importing data from Object Storage, processing it, and exporting it to Managed Service for ClickHouse®
      • Working with Hive jobs
      • Working with MapReduce jobs
      • Working with PySpark jobs
      • Working with Spark jobs
      • Running Apache Hive jobs
      • Running Spark applications
      • Running jobs from a remote host
    • Migrating collections from a third-party MongoDB cluster to Yandex StoreDoc
    • Migrating data to Yandex StoreDoc
    • Migrating Yandex StoreDoc cluster from 4.4 to 6.0
    • Sharding Yandex StoreDoc collections
    • Yandex StoreDoc performance analysis and tuning
    • Migrating a database from a third-party MySQL® cluster to a Managed Service for MySQL® cluster
    • Managed Service for MySQL® performance analysis and tuning
    • Syncing data from a third-party MySQL® cluster to Managed Service for MySQL® using Data Transfer
    • Migrating a database from Managed Service for MySQL® to a third-party MySQL® cluster
    • Migrating a database from Managed Service for MySQL® to Object Storage using Data Transfer
    • Migrating data from Object Storage to Managed Service for MySQL® using Data Transfer
    • Delivering data from Managed Service for MySQL® to Managed Service for Apache Kafka® using Data Transfer
    • Delivering data from Managed Service for MySQL® to Managed Service for Apache Kafka® using Debezium
    • Migrating a database from Managed Service for MySQL® to Managed Service for YDB using Data Transfer
    • MySQL® change data capture and delivery to YDS
    • Migrating data from Managed Service for MySQL® to Managed Service for PostgreSQL using Data Transfer
    • Migrating data from AWS RDS for PostgreSQL to Managed Service for PostgreSQL using Data Transfer
    • Migrating data from Managed Service for MySQL® to Yandex MPP Analytics for PostgreSQL using Data Transfer
    • Configuring an index policy in Managed Service for OpenSearch
    • Migrating data from a third-party OpenSearch cluster to Managed Service for OpenSearch using Data Transfer
    • Loading data from Managed Service for OpenSearch to Object Storage using Data Transfer
    • Migrating data from Managed Service for OpenSearch to Managed Service for YDB using Data Transfer
    • Copying data from Managed Service for OpenSearch to Yandex MPP Analytics for PostgreSQL using Yandex Data Transfer
    • Migrating data from Managed Service for PostgreSQL to Managed Service for OpenSearch using Data Transfer
    • Authenticating a Managed Service for OpenSearch cluster in OpenSearch Dashboards using Keycloak
    • Using the yandex-lemmer plugin in Managed Service for OpenSearch
    • Creating a PostgreSQL cluster for 1C:Enterprise
    • Searching for the Managed Service for PostgreSQL cluster performance issues
    • Managed Service for PostgreSQL performance analysis and tuning
    • Logical replication in PostgreSQL
    • Migrating a database from a third-party PostgreSQL cluster to Managed Service for PostgreSQL
    • Migrating a database from Managed Service for PostgreSQL
    • Delivering data from Managed Service for PostgreSQL to Managed Service for Apache Kafka® using Data Transfer
    • Delivering data from Managed Service for PostgreSQL to Managed Service for Apache Kafka® using Debezium
    • Delivering data from Managed Service for PostgreSQL to Managed Service for YDB using Data Transfer
    • Migrating a database from Managed Service for PostgreSQL to Object Storage
    • Migrating data from Object Storage to Managed Service for PostgreSQL using Data Transfer
    • PostgreSQL change data capture and delivery to YDS
    • Migrating data from Managed Service for PostgreSQL to Managed Service for MySQL® using Data Transfer
    • Migrating data from Managed Service for PostgreSQL to Managed Service for OpenSearch using Data Transfer
    • Fixing string sorting issues in PostgreSQL after upgrading glibc
    • Migrating a database from Greenplum® to ClickHouse®
    • Migrating a database from Greenplum® to PostgreSQL
    • Exporting Greenplum® data to a cold storage in Object Storage
    • Loading data from Object Storage to Yandex MPP Analytics for PostgreSQL using Data Transfer
    • Copying data from Managed Service for OpenSearch to Yandex MPP Analytics for PostgreSQL using Yandex Data Transfer
    • Creating an external table from an Object Storage bucket table using a configuration file
    • Getting data from external sources using named queries in Greenplum®
    • Migrating a database from a third-party Valkey™ cluster to Yandex Managed Service for Valkey™
    • Using a Yandex Managed Service for Valkey™ cluster as a PHP session storage
    • Loading data from Object Storage to Managed Service for YDB using Data Transfer
    • Loading data from Managed Service for YDB to Object Storage using Data Transfer
    • Processing Audit Trails events
    • Processing Cloud Logging logs
    • Processing Debezium CDC streams
    • Analyzing data with Jupyter
    • Processing files with usage details in Yandex Cloud Billing
    • Ingesting data into storage systems
    • Smart log processing
    • Data transfer in microservice architectures
    • Migrating data to Object Storage using Data Transfer
    • Migrating data from a third-party Greenplum® or PostgreSQL cluster to Yandex MPP Analytics for PostgreSQL using Data Transfer
    • Migrating Yandex StoreDoc clusters
    • Migrating MySQL® clusters
    • Migrating to a third-party MySQL® cluster
    • Migrating PostgreSQL clusters
    • Creating a schema registry to deliver data in Debezium CDC format from Apache Kafka®
    • Automating operations using Yandex Managed Service for Apache Airflow™
    • Working with an Object Storage table from a PySpark job
    • Integrating Yandex Managed Service for Apache Spark™ with Apache Hive™ Metastore
    • Running a PySpark job using Yandex Managed Service for Apache Airflow™
    • Using Yandex Object Storage in Yandex Managed Service for Apache Spark™

In this article:

  • Getting started
  • Running a job
  1. Building a data platform
  2. Working with jobs Yandex Data Processing
  3. Running jobs from a remote host

Running jobs from remote hosts that are not part of the Yandex Data Processing cluster

Written by
Yandex Cloud
Updated at September 25, 2025
  • Getting started
  • Running a job

This tutorial describes how to use the spark-submit utility to run Spark jobs in the Yandex Data Processing cluster from hosts that are not part of the cluster.

Note

You can also run jobs in the Yandex Data Processing cluster from Yandex DataSphere. For more information, see this concept.

Getting startedGetting started

Create and configure a host to run jobs remotely on the Yandex Data Processing cluster:

Image version 1.4
Image version 2.0
  1. Create a VM running Ubuntu 16.04 LTS.

  2. To provide network access to the Yandex Data Processing cluster hosting this VM, set up security groups for the cluster.

  3. Connect to the VM over SSH:

    ssh -A <username>@<VM_FDQN>
    
  4. Copy the repository settings from any of the Yandex Data Processing cluster hosts. To do this, run a sequence of commands on the VM you created.

    1. Copy the repository address:

      ssh root@<cluster_host_FQDN> \
      "cat /etc/apt/sources.list.d/yandex-dataproc.list" | \
      sudo tee /etc/apt/sources.list.d/yandex-dataproc.list
      
    2. Copy the GPG key to verify Debian package signatures:

      ssh root@<cluster_host_FQDN> \
      "cat /srv/dataproc.gpg" | sudo apt-key add -
      
    3. Update the repository cache:

      sudo apt update
      
  5. Install the required packages:

    sudo apt install openjdk-8-jre-headless hadoop-client hadoop-hdfs spark-core spark-python
    

    Note

    You need the spark-python package only to run PySpark jobs.

  6. Copy the Hadoop and Spark configuration files:

    sudo -E scp -r \
        root@<cluster_host_FQDN>:/etc/hadoop/conf/* \
        /etc/hadoop/conf/ && \
    sudo -E scp -r \
        root@<cluster_host_FQDN>:/etc/spark/conf/* \
        /etc/spark/conf/
    
  7. Create a user named sparkuser to run jobs:

    sudo useradd sparkuser && \
    ssh root@<cluster_host_FQDN> "
      hadoop fs -mkdir /user/sparkuser
      sudo -u hdfs hdfs dfs -chown sparkuser:sparkuser /user/sparkuser
      sudo -u hdfs hdfs dfs -ls /user/sparkuser
    "
    
  1. Create a VM running Ubuntu 20.04 LTS.

  2. To provide network access to the Yandex Data Processing cluster hosting this VM, set up security groups for the cluster.

  3. Connect to the VM over SSH:

    ssh -A <username>@<VM_FDQN>
    
  4. Copy the repository settings from any of the Yandex Data Processing cluster hosts. To do this, run a sequence of commands on the VM you created.

    1. Copy the repository address:

      ssh ubuntu@<cluster_host_FQDN> \
      "cat /etc/apt/sources.list.d/yandex-dataproc.list" | \
      sudo tee /etc/apt/sources.list.d/yandex-dataproc.list
      
    2. Copy the GPG key to verify Debian package signatures:

      ssh ubuntu@<cluster_host_FQDN> \
      "cat /srv/dataproc.gpg" | sudo apt-key add -
      
    3. Update the repository cache:

      sudo apt update
      
  5. Install the required packages:

    sudo apt install openjdk-8-jre-headless hadoop-client hadoop-hdfs spark-core spark-python
    

    Note

    You need the spark-python package only to run PySpark jobs.

  6. Copy the Hadoop and Spark configuration files:

    sudo -E scp -r \
        ubuntu@<cluster_host_FQDN>:/etc/hadoop/conf/* \
        /etc/hadoop/conf/ && \
    sudo -E scp -r \
        ubuntu@<cluster_host_FQDN>:/etc/spark/conf/* \
        /etc/spark/conf/
    
  7. Create a user named sparkuser to run jobs:

    sudo useradd sparkuser && \
    ssh ubuntu@<cluster_host_FQDN> "
      hadoop fs -mkdir /user/sparkuser
      sudo -u hdfs hdfs dfs -chown sparkuser:sparkuser /user/sparkuser
      sudo -u hdfs hdfs dfs -ls /user/sparkuser
    "
    

Running a jobRunning a job

Spark job
PySpark job
  1. Run a job using this command:

    sudo -u sparkuser spark-submit \
         --master yarn \
         --deploy-mode cluster \
         --class org.apache.spark.examples.SparkPi \
             /usr/lib/spark/examples/jars/spark-examples.jar 1000
    

    Result:

    20/04/19 16:43:58 INFO client.RMProxy: Connecting to ResourceManager at rc1b-dataproc-m-ds7lj5gnnnqggbqd.mdb.yandexcloud.net/  10.13.13.18:8032
    20/04/19 16:43:58 INFO client.AHSProxy: Connecting to Application History server at rc1b-dataproc-m-ds7lj5gnnnqggbqd.mdb.yandexcloud.net/10.13.13.18:10200
    20/04/19 16:43:58 INFO yarn.Client: Requesting a new application from cluster with 4 NodeManagers
    ...
    20/04/19 16:43:58 INFO yarn.Client: Preparing resources for our AM container
    20/04/19 16:43:58 INFO yarn.Client: Uploading resource file:/usr/lib/spark/examples/jars/spark-examples.jar -> hdfs://  rc1b-dataproc-m-ds7lj5gnnnqggbqd.mdb.yandexcloud.net/user/sparkuser/.sparkStaging/application_1586176069782_0003/  spark-examples.jar
    20/04/19 16:43:58 INFO yarn.Client: Uploading resource file:/etc/spark/conf/hive-site.xml -> hdfs://  rc1b-dataproc-m-ds7lj5gnnnqggbqd.mdb.yandexcloud.net/user/sparkuser/.sparkStaging/application_1586176069782_0003/hive-site.  xml
    20/04/19 16:43:58 INFO yarn.Client: Uploading resource file:/tmp/spark-6dff3163-089b-4634-8f74-c8301d424567/  __spark_conf__8717606866210190000.zip -> hdfs://rc1b-dataproc-m-ds7lj5gnnnqggbqd.mdb.yandexcloud.net/user/sparkuser/.  sparkStaging/application_1586176069782_0003/__spark_conf__.zip
    20/04/19 16:44:00 INFO yarn.Client: Submitting application application_1586176069782_0003 to ResourceManager
    20/04/19 16:44:00 INFO impl.YarnClientImpl: Submitted application application_1586176069782_0003
    20/04/19 16:44:01 INFO yarn.Client: Application report for application_1586176069782_0003 (state: ACCEPTED)
    20/04/19 16:44:01 INFO yarn.Client:
       client token: N/A
       diagnostics: AM container is launched, waiting for AM container to Register with RM
       ApplicationMaster host: N/A
       ApplicationMaster RPC port: -1
       queue: default
       start time: 1587314639386
       final status: UNDEFINED
       tracking URL: http://rc1b-dataproc-m-ds7lj5gnnnqggbqd.mdb.yandexcloud.net:8088/proxy/application_1586176069782_0003/
       user: sparkuser
    20/04/19 16:44:05 INFO yarn.Client: Application report for application_1586176069782_0003 (state: RUNNING)
    20/04/19 16:44:05 INFO yarn.Client:
       client token: N/A
       diagnostics: N/A
       ApplicationMaster host: rc1b-dataproc-d-9cd9yoenm4npsznt.mdb.yandexcloud.net
       ApplicationMaster RPC port: 41648
       queue: default
       start time: 1587314639386
       final status: UNDEFINED
       tracking URL: http://rc1b-dataproc-m-ds7lj5gnnnqggbqd.mdb.yandexcloud.net:8088/proxy/application_1586176069782_0003/
       user: sparkuser
    20/04/19 16:44:06 INFO yarn.Client: Application report for application_1586176069782_0003 (state: RUNNING)
    20/04/19 16:44:07 INFO yarn.Client: Application report for application_1586176069782_0003 (state: RUNNING)
    20/04/19 16:44:08 INFO yarn.Client: Application report for application_1586176069782_0003 (state: RUNNING)
    20/04/19 16:44:09 INFO yarn.Client: Application report for application_1586176069782_0003 (state: FINISHED)
    20/04/19 16:44:09 INFO yarn.Client:
       client token: N/A
       diagnostics: N/A
       ApplicationMaster host: rc1b-dataproc-d-9cd9yoenm4npsznt.mdb.yandexcloud.net
       ApplicationMaster RPC port: 41648
       queue: default
       start time: 1587314639386
       final status: SUCCEEDED
       tracking URL: http://rc1b-dataproc-m-ds7lj5gnnnqggbqd.mdb.yandexcloud.net:8088/proxy/application_1586176069782_0003/
       user: sparkuser
    20/04/19 16:44:09 INFO util.ShutdownHookManager: Shutdown hook called
    20/04/19 16:44:09 INFO util.ShutdownHookManager: Deleting directory /tmp/spark-6dff3163-089b-4634-8f74-c8301d424567
    20/04/19 16:44:09 INFO util.ShutdownHookManager: Deleting directory /tmp/spark-826498b1-8dec-4229-905e-921203b7b1d0
    
  2. Check the job execution status using the yarn application utility:

    yarn application -status application_1586176069782_0003
    

    Result:

    20/04/19 16:47:03 INFO client.RMProxy: Connecting to ResourceManager at rc1b-dataproc-m-ds7lj5gn********.mdb.yandexcloud.net/10.13.13.18:8032
    20/04/19 16:47:03 INFO client.AHSProxy: Connecting to Application History server at rc1b-dataproc-m-ds7lj5gn********.mdb.yandexcloud.net/10.13.13.18:10200
    Application Report :
        Application-Id : application_1586176069782_0003
        Application-Name : org.apache.spark.examples.SparkPi
        Application-Type : SPARK
        User : sparkuser
        Queue : default
        Application Priority : 0
        Start-Time : 1587314639386
        Finish-Time : 1587314647621
        Progress : 100%
        State : FINISHED
        Final-State : SUCCEEDED
        Tracking-URL : rc1b-dataproc-m-ds7lj5gn********.mdb.yandexcloud.net:18080/history/application_1586176069782_0003/1
        RPC Port : 41648
        AM Host : rc1b-dataproc-d-9cd9yoen********.mdb.yandexcloud.net
        Aggregate Resource Allocation : 141510 MB-seconds, 11 vcore-seconds
        Aggregate Resource Preempted : 0 MB-seconds, 0 vcore-seconds
        Log Aggregation Status : SUCCEEDED
        Diagnostics :
        Unmanaged Application : false
        Application Node Label Expression : <Not set>
        AM container Node Label Expression : <DEFAULT_PARTITION>
        TimeoutType : LIFETIME    ExpiryTime : UNLIMITED    RemainingTime : -1seconds
    
  3. View logs from all running containers using the yarn logs utility:

    sudo -u sparkuser yarn logs \
         -applicationId application_1586176069782_0003 | grep "Pi is"
    

    Result:

    Pi is roughly 3.14164599141646
    
  1. On the VM, create a file named month_stat.py with the following code:

    import sys
    
    from pyspark import SparkContext, SparkConf
    from pyspark.sql import SQLContext
    
    def main():
        conf = SparkConf().setAppName("Month Stat - Python")
        conf.set("fs.s3a.aws.credentials.provider", "org.apache.hadoop.fs.s3a.AnonymousAWSCredentialsProvider")
        sc = SparkContext(conf=conf)
    
        sql = SQLContext(sc)
        df = sql.read.parquet("s3a://yc-mdb-examples/dataproc/example01/set01")
        defaultFS = sc._jsc.hadoopConfiguration().get("fs.defaultFS")
        month_stat = df.groupBy("Month").count()
        month_stat.repartition(1).write.format("csv").save(defaultFS+"/tmp/month_stat")
    
    if __name__ == "__main__":
            main()
    
  2. Copy the month_stat.py file on the cluster's master host:

    sudo -E scp month_stat.py <username>@<cluster_host_FQDN>:~/month_stat.py
    

    For image version 2.0, specify the ubuntu user; for image version 1.4, specify root.

  3. Run the application:

    sudo -u sparkuser spark-submit \
         --master yarn \
         --deploy-mode cluster \
         month_stat.py
    
  4. The result will be exported to HDFS on the cluster. You can list the files you got using this command:

    ssh <username>@<cluster_host_FQDN> "hdfs dfs -ls /tmp/month_stat"
    

    For image version 2.0, specify the ubuntu user; for image version 1.4, specify root.

Note

You can view the job logs and search data in them using Yandex Cloud Logging. For more information, see Working with logs.

Was the article helpful?

Previous
Running Spark applications
Next
Migrating collections from a third-party MongoDB cluster to Yandex StoreDoc
© 2025 Direct Cursus Technology L.L.C.