background
In order to cope with more traffic impacts, it was decided to migrate the redis of the business to the cluster. The back-end application is developed by golang.
- Source: stand-alone redis
- Goal: Tencent Cloud redis cluster 3 master 0 slave
- Condition: There is data in the cluster redis, not empty
Migration
1. DTS
First adopted the official DTS switching scheme of Tencent Cloud and failed. Reason for failure: DTS only supports node data migration to an empty cluster.
2. Decided to refactor the redis component and complete the migration according to the following process
Refactoring logic:
- In the first step, all applications write to the source and target redis bidirectionally, and the read and write return values take the source return value.
- The second step is to keep it for 15 days+. Ensure that the unsynchronized cache fails normally and the new cache is fully synchronized.
- In the third step, all applications continue to write in both directions, but the read and write return value takes the target redis
- The fourth step, so far, the target redis is written, and the target redis is read. The source redis is officially retired and removed.
- end
Implementation details
https://github.com/fwhezfwhez/redix