Running a Service at Boot
Your .service file should look like this:
[Unit]
Description=Spark service
[Service]
ExecStart=/path/to/spark/sbin/start-all.sh
[Install]
WantedBy=multi-user.targetNow, take a few more steps to enable and use the .service file:
Place it in
/etc/systemd/systemfolder with say a name ofmyfirst.serviceMake sure that your script executable with:
chmod u+x /path/to/spark/sbin/start-all.shStart it:
sudo systemctl start myfirstEnable it to run at boot:
sudo systemctl enable myfirstStop it:
sudo systemctl stop myfirst
Notes
You don't need to launch Spark with
sudoin your service, as the default service user is already root.Look at the links below for more
systemdoptions.
Moreover
Now what we have above is just rudimentary, here is a complete setup for spark:
[Unit]
Description=Apache Spark Master and Slave Servers
After=network.target
After=systemd-user-sessions.service
After=network-online.target
[Service]
User=spark
Type=forking
ExecStart=/opt/spark-1.6.1-bin-hadoop2.6/sbin/start-all.sh
ExecStop=/opt/spark-1.6.1-bin-hadoop2.6/sbin/stop-all.sh
TimeoutSec=30
Restart=on-failure
RestartSec=30
StartLimitInterval=350
StartLimitBurst=10
[Install]
WantedBy=multi-user.targetTo setup the service:
sudo systemctl start spark.service
sudo systemctl stop spark.service
sudo systemctl enable spark.serviceFurther reading
Please read through the following links. Spark is a complex setup, so you should understand how it integrates with Ubuntu's init service.
Last updated
Was this helpful?