Mesos & Marathon 3 Node cluster Setup on Ubuntu 14 LTS

What is Mesos?

Mesos is built using the same principles as the Linux kernel, only at a different level of abstraction. The Mesos
kernel runs on every machine and provides applications (e.g., Hadoop, Spark, Kafka, Elasticsearch) with API’s for
resource management and scheduling across entire data center and cloud environments.

Apache Mesos is an open-source cluster manager that was developed at the University of California, Berkeley. It “provides efficient resource isolation and sharing across distributed applications, or frameworks”. The software enables resource sharing in a fine-grained manner, improving cluster utilization.

What is Marathon?

Marathon is promoted for platform as a service or container orchestration system scaling to thousands of physical servers. It is fully REST based and allows canary style deploys and deployment topologies. It is written in the programming language Scala.

Marathon is used for long running(hence the name ‘Marathon’) tasks. Mesos will ensure that applications it has launched will continue running, even if the slave node(s) they are running on fails.

Installation :

VM Requirements:

Operating system  : Ubuntu 14.04 LTS
CPU Cores                 : 2 (On each box)
Disk                             : 80 GB
RAM                             : 4 GB

Setup Details:

Box IP                                                      Role
192.168.10.236                                         Master, Slave
192.168.10.219                                         Slave
192.168.10.221                                          Slave

Note: Above mentioned IP address details are specific to test environment, Please do consider your box details during your own setup.


Pre-installation (common for all nodes) steps:

Below steps to be performed on all nodes, irrespective of master or slave.

  • Import mesosphere archive automatic signing key

    sudo apt-key adv –keyserver keyserver.ubuntu.com –recv E56151BF

  • Add the mesosphere Ubuntu 14.04 Repo

    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 package lists and information of latest version.

    sudo apt-get -y update

 


Master Node Setup: (Node 1,192.168.10.236):

Since it’s a test environment, out of 3 nodes I will be using one of the node (Node 1) for configuring both master & slave. In production environment dedicated machines will be used for master setups.

Binaries installation:

  • Install Mesos, Marathon & Zookeeper

    sudo apt-get -y install mesos marathon

Mesos & Marathon Configuration:

  • Add Mesos master node Ip to /etc/mesos-master/ip

    echo 192.168.10.236 | sudo tee /etc/mesos-master/ip

  • Add Mesos master node Hostname to /etc/mesos-master/hostname

    echo `hostname -f` | sudo tee /etc/mesos-master/hostname

    Make sure that your hostname can resolve IP address properly. Otherwise use IP address in this case also to avoid further errors.

  • Specify the master Zookeeper URL which the Mesos Master and Marathon will register with.

    echo zk://192.168.10.236:2181/mesos | sudo tee /etc/mesos/zk

  • Add a cluster name which will be displayed in Mesos web console.

    echo TestCluster | sudo tee /etc/mesos-master/cluster

Zookeeper Configuration:

  • Each Zookeeper needs to know its position in the quorum. In my case i have only one Zookeeper so the value for my Zookeeper will be 1.

    echo 1 | sudo tee /etc/zookeeper/conf/myid

    (Note: Incase of 3 node Master and Zookeeper setup above step should be repeated on all 3 nodes with different id like 1,2 & 3. And zookeeper URL will be changed to echo zk://node1:2181,node2:2181,node3:2181/mesos | sudo tee /etc/mesos/zk)

 

Slave configuration:

  • Add Mesos slave IP in /etc/mesos-slave/ip

    echo 192.168.10.236 | sudo tee /etc/mesos-slave/ip

  • Now we need the Slave to discover the Master. This is done by updating the /etc/mesos/zk to the master Zookeeper URL. The command below will cause the Slave to connect to the Zookeeper at 192.168.10.236, which is Master (Node 1) IP address.

    echo zk://192.168.10.236:2181/mesos | sudo tee /etc/mesos/zk

  • Add Mesos slave node Hostname to /etc/mesos-slave/hostname

    echo `hostname -f` | sudo tee /etc/mesos-slave/hostname

    Make sure that your hostname can resolve IP address properly. Otherwise use IP address in this case also to avoid further errors.

  • Add containerizers file in /etc/mesos-slave folder with docker,mesos (This step is very important to work with docker environment)

    echo “docker,mesos” | sudo tee /etc/mesos-slave/containerizers

Bring up Mesos master, Marathon, Mesos slave and Zookeeper services:

  • Once done with all above configuration restart all services on Node 1 (that is master). Because package installation will auto start Mesos, Marathon and Zookeeper services.

    sudo service zookeeper restart
    sudo service mesos-master restart
    sudo service marathon restart
    sudo service mesos-slave restart

  • For a better result reboot the box.

    sudo reboot


Slave Node Setup (Node 2, 192.168.10.219):

  • Assuming pre-installation steps are completed. If not please do complete pre-installation steps before you proceed with further steps.
  • Install Mesos and Zookeeper.

    sudo apt-get -y install mesos

  • Since package installation will auto start all services we have to stop Mesos-master and Zookeeper services on slave nodes. And set them to manual start up during the boot, otherwise these services will come up during the boot time.
    • Disable master service on slave node.

      sudo service mesos-master stop
      echo manual | sudo tee /etc/init/mesos-master.override

    • Disable Zookeeper service.

      sudo service zookeeper stop
      echo manual | sudo tee /etc/init/zookeeper.override
      sudo apt-get -y remove –purge zookeeper

  • Add Mesos slave IP in /etc/mesos-slave/ip

    echo 192.168.10.219 | sudo tee /etc/mesos-slave/ip

  • Now we need the Slave to discover the Master. This is done by updating the /etc/mesos/zk to the master Zookeeper URL. The command below will cause the Slave to connect to the Zookeeper at 192.168.10.236, which is Master (Node 1) IP address.

    echo zk://192.168.10.236:2181/mesos | sudo tee /etc/mesos/zk

  • Add Mesos slave node Hostname to /etc/mesos-slave/hostname

    echo `hostname -f` | sudo tee /etc/mesos-slave/hostname

    Make sure that your hostname can resolve IP address properly. Otherwise use IP address in this case also to avoid further errors.

  • Add containerizers file in /etc/mesos-slave folder with docker,mesos (This step is very important to work with docker environment)

    echo “docker,mesos” | sudo tee /etc/mesos-slave/containerizers

 

Bring up Mesos slave service & Reboot the box once for better result:

sudo service mesos-slave restart


 

Slave Node Setup (Node 3, 192.168.10.221):

  • Assuming pre-installation steps are completed. If not please do complete pre-installation steps before you proceed with further steps.
  • Install Mesos and Zookeeper.

    sudo apt-get -y install mesos

  • Since package installation will auto start all services we have to stop Mesos-master and Zookeeper services on slave nodes. And set them to manual start up during the boot, otherwise these services will come up during the boot time.
    • Disable master service on slave node.

      sudo service mesos-master stop
      echo manual | sudo tee /etc/init/mesos-master.override

    • Disable Zookeeper service.

      sudo service zookeeper stop
      echo manual | sudo tee /etc/init/zookeeper.override
      sudo apt-get -y remove –purge zookeeper

  •  Add Mesos slave IP in /etc/mesos-slave/ip

    echo 192.168.10.221 | sudo tee /etc/mesos-slave/ip

  • Now we need the Slave to discover the Master. This is done by updating the /etc/mesos/zk to the master Zookeeper URL. The command below will cause the Slave to connect to the Zookeeper at 192.168.10.236, which is Master (Node 1) IP address.

    echo zk://192.168.10.236:2181/mesos | sudo tee /etc/mesos/zk

  • Add Mesos slave node Hostname to /etc/mesos-slave/hostname

    echo `hostname -f` | sudo tee /etc/mesos-slave/hostname

    Make sure that your hostname can resolve IP address properly. Otherwise use IP address in this case also to avoid further errors.

  •  Add containerizers file in /etc/mesos-slave folder with docker,mesos (This step is very important to work with docker environment)

    echo “docker,mesos” | sudo tee /etc/mesos-slave/containerizers

 

Bring up Mesos slave service & Reboot the box once for better result:

sudo service mesos-slave restart
Once done with Environment setup, access below mentioned URL’s to check Mesosphere and Marathon.

 

http://192.168.10.236:5050/#/  <—– Mesos URL to check agents, tasks and other                                                                                            resources related info. (each slave in the                                                                                                   environment will act as anagent)

http://192.168.10.236:8080/ui/#/apps <—&#8212; Marathon URL to check applications with                                                                                                 their state.

Advertisements

One thought on “Mesos & Marathon 3 Node cluster Setup on Ubuntu 14 LTS

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s