Skip to content

Latest commit

 

History

History
115 lines (86 loc) · 4.15 KB

README.md

File metadata and controls

115 lines (86 loc) · 4.15 KB

How to use Redis on DC/OS

Redis is a popular in-memory data structure store, used as database, cache and message broker. The DC/OS service mr-redis, maintained by Huawei is a Mesos framework allowing you to manage Redis datastores standalone or in a clustered setup.

  • Estimated time for completion: 5 minutes
  • Target audience: Anyone interested using an in-memory data store.
  • Scope: Learn how to use Redis on DC/OS

Table of Contents:

Prerequisites

  • A running DC/OS 1.8 cluster with at least 2 nodes with 1 CPU and 128MB of RAM available.
  • DC/OS CLI installed.

Install mr-redis

To install mr-redis from the DC/OS CLI, do the following:

$ dcos package install mr-redis
In order for redis framework to start successfully it requires atleast 1 CPU and 128MB of RAM including ports.
Note that the service is alpha and there may be bugs, including possible data loss, incomplete features, incorrect documentation or other discrepancies.
Continue installing? [yes/no] yes
Installing Marathon app for package [mr-redis] version [0.0.1]
Once the cluster initializes download cli from https://github.com/mesos/mr-redis/releases/download/v0.01-alpha/mrr and follow the instructions in github.com/mesos/mr-redis README on how to initialize the cli, you could also use the REST api's directly to create redis instances

To validate that the mr-redis service is running and healthy you can go to the DC/OS UI:

Services

Note that the mr-redis framework scheduler is serving on mrredis.mesos:5656.

Create a Redis instance

While the mr-redis service we installed in the previous step is capable of supervising Redis instances, you will need to download the mrr, the mr-redis CLI to create and delete Redis instances. So, let's install the mrr (from within the DC/OS cluster):

$ dcos node ssh --master-proxy --leader

core@ip-10-0-6-55 ~ $ curl -s -L https://github.com/mesos/mr-redis/releases/download/v0.01-alpha/mrr_linux_amd64 -o mrr
core@ip-10-0-6-55 ~ $ chmod +x mrr
core@ip-10-0-6-55 ~ $ ./mrr init http://mrredis.mesos:5656

Now that we have mrr installed, we want to create a Redis instance with the name test, a memory capacity of 500 MB and 3 Redis slaves, so we do the following:

core@ip-10-0-6-55 ~ $ ./mrr create --name test --memory 500 --slaves 3 --wait
Attempting to Creating a Redis Instance (test) with mem=500 slaves=3
Instance Creation accepted............
Instance Created.

To validate if the Redis Master and the three Redis slaves have been created and to discover their endpoints, execute the following command:

core@ip-10-0-6-55 ~ $ ./mrr status --name test
Status = RUNNING
Type = MS
Capacity = 500
Master = 10.0.3.226:6380
	Slave0 = 10.0.3.226:6381
	Slave1 = 10.0.3.229:6380
	Slave2 = 10.0.3.229:6381

Access the Redis instance

Once you've created the Redis instance, you will want to try it out. For this we will directly talk the Redis protocol using netcat in a Docker container (appropriate/nc) to send Redis commands to the Redis instance we've set up previously.

To access and test the Redis instance, do the following (within the DC/OS cluster and using your own Redis Master address, 10.0.3.226:6380 in our example):

core@ip-10-0-6-55 ~ $ docker run -it --rm appropriate/nc 10.0.3.226 6380
PING
+PONG
SET somekey somevalue
+OK
GET somekey
$9
somevalue
SET anotherkey :42
+OK
GET anotherkey
$3
:42
QUIT
+OK

Uninstall mr-redis

To uninstall mr-redis:

$ dcos package uninstall mr-redis

Further resources

  1. DC/OS mr-redis Official Documentation
  2. Redis commands
  3. Redis protocol
  4. netcat Docker image