簡體   English   中英

無法使用 gcloud cli 創建 google cloud sql 實例,因為它花費的時間太長

[英]Cannot create google cloud sql instance using gcloud cli because it is taking too long

我正在使用 gcloud cli 工具運行以下命令...

gcloud sql instances create sql-db-1 --database-version=MYSQL_8_0 --region=us-central --tier=db-f1-micro

它與以下 output 長時間坐在終端中......

Creating new cloud sql instance...

然后最終失敗了......

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''

同樣的命令對我來說很可靠,然后突然間它就開始這樣做了。

當您執行命令行時,它會創建 Cloud SQL 實例,但 CLI 會拋出一個錯誤,讓您認為這不是創建的; 所以我為你打開了一個問題跟蹤報告

同時你也可以在報錯后運行:

gcloud beta sql operations wait --project my-project xxxxxxxxxxxxxxxxxxxxxx

並等待操作完成。 之后,您必須看到 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

當您在錯誤中打開此鏈接時:

https://sqladmin.googleapis.com/sql/v1beta4/projects/my-project/operations/0d9534c4-9c70-4a77-86a9-ae5c6d3b5fd8

你會得到:

{
  "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"
        }
      }
    ]
  }
}

您需要在本地運行 Cloud SQL Auth Proxy 來模擬 Cloud Run 的用途。

  1. 此處下載最新版本
  2. 確保您擁有一組有效的 gcloud 憑據(即gcloud auth login
  3. 使用如下內容在終端中啟動代理:
./cloud_sql_proxy -instances=my-project:my-region:my-instance -dir ./cloudsql

然后代理將在./cloudsql/my-project:my-region:my-instance創建一個 Unix 套接字。

注意:要使其最像 Cloud Run,您始終可以在根目錄下創建一個/cloudsql目錄。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM