Note:

Connect to Oracle Cloud Infrastructure Cache with Redis using Redis Insight

Introduction

In this tutorial, we will explore how to connect to an Oracle Cloud Infrastructure (OCI) managed Redis database using a database administration tool (Redis Insight). As Redis Insight is a free graphical interface for analyzing Redis data across all operating systems and Redis deployments, it significantly enhances Redis administrators and developers efficiency by providing a user-friendly graphical interface for database administration, development, and data analysis.

The following schema depicts the overall approach.

architecture view

Objectives

Prerequisites

Task 1: Create OCI Cache with Redis Instance in a Private Subnet

This task can also be accomplished with other methods like OCI Command Line Interface (CLI), API. We will use the OCI Console to create a managed OCI Cache with Redis cluster. For more information, see Creating a Cluster.

  1. Go to the OCI Console and click Databases. Under OCI Cache, click Clusters.

    img

  2. Click Create Cluster.

    img

  3. In the Configure cluster section, enter the following information and click Next.

    • Name: Enter a cluster name.
    • Create in compartment: Select the compartment.
    • OCI Cache engine version: Select the Redis version.

    img

  4. In the Configure nodes section, enter the following information and click Next.

    • Cluster mode: Select the cluster mode (non-sharded or sharded).
    • Node Count: Enter a node count.
    • Memory(GB) per node: Enter memory per node.

    creating redis db

  5. In the Configure Networking section, enter the following information and click Next.

    • Compartment: Select the right compartment.
    • VCN: Select or create the virtual cloud network.
    • Subnet: Select or create the private subnet.

    creating redis

  6. In Review and create, review the cluster configuration and click Create Cluster.

    creating redis

  7. After successful creation, access the cluster details page for the Redis deployment. Take note of your nodes (primary, replicas) endpoints, it will be required to connect to the Redis cluster.

    img

Task 2: Create Compute Instance to Connect to OCI Cache with Redis

Redis database being deployed within a private network, we will create an instance with a public IP address and grant it access to Redis. This newly created instance will serve as an entry point to the Redis database.

  1. Go to the OCI Console, click Compute and Instances.

    image

  2. Select a public subnet in the same VCN you provisioned the OCI Cache with Redis cluster.

    image

Task 3: Connect using a VM in the Same Virtual Cloud Network

  1. SSH into the compute instance, download and install the Redis CLI. For more information, see Redis CLI.

    1. Install Redis CLI version 6 or above. For more information, see Install Redis from Source.

      wget http://download.redis.io/redis-stable.tar.gz
      tar xvzf redis-stable.tar.gz
      cd redis-stable
      make redis-cli
      make BUILD_TLS=yes
      sudo cp src/redis-cli /usr/local/bin/
      
    2. Run the following command to check Redis CLI version.

      redis-cli -v
      --Output as of today ==> redis-cli 7.4.0
      
  2. Add port 6379 to the private subnet security list.

    When you create a cluster, to make the data accessible from the cluster, OCI Cache with Redis creates a security list with a stateful ingress security rule for TCP traffic on destination port 6379 for the cluster’s VCN.

    If you do not see the security list or the rule is not configured as required, you can create a new security list and add the rule, or you can add the rule to the default security list for the VCN. For more information, see Security Lists and Creating a Security List.

    When creating and configuring the rule, you need to specify the following options in the Add Ingress Rules page.

    • Stateless: Deselect it.
    • Source Type: Select CIDR.
    • IP Protocol: Select TCP.
    • Source Port Range: Select All.
    • Destination Port Range: Enter 6379.
  3. Connect to Redis cluster node.

    redis-cli --tls -h oci-cache_node-endpoint
    

    Example statement:

    redis-cli --tls -h  aaaeicjx&x&x&x&x&x&x&x&x&x&&x&x&x&x&rtx643xvqycfzq-p.redis.eu-madrid-1.oci.oraclecloud.com
    

    img

Task 4: Connect using Redis Insight

Install Redis Insight on your local laptop and connect to OCI Cache with Redis.

  1. Install Redis Insight.

  2. Add the credentials to connect to the OCI Cache with Redis.

    • Host: Enter cluster node endpoint.
    • Port: Enter 6379.

    1

  3. Enter the Bastion/VM public IP address as Host and Port will be 22. Redis Insight will use the same VM instance in the public subnet using SSH to access the OCI Cache with Redis database.

    2

    Overview of the key created.

    image

Next Steps

In this tutorial, we have seen how to provision an OCI Cache with Redis within a private subnet. In the second and third tasks, we have provisioned a compute instance serving as bastion host in the same virtual cloud network to reach Redis database from an open-source database administration tool (Redis Insight).

Acknowledgments

More Learning Resources

Explore other labs on docs.oracle.com/learn or access more free learning content on the Oracle Learning YouTube channel. Additionally, visit education.oracle.com/learning-explorer to become an Oracle Learning Explorer.

For product documentation, visit Oracle Help Center.