Book Image

Apache Mesos Essentials

By : Dharmesh Kakadia
Book Image

Apache Mesos Essentials

By: Dharmesh Kakadia

Overview of this book

<p>Apache Mesos is a cluster manager that provides efficient resource isolation and sharing across distributed applications, or frameworks. It allows developers to concurrently run the likes of Hadoop, Spark, Storm, and other applications on a dynamically shared pool of nodes. With Mesos, you have the power to manage a wide range of resources in a multi-tenant environment.</p> <p>Starting with the basics, this book will give you an insight into all the features that Mesos has to offer. You will first learn how to set up Mesos in various environments from data centers to the cloud. You will then learn how to implement self-managed Platform as a Service environment with Mesos using various service schedulers, such as Chronos, Aurora, and Marathon. You will then delve into the depths of Mesos fundamentals and learn how to build distributed applications using Mesos primitives.</p> <p>Finally, you will round things off by covering the operational aspects of Mesos including logging, monitoring, high availability, and recovery.</p>
Table of Contents (15 chapters)
Apache Mesos Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Mesos cluster on Amazon EC2


The Amazon Elastic Compute Cloud (EC2) provides access to compute the capacity in a pay-as-you-go model through virtual machines and is an excellent way of trying out Mesos. Mesos provides scripts to create Mesos clusters of various configurations on EC2. The mesos-ec2 script located in the ec2 directory allows launching, running jobs, and tearing down the Mesos clusters. Note that we can use this script even without building Mesos, but you will need Python (>=2.6). We can manage multiple clusters using different names.

We will need an AWS keypair to use the ec2 script, and our access and secret key. We have to make our keys available via an environment variable. Create and download a keypair via the AWS Management Console (https://console.aws.amazon.com/console/home) and give them 600 permissions:

ubuntu@local:~ $ chmod 600 my-aws-key.pem
ubuntu@local:~ $ export AWS_ACCESS_KEY_ID=<your-access-key>
ubuntu@local:~ $ export AWS_SECRET_ACCESS_KEY=<your-secret-key>

Now we can use the EC2 scripts provided with Mesos to launch a new cluster using the following command:

ubuntu@local:~/mesos/ec2 $ ./mesos-ec2 -k <your-key-pair> -i <your-identity-file> -s 3 launch ec2-test

This will launch a cluster named ec2-test with three slaves. Once the scripts are done, it will also print the Mesos web UI link, in the form of <master-hostname>:8080. We can confirm that the cluster is up by going to the web interface. The script provides a number of options, a few of which are listed in the following table. We can list all the available options of the script by running mesos-ec2 --help:

Command

Use

--slave or –s

This is the number of slaves in the cluster

--key-pair or -k

This is the SSH keypair for authentication

--identity-file or –i

This is the SSH identity file used for logging into the instances

--instance-type or –t

This is a slave instance type, must be 64-bit

--ebs-vol-size

This is the size of an EBS volume used to store the persistent HDFS data.

--master-instance-type or –m

This is a master instance type, must be 64-bit

--zone or -z

This is the Amazon availability zone for launching instances

--resume

This flag resumes the installation from the previous run

We can use the login action to log in to the launched cluster by providing a cluster name, as follows:

ubuntu@local:~/mesos/ec2 $ ./mesos-ec2 -k <your-key-pair> -i <your-identity-file> login ec2-test

The script also sets up a HDFS instance that can be used via commands in the /root/ephemeral-hdfs/ directory.

Finally, we can terminate a cluster using the following command. Be sure to copy any important data before terminating the cluster:

ubuntu@local:~/mesos/ec2 $ ./mesos-ec2 destroy ec2-test

The script also supports advance functionalities, such as pausing and restarting clusters with EBS-backed instances. The Mesos documentation is a great source of information for any clarification. It is worth mentioning that Mesosphere (http://mesosphere.com) also provides you with an easy way of creating an elastic Mesos cluster on Amazon EC2, Google Cloud, and other platforms and provides commercial support for Mesos.