Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Apache Mesos Cookbook
Apache Mesos Cookbook

Apache Mesos Cookbook: Efficiently handle and manage tasks in a distributed environment

By David Blomquist , Tomasz Janiszewski
$15.99 per month
Book Aug 2017 146 pages 1st Edition
eBook
$29.99 $20.98
Print
$38.99
Subscription
$15.99 Monthly
eBook
$29.99 $20.98
Print
$38.99
Subscription
$15.99 Monthly

What do you get with a Packt Subscription?

Free for first 7 days. $15.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details


Publication date : Aug 2, 2017
Length 146 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781785884627
Vendor :
Apache
Category :
Table of content icon View table of contents Preview book icon Preview Book

Apache Mesos Cookbook

Chapter 1. Getting Started with Apache Mesos

In this chapter, we present an overview of the Mesos architecture and recipes for installing Mesos on Linux and Mac. The following are the recipes covered in this chapter:

  • Installing Mesos on Ubuntu 16.04 from packages
  • Installing Mesos on Ubuntu 14.04 from packages
  • Installing Mesos on CentOS 7 and RHEL 7 from packages
  • Preparing Ubuntu 16.04 for a Mesos installation from source code
  • Preparing Ubuntu 14.04 for a Mesos installation from source code
  • Preparing OS X (Yosemite and El Capitan) for a Mesos installation from source code
  • Downloading, building, and installing the Mesos source code

Introduction


Apache Mesos is cluster management software that distributes the combined resources of many individual servers to applications through frameworks. Mesos is open source software that is free to download and use in accordance with the Apache License 2.0. This chapter will provide the reader with recipes for installing and configuring Apache Mesos.

Mesos can run on Linux, Mac, and Windows. However, we recommend running Mesos on Linux for production deployments and on Mac and Windows for development purposes only. Mesos can be installed from source code or from binary packages downloaded from repositories. We will cover a few installation methods on select operating systems in this chapter. The reasons for covering these specific operating systems and installation methods are as follows:

  • The operating systems natively include a kernel that supports full resource isolation
  • The operating systems are current as of this writing with long-term support
  • The operating systems and installation methods do not require workarounds or an excessive number of external repositories
  • The installation methods use the latest stable version of Mesos, whether it is from binary packages or source code

Based on these criteria, we have covered the following installation methods for this book:

  • Mesosphere packages on Ubuntu 16.04 LTS
  • Mesosphere packages on Ubuntu 14.04 LTS
  • Mesosphere packages on CentOS 7 and RHEL 7
  • Source code on Ubuntu 16.04 LTS
  • Source code on Ubuntu 14.04 LTS
  • Source code on OS X (Yosemite and El Capitan)

Mesosphere, a company founded by one of the original developers of Mesos, provides free, open source binary packages as well as commercial support for Mesos. Mesosphere binary packages are well maintained and provide an easy way to install and run Mesos. We use Mesosphere packages installed on Ubuntu 14.04 as the base environment for the recipes in chapters 3 - 8 and we recommend you use that installation method with this book. If you need to run Mesos one of the other supported operating systems, we provide you with the installation instructions in this chapter but you will need to adapt the recipes in chapters 3 - 8 for use with your operating system. Installing Mesos from source will allow you to customize the build and install process and enable and disable features so we will also guide you through a source install in this chapter. If you want a development environment on a Mac, building from source on OS X is the only way to go.

We will guide you through the installations in the following sections but first, you will need to plan your Mesos deployment. For a Mesos development environment, you only need one host or node. The node can be a physical computer, a virtual machine, or a cloud instance. For a production cluster, we recommend at least three master nodes and as many slave nodes as you will need to support your application frameworks. You can think of the slave nodes as a pool of CPU, RAM, and storage that can be increased by simply adding more slave nodes. Mesos makes it very easy to add slave nodes to an existing cluster as your application requirements grow. At this point, you should determine whether you will be building a Mesos development environment or a production cluster and you should have an idea of how many master and slave nodes you will need. The next sections will provide recipes for installing Mesos in the environment of your choice.

Installing Mesos on Ubuntu 16.04 from packages


In this recipe, we will be installing Mesos .deb packages from the Mesosphere repositories using apt.

Getting ready

You must be running a 64-bit version of the Ubuntu 16.04 operating system and it should be patched to the most current patch level using apt-get prior to installing the Mesos packages.

How to do it...

  1. First, download and install the OpenPGP key for the Mesosphere packages:
$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv E56151BF
  1. Now install the Mesosphere repository:
$ DISTRO=$(lsb_release -is | tr '[:upper:]' '[:lower:]')$ CODENAME=$(lsb_release -cs)$ echo "deb http://repos.mesosphere.io/${DISTRO} ${CODENAME} main"| 
sudo tee /etc/apt/sources.list.d/mesosphere.list
  1. Update the apt-get package indexes:
$ sudo apt-get update
  1. Install Mesos and the included ZooKeeper binaries:
$ sudo apt-get -y install mesos
  1. At this point, you can start Mesos to do some basic testing. To start the Mesos master and agent (slave) daemons, execute the following:
$ sudo service mesos-master start$ sudo service mesos-slave start
  1. To validate the Mesos installation, open a browser and point it to http://<ipaddress>:5050. Replace <ipaddress> with the actual address of the host with the new Mesos installation.

How it works...

The Mesosphere packages provide the software required to run Mesos. Next, you will configure ZooKeeper, which is covered in Chapter 2, Implementing High Availability with Apache ZooKeeper.

See also

If you prefer to build and install Mesos on Ubuntu from source code, we will cover that in an upcoming section in this chapter.

Installing Mesos on Ubuntu 14.04 from packages


In this recipe, we will be installing Mesos .deb packages from the Mesosphere repositories using apt.

Getting ready

You must be running a 64-bit version of the Ubuntu 14.04 operating system and it should be patched to the most current patch level using apt-get prior to installing the Mesos packages.

How to do it...

  1. First, download and install the OpenPGP key for the Mesosphere packages:
$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv E56151BF
  1. Now install the Mesosphere repository:
$ DISTRO=$(lsb_release -is | tr '[:upper:]' '[:lower:]')$ CODENAME=$(lsb_release -cs)$ echo "deb http://repos.mesosphere.io/${DISTRO} ${CODENAME} main"|
sudo tee /etc/apt/sources.list.d/mesosphere.list
  1. Update the apt-get package indexes:
$ sudo apt-get update
  1. Install Mesos and the included ZooKeeper binaries:
$ sudo apt-get -y install mesos
  1. At this point, you can start Mesos to do some basic testing. To start the Mesos master and agent (slave) daemons, execute the following command:
$ sudo service mesos-master start$ sudo service mesos-slave start
  1. To validate the Mesos installation, open a browser and point it to http://<ipaddress>:5050. Replace <ipaddress> with the actual address of the host with the new Mesos installation.

How it works...

The Mesosphere packages provide the software required to run Mesos. Next, you will configure ZooKeeper, which is covered in Chapter 2, Implementing High Availability with Apache ZooKeeper.

See also

If you prefer to build and install Mesos on Ubuntu from source code, we will cover that in an upcoming section in this chapter.

Installing Mesos on CentOS 7 and RHEL 7 from packages


In this recipe, we will be installing Mesos .rpm packages from the Mesosphere repositories using yum.

Getting ready

Your CentOS 7 or RHEL 7 operating system should be patched to the most current patch level using yum prior to installing the Mesosphere packages.

How to do it...

  1. First, add the Mesosphere repository:
$ sudo rpm -Uvh http://repos.mesosphere.io/el/7/noarch/RPMS/mesosphere-el-repo-7-1.noarch.rpm  
  1. And now, install Mesos and ZooKeeper:
$ sudo yum -y install mesos mesosphere-zookeeper
  1. At this point, you can start Mesos to do some basic testing. To start the Mesos master and agent (slave) daemons, execute the following:
$ sudo service mesos-master start$ sudo service mesos-slave start
  1. To validate the Mesos installation, open a browser and point it to http://<ipaddress>:5050. Replace <ipaddress> with the actual address of the host with the new Mesos installation.

How it works...

The Mesosphere packages provide the software required to run Mesos. Next, you will configure ZooKeeper, which is covered in Chapter 2, Implementing High Availability with Apache ZooKeeper.

See also

If you prefer to build and install Mesos from source code on RHEL 7 or CentOS 7, you can find installation instructions for CentOS 7 on the mesos.apache.org website. We do not cover installing Mesos source code on RHEL7 or CentOS 7 in this book due to dependencies that require packages from multiple third-party repositories.

Preparing Ubuntu 16.04 for a Mesos installation from source code


In this recipe, we will prepare the Ubuntu 16.04 operating system for a Mesos source code installation.

Getting ready

You must be running a 64-bit version of the Ubuntu 16.04 operating system and it should be patched to the most current patch level using apt-get prior to building the Mesos source code.

How to do it...

  1. First, we need to sync the latest package lists from the apt repositories with the update command:
$ sudo apt-get update
  1. Then we will install the prerequisite packages for building and running the Mesos source code:
$ sudo apt-get install -y tar wget git openjdk-8-
jdk autoconf libtool
build-essential python-dev python-boto libcurl4-
nss-dev libsasl2-dev
libsasl2-modules maven libapr1-dev libsvn-dev 
libghc-zlib-dev
  1. Next, continue to the Downloading, building, and installing the Mesos source code recipe at the end of this chapter.

