Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Enabling and Using Memory Acceleration

Updated on 2025-01-03 GMT+08:00

Enable memory acceleration.

Step 1: Create a GeminiDB instance.

Step 2: Create a mapping rule.

Step 3: Use the memory acceleration module.

Precautions

  • After memory acceleration is enabled, commands such as RESET MASTER and FLUSH LOGS used to delete binlogs on MySQL instances are not allowed.
  • Currently, only hash data from MySQL can be converted to GeminiDB Redis API.
  • A Redis key prefix and a delimiter in a new rule can neither include those nor be included in those specified for an existing rule. For example, if the key prefix in a new rule is pre1: and is separated by a comma (,) and the key prefix in an existing rule is pre1 and is separated by a colon (:), the new rule cannot be created.
  • Currently, the ENUM, SET, and JSON data cannot be synchronized.

Procedure

Using the Memory Acceleration Module

  1. Create database db1 in the source MySQL instance and create table students in db1.
    mysql> CREATE DATABASE db1;
    Query OK, 1 row affected (0.00 sec)
    
    mysql> CREATE TABLE db1.students(
           sid INT UNSIGNED PRIMARY KEY AUTO_INCREMENT NOT NULL,
           sname VARCHAR(20),
           sclass INT,
           sgender VARCHAR(10),
           sbirthday DATE
           );
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> DESC db1.students;
    +-----------+--------------+------+-----+---------+----------------+
    | Field     | Type         | Null | Key | Default | Extra          |
    +-----------+--------------+------+-----+---------+----------------+
    | sid       | int unsigned | NO   | PRI | NULL    | auto_increment |
    | sname     | varchar(20)  | YES  |     | NULL    |                |
    | sclass    | int          | YES  |     | NULL    |                |
    | sgender   | varchar(10)  | YES  |     | NULL    |                |
    | sbirthday | date         | YES  |     | NULL    |                |
    +-----------+--------------+------+-----+---------+----------------+
    5 rows in set (0.00 sec)
  2. After the table is created, on the memory acceleration page, create a mapping rule to convert each row in the students table into a Redis hash. The key of a hash is in the format of Database name:Data table name:sid:<sid value>. The selected fields are sname, sclass, sgender, and sbirthday.
    Figure 8 Configuring a mapping rule
  3. After a mapping rule is created, check the mapping rule and information.
    Figure 9 Mapping information
  4. Insert a new data record to the students table in the MySQL instance.
    mysql> INSERT INTO db1.students (sname, sclass, sgender, sbirthday) VALUES ('zhangsan', 1, 'male', '2015-05-20');
    Query OK, 1 row affected (0.01 sec)
    
    mysql> SELECT * FROM db1.students;
    +-----+----------+--------+---------+------------+
    | sid | sname    | sclass | sgender | sbirthday  |
    +-----+----------+--------+---------+------------+
    |   1 | zhangsan |      1 | male    | 2015-05-20 |
    +-----+----------+--------+---------+------------+
    1 row in set (0.00 sec)
  5. After the mapping rule is created, the data is automatically synchronized to the GeminiDB instance. Run commands in the GeminiDB instance to query the data.
    127.0.0.1:6379> KEYS *
    1) "db1:students:sid:1"
    
    127.0.0.1:6379> HGETALL db1:students:sid:1
    1) "sbirthday"
    2) "2015-05-20"
    3) "sclass"
    4) "1"
    5) "sgender"
    6) "male"
    7) "sname"
    8) "zhangsan"
  6. Insert a new data record to the students table in the MySQL instance.
    mysql> INSERT INTO db1.students (sname, sclass, sgender, sbirthday) VALUES ('lisi', 10, 'male', '2015-05-22');
    Query OK, 1 row affected (0.00 sec)
    
    mysql> SELECT * FROM db1.students;
    +-----+----------+--------+---------+------------+
    | sid | sname    | sclass | sgender | sbirthday  |
    +-----+----------+--------+---------+------------+
    |   1 | zhangsan |      1 | male    | 2015-05-20 |
    |   2 | lisi     |     10 | male    | 2015-05-22 |
    +-----+----------+--------+---------+------------+
    2 rows in set (0.00 sec)
  7. Check whether the new data is synchronized to the GeminiDB instance.
    127.0.0.1:6379> KEYS *
    1) "db1:students:sid:1"
    2) "db1:students:sid:2"
    
    127.0.0.1:6379> HGETALL db1:students:sid:2
    1) "sbirthday"
    2) "2015-05-22"
    3) "sclass"
    4) "10"
    5) "sgender"
    6) "male"
    7) "sname"
  8. Update data in the students table in the MySQL instance.
    mysql> UPDATE db1.students SET sclass=12, sname='wangwu' WHERE sid = 1;
    Query OK, 1 row affected (0.00 sec)
    Rows matched: 1  Changed: 1  Warnings: 0
    
    mysql> SELECT * FROM db1.students;
    +-----+--------+--------+---------+------------+
    | sid | sname  | sclass | sgender | sbirthday  |
    +-----+--------+--------+---------+------------+
    |   1 | wangwu |     12 | male    | 2015-05-20 |
    |   2 | lisi   |     10 | male    | 2015-05-22 |
    +-----+--------+--------+---------+------------+
    2 rows in set (0.00 sec)
  9. Check whether the data is updated in the GeminiDB instance.
    127.0.0.1:6379> KEYS *
    1) "db1:students:sid:1"
    2) "db1:students:sid:2"
    
    127.0.0.1:6379> HGETALL db1:students:sid:1
    1) "sbirthday"
    2) "2015-05-20"
    3) "sclass"
    4) "12"
    5) "sgender"
    6) "male"
    7) "sname"
    8) "wangwu"
  10. Delete data from the students table in the MySQL instance.
    mysql> DELETE FROM db1.students WHERE sid = 1;
    Query OK, 1 row affected (0.00 sec)
    
    mysql> SELECT * FROM db1.students;
    +-----+-------+--------+---------+------------+
    | sid | sname | sclass | sgender | sbirthday  |
    +-----+-------+--------+---------+------------+
    |   2 | lisi  |     10 | male    | 2015-05-22 |
    +-----+-------+--------+---------+------------+
    1 row in set (0.00 sec)
  11. Check whether the data is deleted from the GeminiDB instance.
    127.0.0.1:6379> KEYS *
    1) "db1:students:sid:2"

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback