Tutorial - Installing the First Package

Part 2 of the DC/OS 101 tutorial

IMPORTANT: Tutorials are intended to give you hands-on experience working with a limited set of DC/OS features with no implied or explicit warranty of any kind. None of the information provided—including sample scripts, commands, or applications—is officially supported by Mesosphere. You should not use this information in a production environment without independent testing and validation.

Welcome to part 2 of the DC/OS 101 Tutorial.

Prerequisites

By now, you should have a running DC/OS cluster and the DC/OS CLI installed and configured. If that isn’t the case, please follow the first part of this tutorial. The next stage of this tutorial uses jq, a command line JSON processor to simplify some of the commands. Follow the instructions here to install JQ for your operating system.

Objective

By the end of this session you will have installed your first service - Redis - from the DC/OS Catalog repository. Redis is a key-value store, which you will use for persisting data in this tutorial.

Steps

  • Install Redis

    • Search the Catalog repository for Redis packages:

      1. dcos package search redis

      This should return two entries (mr-redis and redis).

    • You are interested in the Redis package, which installs a single Redis container. Install the package with this command:

      1. dcos package install redis
  • You can use any of the following methods to check that Redis is running:

    • By looking at the GUI: The Redis task should be displayed in the Service Health tab along with the health status.
    • By looking at all DC/OS tasks with the dcos task command. This command will show us all running DC/OS tasks (i.e. Mesos tasks).
    • By looking at all Marathon apps: dcos marathon app list. This command will show us all running Marathon apps. Since services are started via Marathon, you should see Redis here as well. Note that the health status (i.e. 1/1) is also shown here.
    • By looking at the Redis log: dcos task log redis. This command will show us the logs (stdout and stderr) of the Redis task. This allows you to check whether the actual startup was successful. You can increase the number of log lines displayed by using the --lines= argument, the default is 10.
  • Let’s use Redis by storing a key manually via the redis-cli command

    • SSH into the node where Redis is running:

      1. dcos node ssh --master-proxy --mesos-id=$(dcos task redis --json | jq -r '.[] | .slave_id')
    • Because Redis is running in a Docker container, you can list all Docker containers using docker ps and get the ContainerID of the container running the Redis service.

    • Start a bash session in the running container, substituting CONTAINER_ID with the ContainerID you got from the previous command:

      1. sudo docker exec -i -t CONTAINER_ID /bin/bash
    • Start the Redis CLI:

      1. redis-cli
    • Set a key with a value:

      1. set mykey key1
    • Check the value is there:

      1. get mykey

Outcome

You have just successfully installed your first service from the Catalog repository and verified it is running!

Deep Dive

Catalog is a package repository made available for DC/OS Clusters. It enables you to easily install services such as Apache Spark or Apache Cassandra in your cluster without having to deal with manual configuration. Catalog packages are developed and maintained by many different contributors.

There are currently two categories of packages:

  1. Curated packages that have undergone testing and certification.
  2. Community contributed packages, which may not be as well tested.

You can also add your own repo that includes your custom packages. See the documentation for details.