详情页标题前

阿里云RDS数据库版本升级-云淘科技

详情页1

本文介绍如何使用Terraform升级RDS PostgreSQL实例版本

前提条件

  • 已创建RDS PostgreSQL实例,详情请参见创建RDS PostgreSQL实例。

  • 实例状态为运行中,您可以通过如下两种方式查看:

    • 参见查询实例详情查看参数status,如果取值为Runing则表示实例状态为运行中。

    • 前往RDS管理控制台,切换到目标地域,找到指定实例后,查看实例状态。

升级实例内核小版本

以升级RDS PostgreSQL实例内核小版本到20220830为例。

  1. 在terraform.tf文件的resource "alicloud_db_instance" "instance" {}中增加target_minor_version配置项,具体配置如下:

    ...
    resource "alicloud_db_instance" "instance" {
    ...
      target_minor_version = "rds_postgres_1300_20220830"
    }

    说明

    小版本号rds_postgres_1300_20220830各字段含义:

    • rds:RDS实例。

    • postgres:PostgreSQL数据库。

    • 1300:PostgreSQL大版本为13。

    • 20220830:AliPG内核小版本,支持设置20220130或以上版本。各小版本的具体信息,请参见AliPG内核小版本发布记录。

  2. 运行terraform apply

    出现如下配置信息后,确认配置信息并输入yes,开始修改实例配置。

    alicloud_vpc.main: Refreshing state... [id=vpc-****]
    alicloud_vswitch.main: Refreshing state... [id=vsw-****]
    alicloud_db_instance.instance: Refreshing state... [id=pgm-****]
    
    Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the
    following symbols:
      ~ update in-place
    
    Terraform will perform the following actions:
    
      # alicloud_db_instance.instance will be updated in-place
      ~ resource "alicloud_db_instance" "instance" {
            id                         = "pgm-****"
          ~ target_minor_version       = rds_postgres_1300_20220730 -> rds_postgres_1300_20220830
            # (31 unchanged attributes hidden)
        }
    
    Plan: 0 to add, 1 to change, 0 to destroy.
    
    Do you want to perform these actions?
      Terraform will perform the actions described above.
      Only 'yes' will be accepted to approve.
    
      Enter a value:

    出现类似如下日志时,表示升级成功。

    alicloud_db_instance.instance: Modifying... [id=pgm-****]
    alicloud_db_instance.instance: Still modifying... [id=pgm-****, 10s elapsed]
    ......
    alicloud_db_instance.instance: Still modifying... [id=pgm-****, 4m0s elapsed]
    alicloud_db_instance.instance: Modifications complete after 4m1s [id=pgm-***]
    
    Apply complete! Resources: 0 added, 1 changed, 0 destroyed.
  3. 查看结果。

    • 运行terraform show查看RDS PostgreSQL实例内核小版本。

      # alicloud_db_instance.instance:
      resource "alicloud_db_instance" "instance" {
          client_ca_enabled          = 0
          client_crl_enabled         = 0
          connection_string          = "pgm-****.pg.rds.aliyuncs.com"
          connection_string_prefix   = "pgm-****"
          db_instance_storage_type   = "cloud_essd"
          db_time_zone               = "Asia/Shanghai"
          deletion_protection        = false
          engine                     = "PostgreSQL"
          engine_version             = "13.0"
          force_restart              = false
          ha_config                  = "Auto"
          id                         = "pgm-****"
          instance_charge_type       = "Postpaid"
          instance_name              = "terraformtest"
          instance_storage           = 50
          instance_type              = "pg.n2.2c.2m"
          maintain_time              = "05:00Z-06:00Z"
          monitoring_period          = 300
          period                     = 0
          port                       = "5432"
          private_ip_address         = "172.16.XX.XX"
          resource_group_id          = "rg-****"
          security_group_ids         = []
          security_ip_mode           = "normal"
          security_ips               = [
              "127.0.0.1",
          ]
          sql_collector_config_value = 30
          sql_collector_status       = "Disabled"
          storage_auto_scale         = "Enable"
          storage_threshold          = 30
          storage_upper_bound        = 100
          target_minor_version       = "rds_postgres_1300_20220830"
          tcp_connection_type        = "SHORT"
          vpc_id                     = "vpc-****"
          vswitch_id                 = "vsw-****"
          zone_id                    = "cn-hangzhou-h"
      
          pg_hba_conf {
              address     = "127.0.0.1"
              database    = "all"
              method      = "md5"
              priority_id = 1
              type        = "host"
              user        = "all"
          }
      }
                                      
    • 登录RDS控制台查看RDS PostgreSQL实例内核小版本。阿里云RDS数据库版本升级-云淘科技

