Connect to the Spark shell

Before running the commands shown on this page, you should load the Bitnami stack environment by executing the installdir/use_APPNAME script (Linux and MacOS) or by clicking the shortcut in the Start Menu under “Start -> Bitnami APPNAME Stack -> Application console” (Windows). On OS X VMs, the installation directory is /opt/bitnami and OS X VM users can click the “Open Terminal” button to run commands. Learn more about the Bitnami stack environment and about OS X VMs.

Spark provides a shell, which allows you to run Spark interactively. You can access the Spark shell with the following command:

$ spark-shell

After some seconds, you will see the prompt:


The Bitnami Hadoop Stack includes Spark, a fast and general-purpose cluster computing system. Spark includes several example programs.

In order to run Spark examples, you must use the run-example program. In order to estimate a value for Pi, you can run the following test:

$ run-example SparkPi 10

After some seconds, Spark will output the result:

2018-02-15 12:37:29,410 INFO scheduler.DAGScheduler: Job 0 finished: reduce at SparkPi.scala:38, took 1.697757 s
Pi is roughly 3.1426351426351427
Last modification April 8, 2020