Lab 2.2 - Setup the Master

Important

The following commands need to be run on the master only unless otherwise specified.

Install Mesos, Marathon and Zookeeper

  1. Add the mesos/marathon repo

    Run the following commands:

    apt-key adv --keyserver keyserver.ubuntu.com --recv E56151BF
    
    cat <<EOF >> /etc/apt/sources.list.d/mesosphere.list
    deb http://repos.mesosphere.com/ubuntu $(lsb_release -cs) main
    EOF
    
  2. Install the mesos, marathon and zookeeper packages

    apt update && apt install mesos marathon zookeeperd -y
    

Setup Zookeeper

Note

2181 is zookeeper’s default port.

  1. Setup a unique ID per zookeeper instance. Update /etc/zookeeper/conf/myid to 1, 2 or 3 depending on the number of master nodes. In our case 1

    echo 1 > /etc/zookeeper/conf/myid
    
  2. Modify the zookeeper config file on each master

    sed -i /^#server.1/s/#server.1=zookeeper1/server.1=10.2.10.21/ /etc/zookeeper/conf/zoo.cfg
    

Setup Mesos

  1. Create mesos ip file /etc/mesos-master/ip

    echo "10.2.10.21" > /etc/mesos-master/ip
    
  2. Create mesos hostname file /etc/mesos-master/hostname (specify the IP address of your node)

    echo "10.2.10.21" > /etc/mesos-master/hostname
    
  3. Change the quorum value to reflect our cluster size. It should be set over 50% of the number of master instances. In this case it should be 1 because we have only one master

    echo 1 > /etc/mesos-master/quorum
    
  4. Point zookeeper to the master instance. This is done in the file /etc/mesos/zk

    echo "zk://10.2.10.21:2181/mesos" > /etc/mesos/zk
    

Setup Marathon

  1. First we need to specify the zookeeper masters that marathon will connect to (for information and things like scheduling). We can copy the previous file we setup for mesos:

    echo "MARATHON_MASTER=`cat /etc/mesos/zk`" > /etc/default/marathon
    
  2. We also need to have marathon store its own state in zookeper (since it runs on all three masters):

    echo "MARATHON_ZK=zk://10.2.10.21:2181/marathon" >> /etc/default/marathon
    

Start your services

  1. When you install mesos, the master and slave services are enabled (called mesos-master and mesos-slave). Here, we want our master to focus on this tasks so we need to disable the slave service. Do this on all the master nodes:

    systemctl stop mesos-slave
    echo manual > /etc/init/mesos-slave.override
    
  2. We need to restart zookeeper and start mesos-master and marathon process on all master nodes:

    systemctl restart zookeeper
    
    systemctl start mesos-master
    systemctl enable mesos-master
    
    systemctl start marathon
    
  3. We can validate that it works by connecting to mesos and marathon via a browser. Mesos runs on port 5050 (http) and marathon runs on port 8080 (http).

    Mesos:

    ../../_images/setup-master-check-UI-mesos-master.png

    Marathon:

    ../../_images/setup-master-check-UI-marathon.png
  4. If you want to check whether the service started as expected, you can use the following commands:

    systemctl status mesos-master
    
    systemctl status marathon
    

    You should see something like the following:

    Mesos:

    ../../_images/setup-master-check-service-mesos-master.png

    Marathon:

    ../../_images/setup-master-check-service-marathon.png
  5. For more information about the marathon service, check the about section in marathon by clicking the ? drop down in the upper right hand side of the marathon page.

    ../../_images/setup-master-about-marathon.png
  6. If multiple masters were configured for high availability you can do the following to test the HA of marathon:

    Attention

    For our lab we have only one master so this step is for documentation purposes.

    • Figure out which mesos is running the framework marathon (based on our screenshot above, it is available on master1)
    • Restart this master and you should see the framework was restarted automatically on another host. “mesos-master1” would change to “mesos-master2, 3, etc.”
    ../../_images/setup-master-test-HA-marathon.png