简体   繁体   English

将数据从Google Cloud-SQL移至Cloud Datastore

[英]Move data from Google Cloud-SQL to Cloud Datastore

I am trying to move my data from Cloud SQL to Cloud Datastore. 我正在尝试将数据从Cloud SQL移到Cloud Datastore。

There are a bit under 5 million entries in the SQL database. SQL数据库中的条目少于500万。

It seems like I can only move over 100,000 entities per day before I get a quota error. 似乎我每天只能移动超过100,000个实体,然后才能收到配额错误。

I can't figure out which exact quota I'm exceeding, however I have exponential backoff to make sure I'm not sending it too fast. 我无法弄清楚我超出了哪个确切的配额,但是我有指数补偿以确保我发送的速度不会太快。

Eventually it hits 5 minutes and the connection to the SQL server dies, but I don't think the writes per second quota is the problem. 最终它达到5分钟,并且与SQL Server的连接中断,但是我认为每秒写入的配额不是问题。 And I don't see any other quota exceeding in my APIs page or the App Engine API page. 而且我的API页或App Engine API页中没有其他配额超出限制。

I have tried two different APIs to write the records. 我尝试了两种不同的API来编写记录。

The GCP Datastore API GCP数据存储区API

import googledatastore 导入googledatastore
Here is the code: 这是代码:
https://gist.github.com/nburn42/d8b488da1d2dc53df63f4c4a32b95def https://gist.github.com/nburn42/d8b488da1d2dc53df63f4c4a32b95def

And the Dataflow API 和数据流API
from apache_beam.io.gcp.datastore.v1.datastoreio import WriteToDatastore 从apache_beam.io.gcp.datastore.v1.datastoreio导入WriteToDatastore
Here is the code: 这是代码:
https://gist.github.com/nburn42/2c2a06e383aa6b04f84ed31548f1cb09 https://gist.github.com/nburn42/2c2a06e383aa6b04f84ed31548f1cb09

Here is the error I see after one or two hundred thousand good writes. 这是我在一二十万次良好写入后看到的错误。
RPCError: datastore call commit [while running 'Write To Datastore/Write Mutation to Datastore'] failed: Error code: RESOURCE_EXHAUSTED. RPCError:数据存储区调用提交[在运行“写入数据存储区/将突变写入数据存储区”时]失败:错误代码:RESOURCE_EXHAUSTED。 Message: Quota exceeded. 消息:超出配额。

I'm running this on compute engine. 我正在计算引擎上运行它。

Any help is greatly appreciated! 任何帮助是极大的赞赏! Thanks, 谢谢,
Nathan 内森

I asked for a quota increase and someone at google checked my account to find the problem. 我要求增加配额,谷歌的某个人检查了我的帐户以发现问题。

Here is their reply. 这是他们的答复。

I understand that you want to know what specific quota you are reaching whenever you try to backup your Cloud SQL to Cloud Datastore. 我了解您想知道在尝试将Cloud SQL备份到Cloud Datastore时达到的特定配额。

Upon checking your project, it seems that the problem is that your App Engine application is at or near its spending limit. 在检查您的项目后,看来问题出在您的App Engine应用程序已达到或接近其支出限额。 As of this time of writing, the Datastore Write Operations you have executed costed you 1.10$, which will be refreshed after 5 hours. 截至撰写本文时,您执行的数据存储区写入操作的费用为1.10美元,将在5小时后刷新。 It can definitely cause your resources to become unavailable until the daily spending limit is replenished. 肯定会导致您的资源在补充每日支出限额之前变得不可用。 Kindly try to increase your spending limit as soon as possible to avoid service interruption and then run or execute your datastore write operations. 请尝试尽快增加支出限额,以避免服务中断,然后运行或执行数据存储区写操作。

Give this a shot and let me know what happens. 试试看,让我知道会发生什么。 I will be looking forward to your reply. 我期待着您的答复。

This fixed the problem. 这解决了问题。 I just needed to go into app engine and set a much higher daily spending limit. 我只需要进入应用程序引擎并设置更高的每日支出限额即可。

Hopefully the code I included above will help others. 希望我上面包含的代码对其他人有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM