当前位置:网站首页>Cloudbase database migration scheme
Cloudbase database migration scheme
2022-06-24 08:32:00 【songs of the people of Chu】
Function is introduced
Migration between cloud development database environments has always been a difficult problem , although SDK For a single set export and import, But to achieve the migration of the entire database is just 100 The first of the steps , The scheme is to introduce a method of A The environment database is migrated to B The idea of environmental database , For reference only .
Preparation needed
- Deploy the functions under the folder to the corresponding environment
- Created A Environment and B Environmental Science
- If the migrated environment is under another account , You need another account secretID and secretKey, And in init The two fields are added to the environment
- You can operate directly on the cloud development console , There is no need to initiate a call
- Set the timeout of the function to 900 second .
Resources used
- Cloud functions for both environments
- Cloud databases for both environments
- Cloud storage for the target environment
Function introduction
migrate
Migration functions , To be deployed to In a migrated environment
Remember to revise demo Environment in ID For your own environment ID
It is necessary to initiate the call , No parameters required .
It will be called exportDatabase Function to export data , And get an array of return values , The data format is roughly as follows
[
{
"result": {
"CollectionName": "test2Collection",
"exportRes": {
"JobId": 102223492,
"RequestId": "332f1595-9b64-4a42-a6b3-a0ca1e0b50e5"
}
},
"requestId": "ff84c3dc-d3fa-11eb-bb41-525400be5245"
},
{
"result": {
"CollectionName": "testCollection",
"exportRes": {
"JobId": 102223493,
"RequestId": "92b8e0b5-e4a9-43bd-b9ef-37e6abca8b83"
}
},
"requestId": "004ba931-d3fb-11eb-a0a6-52540096f86f"
}
]And then call copyDatabase, Migration
exportDatabase
The export function , To be deployed to In a migrated environment
By migrate call
copyDatabase
To be deployed to In a migrated environment
By migrate call
{
JobIdList:Array
}This function will initiate a call importDatabase, If returns success, The migration is successful .
importDatabase
Import function , To be deployed to Migrate to the target environment
This function receives CollectionName Function for collection import , Users do not need to actively invoke , The function is copyDatabase call .
Sequence diagram
Complete steps
- Deploy the function to the corresponding environment ( except importDatabase Is deployed to the target environment , The remaining three are migrated environments ), Remember that cloud installation depends on .
- call migrate( It is recommended that the console directly call )
- Wait for the return value
- Go to the new environment database to view the migration results
matters needing attention
- because export This interface can only be called once per second , So to be on the safe side , At the code level, each set is exported every second . therefore migrate This function will take a long time to call , It is recommended to wait patiently ( Every set needs about 2 second ), If the number of sets is large , It is recommended to adjust the function timeout upwards . If greater than 900 second , Consider using cloud hosting to implement .
- migrate All logic will be executed at once , Long running time , Please be patient , You can do other things while waiting .
- The export of each document is asynchronous and takes time , obtain migrate After the return value of , Please wait a while before calling copyDatabase, Since the size of each document is variable, the time is uncertain , But in copyDatabase Detection function is built in , If the call is initiated before the full export , This function will stop and prompt which item has not been exported yet , You can call .
- return success after , Go to the console to check that the collection has been created , But the number of documents is 0 The situation of , This is because the import is an asynchronous event , Creating collections and importing documents are not done at the same time , Just wait for a while .
- The number of documents is 0 Will be skipped .
- If a system error occurs , Internal errors, etc , You can appropriately increase the cloud function running memory .
- if migrate The function console appears ESOCKETTIMEDOUT Or other errors , But the other three functions all work well , That can be ignored , It depends on whether the database data of the target environment is migrated correctly .
- The cloud storage of the target environment is borrowed as the medium , If it is too large, it can be deleted , The catalogue is /tmp/db-imports
- Not rigorously tested , I don't know the performance limit yet , Current test 20+ aggregate , Hundreds of documents are OK .
Open source code
边栏推荐
- Synthesize video through ffmpeg according to m3u8 file of video on the network
- JUC personal simple notes
- 2021-03-11 COMP9021第八节课笔记
- 487. 最大连续1的个数 II ●●
- 新准则金融资产三分类:AMC、FVOCI和FVTPL
- How to configure networkpolicy for nodeport in kubernetes
- Micro build low code online "quick registration applet" capability
- Swift extension chainlayout (UI chain layout) (source code)
- Permission model DAC ACL RBAC ABAC
- SQL intra statement operation
猜你喜欢

小样本故障诊断 - 注意力机制代码 - BiGRU代码解析实现

For a detailed explanation of flex:1, flex:1

A preliminary study of IO model

2021-03-16 comp9021 class 9 notes

Small sample fault diagnosis - attention mechanism code - Implementation of bigru code parsing

Two methods of QT exporting PDF files

Opencv实现图像的基本变换
![3D数学基础[十七] 平方反比定理](/img/59/bef931d96883288766fc94e38e0ace.png)
3D数学基础[十七] 平方反比定理

Search and recommend those things

How to improve the customer retention rate in the operation of independent stations? Customer segmentation is very important!
随机推荐
Review SGI STL secondary space configurator (internal storage pool) | notes for personal use
The JS macro of WPS implements the separation method of picture text in the same paragraph
QPS, TPS, concurrent users, throughput relationship
Question 4 - datepicker date selector, disabling two date selectors (start and end dates)
Permission model DAC ACL RBAC ABAC
Future trends in automated testing
12--合并两个有序链表
JS scroll div scroll bar to bottom
搜索与推荐那些事儿
487. number of maximum consecutive 1 II ●●
Question bank and simulation examination for operation certificate of refrigeration and air conditioning equipment in 2022
3D数学基础[十七] 平方反比定理
Introduction to NC machine tool programming [G-code]
MAYA重新拓布
Export MySQL database to xxx SQL, set xxx The SQL file is imported into MySQL on the server. Project deployment.
Qt导出PDF文件的两种方法
2021-06-24: find the length of the longest non repeating character substring in a string.
李白最经典的20首诗排行榜
ZUCC_ Principles of compiling language and compilation_ Experiment 05 regular expression, finite automata, lexical analysis
贷款五级分类