How it works...

Preparing the operating system will enable us to build and install the Mesos source code. Next, you will need to download the Mesos source files and build the code.

Preparing Ubuntu 14.04 for a Mesos installation from source code


In this recipe, we will prepare the Ubuntu 14.04 operating system for a Mesos source code installation.

Getting ready

You must be running a 64-bit version of the Ubuntu 14.04 operating system and it should be patched to the most current patch level using apt-get prior to building the Mesos source code.

How to do it...

  1. First, we need to sync the latest package lists from the apt repositories with the update command:
$ sudo apt-get update
  1. Then, we install the prerequisite packages for building and running the Mesos source code:
$ sudo apt-get install -y tar wget git openjdk-7-
jdk autoconf libtool
build-essential python-dev python-boto libcurl4-
nss-dev libsasl2-dev
libsasl2-modules maven libapr1-dev libsvn-dev
  1. Next, continue to the Downloading, building, and installing the Mesos source code recipe at the end of this chapter.

How it works...

Preparing the operating system will enable us to build and install the Mesos source code. Next, you will need to download the Mesos source files and build the code.

Preparing OS X (Yosemite and El Capitan) for a Mesos Installation from source code


In this recipe, we will prepare the OS X operating system for a Mesos source code installation.

Getting ready

Building the current version of Mesos (which is 1.0.1 at the time of this writing) requires GCC 4.8.1+ or Clang 3.5+. You should be running a 64-bit version of OS X and it should be patched to the most current patch level prior to building the Mesos source code.

How to do it...

  1. Install command-line tools, Homebrew, Java, and libraries required for Mesos:
$ xcode-select --install
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ brew install Caskroom/cask/java
$ brew install wget git autoconf automake libtool subversion maven
  1. Next, continue to the Downloading, building, and installing the Mesos source code recipe at the end of this chapter.

How it works...

Preparing the operating system will enable us to build and install the Mesos source code. Next, you will need to download the Mesos source files and build the code.

Downloading, building, and installing the Mesos source code


In this recipe, we will download the Mesos source files, build the code, and install the Mesos binaries and libraries.

Getting ready

Follow the previous sections in this chapter to prepare your operating system for a Mesos source installation.

How to do it...

  1. Browse to the following location: http://mesos.apache.org/downloads/.
  2. Download the TAR file for the most recent stable release of Mesos. For example, to download Mesos version 1.0.1:
$ wget http://www.apache.org/dist/mesos/1.0.1/mesos-1.0.1.tar.gz
  1. Extract the contents of the TAR file. For example, to extract the Mesos 1.0.1 TAR file:
$ tar xvzf mesos-1.0.1.tar.gz
  1. Change the directory to the extracted TAR file directory created in the previous step, for example:
$ cd mesos-1.0.1
  1. Create the build directory:
$ mkdir build
  1. Change directory to the build directory:
$ cd build
  1. Configure the Mesos build script. You can run ../configure --help to see all the available configuration options. Refer to the There's more... section at the end of this recipe for more configuration tips:
