Monday, November 23, 2015

Installing Mesos and marathon on Red Hat 7

Today I gonna write my first post on this blog with a brief annotation about installing mesos and marathon on Red Hat 7. I will explain, in a following article, what is mesos, marathon and all this bunch of new technologies everybody is talking about and, surely, we all have heard about.


We will install a mesos cluster under Red Hat 7 nodes with the following architecture:





Mesos Master: The master is a process which runs on a node in the cluster and orchestrates the running of tasks on slaves by receiving resource offers from slaves and offering those resources to registered frameworks, such as Mesosphere Marathon. This service is crucial for mesosphere to work, so it's very important keep this service under an high availability configuration (mesos recommends a minimum of three master nodes).

Mesos Slave: The slave is a process which runs on a node in the cluster and offers up resources available on that node to the Mesos Master. The slave also takes schedule requests from the master and invokes an executor to launch a task. The number of nodes can be increased or decreased "on the fly".

Mesos zookeeper: Is a centralized fault-tolerant cluster manager. Only one master must be active. The election of the leader is done by Apache ZooKeeper , as well as is used by the slaves to join the cluster.  This service will be installed in the master service nodes

This will be a simple default installation. Advanced configuration will be talked about in following articles.



Master: Installation And Configuration


On every master node :
Add the repository
# sudo rpm -Uvh http://repos.mesosphere.com/el/7/noarch/RPMS/mesosphere-el-repo-7-1.noarch.rpm
Install the packages mesos and marathon with yum
# sudo yum -y install mesos marathon
In redhat  7,  apache zookeeper is not installed along the mesos package, so now we must install it.
# sudo yum -y install mesosphere-zookeeper
Now we must configure zookeeper by giving an id to every master node inside the file /var/lib/zookeeper/myid. This number must be unique and be between 1 and 255 on every node.

Append the following values to /etc/zookeeper/conf/zoo.cfg on each node, replacing the tags with your own master's IP addresses:

server.1=[master1 IP]:2888:3888
server.2=[master2 IP]:2888:3888
server.3=[master3 IP]:2888:3888
It's time to start zookeeper's service. Let's do it:
# sudo systemctl enable zookeeper
# sudo systemctl start zookeeper
# sudo journalctl -u zookeeper | tail -10

[...]
14:22:52,384 [myid:] - INFO  [main:NIOServerCnxnFactory@94] - binding to port 0.0.0.0/0.0.0.0:2181
Now zookeeper is working, it's time for mesos and marathon. In every master node we must configure the file /etc/mesos/zk with the following line, replacing tags for your master node IP
zk://[master1 IP]:2181,[master2 IP]:2181,[master3 IP]:2181/mesos
In /etc/mesos-master/quorum we must set a number greater than the number of masters divide by . In our example of three masters, 2 is a proper number.

If we have problems resolving you host's names from mesos (for example public or private IP), we can set a fixed name resolution in the file /etc/mesos-master/hostname. This will ensure all links from the Mesos console work correctly. Also we can do the same for marathon's links with the file /etc/marathon/conf/hostname. 

To ensure only master service is up on this nodes, we must disable mesos-slave service.
# sudo systemctl disable mesos-slave
Finally we can start the mesos-master and marathon service
# sudo systemctl enable mesos-master
# sudo systemctl start mesos-master
# sudo systemctl enable marathon
# sudo systemctl start marathon
If you are having troubles with the master's election, try to restart all mesos-master at roughly the same time


Slaves: Installation And Configuration

We will do this with three nodes, but this number can be increased or decreased easily on the fly due to our requirements:

Add the repository
# sudo rpm -Uvh http://repos.mesosphere.com/el/7/noarch/RPMS/mesosphere-el-repo-7-1.noarch.rpm
Install the packages mesos and marathon with yum
# sudo yum -y install mesos
On every node configure the masters node name by editing the file /etc/mesos/zk with this content, and replacing the tags for the master's nodes IP.
 zk://[master1 IP]:2181,[master2 IP]:2181,[master3 IP]:2181/mesos
Ensure no master service is running and only the slave ones.
# sudo systemctl disable mesos-master
# sudo systemctl enable mesos-slave
# sudo systemctl start mesos-slave 


Testing The Cluster


We can test now if the mesos cluster is working as we expected by browsing the following URLs


Mesos console: http://<master-ip>:5050


Marathon console: http://<master-ip>:8080

Or sending a task to the cluster to be executed
# MASTER=$(mesos-resolve `cat /etc/mesos/zk`)
# mesos-execute --master=$MASTER --name="cluster-test" --command="sleep 5
"

UPDATE
I noticed a lot of problems with some tasks using uris in zip format. Finally I fixed it by installing the unzip package, so don't forget to install it as well.


 Bibliography:
https://open.mesosphere.com/getting-started/install/


5 comments:

  1. Simple and neat explanation, Thanks a lot

    ReplyDelete
  2. Thank you so much. Its really helped me a lot.

    ReplyDelete
  3. I am keep getting "failed to connect mesos xx.xx.xx.xx:5050

    ReplyDelete