升级实例大版本

以将实例pgm-****的大版本由RDS PostgreSQL 13升级为RDS PostgreSQL 14为例。

  1. 在terraform.tf文件中增加resource "alicloud_rds_upgrade_db_instance" "upgrade" {}配置项,具体配置如下:

    ...
    resource "alicloud_rds_upgrade_db_instance" "upgrade" {
      source_db_instance_id    = alicloud_db_instance.instance.id
      target_major_version     = "14.0"
      db_instance_class        = "pg.n2.2c.2m"
      db_instance_storage      = "50"
      instance_network_type    = "VPC"
      db_instance_storage_type = "cloud_essd"
      collect_stat_mode        = "After"
      switch_over              = "false"
      payment_type             = "PayAsYouGo"
      vswitch_id               = alicloud_vswitch.main.id
    }
  2. 运行terraform apply开始升级RDS PostgreSQL实例大版本。

    出现如下配置信息后,确认配置信息并输入yes,开始升级。

    alicloud_vpc.main: Refreshing state... [id=vpc-****]
    alicloud_vswitch.main: Refreshing state... [id=vsw-****]
    alicloud_db_instance.instance: Refreshing state... [id=pgm-****]
    
    Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the
    following symbols:
      + create
    
    Terraform will perform the following actions:
    
      # alicloud_rds_upgrade_db_instance.upgrade will be created
      + resource "alicloud_rds_upgrade_db_instance" "upgrade" {
          + acl                        = (known after apply)
          + auto_upgrade_minor_version = (known after apply)
          + ca_type                    = (known after apply)
          + collect_stat_mode          = "After"
          + connection_string          = (known after apply)
          + db_instance_class          = "pg.n2.2c.2m"
          + db_instance_description    = (known after apply)
          + db_instance_storage        = 50
          + db_instance_storage_type   = "cloud_essd"
          + engine                     = (known after apply)
          + engine_version             = (known after apply)
          + ha_mode                    = (known after apply)
          + id                         = (known after apply)
          + instance_network_type      = "VPC"
          + maintain_time              = (known after apply)
          + payment_type               = "PayAsYouGo"
          + port                       = (known after apply)
          + private_ip_address         = (known after apply)
          + replication_acl            = (known after apply)
          + security_ips               = (known after apply)
          + server_cert                = (known after apply)
          + server_key                 = (known after apply)
          + source_db_instance_id      = "pgm-****"
          + ssl_enabled                = (known after apply)
          + switch_over                = "false"
          + sync_mode                  = (known after apply)
          + target_major_version       = "14.0"
          + tcp_connection_type        = (known after apply)
          + vpc_id                     = (known after apply)
          + vswitch_id                 = "vsw-****"
          + zone_id                    = (known after apply)
          + zone_id_slave_1            = (known after apply)
    
          + parameters {
              + name  = (known after apply)
              + value = (known after apply)
            }
        }
    
    Plan: 1 to add, 0 to change, 0 to destroy.
    
    Do you want to perform these actions?
      Terraform will perform the actions described above.
      Only 'yes' will be accepted to approve.
    
      Enter a value:

    出现类似如下日志时,表示升级成功。

    alicloud_rds_upgrade_db_instance.upgrade: Creating...
    alicloud_rds_upgrade_db_instance.upgrade: Still creating... [10s elapsed]
    ...
    alicloud_rds_upgrade_db_instance.upgrade: Still creating... [23m41s elapsed]
    alicloud_rds_upgrade_db_instance.upgrade: Creation complete after 23m51s [id=pgm-****]
    
    Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
  3. 查看结果。

    • 运行terraform show查看升级的RDS PostgreSQL实例。

      # alicloud_rds_upgrade_db_instance.upgrade:
      resource "alicloud_rds_upgrade_db_instance" "upgrade" {
          collect_stat_mode        = "After"
          connection_string        = "pgm-****.pg.rds.aliyuncs.com"
          db_instance_class        = "pg.n2.2c.2m"
          db_instance_description  = "Upgrade from pgm-****"
          db_instance_storage      = 50
          db_instance_storage_type = "cloud_essd"
          deletion_protection      = false
          engine                   = "PostgreSQL"
          engine_version           = "14.0"
          ha_mode                  = "RPO"
          id                       = "pgm-****"
          instance_network_type    = "VPC"
          maintain_time            = "18:00Z-22:00Z"
          payment_type             = "PayAsYouGo"
          port                     = "5432"
          private_ip_address       = "172.16.XX.XX"
          security_ips             = [
              "127.0.0.1",
          ]
          source_db_instance_id    = "pgm-****"
          switch_over              = "false"
          sync_mode                = "Async"
          target_major_version     = "14.0"
          tcp_connection_type      = "LONG"
          vpc_id                   = "vpc-****"
          vswitch_id               = "vsw-****"
          zone_id                  = "cn-hangzhou-h"
      }
    • 登录RDS控制台查看升级的RDS PostgreSQL实例。阿里云RDS数据库版本升级-云淘科技