$ ../configure
  1. Build the Mesos binaries (executing 'make -j <number of cores> V=0 will decrease both the build time and log verbosity on multicore systems). Refer to the There's more... section at the end of this recipe for more build tips:
$ make
  1. Optional: Run some tests:
$ make check
  1. Optional: Execute the make install command if you would like to install the Mesos binaries and libraries in /usr/local/ and add them to the system path. Mesos can also be installed in other locations or run directly from the build directory. Refer to the There's more... section at the end of this recipe for instructions on installing Mesos to alternative locations, as well as for other installation tips:
$ sudo make install
  1. Optional: For Ubuntu only, create links to the Mesos libraries if you chose the default installation to /usr/local:
$ sudo ldconfig
  1. At this point, you can start Mesos to do some basic testing. To start the Mesos master and agent daemons, first create the mesos working directory:
$ sudo mkdir /var/lib/mesos
  1. Change into the Mesos source build directory:
$ cd build
  1. Now start the Mesos master:
$ sudo ./bin/mesos-master.sh --ip=127.0.0.1 --work_dir=/var/lib/mesos
  1. And start the Mesos agent (in a separate terminal session):
$ sudo ./bin/mesos-agent.sh --master=127.0.0.1:5050 --work_dir=/var/lib/mesos
  1. To validate the Mesos installation, open a browser on the Mesos host and point it to http://127.0.0.1:5050. If you wish to validate with a browser remotely, you will need to replace 127.0.0.1 with the real IP of the Mesos host in the previous commands and restart both the master and agent. You will also need to use the real IP of the Mesos host in the browser.

Note

Warning When using the real IP in the command line, the Mesos master and agent processes will fail to start unless the Mesos host is registered in DNS.

How it works...

Building the Mesos source code will create the binaries needed to run Mesos. Next, you will configure ZooKeeper, which is covered in Chapter 2, Implementing High Availability with Apache ZooKeeper.

There's more...

Refer to the following tips.

Configuration tips

There are a number of options that can be configured in the Mesos build script. For example, if you want to build Mesos with SSL support, you will need to enable the ssl and libevent features by executing ../configure --enable-ssl --enable-libevent prior to executing make. To see a full list of the configure options, execute ../configure --help from the Mesos build directory.

Build tips

If you are building out a Mesos cluster using hosts with the same operating system version, you can configure and build the source code on one server and then copy that source directory to the other servers. You can then skip the ../configure and make commands and just run Mesos from the build directory or execute make install to install it without having to go through the build (make) process on every server.

If you do plan on copying pre-built Mesos software to other servers, make sure all of the servers have the supporting packages required to run Mesos and that the OS is patched to the same version.

Installation tips

The default behavior of make install is to install the Mesos binaries and libraries in the /usr/local path. If you would like to change the installation path, execute ../configure --prefix=/path/to/install/directory during the configure stage prior to the build (make) and install (make install) stages.

If at some point you would like to uninstall the Mesos binaries from the installation path, you can execute make uninstall from the source code build directory. After building and installing the Mesos source code, we recommend archiving the source code directory for future reference.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Learn to install and configure Mesos to suit the needs of your organization
  • Follow step-by-step instructions to deploy application frameworks on top of Mesos, saving you many hours of research and trial and error
  • Use this practical guide packed with powerful recipes to implement Mesos and easily integrate it with other application frameworks

Description

Apache Mesos is open source cluster sharing and management software. Deploying and managing scalable applications in large-scale clustered environments can be difficult, but Apache Mesos makes it easier with efficient resource isolation and sharing across application frameworks. The goal of this book is to guide you through the practical implementation of the Mesos core along with a number of Mesos supported frameworks. You will begin by installing Mesos and then learn how to configure clusters and maintain them. You will also see how to deploy a cluster in a production environment with high availability using Zookeeper. Next, you will get to grips with using Mesos, Marathon, and Docker to build and deploy a PaaS. You will see how to schedule jobs with Chronos. We’ll demonstrate how to integrate Mesos with big data frameworks such as Spark, Hadoop, and Storm. Practical solutions backed with clear examples will also show you how to deploy elastic big data jobs. You will find out how to deploy a scalable continuous integration and delivery system on Mesos with Jenkins. Finally, you will configure and deploy a highly scalable distributed search engine with ElasticSearch. Throughout the course of this book, you will get to know tips and tricks along with best practices to follow when working with Mesos.

What you will learn

[*] Set up Mesos on different operating systems [*] Use the Marathon and Chronos frameworks to manage multiple applications [*] Work with Mesos and Docker [*] Integrate Mesos with Spark and other big data frameworks [*] Use networking features in Mesos for effective communication between containers [*] Configure Mesos for high availability using Zookeeper [*] Secure your Mesos clusters with SASL and Authorization ACLs [*] Solve everyday problems and discover the best practices

What do you get with a Packt Subscription?

Free for first 7 days. $15.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details


Publication date : Aug 2, 2017
Length 146 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781785884627
Vendor :
Apache
Category :

Table of Contents

15 Chapters
Title Page Chevron down icon Chevron up icon
Credits Chevron down icon Chevron up icon
About the Authors Chevron down icon Chevron up icon
About the Reviewer Chevron down icon Chevron up icon
www.PacktPub.com Chevron down icon Chevron up icon
Customer Feedback Chevron down icon Chevron up icon
Preface Chevron down icon Chevron up icon
1. Getting Started with Apache Mesos Chevron down icon Chevron up icon
2. Implementing High Availability with Apache ZooKeeper Chevron down icon Chevron up icon
3. Running and Maintaining Mesos Chevron down icon Chevron up icon
4. Understanding the Scheduler API Chevron down icon Chevron up icon
5. Managing Containers Chevron down icon Chevron up icon
6. Deploying PaaS with Marathon Chevron down icon Chevron up icon
7. Job Scheduling with Metronome Chevron down icon Chevron up icon
8. Continuous Integration with Jenkins Chevron down icon Chevron up icon

Customer reviews

Filter icon Filter
Top Reviews
Rating distribution
Empty star icon Empty star icon Empty star icon Empty star icon Empty star icon 0
(0 Ratings)
5 star 0%
4 star 0%
3 star 0%
2 star 0%
1 star 0%

Filter reviews by


No reviews found
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.