Mesos runs on Linux and Mac OS X. A single machine Mesos setup is the simplest way of trying out Mesos, so we'll go through it first. Currently, Mesos does not provide binary packages for different operating systems, and we need to compile it from the source. There are binary packages available by community.
Homebrew is a Linux-style package manager for Mac. Homebrew provides a formula for Mesos and compiles it locally. We need to perform the following steps to install Mesos on Mac:
Install Homebrew from http://brew.sh/.
Homebrew requires Java to be installed. Mac has Java installation by default, so we just have to make sure that
JAVA_HOME
is set correctly.Install Mesos using Homebrew with the following command:
mac@master:~ $ brew install mesos
Starting from Fedora 21, the Fedora repository contains the Mesos packages. There are mesos-master
and mesos-slave
packages to be installed on the master and slave respectively. Also, there is a mesos
package, which contains both the master and slave packages. To install the mesos
package on Fedora version >= 21, use the following command:
fedora@master:~ $ sudo yum install –y mesos
Now we can continue with the Start Mesos
section to run Mesos. For Fedora Version <= 21, we have to install the dependencies and Mesos from the source, similar to CentOS as explained in the following section.
Mesos requires the following prerequisites to be installed:
g++ (>=4.1)
Python 2.6 developer packages
Java Development Kit (>=1.6) and Maven
The cURL library
The SVN development library
Apache Portable Runtime Library (APRL)
Simple Authentication and Security Layer (SASL) library
Additionally, we will need autoconf (Version 1.12) and libtool if we want to build Mesos from the git repository. The installation of this software differs for various operating systems. We will show you the steps to install Mesos on Ubuntu 14.10 and CentOS 6.5. The steps for other operating systems are also fairly similar.
Use the following commands to install all the required dependencies on CentOS:
Currently, the CentOS default repository does not provide a SVN library >= 1.8. So, we need to add a repository, which provides it. Create a new
wandisco-svn.repo
file in/etc/yum.repos.d/
and add the following lines:centos@master:~ $ sudo vim /etc/yum.repos.d/wandisco-svn.repo [WandiscoSVN] name=Wandisco SVN Repo baseurl=http://opensource.wandisco.com/centos/6/svn-1.8/RPMS/$basearch/ enabled=1 gpgcheck=0
Now, we can install
libsvn
using the following command:centos@master:~ $ sudo yum groupinstall -y "Development Tools"
We need to install Maven by downloading it, extracting it, and putting it in
PATH
. The following commands extract it to/opt
after we download it and linkmvn
to/usr/bin
:centos@master:~ $ wget http://mirror.nexcess.net/apache/maven/maven-3/3.0.5/binaries/apache-maven-3.0.5-bin.tar.gz centos@master:~ $ sudo tar -zxf apache-maven-3.0.5-bin.tar.gz -C /opt/ centos@master:~ $ sudo ln -s /opt/apache-maven-3.0.5/bin/mvn /usr/bin/mvn
Install the other dependencies using the following command:
centos@master:~ $ sudo yum install -y python-devel java-1.7.0-openjdk-devel zlib-devel libcurl-devel openssl-devel cyrus-sasl-devel cyrus-sasl-md5 apr-devel subversion-devel
Once we have installed all the required software, we can follow these steps to build Mesos:
Download the latest stable release from http://mesos.apache.org/downloads/. At the time of writing, the latest release is 0.21.0. Save the
mesos-0.21.0.tar.gz
file in some location. Open the terminal and go to the directory, where we have saved the file or you can directly run the following command on the terminal to download Mesos:ubuntu@master:~$ wget http://www.apache.org/dist/mesos/0.21.0/mesos-0.21.0.tar.gz
Extract Mesos with the following command and enter the extracted directory. Note that the second command will remove the downloaded
.tar
file, and rename the version name from the extracted folder:ubuntu@master:~ $ tar –xzf mesos-*.tar.gz ubuntu@master:~ $ rm mesos-*.tar.gz ; mv mesos-* mesos ubuntu@master:~ $ cd mesos
Create a
build
directory. This will contain the compiled Mesos binaries. This step is optional, but it is recommended. The build can be distributed to slaves instead of recompiling on every slave:ubuntu@master:~/mesos $ mkdir build ubuntu@master:~/mesos $ cd build
Configure the installation by running the
configure
script:ubuntu@master:~/mesos/build $ ../configure
The
configure
script supports tuning the build environment, which can be listed by runningconfigure --help
. If there are any dependencies missing, then the configure script will report, and we can go back and install the missing packages. Once the configuration is successful, we can continue with the next step.Compile it using
make
. This might take a while. The second step ismake check
:ubuntu@master:~/mesos/build $ make ubuntu@master:~/mesos/build $ make check
The
make check
step builds the example framework, and we can now run Mesos from the build folder directly without installing it.Install Mesos using the following command:
ubuntu@master:~/mesos/build $ make install
The list of commands that Mesos provides is as follows:
We can now start the local Mesos cluster using the mesos-local
command, which will start both the master and slave in a single process and provide a quick way to check the Mesos installation.
Now we are ready to start the Mesos process. First, we need to create a directory for the Mesos replicated logs with read-write permissions:
ubuntu@master:~ $ sudo mkdir –p /var/lib/mesos ubuntu@master:~ $ sudo chown `whoami` /var/lib/mesos
Now, we can start the master with the following command, specifying the directory we created:
ubuntu@master:~ $ mesos-master --work_dir=/var/lib/mesos I1228 07:29:16.367847 2900 main.cpp:167] Build: 2014-12-26 06:31:26 by ubuntu I1228 07:29:16.368180 2900 main.cpp:169] Version: 0.21.0 I1228 07:29:16.387505 2900 leveldb.cpp:176] Opened db in 19.050311ms I1228 07:29:16.390425 2900 leveldb.cpp:183] Compacted db in 2.731972ms ... I1228 07:29:16.474812 2900 main.cpp:292] Starting Mesos master ... I1228 07:29:16.488203 2904 master.cpp:318] Master 20141228-072916-251789322-5050-2900 (ubuntu-master) started on master:5050 ... I1228 07:29:16.510967 2903 master.cpp:1263] The newly elected leader is master@master:5050 with id 20141228-072916-2 51789322-5050-2900 I1228 07:29:16.511157 2903 master.cpp:1276] Elected as the leading master! ...
The output here lists the build version, various configurations that the master has used, and the master ID of the cluster. The slave process should be able to connect to the master. The slave process can specify the IP address or the hostname of the master by the --master
option. In the rest of the book, we will assume that the machine on which the master is running has the hostname master
and should be replaced with an appropriate hostname or IP address.
ubuntu@master:~ $ mesos-slave --master=master:5050 I1228 07:33:32.415714 4654 main.cpp:142] Build: 2014-12-26 06:31:26 by vagrant I1228 07:33:32.415992 4654 main.cpp:144] Version: 0.21.0 I1228 07:33:32.416199 4654 containerizer.cpp:100] Using isolation: posix/cpu,posix/mem I1228 07:33:32.443282 4654 main.cpp:165] Starting Mesos slave I1228 07:33:32.447244 4654 slave.cpp:169] Slave started on 1)@master:5051 I1228 07:33:32.448254 4654 slave.cpp:289] Slave resources: cpus(*):2; mem(*):1961; disk(*):35164; ports(*):[31000-32000 ] I1228 07:33:32.448619 4654 slave.cpp:318] Slave hostname: master I1228 07:33:32.462025 4655 slave.cpp:602] New master detected at master@master5050 ...
The output confirms the connection to the master and lists the slave resources. Now, the cluster is running with one slave ready to run the frameworks.