内容没看懂? 不太想学习?想快速解决? 有偿解决: 联系专家

阿里云企业补贴进行中: 马上申请

腾讯云限时活动1折起,即将结束: 马上收藏

同尘科技为腾讯云授权服务中心。

购买腾讯云产品享受折上折,更有现金返利:同意关联,立享优惠

转转请注明出处:https://www.yunxiaoer.com/167509.html

(0)
上一篇 2023年12月10日
下一篇 2023年12月10日
详情页2

相关推荐

  • 阿里云负载均衡释放负载均衡实例-云淘科技

    您可以根据需要删除CLB实例,避免不必要的计费。删除CLB实例不会删除后端ECS,也不会影响后端ECS的运行。 前提条件 在释放CLB实例前,确保您已经关闭了删除保护开关。 背景信息 释放CLB实例前,您需要了解以下信息:警告 如果您已经将一个域名解析至CLB实例的公网服务地址,在释放CLB实例之前,建议先将该自定义域名解析至另外一个负载均衡实例,避免业务中…

    2023年12月10日
  • 阿里云RDS数据库DeleteSlot – 删除PostgreSQL实例Replication Slot-云淘科技

    该接口用于删除实例的指定Replication Slot。 接口说明 适用引擎 RDS PostgreSQL 注意事项 仅当Replication Slot的状态(SlotStatus)为INACTIVE时,可以被删除。您可以调用DescribeSlots接口查询Replication Slot状态。 调试 您可以在OpenAPI Explorer中直接运行…

    阿里云数据库 2023年12月9日
  • 阿里云RDS数据库CopyDatabaseBetweenInstances – RDS SQL Server实例间复制数据库-云淘科技

    该接口用于在RDS SQL Server实例间复制数据库。 接口说明 适用引擎 RDS SQL Server 相关功能文档 注意 使用该接口前,请仔细阅读功能文档,确保完全了解使用接口的前提条件及使用后造成的影响后,再进行操作。 RDS SQL Server实例间数据库复制 调试 您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰…

    阿里云数据库 2023年12月9日
  • 阿里云ECS云服务器通过会话管理连接实例-云淘科技

    会话管理(Session Manager)是由云助手提供的功能,相比SSH、VNC等方式,可以更便捷地远程连接ECS实例,且兼具安全性。 会话管理涉及以下客户端和服务端,关于具体会话管理工作原理信息,请参见会话管理工作原理。 会话管理客户端:负责发起会话、接收用户输入并展示输出。 云助手服务端:负责权限控制、管理会话状态。 ECS实例内部的云助手Agent:…

    阿里云服务器 2023年12月9日
  • 信息流广告,信息流部分建议宽度830px,只针对默认列表样式,顺序随机
  • 阿里云RDS数据库变更配置-云淘科技

    本文说明RDS实例变更配置的费用。 按量付费实例变配费用 按量付费实例是每小时收费,变更配置后按照新的售价每小时收费。 包年包月实例变配费用 包年包月实例变配时会产生补差价或者退款。 升配:需选择立即升配,根据所选规格,需要支付差价。 降配:需选择立即降配,根据所选规格,系统会退还差价。 变配类型 费用说明 立即升配 支付费用 = 新配置剩余时长总价(新配置…

    阿里云数据库 2023年12月9日

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信
本站为广大会员提供阿里云、腾讯云、华为云、百度云等一线大厂的购买,续费优惠,保证底价,买贵退差。