Configuring resource offers on Mesos

 

by Frank Scholten

Apache Mesos

The other day I was working on Mesos Elasticsearch and encountered a problem while running the framework. The framework did not accept any offers from slaves because I had not properly configured the resources. Right now the Elasticsearch framework requires ports 9200 and 9300 but by default the slaves offer a port range 31000 to 32000. The default slave resources offers are defined in src/slave/constants.cpp. See the snippet below.


const double DEFAULT_CPUS = 1;
const Bytes DEFAULT_MEM = Gigabytes(1);
const Bytes DEFAULT_DISK = Gigabytes(10);
const std::string DEFAULT_PORTS = "[31000-32000]";

There are two ways to configure the slaves to offer the correct resources. The first is to add a resources parameter to the mesos-slave command like this:


$ /usr/local/sbin/mesos-slave --resources='ports:[9200-9200,9300-9300]' ...

The resource string is a comma-separated string consisting of scalar, ranges and sets. Checkout the Mesos resources documentation to see how to create valid resources expressions. The other way to configure resources is to create a file under /etc/mesos-slave called resources whose contents is the resource string.


$ cat /etc/mesos-slave/resources
ports:[9200-9200,9300-9300]
$

Note that any type of configuration can be expressed this way. This is really useful when provisioning a cluster. For instance with Terraform. For more information about configuration checkout the Mesos configuration documentation.

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *