IBM Cloud Docs
Getting Started

Getting Started

This tutorial is a short introduction to using an IBM Cloud® Databases for Redis deployment.

Before you begin

  • You need an IBM Cloud account.

  • You also need a Databases for Redis deployment, which can be provisioned from the IBM Cloud catalog. Give your deployment a memorable name that appears in your account's Resource List.

  • Download and install the IBM Cloud CLI and the Cloud Databases CLI Plugin. Use the IBM Cloud CLI tool to communicate with IBM Cloud from your terminal or command line, and the plugin contains communication commands for your database deployments.

  • Before connecting, set your admin password. For more information, see Setting the Admin Password.

For more information, see Getting to production.

Download and Install Redli

To get a feel for connecting, sending, and retrieving data with Redis, start by connecting with a CLI client. All IBM Cloud Databases use TLS/SSL secured connections, so use a Redis CLI client that supports TLS/SSL, like Redli.

To install Redli, download and install the package for your system. Uncompress the files, give the binary executable permissions, and move it to your path. For example, to install it on a Mac, download the redli....darwin_amd64.tar.gz file and run a command like this one:

tar zxvf redli_0.4.4_darwin_amd64.tar.gz
chmod +x redli
sudo cp redli /usr/local/bin

Unfortunately, the native Redis CLI client does not support TLS/SSL connections and deployments require secure connections. To use Redis CLI, set up something like Stunnel to handle the TLS/SSL connection. For more information, see Connecting with a CLI client.

Connect to Redis

You can connect to Redis through the IBM Cloud CLI or through Redli.

Connect through the IBM Cloud CLI

Now that you've installed and set up Redli, the IBM Cloud CLI tool, and the IBM Cloud Databases plugin, connect to your deployment. Log in with ibmcloud login, and connect with ibmcloud cdb cxn -s, for example:

ibmcloud cdb cxn -s <deployment-name>

When prompted for the admin password, use Redli to connect. You can now store and retrieve data with your IBM Cloud® Databases for Redis deployment.

Connect through Redli

You can also connect to your deployment through Redli, without using the IBM Cloud CLI.

Connection strings for your deployment are displayed in the Dashboard Overview, in the Endpoints panel. The CLI tab contains information that a CLI client uses to connect to your deployment. To connect, you need the self-signed certificate, the certificate name, and the connection string in the CLI endpoint field.

CLI Endpoints panel
Figure 1. CLI Endpoints panel

Download or save the contents of the TLS certificate to a file and name the file with the TLS certificate name. Remember where the file is saved.

The connection string in the CLI endpoint field is the fully-formatted command to make a CLI connection to your deployment using Redli. Navigate to where you have saved the certificate on your system, or provide the full path to the certificate to the REDIS_CERTFILE environment variable. Set the admin user name and password in the environment as USERNAME and PASSWORD. Use the CLI connection string to start Redli, for example:

REDIS_CERTFILE=101afa63-91d0-11e9-a88d-5a059876d90f redli -u rediss://$USERNAME:$PASSWORD@da4103eb-f1ef-4f2d-8b41-0bfd98cb65bc.8117147f814b4b2ea643610826cd2046.databases.appdomain.cloud:30174/0

Use Redis

Your connection is now open, which looks like:

Connected to 4.0.10
>

you can start storing and retrieving data.

Connected to 4.0.10
> set foo bar
OK
> get foo
"bar"
>

Next Steps

The Redis documentation has an introduction to Redis data types and abstractions, and a Command Reference.

For information on best practices, see Best Practices for Redis on the IBM Cloud.

If you are using Redis for the first time, see the official Redis documentation.

To use IBM Cloud® Databases for Redis with your applications, see Connecting an external application and Connecting an IBM Cloud application.

To ensure the stability of your applications and your database, see High-Availability and Performance

For more information on migrating your existing data to Databases for Redis, see A How-To for Migrating Redis to IBM Cloud Databases for Redis.