MySQL to Redis Synchronization
Overview
This topic describes how to use CloudCanal build a MySQL-to-Redis data synchronization link, including the following features:
- Support Redis single-node, primary-standby, and sharded cluster
- Support cache expiration time when write to Redis
Key Points
Automatically Adapt to Redis Various Deployments
Redis sharded and non-sharded clusters have different ways of writing data and query metadata.
CloudCanal automatically identifies the deployment form of Redis by obtaining Redis parameters, and adjusts the writing method to make the synchronization DataJob run normally.
Support Cache Expiration
Redis can set the cache expiration time when writing data.
When creating a CloudCanal DataJob, you can optionally set the expiration time (seconds).
After creating, DataJob will set the expiration time when writing data to Redis.
Example
Install CloudCanal
- See Install(Linux/MacOS) document.
Add DataSource
In this example, one Redis cluster purchased by Alibaba Cloud Marketplace and a MySQL are used.
Log in to the CloudCanal, DataSource > Add DataSource , add 2 DataSource
If Redis is a cluster, you can fill in all nodes or all master nodes and separate them with commas.
Create DataJob
DataJob->Create DataJob
Advanced configuration of the target DataSource, you can set the cache invalid time (second), <=0 means not set.
Click Next Step.
Select Incremental, then check Full Data option.
Click Next Step.
Select tables.
Because the cache key in Redis is composed of the primary key of the source table, it is not recommended to select the tables without a primary key.
Click Next Step.
Select columns and click Next Step.
Confirm the Creating.
Test And Verify Data
Create INSERT,UPDATE,DELETE work load.
Stop work load.
Create Data Verification DataJob, and the result is correct.
FAQ
What should I do if Redis is primary and standby switched?
- CloudCanal uses JedisCluster for writes, which automatically senses changes in primary and standby changes
What about Redis changing nodes?
- You can manually modify the node information of the task configuration and restart the task to continue.
Summary
This topic describes how to use CloudCanal to build a MySQL to Redis data synchronization link to help you accelerate your business queries.