Getting Started with Redis and Reading and Writing Data Using Web CLI
This section takes the example of creating a single-node Distributed Cache Service (DCS) Redis 5.0 instance, connecting to it, and performing data read and write operations on the DCS console to get you quickly started with DCS.
There are three steps to get started with DCS:
- Preparations
Before creating a Redis instance, an authenticated Huawei Cloud account with balance, users with required permissions, and a set of VPC and subnet should be prepared.
- Creating a DCS Redis Instance
When creating a Redis instance, you can customize it with the required type and specifications, and configure a VPC and a subnet.
- Accessing a Redis Instance and Reading and Writing Data
Access Redis instances and run Redis commands to read and write data on a client compatible with Redis or using Web CLI on the DCS console.
Preparations
- Register a Huawei Cloud account and authenticate it.
If you already have one, go to 2. If you do not have one, do as follows:
- Log in to the Huawei Cloud official website, and click Register.
- Complete the registration as prompted. For details, see Signing up for a HUAWEI ID and Enabling Huawei Cloud Services.
Your personal information page is displayed after the registration completes.
- Complete real-name authentication for individual or enterprise users by referring to Real-Name Authentication.
Real-name authentication is required only when you buy or use resources in the Chinese mainland.
- Top up your account.
Ensure enough balance in your account.
- About Redis instance prices, see Price Calculator.
- About topping up an instance, see Top-Up and Repayment.
- Add DCS permissions.
Before creating a Redis instance and its dependencies, specific permissions are required. For details about how to add user permissions, see Creating a User and Granting DCS Permissions.
- Create a VPC and a subnet.
A DCS instance runs in a virtual private cloud (VPC) and has a subnet. Prepare a VPC and a subnet before creating a DCS instance. For more information, see Creating a VPC. If you already have an available VPC and subnet, use them.
- The VPC must be created in the same region as your DCS Redis instance.
- In VPC and subnet creation, retain the default settings unless otherwise specified.
Creating a DCS Redis Instance
- Go to the Buy DCS Instance page.
- Select Custom.
- Configure the instance. For details, see Table 1.
Table 1 Configuring an instance Parameter
Description
Billing Mode
Select Pay-per-use.
Region
Retain the default setting.
Project
Retain the default setting.
Cache Engine
This example uses Redis.
Edition
This example uses Basic.
CPU Architecture
This example uses x86.
Version
Select 5.0 in this operation.
Instance Type
Select Single-node in this operation. Single-node Redis instances use single nodes, do not persist data, and cost low. They are applicable in development and testing.
AZ
Each region contains multiple AZs. This example retains the default AZ.
Instance Specification
Select 128 MB in this operation.
VPC
Select the VPC in Preparations.
Subnet
Select the subnet in Preparations.
IPv4 Address
Auto and Manual are available.
In this example, select Auto.
Port
Custom. The default port 6379 will be used when unspecified.
In this example, use 6379.
Security Group
Skip it.
Instance Name
By default, a random name is generated. Retain it.
Enterprise Project
An enterprise project manages cloud resources by gathering relevant ones together. The default option default is available.
If you cannot select a required enterprise project, see Why Can't I Select the Required Enterprise Project When Creating a DCS Instance?
Password Protected
Select Yes and enter Password and Confirm Password.
(Optional) Advanced Settings
In this example, you can skip these settings.
Quantity
One instance will be created by default, and you can buy up to 100 DCS instances at a time.
- Check the estimated price in the lower left corner of the page. You can click Pricing details to learn more.
- Click Next.
- Confirm the instance settings, and click Submit.
The instance has been created successfully if it is in the Running state.
- After the task is successfully submitted, the Cache Manager page is displayed. When the new instance is in the Running state, the instance is created successfully.
Accessing a Redis Instance and Reading and Writing Data
This section takes the example of accessing a DCS Redis instance by using Web CLI on the console.
To access a DCS Redis instance on a compatible client, see Accessing Redis on a Client.
- In the navigation pane, choose Cache Manager. In the Operation column of the instance, choose More > Connect to Redis, as shown in the following figure.
Figure 1 Accessing Web CLI
- Enter the password set in instance creation and go to Web CLI.
- If no operation is performed for more than 5 minutes, the connection times out. You need to enter the password to access the instance again.
- You do not need to enter a password for accessing a password-free DCS Redis instance.
- Single-node instances support multiple databases (multi-DB). Select one of the databases. Select "Database 0" here.
Figure 2 Selecting a Database
- Enter Redis commands in the input box. For example, run the SET command to write a data name KEY_NAME and data value VALUE, and press Enter. The data is written when "OK" is returned. Write another ABC data of 123 again.
> SET KEY_NAME VALUE OK > SET ABC 123 OK
- Run the GET command to read the written data.
> GET KEY_NAME VALUE > GET ABC 123
Related Information
- For details about related concepts of DCS, see Basic Concepts.
- For details about the supported commands in DCS, see Command Compatibility.
- For details about DCS monitoring metrics, see DCS Metrics and Configuring Alarm Rules for Critical Metrics.
- For suggestions on using DCS instances, see Suggestions on Using DCS.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot