[英]Cannot create google cloud sql instance using gcloud cli because it is taking too long
I am running the following command using the gcloud cli tool...我正在使用 gcloud cli 工具运行以下命令...
gcloud sql instances create sql-db-1 --database-version=MYSQL_8_0 --region=us-central --tier=db-f1-micro
It sits in the terminal for a long time with the following output...它与以下 output 长时间坐在终端中......
Creating new cloud sql instance...
and then finally fails with...然后最终失败了......
ERROR: (gcloud.sql.instances.create) Operation https://sqladmin.googleapis.com/sql/v1beta4/projects/my-project/operations/0d9534c4-9c70-4a77-86a9-ae5c6d3b5fd8 is taking longer than expected. You can continue waiting for the operation by running `gcloud beta sql operations wait --project my-project 0d9534c4-9c70-4a77-86a9-ae5c6d3b5fd8`
Status : FAIL 1 b''
This same command was working for me reliably, and then all of a sudden it just started doing this.同样的命令对我来说很可靠,然后突然间它就开始这样做了。
When you execute the command line, it creates the Cloud SQL instance, but the CLI throws an ERROR making you think that this wasn't created;当您执行命令行时,它会创建 Cloud SQL 实例,但 CLI 会抛出一个错误,让您认为这不是创建的; so I opened an issue tracker report for you.
所以我为你打开了一个问题跟踪报告。
Meanwhile you can also run after the error:同时你也可以在报错后运行:
gcloud beta sql operations wait --project my-project xxxxxxxxxxxxxxxxxxxxxx
And wait for the operation to complete.并等待操作完成。 After that, you must see STATUS as DONE:
之后,您必须看到 STATUS 为 DONE:
NAME TYPE START END ERROR STATUS
XXXXXXXXXXXXXXXXXXXXXXXXX CREATE 2022-03-09T21:53:40.532+00:00 2022-03-09T22:06:53.389+00:00 - DONE
When you open this link in the ERROR:当您在错误中打开此链接时:
https://sqladmin.googleapis.com/sql/v1beta4/projects/my-project/operations/0d9534c4-9c70-4a77-86a9-ae5c6d3b5fd8
You will get:你会得到:
{
"error": {
"code": 401,
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"errors": [
{
"message": "Login Required.",
"domain": "global",
"reason": "required",
"location": "Authorization",
"locationType": "header"
}
],
"status": "UNAUTHENTICATED",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "CREDENTIALS_MISSING",
"domain": "googleapis.com",
"metadata": {
"service": "sqladmin.googleapis.com",
"method": "google.cloud.sql.v1beta4.SqlOperationsService.Get"
}
}
]
}
}
You'll need to run the Cloud SQL Auth Proxy locally to mimic what Cloud Run does for.您需要在本地运行 Cloud SQL Auth Proxy 来模拟 Cloud Run 的用途。
gcloud auth login
)gcloud auth login
)./cloud_sql_proxy -instances=my-project:my-region:my-instance -dir ./cloudsql
Then the Proxy will create a Unix socket at ./cloudsql/my-project:my-region:my-instance
.然后代理将在
./cloudsql/my-project:my-region:my-instance
创建一个 Unix 套接字。
Note: to make this most like Cloud Run, you can always create a /cloudsql
directory at the root.注意:要使其最像 Cloud Run,您始终可以在根目录下创建一个
/cloudsql
目录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.