【问题标题】:Is there a way to get the details of a Google Cloud SQL failover replica instance?有没有办法获取 Google Cloud SQL 故障转移副本实例的详细信息?
【发布时间】:2019-12-30 14:18:29
【问题描述】:

我知道我可以使用gcloud sql instances describe 或 Cloud SQL REST API 来获取 Cloud SQL 实例的详细信息,并且我还可以在故障转移完成后获取辅助区域(例如 gceZone)。

为 Cloud SQL 实例启用高可用性(区域)功能后,是否可以获取 Cloud SQL 故障转移副本实例的详细信息?

【问题讨论】:

  • 故障转移副本名称由密钥 failoverReplica 下的 REST API 返回。使用failoverReplica.name,您可以获取有关故障转移副本的详细信息。

标签: google-cloud-platform google-cloud-sql


【解决方案1】:

正如 John 还提到的,您可以使用 Cloud SQL Admin API:Method: instances.failover

  1. 获取设置版本:

      gcloud sql instances describe my-instance | grep settingsVersion
    
  2. 设置请求参数:

      project = your-project
      instance = your-instance
      Request body = {
        "failoverContext": {
          "settingsVersion": "settingsVersion you got from command 1",
          "kind": "sql#failoverContext"
          }
      }
    
  3. 回复:

      {
     "kind": "sql#operation",
     "targetLink": "https://content- 
     sqladmin.googleapis.com/sql/v1beta4/projects/my-project/instances/my-instance
     "status": "PENDING",
     "user": "user@gmail.com",
     "insertTime": "2019-12-30T16:30:29.446Z",
     "operationType": "FAILOVER",
     "name": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
     "targetId": "my-instance
     "selfLink": "https://content-sqladmin.googleapis.com/sql/v1beta4/projects/my-projects/operations/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
     "targetProject": "my-project"
    }
    
  4. 使用 curl 命令:

      curl --request POST \
     'https://sqladmin.googleapis.com/sql/v1beta4/projects/my-project/instances/my-instance/failover' \
          --header 'Authorization: Bearer $ACCESS_TOKEN' \
          --header 'Accept: application/json' \
          --header 'Content-Type: application/json' \
          --data '{"failoverContext":{"kind":"sql#failoverContext","settingsVersion" $SETTINGS_VERSION:}}' \
          --compressed 
    
      where ACCESS_TOKEN=$(gcloud auth print-access-token)
    

【讨论】:

    【解决方案2】:

    有没有办法获取 Cloud SQL 故障转移副本实例的详细信息?

    ,以前可以在第一代 Cloud SQL 实例中查看主实例对应的 Cloud SQL 故障转移副本,但后来随着第二代实例的到来发生了变化。

    因此,现在从用户的角度来看,此信息已被隐藏。

    如果你真的想看,可以trigger a failover manually,主实例将被故障转移副本替换。

    您可以尝试在触发故障转移时运行 gcloud sql instances describe,以查看是否可以看到有关故障转移的任何更多详细信息,但我无法确认它会为您提供任何更多信息。

    希望对你有帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-12-20
      • 1970-01-01
      • 2021-09-12
      • 2023-02-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多