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

Google cloud platform 有没有办法获得Google Cloud SQL故障转移副本实例的详细信息?,google-cloud-platform,google-cloud-sql,Google Cloud Platform,Google Cloud Sql,我知道我可以使用gcloud sql instances Descripte或Cloud sql REST API获取云sql实例的详细信息,并且我还可以在完成故障转移后获取辅助区域,例如gceZone 在为云SQL实例启用高可用性区域功能后,是否有方法获取云SQL故障转移副本实例的详细信息 有没有办法获取云SQL故障转移副本实例的详细信息 不,以前可以在第一代云SQL实例中查看主实例的相应云SQL故障转移副本,但后来随着第二代实例的到来而发生了更改 因此,该信息现在从用户的角度被屏蔽 如果您真

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

在为云SQL实例启用高可用性区域功能后,是否有方法获取云SQL故障转移副本实例的详细信息

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

不,以前可以在第一代云SQL实例中查看主实例的相应云SQL故障转移副本,但后来随着第二代实例的到来而发生了更改

因此,该信息现在从用户的角度被屏蔽

如果您真的想看到它,可以这样做,并且主实例将被故障转移副本替换

您可以尝试在触发故障切换时运行gcloud sql instances description,以查看是否可以看到有关故障切换的更多详细信息,但我无法向您确认它是否会提供更多信息


我希望它能有所帮助。

正如John也提到的,您可以使用云SQL管理API:

获取设置版本:

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

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

  {
 "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"
}
使用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)

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