Files
doc-exports/docs/dcs/umn/dcs-migration-0312010.html
Chen, Junjie 2b90aa9fff DCS UMN 20240313 version
Reviewed-by: Mützel, Andrea <andrea.muetzel@t-systems.com>
Co-authored-by: Chen, Junjie <chenjunjie@huawei.com>
Co-committed-by: Chen, Junjie <chenjunjie@huawei.com>
2024-04-10 14:46:00 +00:00

36 lines
5.8 KiB
HTML

<a name="dcs-migration-0312010"></a><a name="dcs-migration-0312010"></a>
<h1 class="topictitle1">Self-Hosted Redis Migration with redis-cli (AOF)</h1>
<div id="body1521621550550"><div class="section" id="dcs-migration-0312010__section6939586315"><h4 class="sectiontitle">Introduction</h4><p id="dcs-migration-0312010__p98811414163215">redis-cli is the command line tool of Redis, which can be used after you install the Redis server.</p>
<p id="dcs-migration-0312010__p745081364515">Run the following command to download Redis:</p>
<p id="dcs-migration-0312010__p820445422318"><strong id="dcs-migration-0312010__b113982613241">wget http://download.redis.io/releases/redis-5.0.8.tar.gz</strong></p>
<p id="dcs-migration-0312010__p1458314211314">This section describes how to use redis-cli to migrate a data from a self-hosted Redis instance to a DCS instance.</p>
</div>
<div class="section" id="dcs-migration-0312010__section715982193316"><h4 class="sectiontitle">Step 1: Generating an AOF File</h4><div class="notice" id="dcs-migration-0312010__note17694182220346"><span class="noticetitle"><img src="public_sys-resources/notice_3.0-en-us.png"> </span><div class="noticebody"><ul id="dcs-migration-0312010__ul4345165217345"><li id="dcs-migration-0312010__li16345115233416">Before data migration, suspend your services so that data changes newly generated will not be lost during the migration.</li><li id="dcs-migration-0312010__li13242550342">Migrate data during off-peak hours.</li></ul>
</div></div>
<p id="dcs-migration-0312010__p4810151843510">Run the following command to enable cache persistence and obtain an AOF persistence file:</p>
<p id="dcs-migration-0312010__p87621845165017"><strong id="dcs-migration-0312010__b3974185419506">redis-cli -h <em id="dcs-migration-0312010__i31180255112">{source_redis_address}</em> -p 6379 -a <em id="dcs-migration-0312010__i25352263012">{password}</em> config set appendonly yes</strong></p>
<p id="dcs-migration-0312010__p1274325217213">If the size of the AOF file does not change after you have enabled persistence, the AOF file contains full cached data.</p>
<div class="note" id="dcs-migration-0312010__note183105714711"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="dcs-migration-0312010__ul14169633163914"><li id="dcs-migration-0312010__li15169233123919">To find out the path for storing the AOF file, use redis-cli to access the Redis instance, and run the <strong id="dcs-migration-0312010__b61691633143916">config get dir</strong> command. Unless otherwise specified, the file is named as <strong id="dcs-migration-0312010__b9514329195810">appendonly.aof</strong> by default.</li><li id="dcs-migration-0312010__li151694330394">To disable synchronization after the AOF file is generated, use redis-cli to log in to the Redis instance and run the <strong id="dcs-migration-0312010__b171692033103916">config set appendonly no</strong> command.</li></ul>
</div></div>
</div>
<div class="section" id="dcs-migration-0312010__section1146318206338"><h4 class="sectiontitle">Step 2: Uploading the AOF file to ECS</h4><ol id="dcs-migration-0312010__ol24089454211"><li id="dcs-migration-0312010__li4853142144220">To save the transmission time, compress the AOF file before transmission.</li><li id="dcs-migration-0312010__li84081442422">Upload the compressed file to ECS using an appropriate mode (for example, SFTP mode).</li></ol>
<div class="note" id="dcs-migration-0312010__note22211616174320"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="dcs-migration-0312010__dcs-migration-0312012_p1922181634311">Ensure that the ECS has sufficient disk space for data file decompression, and can communicate with the DCS instance. Generally, the ECS and DCS instance are configured to belong to the same VPC and subnet, and the configured security group rules do not restrict access ports. For details about how to configure a security group, see <a href="en-us_topic_0090662012.html">Security Group Configurations</a>.</p>
</div></div>
</div>
<div class="section" id="dcs-migration-0312010__section1458283216500"><h4 class="sectiontitle">Step 3: Importing Data</h4><p id="dcs-migration-0312010__p011163204217"><strong id="dcs-migration-0312010__b278592218432">redis-cli -h {dcs_instance_address} -p <em id="dcs-migration-0312010__i1590341311434">6379</em> -a {password} --pipe &lt; appendonly.aof</strong></p>
</div>
<div class="section" id="dcs-migration-0312010__section1762337185412"><h4 class="sectiontitle">Step 4: Verifying Migration</h4><p id="dcs-migration-0312010__p279273895413">After the data is imported successfully, access the DCS instance and run the <strong id="dcs-migration-0312010__b4358102614910">info</strong> command to check whether the data has been successfully imported as required.</p>
<p id="dcs-migration-0312010__p1692631220146">If the data import fails, analyze the cause, modify the data import statement, run the <strong id="dcs-migration-0312010__b2512221013">flushall</strong> or <strong id="dcs-migration-0312010__b179081749105">flushdb</strong> command to clear the cached data in the instance, and import the data again.</p>
</div>
<div class="section" id="dcs-migration-0312010__section12903941155218"><h4 class="sectiontitle">Efficiency of Data Export and Import</h4><p id="dcs-migration-0312010__p187251431124014">An AOF file can be generated quickly. It applies to scenarios where you can access the Redis server and modify the configurations, such as scenarios with self-built Redis servers.</p>
<p id="dcs-migration-0312010__p106998316559">It takes 4s to 10s to import 1 million data records (20 bytes per data record) in a VPC.</p>
</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>