详情页标题前

阿里云RDS数据库修改pg_hba.conf文件配置-云淘科技

详情页1

本文介绍如何使用Terraform修改pg_hba.conf文件配置

前提条件

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

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

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

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

操作步骤

说明

通过terraform修改pg_hba.conf文件配置时,会覆盖原默认配置。

  1. terraform.tf配置文件的中resource "alicloud_db_instance" "instance"中,补充pg_hba_conf配置项,具体配置如下。

    resource "alicloud_db_instance" "instance" {
    ...
      pg_hba_conf  {
          type =  "host"
          database = "all"
          user = "all"
          address = "127.0.0.1"
          method = "md5"
          priority_id = 1
      }
    }
  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-****]
    alicloud_db_account.account: Refreshing state... [id=pgm-****:tf_account_test]
    
    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-****"
            # (34 unchanged attributes hidden)
    
          + pg_hba_conf {
              + address     = "127.0.0.1"
              + database    = "all"
              + method      = "md5"
              + priority_id = 1
              + type        = "host"
              + user        = "all"
            }
        }
    
    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=****]
    alicloud_db_instance.instance: Still modifying... [id=pgm-****], 10s elapsed]
    ...
    alicloud_db_instance.instance: Still modifying... [id=pgm-****], 1m10s elapsed]
    alicloud_db_instance.instance: Modifications complete after 1m18s [id=pgm-****]]
    
    Apply complete! Resources: 0 added, 1 changed, 0 destroyed.
  3. 查看结果。

    • 运行terraform show查看pg_hba.conf文件配置。

      # alicloud_db_account.account:
      resource "alicloud_db_account" "account" {
          account_name     = "tf_account_test"
          account_password = (sensitive value)
          account_type     = "Normal"
          db_instance_id   = "pgm-****"
          id               = "pgm-****:tf_account_test"
          instance_id      = "pgm-****"
          name             = "tf_account_test"
          status           = "Available"
          type             = "Normal"
      }
      
      # 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_20220730"
          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控制台查看pg_hba.conf文件配置。阿里云RDS数据库修改pg_hba.conf文件配置-云淘科技

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

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

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

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

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

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

(0)
上一篇 2023年12月9日 下午7:50
下一篇 2023年12月9日
详情页2

相关推荐

  • 阿里云云原生大数据计算服务 MaxCompute参考:渐进式计算-云淘科技

    渐进式计算(Progressive Computing)是处于传统的流计算和批处理之间的一种计算方式,具有高资源利用率和低延迟的优势。本文为您介绍渐进式计算的基础配置、作业调优配置以及使用示例。 背景信息 渐进式计算能够处理增量数据并维护中间结果数据,提高了在计算资源消耗、执行时间调度、查询延迟、数据处理粒度等方面的灵活性。例如在范围查询(Range Que…

    2023年12月10日
  • 阿里云RDS数据库查看实例参数-云淘科技

    您可以通过云数据库RDS控制台或命令查看当前实例的参数配置。 方法一:通过控制台查看 访问RDS实例列表,在上方选择地域,然后单击目标实例ID。 在左侧导航栏中,单击参数设置,即可在参数列表中查看到每个参数的配置。 说明 参数列表中仅包含支持修改的参数,如需查看实例的所有参数配置,请参见方法二:通过命令查看。 方法二:通过命令查看 通过客户端、命令行连接RD…

    阿里云数据库 2023年12月9日
  • 信息流广告,信息流部分建议宽度830px,只针对默认列表样式,顺序随机
  • 阿里云日志服务SLS合并集合去重机制-云淘科技

    告警管理系统接收到告警后,按照路由合并策略对符合条件的告警进行合并分组,并归到合并集合中。合并集合在经过抑制、静默、去重等操作后,被发送到行动(通知)管理系统中进行告警通知。 路由合并规则 告警路由合并基于合并基准、行动策略、首次等待时间、变化等待时间和重复等待时间完成。只有上述配置完全相同时,才会被归到同一个合并集合中。 例如某服务中的2个主机分别从20:…

    2023年12月10日
  • 阿里云对象存储OSSPython生命周期-云淘科技

    OSS支持设置Bucket生命周期(Lifecycle)规则,自动删除过期的文件(Object)和碎片,或将到期的文件转储为低频或归档存储类型,从而节省存储费用。本文介绍如何管理存储空间(Bucket)的生命周期规则。 注意事项 本文以华东1(杭州)外网Endpoint为例。如果您希望通过与OSS同地域的其他阿里云产品访问OSS,请使用内网Endpoint。…

    阿里云对象存储 2023年12月10日
  • 阿里云日志服务SLSCLI概述-云淘科技

    为满足越来越多的自动化日志服务配置需求,日志服务提供命令行工具CLI(Command Line Interface)。 主要功能 日志服务命令行工具CLI的主要功能包括: 支持大部分的日志服务REST接口。例如管理Project、Logstore、机器组、消费组和Logtail配置等。 支持多账号,便于跨地域操作日志。 支持基本查询和拉取日志。 支持Elas…

    阿里云日志服务SLS 2023年12月10日

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

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

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