Spark: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
Line 24: Line 24:
==Slave Daemon==
==Slave Daemon==
<source lang="bash">
<source lang="bash">
sudo tee -a /etc/systemd/system/spark-slave.service >/dev/null <<EOF
sudo apt -qq update;\
[Unit]
export PYSPARK_PYTHON='/usr/bin/python3';\
Description=Apache Spark Slave
export SPARK_MASTER_NODE='spark://ns12-pc04:7077';\
Documentation=https://spark.apache.org/docs/3.3.0
export SPARK_HOME='/opt/cli/spark-3.3.0-bin-hadoop3';\
Wants=network-online.target
export JAVA_HOME='/usr/lib/jvm/java-17-openjdk-amd64';\
After=network-online.target
bash <(curl -s 'https://cdn.chorke.org/exec/cli/bash/install/apache-spark-slave/3.3.0.sh.txt')
AssertFileNotEmpty=${SPARK_HOME}/etc/env
 
[Service]
User=spark
Group=spark
Type=forking
 
EnvironmentFile=${SPARK_HOME}/etc/env
WorkingDirectory={{SPARK_HOME}}/sbin
ExecStartPre=/bin/bash -c "if [ -z \"\${PYSPARK_PYTHON}\" ]; then echo \"Variable PYSPARK_PYTHON not set in ${SPARK_HOME}/etc/env\"; exit 1; fi"
ExecStartPre=/bin/bash -c "if [ -z \"\${SPARK_HOME}\" ]; then echo \"Variable SPARK_HOME not set in ${SPARK_HOME}/etc/env\"; exit 1; fi"
ExecStartPre=/bin/bash -c "if [ -z \"\${JAVA_HOME}\" ]; then echo \"Variable JAVA_HOME not set in ${SPARK_HOME}/etc/env\"; exit 1; fi"
ExecStartPost=/bin/bash -c "echo \$MAINPID > ${SPARK_HOME}/etc/spark-slave.pid"
ExecStart={{SPARK_HOME}}/sbin/start-slave.sh spark://10.20.22.10:7077
ExecStop={{SPARK_HOME}}/sbin/stop-slave.sh
Restart=on-failure
RestartSec=10s
 
[Install]
WantedBy=multi-user.target
EOF
</source>
</source>



Revision as of 11:19, 25 September 2022

Spark Master

sudo tee -a /etc/systemd/system/spark-master.service >/dev/null <<EOF
[Unit]
Description=Apache Spark Master
Documentation=https://spark.apache.org/docs/3.3.0
Wants=network-online.target
After=network-online.target
After=systemd-user-sessions.service

[Service]
User=spark
Group=spark
Type=forking
EnvironmentFile=${SPARK_HOME}/etc/env
ExecStart=${SPARK_HOME}/sbin/start-master.sh
ExecStop=${SPARK_HOME}/sbin/stop-master.sh

[Install]
WantedBy=multi-user.target
EOF

Slave Daemon

sudo apt -qq update;\
export PYSPARK_PYTHON='/usr/bin/python3';\
export SPARK_MASTER_NODE='spark://ns12-pc04:7077';\
export SPARK_HOME='/opt/cli/spark-3.3.0-bin-hadoop3';\
export JAVA_HOME='/usr/lib/jvm/java-17-openjdk-amd64';\
bash <(curl -s 'https://cdn.chorke.org/exec/cli/bash/install/apache-spark-slave/3.3.0.sh.txt')

References