Deploy a Mesos Cluster with 7 Commands Using Docker
This tutorial will show you how to bring up a single node Mesos cluster all provisioned out using Docker containers (a future post will show how to easily scale this out to multi nodes). This means that you can startup an entire cluster with 7 commands! Nothing to install except for starting out with a working Docker server.
This will startup 4 containers:
As mentioned the only prerequisite is to have a working Docker server. This means you can bring up a local Vagrant box with Docker installed, use Boot2Docker, use CoreOS, instance on AWS, or however you like to get a Docker server.
The entire process is outlined in this Github repository.
Contribute to mesosphere-docker development by creating an account on GitHub.github.com
All of the Docker container build files used are there also. You can build each container locally or just use the pre-built containers located on the Docker Hub. The commands below will automatically download the needed pre-built containers for you.
ZooKeeper — https://registry.hub.docker.com/u/garland/zookeeper/
Meso Master — https://registry.hub.docker.com/u/garland/mesosphere-docker-mesos-master/
Marathon — https://registry.hub.docker.com/u/garland/mesosphere-docker-marathon/
Lets Get Started
Step 1: Get the IP of the Docker server and export it out to the environment. We will use this IP over and over again in subsequent Docker commands.
root@docker-server:/# HOST_IP=10.11.31.7
Step 2: Start the ZooKeeper container.
docker run -d \
-p 2181:2181 \
-p 2888:2888 \
-p 3888:3888 \
garland/zookeeper
docker run --net="host" \
-p 5050:5050 \
-e "MESOS_HOSTNAME=${HOST_IP}" \
-e "MESOS_IP=${HOST_IP}" \
-e "MESOS_ZK=zk://${HOST_IP}:2181/mesos" \
-e "MESOS_PORT=5050" \
-e "MESOS_LOG_DIR=/var/log/mesos" \
-e "MESOS_QUORUM=1" \
-e "MESOS_REGISTRY=in_memory" \
-e "MESOS_WORK_DIR=/var/lib/mesos" \
-d \
garland/mesosphere-docker-mesos-master
docker run \
-d \
-p 8080:8080 \
garland/mesosphere-docker-marathon --master zk://${HOST_IP}:2181/mesos --zk zk://${HOST_IP}:2181/marathon
Step 5: Start Mesos Slave in a container
docker run -d \
--name mesos_slave_1 \
--entrypoint="mesos-slave" \
-e "MESOS_MASTER=zk://${HOST_IP}:2181/mesos" \
-e "MESOS_LOG_DIR=/var/log/mesos" \
-e "MESOS_LOGGING_LEVEL=INFO" \
garland/mesosphere-docker-mesos-master:latest
Step 6: Goto the Mesos’ webpage
Depending on how you brought up your Docker server and it’s IP address you might have to change the IP you point your browser to but the port will be the same.
The Mesos webpage will be at this address:
http://${HOST_IP}:5050
Then you should get a page like this but probably at first without all the items in the “Tasks” tables.
Step 7: Goto Marathon’s webpage to start a job
The Marathon webpage lets you schedule long running tasks onto the Meso Slave container. This is a good test to see if your cluster is up and running. You can view the Marathon’s webpage at:
http://${HOST_IP}:8080
Clicking on the “New App” button on the top right gives you the following menu where you can create a new job/task. We are simply going to echo out hello to a file. We can go into the container and check if the file is created and if the job is continuously running.
Step 8: Check if job/task is running
Lets check if the job/task is continuously running on the Mesos Slave.
On the Docker server run the following commands. It will place you inside the slave container and from there tail out the output.txt file.
docker exec -it mesos_slave_1 /bin/bash
root@ca83bf0ea76a:/# tail -f /tmp/output.txt
You will see “hello” being placed into this file about once a second.