Mesosphere is a software solution that provides ways of managing server infrastructures and basically expands upon the cluster-management capabilities of Apache Mesos. Mesosphere has also launched the DCOS (data center operating system), used to manage data centers by spanning all the machines and treating them as a single computer, providing a highly scalable and elastic way of deploying apps on top of it. DCOS can be installed on any public cloud or your own private data center, ranging from AWS, GCE, and Microsoft Azure to VMware. Marathon is the framework for Mesos and is designed to launch and run applications; it serves as a replacement for the init system. Marathon provides various features such as high availability, application health check, and service discovery, which help you run applications in Mesos clustered environments.
This session describes how to bring up a single-node Mesos cluster.
Mesos can run and manage Docker containers using the Marathon framework.
In this exercise, we will use CentOS 7 to deploy a Mesos cluster:
# sudo rpm -Uvh http://repos.mesosphere.com/el/7/noarch/RPMS/mesosphere-el-repo-7-1.noarch.rpm # sudo yum -y install mesos marathon
Apache Mesos uses Zookeeper to operate. Zookeeper acts as the master election service in the Mesosphere architecture and stores states for the Mesos nodes.
# sudo rpm -Uvh http://archive.cloudera.com/cdh4/one-click-install/redhat/6/x86_64/cloudera-cdh-4-0.x86_64.rpm # sudo yum -y install zookeeper zookeeper-server
# sudo service zookeeper-server stop # sudo service zookeeper-server start
Mesos uses a simple architecture to give you intelligent task distribution across a cluster of machines without worrying about where they are scheduled.
mesos-master
and mesos-slave
processes as follows:# sudo service mesos-master start # sudo service mesos-slave start
5050
. As shown in the following screenshot, you can access the Mesos interface with your machine's IP address, here, http://192.168.10.10:5050
:mesos-execute
command:# export MASTER=$(mesos-resolve `cat /etc/mesos/zk` 2>/dev/null) # mesos help # mesos-execute --master=$MASTER --name="cluster-test" --command="sleep 40"
mesos-execute
command running, enter Ctrl + Z to suspend the command. You can see how it appears in the web UI and command line:# hit ctrl-z # mesos ps --master=$MASTER
The Mesosphere stack uses Marathon to manage processes and services. It serves as a replacement for the traditional init system. It simplifies the running of applications in a clustered environment. The following figure shows the Mesosphere Master slave topology with Marathon:
Marathon can be used to start other Mesos frameworks; as it is designed for long-running applications, it will ensure that the applications it has launched will continue running even if the slave nodes they are running on fail.
# sudo service marathon start
In this exercise, we will install a simple Outyet web application:
# sudo yum install -y golang git device-mapper-event-libs docker # sudo chkconfig docker on # sudo service docker start # export GOPATH=~/go # go get github.com/golang/example/outyet # cd $GOPATH/src/github.com/golang/example/outyet # sudo docker build -t outyet.
# sudo docker run --publish 6060:8080 --name test --rm outyet
http://192.168.10.10:6060/
on your browser in order to confirm it works. Once it does, you can hit CTRL + C to exit the Outyet Docker.# vi /home/user/outyet.json { "id": "outyet", "cpus": 0.2, "mem": 20.0, "instances": 1, "constraints": [["hostname", "UNIQUE", ""]], "container": { "type": "DOCKER", "docker": { "image": "outyet", "network": "BRIDGE", "portMappings": [ { "containerPort": 8080, "hostPort": 0, "servicePort": 0, "protocol": "tcp" } ] } } } # echo 'docker,mesos' | sudo tee /etc/mesos-slave/containerizers # sudo service mesos-slave restart
# curl -X POST http://192.168.10.10:8080/v2/apps -d /home/user/outyet.json -H "Content-type: application/json"
http://192.168.10.10:8080
, as shown in the following screenshot:In this final section, we will be deploying the latest launch of DCOS by Mesosphere on AWS in order to manage and deploy Docker services in our data center:
.pem
) file should be stored in a secure location for future use:It can also be done by providing the link for the Amazon S3 template URL in the stack deployment:
$ sudo pip install virtualenv $ mkdir dcos $ cd dcos $ curl -O https://downloads.mesosphere.io/dcos-cli/install.sh % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 3654 100 3654 0 0 3631 0 0:00:01 0:00:01 --:--:-- 3635 $ ls install.sh $ bash install.sh . http://mesos-dco-elasticl-17lqe4oh09r07-1358461817.us-west-1.elb.amazonaws.com Installing DCOS CLI from PyPI... New python executable in /home/vkohli/dcos/bin/python Installing setuptools, pip, wheel...done. [core.reporting]: set to 'True' [core.dcos_url]: set to 'http://mesos-dco-elasticl-17lqe4oh09r07-1358461817.us-west-1.elb.amazonaws.com' [core.ssl_verify]: set to 'false' [core.timeout]: set to '5' [package.cache]: set to '/home/vkohli/.dcos/cache' [package.sources]: set to '[u'https://github.com/mesosphere/universe/archive/version-1.x.zip']' Go to the following link in your browser: https://accounts.mesosphere.com/oauth/authorize?scope=&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&client_id=6a552732-ab9b-410d-9b7d-d8c6523b09a1&access_type=offline Enter verification code: Skipping authentication. Enter email address: Skipping email input. Updating source [https://github.com/mesosphere/universe/archive/version-1.x.zip] Modify your bash profile to add DCOS to your PATH? [yes/no] yes Finished installing and configuring DCOS CLI. Run this command to set up your environment and to get started: source ~/.bashrc && dcos help
The DCOS help file can be listed as follows:
$ source ~/.bashrc && dcos help Command line utility for the Mesosphere Datacenter Operating System (DCOS). The Mesosphere DCOS is a distributed operating system built around Apache Mesos. This utility provides tools for easy management of a DCOS installation. Available DCOS commands: config Get and set DCOS CLI configuration properties help Display command line usage information marathon Deploy and manage applications on the DCOS node Manage DCOS nodes package Install and manage DCOS packages service Manage DCOS services task Manage DCOS tasks
dcos <command> --help
:$ dcos config show package.sources [ "https://github.com/mesosphere/universe/archive/version-1.x.zip" ] $ dcos package update Updating source [https://github.com/mesosphere/universe/archive/version-1.x.zip] $ dcos package search NAME VERSION FRAMEWORK SOURCE DESCRIPTION arangodb 0.2.1 True https://github.com/mesosphere/universe/archive/version-1.x.zip A distributed free and open-source database with a flexible data model for documents, graphs, and key-values. Build high performance applications using a convenient SQL-like query language or JavaScript extensions. cassandra 0.2.0-1 True https://github.com/mesosphere/universe/archive/version-1.x.zip Apache Cassandra running on Apache Mesos. chronos 2.4.0 True https://github.com/mesosphere/universe/archive/version-1.x.zip A fault tolerant job scheduler for Mesos which handles dependencies and ISO8601 based schedules. hdfs 0.1.7 True https://github.com/mesosphere/universe/archive/version-1.x.zip Hadoop Distributed File System (HDFS), Highly Available. kafka 0.9.2.0 True https://github.com/mesosphere/universe/archive/version-1.x.zip Apache Kafka running on top of Apache Mesos. marathon 0.11.1 True https://github.com/mesosphere/universe/archive/version-1.x.zip A cluster-wide init and control system for services in cgroups or Docker containers. spark 1.5.0-multi-roles-v2 True https://github.com/mesosphere/universe/archive/version-1.x.zip Spark is a fast and general cluster computing system for Big Data.
$ dcos package install spark Note that the Apache Spark DCOS Service is beta and there may be bugs, incomplete features, incorrect documentation or other discrepancies. We recommend a minimum of two nodes with at least 2 CPU and 2GB of RAM available for the Spark Service and running a Spark job. Note: The Spark CLI may take up to 5min to download depending on your connection. Continue installing? [yes/no] yes Installing Marathon app for package [spark] version [1.5.0-multi-roles-v2] Installing CLI subcommand for package [spark] version [1.5.0-multi-roles-v2]
$ nano definition.json { "container": { "type": "DOCKER", "docker": { "image": "superguenter/demo-app" } }, "cmd": "python -m SimpleHTTPServer $PORT", "id": "demo", "cpus": 0.01, "mem": 256, "ports": [3000] }
$ dcos marathon app add definition.json $ dcos marathon app list ID MEM CPUS TASKS HEALTH DEPLOYMENT CONTAINER CMD /demo 256.0 0.01 1/1 --- --- DOCKER python -m SimpleHTTPServer $PORT /spark 1024.0 1.0 1/1 1/1 --- DOCKER mv /mnt/mesos/sandbox/log4j.properties conf/log4j.properties && ./bin/spark-class org.apache.spark.deploy.mesos.MesosClusterDispatcher --port $PORT0 --webui-port $PORT1 --master mesos://zk://master.mesos:2181/mesos --zk master.mesos:2181 --host $HOST --name spark
$ dcos marathon app update --force demo instances=3 Created deployment 28171707-83c2-43f7-afa1-5b66336e36d7 $ dcos marathon deployment list APP ACTION PROGRESS ID /demo scale 0/1 28171707-83c2-43f7-afa1-5b66336e36d7