Skip to content

Instantly share code, notes, and snippets.

@poad
Created February 21, 2017 22:17
Show Gist options
  • Save poad/69b9edc1a208b7fcd956c32017533f27 to your computer and use it in GitHub Desktop.
Save poad/69b9edc1a208b7fcd956c32017533f27 to your computer and use it in GitHub Desktop.
Spark History Server by Docker ref: http://qiita.com/poad1010/items/24dbcc290e4deeee68d7
#!/bin/bash
: ${HADOOP_PREFIX:=/usr/local/hadoop}
$HADOOP_PREFIX/etc/hadoop/hadoop-env.sh
rm /tmp/*.pid
# installing libraries if any - (resource urls added comma separated to the ACP system variable)
cd $HADOOP_PREFIX/share/hadoop/common ; for cp in ${ACP//,/ }; do echo == $cp; curl -LO $cp ; done; cd -
# altering the core-site configuration
sed s/HOSTNAME/$HOSTNAME/ /usr/local/hadoop/etc/hadoop/core-site.xml.template > /usr/local/hadoop/etc/hadoop/core-site.xml
# setting spark defaults
echo spark.yarn.jar hdfs:///spark/spark-assembly-1.6.2-hadoop2.6.0.jar > $SPARK_HOME/conf/spark-defaults.conf
cp $SPARK_HOME/conf/metrics.properties.template $SPARK_HOME/conf/metrics.properties
if [ -z "${SPARK_HOME}" ]; then
export SPARK_HOME="$(cd "`dirname "$0"`"/..; pwd)"
fi
service sshd start
$HADOOP_PREFIX/sbin/start-dfs.sh
$HADOOP_PREFIX/sbin/start-yarn.sh
${SPARK_HOME}/sbin/start-history-server.sh
CMD=${1:-"exit 0"}
if [[ "$CMD" == "-d" ]];
then
service sshd stop
/usr/sbin/sshd -D -d
else
/bin/bash -c "$*"
fi
FROM poad/docker-spark:1.6.2
USER root
COPY bootstrap.sh /etc/bootstrap.sh
RUN chown root.root /etc/bootstrap.sh
RUN chmod 700 /etc/bootstrap.sh
RUN mkdir /tmp/spark-events
EXPOSE 18080
ENTRYPOINT ["/etc/bootstrap.sh"]
${SPARK_HOME}/sbin/start-history-server.sh
RUN mkdir /tmp/spark-events
EXPOSE 18080
docker run -d -h sandbox -p 18080:18080 -p 50010:50010 -p 50020:50020 -p 50070:50070 -p 50075:50075 -p 50090:50090 -p 8020:8020 -p 9000:9000 -p 19888:19888 -p 8030:8030 -p 8031:8031 -p 8032:8032 -p 8033:8033 -p 8040:8040 -p 8042:8042 -p 8088:8088 -p 49707:49707 -p 2122:2122 -v /vagrant/logs/spark:/tmp/spark-events --name spark poad/docker-spark:1.6.2-with-history-server -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment