Note:
- This tutorial requires access to Oracle Cloud. To sign up for a free account, see Get started with Oracle Cloud Infrastructure Free Tier.
- It uses example values for Oracle Cloud Infrastructure credentials, tenancy, and compartments. When completing your lab, substitute these values with ones specific to your cloud environment.
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.
Objectives
-
Create OCI Cache with Redis instance in a private subnet.
-
Create compute or virtual machine (VM) instance to connect to OCI Cache with Redis in a public subnet, using the same VCN. Add port 6379 to the private subnet security list.
-
Connect using Redis Insight.
Prerequisites
- Access to an OCI tenancy with privileges to create databases and compute instances.
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.
-
Go to the OCI Console and click Databases. Under OCI Cache, click Clusters.
-
Click Create Cluster.
-
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.
-
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.
-
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.
-
In Review and create, review the cluster configuration and click Create Cluster.
-
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.
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.
-
Go to the OCI Console, click Compute and Instances.
-
Select a public subnet in the same VCN you provisioned the OCI Cache with Redis cluster.
Task 3: Connect using a VM in the Same Virtual Cloud Network
-
SSH into the compute instance, download and install the Redis CLI. For more information, see Redis CLI.
-
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/
-
Run the following command to check Redis CLI version.
redis-cli -v --Output as of today ==> redis-cli 7.4.0
-
-
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.
-
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
Task 4: Connect using Redis Insight
Install Redis Insight on your local laptop and connect to OCI Cache with Redis.
-
Install Redis Insight.
-
Add the credentials to connect to the OCI Cache with Redis.
- Host: Enter cluster node endpoint.
- Port: Enter 6379.
-
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.
Overview of the key created.
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).
Related Links
Acknowledgments
- Author - Ismael Hassane (Senior Solution Architect, Data Platform).
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.
Connect to Oracle Cloud Infrastructure Cache with Redis using Redis Insight
G17991-01
October 2024