|Learn how to quickly deploy a multi-node Redis cluster on Ubuntu Server
|Tim McNamara firstname.lastname@example.org
This tutorial walks you through the process of deploying a Redis cluster on Ubuntu Server. The instructions work on all clouds supported by Juju—even bare metal servers—but this tutorial includes specific instructions to deploy the cluster to AWS, Google Compute Platform or Azure.
You will be able to configure the exact scale that you require and deploy it into any region supported by each cloud.
- Deploy a Redis cluster
- Tweak the cluster’s settings to add authentication
- Test our deployment
- Juju installed (install it by running
snap install juju --claasicor by following the instructions on the Juju documentation)
- (Optional) An Ubuntu SSO account (visit login.ubuntu.com to create one)
- (Optional) Credential information for AWS, GCP or Azure (created when you create an account with your preferred cloud provider)
ⓘ Looking for a fully hosted solution? Use Juju as a Service (JAAS)
JAAS is a hosted service provided by Canonical, the company behind Ubuntu. It’s a “Juju controller” for free. The Juju controller talks to the cloud provider programmatically to provision machines and manage software deployments. Once they’re online, the controller then installs the software that we care about: Redis. To use JAAS for this tutorial, create an account on jaas.ai and run ‘juju login jaas’ in a terminal.
The top of each step provides a command to be executed in the terminal window. Explanatory text then follows for people who want to know more.
To open a terminal window in Ubuntu, open the Terminal app or holding
Originally authored by Tim McNamara.
A “model” is Juju a term to describe a logical service made up applications. A model might represent a whole web app, including its web server, databases and work queues.
For our purposes, our Redis cluster will make up the entire model. We’ll use the name
To create the model on AWS, use the following command:
juju add-model redis-cluster-tutorial aws/us-west-1
The command at the top of this page uses the “US West 1” region from the AWS cloud provider by specifying
To get a list of cloud providers and supported regions, just omit that argument from the command:
juju add-model redis-cluster-tutorial
juju add-model command will probably launch a browser window asking you to log in.
Juju (and JAAS) need to be granted permission to act on your behalf. Juju works by talking to the cloud provider programmatically. This login process confirms that you’re willing to delegate authority to Juju to do so.
To install Redis, we’ll use the
juju deploy command.
juju deploy works with the model that we’ve just defined to install software there.
Enter this command in the command line:
juju deploy cs:~omnivector/redis \
--config cluster-enabled=true \
--constraints 'mem=4G' \
That command can be a little confusing if you haven’t encountered Juju before. Here is an explanation of each part of the command that you used:
juju deploy command instructs Juju to deploy a charm (defined beflow) into machines that are hosted within our model.
|This is the charm that we're deploying. It is made up of the parts "
cs:" to denote the public charm store, "
~omnivector" to denote the
omnivector user account (as the author of the charm) and "
redis" as the charm's name.
|Sets the configuration option
true. This instructs the charm code to deploy a Redis as a cluster.
|Specify that the virtual machines that we want Juju to deploy on our behalf have at least 4GB of RAM.
|Set the desired scale of our cluster to be 3 virtual machines
ⓘ Check that the clustering configuration option is enabled
It’s important to include the option
--config cluster-enabled. Without it, three independent Redis instances will be deployed.
ⓘ Use whatever scale you want
If you would like to use a 5 node cluster, for example, change the
--num-unitsoption to 5. The
--contraintsoption can also be tweaked.
A charm is software that deploys other software and makes it easy to maintain. The
cs:~omnivector/redis charm has its own website.
cs:~omnivector/redis is the Juju Charm Store account for Omnivector Solutions. Omnivector Solutions is a commercial enterpise based in the Oregon, USA. From their website:
Omnivector is a member of the Juju Experts program. Their team has written the Redis charm that we’re deploying and released it as open source software.
juju status command provides a live view of what is happening behind the scenes.
Will eventually produce an output similar to this:
Model Controller Cloud/Region Version SLA Timestamp
redis-cluster-tutorial jaas aws/us-west-1 2.6.8 unsupported 16:54:19+13:00
App Version Status Scale Charm Store Rev OS Notes
redis 5.0.5 active 3 redis jujucharms 25 ubuntu
Unit Workload Agent Machine Public address Ports Message
redis/0* active idle 0 18.104.22.168 6379/tcp successfully clustered
redis/1 active idle 1 22.214.171.124 6379/tcp successfully clustered
redis/2 active idle 2 126.96.36.199 6379/tcp successfully clustered
Machine State DNS Inst id Series AZ Message
0 started 188.8.131.52 i-0924efebda490847f bionic us-west-1b running
1 started 184.108.40.206 i-0865d0af27dae812f bionic us-west-1c running
2 started 220.127.116.11 i-037f8bdc3cf0b3d22 bionic us-west-1b running
Once all of the workloads are in the “active” state, it’s time to move on.
ⓘ Hint: use the watch command to avoid retyping
watchcommand enables you to repeatedly execute a command without needing to retype it. Try
watch -c -n5 juju status --color
Redis is now installed and working correctly. Well done! You’re now able to tweak the deployment.
To require that Redis clients specify a password when they execute commands, use the
juju config command. The command supports setting multiple options at the same time by adding additional setting=value pairs.
juju config redis password=password123
Use the same command with different arguments to increase the TCP Keep Alive connection settings.
juju config redis tcp-keepalive=30
Our Redis cluster is now ready. To make it accessible to the Internet, enter this command in the terminal:
juju expose redis
juju expose command talks to the cloud’s firewall systems to make them publicly accessible.
To test that everything is functional, we’ll use the Redis command line tools:
apt to install the Redis CLI client
sudo apt install -y redis-tools
To know where to ping, we’ll make use of the output from
juju status again.
juju status --format=oneline
This command will spend a moment or two probing the model, then report something similar to this:
- redis/0: 18.104.22.168 (agent:idle, workload:active) 6379/tcp
- redis/1: 22.214.171.124 (agent:idle, workload:active) 6379/tcp
- redis/2: 126.96.36.199 (agent:idle, workload:active) 6379/tcp
With the Redis CLI installed and a host to connect to, let’s send the
redis-cli -h 188.8.131.52 ping;
With some luck, it will produce this encouraging response:
Redis is installed and active in the cloud.
We recommend creating an account at the Juju Discourse forum. That’s the best place to ask any questions.