本文介绍了部署管理器Cloud SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Deployment Manager创建具有故障转移副本的CloudSQL实例.

I am trying to create CloudSQL Instance with Failover Replica using Deployment Manager.

我能够创建一个只读副本,但无法创建故障转移副本.

I am able to create a Read Replica but couldn't create Failover Replica.

能否请您向我提供一个Deployment Manager脚本或向我建议以下代码的更改:

Can you please provide me a Deployment Manager Script or suggest me with the changes to the code below:

https://github.com/GoogleCloudPlatform /deploymentmanager-samples/tree/master/examples/v2/sqladmin/jinja

谢谢

推荐答案

此处您将获得有关如何创建具有高可用性的CloudSQL数据库(主+故障转移副本)的教程.

Here you have a tutorial on how to create a CloudSQL database with high availability (Master + Failover replica).

为此,Deployment Manager并没有真正起作用.如果要使用控制台,我将继续介绍如何使用gcloud SDK创建数据库和副本.

For this purpose the Deployment Manager doesn't really make a difference. I will go on how to create the database and replica with the gcloud SDK, if you want to use the console it's explained on the link I provided.

使用以下命令从Cloud Shell创建数据库和副本:

Create the database and replica from the Cloud Shell with this command:

gcloud sql instances create [MASTER INSTANCE NAME]  --enable-bin-log --backup-start-time=00:01 --failover-replica-name=[FAILOVER INSTANCE NAME]

检查其余选项,以在此处创建 gcloud sql实例. 为此,需要启用--enable-bin-log标志,并且由于具有二进制日志,因此需要启用备份. "backup-start-time =以UTC时间表示.

Check the rest of the options for gcloud sql instances create here. You need the flags --enable-bin-log enabled for this, and as you have binary logs you need to enable the backups. The "backup-start-time=" is in UTC time.

现在,您面临的主要问题是您想修改该模板以部署主副本和故障转移副本,但是该模板正在部署FIRST GENERATION实例(请参见"replicationType:SYNCHRONOUS"值),并进行故障转移副本仅限于SECOND GENERATION实例.

NOW, the main issue you are facing is that you want to modify that template to deploy a master and failover replica, but the template is deploying a FIRST GENERATION instance (see the "replicationType: SYNCHRONOUS" value), and the failover replica is limited to SECOND GENERATION instances.

您要完成的API请求将如下所示:

The API request for what you are trying to accomplish would go something like this:

{
 "name": "master-db",
 "settings": {
  "tier": "db-n1-standard-1",
  "backupConfiguration": {
   "binaryLogEnabled": true,
   "startTime": "00:01",
   "enabled": true
  }
 },
 "failoverReplica": {
  "name": "failover-db"
 }
}

检查 sqladmin API资源管理器页面以轻松探索不同的可能值.然后将调用转换为Jinja模板应该很容易.

Check the sqladmin API explorer page to explore the different possible values easily. Afterwards converting the calls to a jinja template should be easy.

这篇关于部署管理器Cloud SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 16:35