Migrating SQL jobs

You can migrate your SQL jobs using the SQL Stream Builder (SSB) job migration tool. The migration tool can be used from Command Line Interface (CLI) or using the SSB REST API. The migration tool enables you to export your SQL jobs with configurations, and import them to a different cluster or deployment when needed.

You can migrate you SQL jobs either using the API Explorer or the SSB migration tool from CLI. The migration process consists of exporting and importing the details of the SQL job. No matter which migration option you choose, the underlying process is the same as both solutions are based on calling the SSB REST API endpoints. However, when using the API Explorer, you need to manual copy and paste the job details between the endpoints. The migration tool in CLI automatically takes care of accessing this information.

Before migrating your SQL jobs, you need to stop the job if it is in a running state. To stop the SQL job you can use the Stop button either under the SQL window on the Compose page, or next to the running job on the SQL Jobs tab. Make a note of the SQL job name as you need to provide it for the job migration.

  1. Access the API Explorer.
    1. Click API Explorer on the main menu of Streaming SQL Console.
    2. Go to Cloudera Manager > Cluster > SQL Stream Builder, and click SQLStreamBuilder API Explorer from Web UI.
  2. Open the GET/api/v1/ssb/jobs/{jobsName} operation.
  3. Paste the copied job name to jobName.
  4. Provide your username.
  5. Click Execute.

    The details about the job is exported, and returned in a JSON string. To import the job, you need to copy the JSON detail and add it to the POST request.

  6. Copy the JSON string.
  7. Open the POST/api/v1/ssb/jobs/{jobsName} operation.
  8. Provide a job name.
  9. Provide your username.
  10. Click Execute.

    The job is imported to the Streaming SQL Console, and is listed under the SQL jobs tab with a stopped status.

  1. Connect to your cluster using ssh.
  2. Use the following command to export the job:
    ssb-job-migration -api <cluster_hostname> -o job-export -j <jobname> -f <target_filename>
  3. Use the following command to import the job:
    ssb-job-migration -api <cluster_hostname> -o job-import -j <jobname> -f <source_filename>

    The job is imported to the Streaming SQL Console, and is listed under the SQL jobs tab with a stopped status.