Files
doc-exports/docs/dcs/umn/dcs-migrate-demo02.html
chenjunjie ab5f2db011 DCS UMN 20240705 version
Reviewed-by: Mützel, Andrea <andrea.muetzel@t-systems.com>
Co-authored-by: chenjunjie <chenjunjie@huawei.com>
Co-committed-by: chenjunjie <chenjunjie@huawei.com>
2025-02-26 10:24:22 +00:00

55 lines
9.6 KiB
HTML

<a name="dcs-migrate-demo02"></a><a name="dcs-migrate-demo02"></a>
<h1 class="topictitle1">Self-Hosted Redis Cluster Migration with redis-shake (Online)</h1>
<div id="body1562070011766"><p id="dcs-migrate-demo02__p183741837161419">redis-shake is an open-source tool for migrating data online or offline (by importing backup files) between Redis Clusters. Data can be migrated to DCS Redis Cluster instances seamlessly because DCS Redis Cluster inherits the native Redis Cluster design.</p>
<p id="dcs-migrate-demo02__p8060118">The following describes how to use Linux redis-shake to migrate self-hosted Redis Cluster to a DCS Redis Cluster instance online.</p>
<div class="section" id="dcs-migrate-demo02__section01321811133220"><h4 class="sectiontitle">Notes and Constraints</h4><ul id="dcs-migrate-demo02__ul1383184352119"><li id="dcs-migrate-demo02__li1283124382119">To migrate data from a self-hosted Redis Cluster instance to a DCS Redis Cluster instance online, ensure that the source Redis is connected to the target Redis, or use a transit cloud server to connect the source and target cluster instances.</li><li id="dcs-migrate-demo02__li921571317245">To migrate to an instance with SSL enabled, disable the SSL setting first. For details, see <a href="dcs-ug-023129.html">Transmitting DCS Redis Data with Encryption Using SSL</a>.</li></ul>
</div>
<div class="section" id="dcs-migrate-demo02__section17937122314119"><h4 class="sectiontitle">Prerequisites</h4><ul id="dcs-migrate-demo02__ul14456192935418"><li id="dcs-migrate-demo02__li20949052135714">If a target DCS Redis instance is not available, create one first. For details, see <a href="dcs-ug-0312003.html">Creating a DCS Redis Instance</a>.</li><li id="dcs-migrate-demo02__li125429292588">If you already have a DCS Redis instance, you do not need to create one again. For comparing migration data and reserving sufficient memory, you are advised to clear the instance data before the migration. For details, see <a href="dcs-ug-0312018.html">Clearing DCS Instance Data</a>. If any data exists on the target instance, duplicate data between the source and target is overwritten. If the data exists only on the target instance, the data will be retained.</li></ul>
<ul id="dcs-migrate-demo02__ul1119121144311"><li id="dcs-migrate-demo02__li1863392615714">An Elastic Cloud Server (ECS) has been created. For details about how to create an ECS, see <em id="dcs-migrate-demo02__i344871153104631"></em><a href="https://docs.otc.t-systems.com/en-us/usermanual/ecs/en-us_topic_0163572588.html" target="_blank" rel="noopener noreferrer">Elastic Cloud Server User Guide</a>.<p id="dcs-migrate-demo02__p138084281778">Select the same VPC, subnet, and security group as the DCS Redis Cluster instance, and bind EIPs to the ECS.</p>
</li><li id="dcs-migrate-demo02__li9131844111313">If the source self-hosted Redis Cluster is deployed on cloud servers of another cloud, allow public access to the servers.</li></ul>
</div>
<div class="section" id="dcs-migrate-demo02__section51871956154311"><h4 class="sectiontitle">Obtaining Information of the Source and Target Redis Nodes</h4><ol id="dcs-migrate-demo02__ol937917016457"><li id="dcs-migrate-demo02__li10140101218452">Connect to the source and target Redis instances, respectively. Connect to Redis by referring to <a href="dcs-ug-0326009.html">Accessing a DCS Redis Instance Through redis-cli</a>.</li><li id="dcs-migrate-demo02__li75216113412">In online migration of Redis Clusters, the migration must be performed node by node. Run the following command to query the IP addresses and ports of all nodes in both the source and target Redis Clusters.<pre class="screen" id="dcs-migrate-demo02__screen9190174216389">redis-cli -h {redis_address} -p {redis_port} -a {redis_password} cluster nodes</pre>
<p id="dcs-migrate-demo02__p18729195453"><em id="dcs-migrate-demo02__i38712590538">{redis_address}</em> indicates the Redis connection address, <em id="dcs-migrate-demo02__i19381910105416">{redis_port}</em> indicates the Redis port, and <em id="dcs-migrate-demo02__i6189101415410">{redis_password}</em> indicates the Redis connection password.</p>
<p id="dcs-migrate-demo02__p1719124210381">In the command output similar to the following, obtain the IP addresses and ports of all masters.</p>
<p id="dcs-migrate-demo02__p151917424388"><span><img id="dcs-migrate-demo02__image201913423389" src="en-us_image_0000002001365365.png"></span></p>
</li></ol>
</div>
<div class="section" id="dcs-migrate-demo02__section194954610107"><h4 class="sectiontitle">Configuring the redis-shake Tool</h4><ol id="dcs-migrate-demo02__ol0483154263117"><li id="dcs-migrate-demo02__li630814352317">Log in to the ECS.</li><li id="dcs-migrate-demo02__li15905189153217">Run the following command on the ECS to download the redis-shake: This section uses v2.1.2 as an example. You can also download <a href="https://github.com/alibaba/RedisShake/releases" target="_blank" rel="noopener noreferrer">other redis-shake versions</a> as required.<pre class="screen" id="dcs-migrate-demo02__screen195204110481">wget https://github.com/tair-opensource/RedisShake/releases/download/release-v2.1.2-20220329/release-v2.1.2-20220329.tar.gz</pre>
</li><li id="dcs-migrate-demo02__li8781918103217">Decompress the redis-shake file.<pre class="screen" id="dcs-migrate-demo02__screen65481045101912">tar -xvf redis-shake-v2.1.2.tar.gz</pre>
<p id="dcs-migrate-demo02__p17330129173"><span><img id="dcs-migrate-demo02__image64611312101716" src="en-us_image_0000001964418130.png"></span></p>
</li><li id="dcs-migrate-demo02__li52093712471">Go to the redis-shake directory.<pre class="screen" id="dcs-migrate-demo02__screen383515448361">cd redis-shake-v2.0.3</pre>
</li><li id="dcs-migrate-demo02__li427914206484">Edit the <strong id="dcs-migrate-demo02__b94161456567">redis-shake.conf</strong> file by providing the following information about all the masters of both the source and the target:<pre class="screen" id="dcs-migrate-demo02__screen162871920114818">vim redis-shake.conf</pre>
<div class="p" id="dcs-migrate-demo02__p58009481215">The modification is as follows:<pre class="screen" id="dcs-migrate-demo02__screen196193138478">source.type = cluster
# If there is no password, skip the following parameter.
source.password_raw = {source_redis_password}
# IP addresses and port numbers of all masters of the source Redis Cluster, which are separated by semicolons (;).
source.address = {master1_ip}:{master1_port};{master2_ip}:{master2_port}...{masterN_ip}:{masterN_port}
target.type = cluster
# If there is no password, skip the following parameter.
target.password_raw = {target_redis_password}
# IP addresses and port numbers of all masters of the target instance, which are separated by semicolons (;).
target.address = {master1_ip}:{master1_port};{master2_ip}:{master2_port}...{masterN_ip}:{masterN_port}</pre>
</div>
<p id="dcs-migrate-demo02__p26193138477">Press <strong id="dcs-migrate-demo02__b1232910345714">Esc</strong> to exit the editing mode and enter <strong id="dcs-migrate-demo02__b17329338576">:wq!</strong>. Press <strong id="dcs-migrate-demo02__b1132943135719">Enter</strong> to save the configuration and exit the editing interface.</p>
</li></ol>
</div>
<div class="section" id="dcs-migrate-demo02__section2049172055811"><h4 class="sectiontitle">Migrating Data Online</h4><div class="p" id="dcs-migrate-demo02__p229612448595">Run the following command to synchronize data between the source and the target Redis:<pre class="screen" id="dcs-migrate-demo02__screen153902112599">./redis-shake -type sync -conf redis-shake.conf</pre>
</div>
<p id="dcs-migrate-demo02__p111506489581">If the following information is displayed, the full synchronization has been completed and incremental synchronization begins.</p>
<pre class="screen" id="dcs-migrate-demo02__screen1150174855820">sync rdb done.</pre>
<p id="dcs-migrate-demo02__p151501448145815">If the following information is displayed, no new data is incremented. You can stop the incremental synchronization by pressing <strong id="dcs-migrate-demo02__b852141612475">Ctrl</strong>+<strong id="dcs-migrate-demo02__b1351220201478">C</strong>.</p>
<pre class="screen" id="dcs-migrate-demo02__screen121501848105813">sync: +forwardCommands=0 +filterCommands=0 +writeBytes=0</pre>
<div class="fignone" id="dcs-migrate-demo02__fig16151548165811"><span class="figcap"><b>Figure 1 </b>Online migration using redis-shake</span><br><span><img id="dcs-migrate-demo02__image7151194815582" src="en-us_image_0000002000818973.png"></span></div>
</div>
<div class="section" id="dcs-migrate-demo02__section1284020211609"><h4 class="sectiontitle">Verifying the Migration</h4><ol id="dcs-migrate-demo02__ol1397335516813"><li id="dcs-migrate-demo02__li180911211257">After the data synchronization, connect to the Redis Cluster DCS instance by referring to <a href="dcs-ug-0326009.html">Accessing a DCS Redis Instance Through redis-cli</a>.</li><li id="dcs-migrate-demo02__li199735553817">Run the <strong id="dcs-migrate-demo02__b8904623195811">info</strong> command to check whether the data has been successfully imported as required.<p id="dcs-migrate-demo02__p03492001695">If the data has not been fully imported, run the <strong id="dcs-migrate-demo02__b79291718165918">flushall</strong> or <strong id="dcs-migrate-demo02__b3929218155919">flushdb</strong> command to clear the cached data in the target instance, and migrate data again.</p>
</li><li id="dcs-migrate-demo02__li105900617920">After the verification is complete, delete the redis shake configuration file.</li></ol>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dcs-migration-0312002.html">Migrating Data from Self-Hosted Redis to DCS</a></div>
</div>
</div>