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
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.
In this recipe, we will be installing Mesos .deb
packages from the Mesosphere repositories using apt
.
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.
- First, download and install the OpenPGP key for the Mesosphere packages:
$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv E56151BF
- 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
- Update the
apt-get
package indexes:
$ sudo apt-get update
- Install Mesos and the included ZooKeeper binaries:
$ sudo apt-get -y install mesos
- 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
- 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.
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.
In this recipe, we will be installing Mesos .deb
packages from the Mesosphere repositories using apt
.
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.
- First, download and install the OpenPGP key for the Mesosphere packages:
$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv E56151BF
- 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
- Update the
apt-get
package indexes:
$ sudo apt-get update
- Install Mesos and the included ZooKeeper binaries:
$ sudo apt-get -y install mesos
- 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
- 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.
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.
In this recipe, we will be installing Mesos .rpm
packages from the Mesosphere repositories using yum
.
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.
- First, add the Mesosphere repository:
$ sudo rpm -Uvh http://repos.mesosphere.io/el/7/noarch/RPMS/mesosphere-el-repo-7-1.noarch.rpm
- And now, install Mesos and ZooKeeper:
$ sudo yum -y install mesos mesosphere-zookeeper
- 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
- 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.
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.
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.
In this recipe, we will prepare the Ubuntu 16.04 operating system for a Mesos source code installation.
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.
- First, we need to sync the latest package lists from the
apt
repositories with theupdate
command:
$ sudo apt-get update
- 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
- Next, continue to the Downloading, building, and installing the Mesos source code recipe at the end of this chapter.
In this recipe, we will prepare the Ubuntu 14.04 operating system for a Mesos source code installation.
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.
- First, we need to sync the latest package lists from the
apt
repositories with theupdate
command:
$ sudo apt-get update
- 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
- Next, continue to the Downloading, building, and installing the Mesos source code recipe at the end of this chapter.
In this recipe, we will prepare the OS X operating system for a Mesos source code installation.
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.
- 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
- Next, continue to the Downloading, building, and installing the Mesos source code recipe at the end of this chapter.
In this recipe, we will download the Mesos source files, build the code, and install the Mesos binaries and libraries.
Follow the previous sections in this chapter to prepare your operating system for a Mesos source installation.
- Browse to the following location: http://mesos.apache.org/downloads/.
- 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
- 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
- Change the directory to the extracted TAR file directory created in the previous step, for example:
$ cd mesos-1.0.1
- Create the
build
directory:
$ mkdir build
- Change directory to the
build
directory:
$ cd build
- 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
- 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
- Optional: Run some tests:
$ make check
- 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
- Optional: For Ubuntu only, create links to the Mesos libraries if you chose the default installation to
/usr/local
:
$ sudo ldconfig
- 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
- Change into the Mesos source
build
directory:
$ cd build
- Now start the Mesos master:
$ sudo ./bin/mesos-master.sh --ip=127.0.0.1 --work_dir=/var/lib/mesos
- 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
- 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.
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.
Refer to the following 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.
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.
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.