IaC基础设施即代码:Terraform 连接 tencentcloud COS 实现多资源管理

发布时间:2024年01月24日

目录

?一、实验

1.环境

?2.Terraform 连接 tencentcloud 腾讯云COS

3.申请VPC专有网络资源

4.申请安全组资源

5.申请CVM资源

6.申请CLB资源

7.申请DNS资源

8.销毁资源

二、问题

1. Terraform申请安全组资源失败

2.Terraform验证云主机资源报错

3. A记录和CNAME的区别

4. 存储桶无法删除


?

?

?一、实验

1.环境

(1)主机

表1-1 主机

主机系统软件工具备注
jia

Windows?

Terraform 1.6.6VS Code、?PowerShell、?Chocolatey?

?

?2.Terraform 连接 tencentcloud 腾讯云COS

(1)验证版本

terraform version

terraform -v 

d03d3f90206543079c42718fc8258d9d.pngcc7d56c2eea440dcb203786dfc3bc81d.png

(2)连接

参考本人上一篇博客:

IaC基础设施即代码:使用Terraform 连接 tencentcloud腾讯云 并创建后端COS-CSDN博客

?

3.申请VPC专有网络资源

(1)查看目录

1988bd1667184c91bfece27bf04eea06.png

?(2)创建主配置文件

main.tf

# Configure the TencentCloud Provider
provider "tencentcloud" {
  secret_id  = var.secret_id
  secret_key = var.secret_key
  region     = var.region
}

?

565571899e6a4f1dbaa3d22349faf346.png

(3) 创建密钥配置文件

terraform.tfvars

secret_id = "XXXXX"
secret_key = "XXXXX"

?

?

(4)创建版本配置文件

versions.tf

terraform {
  required_providers {
    tencentcloud = {
      source  = "tencentcloudstack/tencentcloud"
      version = "1.81.69"
    }
  }
}

?

b0b66988cd3b4e81a5704c6ffe02b1dc.png

(5)创建变量配置文件

variables.tf

variable "secret_id" {
  type = string

}

variable "secret_key" {
  type = string
}

variable "region" {
  type      = string
  default   = "ap-nanjing"
  sensitive = true
}

?

7177c51e29b94a86a558a6b5d4fd1ccc.png

(6)创建后端配置文件

backend.tf

cf36e16c717a49a891cfe533e243cd49.png

(8)?初始化

terraform init

c3b6dcadf0d14f1ca3468d4d867b6455.png

?

(7)格式化代码

terraform fmt

?

e2c4d17e95194b4f9707ed45a5a50d65.png

(8)验证代码

terraform validate 

?

bd7cf39f97804c5d929251f0e54127c2.png

?

(9) 创建网络模块

主配置文件 main.tf

resource "tencentcloud_vpc" "vpc" {
    name         = var.vpc_name
    cidr_block   = var.vpc_cidr_block
    tags = {
        "env" = var.env_name
    }
}

resource "tencentcloud_subnet" "subnet" {
  availability_zone = var.availability_zone
  name              = var.subnet_name
  vpc_id            = tencentcloud_vpc.vpc.id
  cidr_block        = var.subnet_cidr_block
}

4fa5ccbc80834693911aeafc10c1463d.png

变量配置文件 variables.tf

variable "vpc_name" {
    type = string
    default = "vpc"
    sensitive = true
}

variable "vpc_cidr_block" {
    type = string
    sensitive = true  
}


variable "env_name" {
    type = string
}

variable "subnet_cidr_block" {
    type = string
  
}

variable "subnet_name" {
    type = string
  
}
variable "availability_zone" {
    type = string
  
}

eae273fe87d0476cb2accd1673128b91.png

版本配置文件 versions.tf

terraform {
  required_providers {
    tencentcloud = {
      source  = "tencentcloudstack/tencentcloud"
      version = "1.81.69"
    }
  }
}

0aecef14eeca437eb1d1f808e2981f34.png

(10)查看网络模块目录

cba9061e16144f1b98a3a35fa34d5f46.png

(11)创建专有网络资源配置文件

vpc.tf

locals {
  vpc_name          = "dev-vpc"
  vpc_cidr_block    = "172.16.0.0/12"
  env_name          = "dev"
  subnet_cidr_block = "172.16.0.0/21"
  availability_zone = "ap-nanjing-1"
  subnet_name       = "dev-subnet"
}

module "dev-vpc" {
  source = "../../../modules/vpc"
  vpc_name          = local.vpc_name
  vpc_cidr_block    = local.vpc_cidr_block
  env_name          = local.env_name
  subnet_name       = local.subnet_name
  availability_zone = local.availability_zone
  subnet_cidr_block = local.subnet_cidr_block   
}

bff5cd4b179943c29412e15d459303e0.png

(12)查看网路服务目录

fa41295e32ff4cfc9d30652aab289dca.png

(13)?初始化

terraform init

?

198e57475a9c449cb0d366eccbe72165.png

(14)格式化代码

terraform fmt

211faf8de9234639b092fb1f14267778.png

?

(15)验证代码

terraform validate 

080a2211e1e84198b487934b332ae38e.png

?

(16)计划与预览

 terraform plan

543eab9fe0984f4e882a9d7bf6d18fe5.png

(17)申请资源

terraform apply

27f30d9597604b7986014dd7bc3316a9.png

(18)登录腾讯云系统查看

存储桶已添加网络服务配置文件

dcac6d3bd5aa45018a033a52d9b3ded9.png

私有网络

5af2c7bbfa144d3bad3c17ace3f1908b.png

子网

10cf28a67c4649cc97396b6544636dbd.png

?

4.申请安全组资源

(1) 创建安全组模块

主配置文件 main.tf

?

# Create security group
resource "tencentcloud_security_group" "default" {
  name        = var.security_group_name
  description = var.security_group_desc
}

resource "tencentcloud_security_group_lite_rule" "web" {
  security_group_id = tencentcloud_security_group.default.id

  ingress = [
    "ACCEPT#0.0.0.0/0#80#TCP",
    "ACCEPT#0.0.0.0/0#8080#TCP",
    "ACCEPT#0.0.0.0/0#443#TCP",
    "ACCEPT#0.0.0.0/0#22#TCP"
  ]

  egress = [
    "ACCEPT#0.0.0.0/0#22#TCP",
    "ACCEPT#0.0.0.0/0#80#TCP", 
    "ACCEPT#0.0.0.0/0#8080#TCP", 
    "ACCEPT#0.0.0.0/0#443#TCP"
  ]
}

?

4494562e8138445fb976d06bd525b72e.png

1533a88d55214c89af0aded62d849697.png

变量配置文件 variables.tf

variable "security_group_name" {
    type = string
}

variable "security_group_desc" {
    type = string
}

?

9ecd319003bb49b7a57967b70b57339d.png

版本配置文件 versions.tf

terraform {
  required_providers {
    tencentcloud = {
      source  = "tencentcloudstack/tencentcloud"
      version = "1.81.69"
    }
  }
}

?

0936d291972f48e3b6b5fb83d90ba8d6.png

(2)查看安全组模块目录

9f4e77901d0542ae864ab97f2af51227.png

(3)创建安全配置文件

security_group.tf

locals {
  security_group_name = "dev-sec-group"
  security_group_desc = "dev env group"
}

module "dev-sec-group" {
  source              = "../../../modules/security_group"
  security_group_desc = local.security_group_desc
  security_group_name = local.security_group_name
}

f50b5083ef434b719141940731e3ee01.png

(4)创建输出配置文件

output "vpc_id" {
  value = module.dev-vpc.vpc_id

}

output "subnet_id" {
  value = module.dev-vpc.subnet_id
}

output "security_group_id" {
  value = module.dev-sec-group.security_group_id
}

7283221cccca4fcbab6efc08bf4f25f1.png

(5)查看网络服务目录

3c3eabfa88f74782bd2cde2f8fd2d607.png

?

(6)格式化代码

terraform fmt

?

70b6fb49255546ed868e448393473045.png

(7)验证代码

terraform validate 

?

676ccf2ce35d4f1c8aaf3ec150f61eab.png

(8)计划与预览

 terraform plan

?

24c495c28e90422aa96c6347549392bb.png

(9)申请资源

terraform apply

?

d6cd1add13274db88b91dd3552fb267a.png

?

(10)登录腾讯云系统查看

安全组

44cb2c83303d4a33b014bc6fe67810c2.png

入站规则

47c5506ca5d3462d8198f0dc42b8c759.png

出站规则

3c7dfe16389e43a9877cedf4f0315aac.png

?

?

?

5.申请CVM资源

(1)查看目录

c82866a1c1b744288ccfb6843b0a4714.png

?(2)创建配置文件

主配置文件main.tf 、密钥配置文件terraform.tfvars、版本配置文件versions.tf 与之前的网络服务相同。

?

(3)创建后端配置文件

backend.tf

cf36e16c717a49a891cfe533e243cd49.png

(4)? 修改主配置文件

main.tf

a2758d94c984471e89f91a01735b82da.png

?

(5)?初始化

terraform init

9f76bb09dc4847a3ae14133fabadad46.png(6)创建云主机模块

主配置文件main.tf

resource "tencentcloud_instance" "instance" {
  instance_name              = var.instance_name
  availability_zone          = var.availability_zone
  image_id                   = var.image_id
  instance_type              = var.instance_type
  system_disk_type           = "CLOUD_PREMIUM"
  system_disk_size           = 50
  allocate_public_ip         = false
#   internet_charge_type       = "BANDWIDTH_POSTPAID_BY_HOUR"
  internet_max_bandwidth_out = 0
  orderly_security_groups    =  var.security_group_id
  vpc_id                     = var.vpc_id
  subnet_id                  = var.subnet_id
  password                   = "root@123"
  user_data_raw              =  <<-EOF
                                #!/bin/bash 
                                yum -y install nginx 
                                echo `hostname` >/usr/share/nginx/html/index.html
                                systemctl restart nginx 
                                EOF
  lifecycle {
    create_before_destroy = true
  }
}

c0232df6ce7345178db4ac9fad24845b.png

输出配置文件outputs.tf

output "instance_id" {
    value = tencentcloud_instance.instance.id
}

8128ce343bee4fa7aea0901b1a7d08fd.png

变量配置文件cariables.tf

variable "instance_name" {
    type = string
  
}

variable "availability_zone" {
    type = string
  
}

variable "image_id" {
    type = string
}

variable "instance_type" {
    type = string
  
}

variable "security_group_id" {
  type = list(string)
}

variable "vpc_id" {
}

variable "subnet_id" {
}

08152ed1f6f84bef89bac1c4fdd0f1ac.png

版本配置文件versions.tf

terraform {
  required_providers {
    tencentcloud = {
      source  = "tencentcloudstack/tencentcloud"
      version = "1.81.69"
    }
  }
}

3c9dcda5d68044f6b28cc20ee98de988.png

?

(7)查看云主机模块

a3ff96d350274b2ab27c83b89ae9da07.png

(8) 创建云主机配置文件

cvm.tf

data "tencentcloud_instance_types" "t2c2g" {
  cpu_core_count   = 2
  memory_size      = 2
  exclude_sold_out = true
  filter {
    name   = "instance-family"
    values = ["S5"]
  }
  filter {
    name   = "zone"
    values = ["ap-nanjing-1"]
  }

  filter {
    name   = "instance-charge-type"
    values = ["POSTPAID_BY_HOUR"]
  }
}

data "tencentcloud_images" "images" {
  image_type = ["PUBLIC_IMAGE"]
  os_name    = "centos 7.9"
}

output "instance_type" {
  value = data.tencentcloud_instance_types.t2c2g.instance_types.0.instance_type
}

output "image_id" {
    value = data.tencentcloud_images.images.images[0].image_id
}

3683298d14f449509fc7f37821eeda0f.png

(9)?计划与预览

 terraform plan

拿到镜像id和实例类型

cbea44b9cd6e445eace0c08f4842f6ef.png

(10)修改云主机配置文件

cvm.tf ,添加如下代码

locals {
  instance_name     = "dev-instance"
  instance_type     = data.tencentcloud_instance_types.t2c2g.instance_types.0.instance_type
  image_id          = data.tencentcloud_images.images.images[0].image_id
  security_group_id = [data.terraform_remote_state.network-data.outputs.security_group_id]
  availability_zone = "ap-nanjing-1"
  counts            = 2
  vpc_id            = data.terraform_remote_state.network-data.outputs.vpc_id
  subnet_id         = data.terraform_remote_state.network-data.outputs.subnet_id
}

module "dev-cvm" {
  source            = "../../../modules/cvm"
  count             = local.counts
  instance_name     = "${local.instance_name}-${count.index}"
  instance_type     = local.instance_type
  image_id          = local.image_id
  security_group_id = local.security_group_id
  availability_zone = local.availability_zone
  vpc_id            = local.vpc_id
  subnet_id         = local.subnet_id
}

3520c30372bf401ca0eece394736316f.png

(11)初始化

terraform init

72d71f288f4e4a769e29ee03b3a8062e.png

(12)格式化代码

terraform fmt

88cea61fdf664eeabab8a72bb3aa1e3a.png

(13)验证代码

terraform validate

9fc5dd0287e347328984d59bd0818613.png

(14)计划与预览

 terraform plan

09b76a811029435eae6ab3a79dfda478.png

cb3d6df548244625bf60d41d9323862b.png

(15)申请资源

terraform apply

436e58acdc1c445b82d53fc9fe8dab6f.png

8ffda3f235604e9e9da930b8863b86fa.png

yes

f0e65083641a4582af5c75d8744985a4.png

(16) 登录腾讯云系统查看

已新增2台云主机

2fd2290ea23c4a2891ab2faee56609c4.png

(17)远程登录

c3560d1aec894bcea7f373676e65b9a2.png

(18)登录成功

c55d07048a84485d847e2877134a32e5.png

(19) 测试

curl 127.0.0.1

返回当前主机名

e25499db1a3444ccb9d825b9b15b01f8.png

(20) 查看存储桶

已新增service配置文件

aad0606048494a2c90e149fcad2a6fb2.png

(21)查看服务目录

f11eaf2cf48442cabb036556e1028a83.png

?

6.申请CLB资源

?(1)创建CLB模块

主配置文件main.tf

resource "tencentcloud_clb_instance" "internal_clb" {
  network_type = "OPEN"
  clb_name     = var.clb_name
  vpc_id       = var.vpc_id
#   subnet_id    = var.subnet_id

  tags = {
    test = var.env_name
  }
}

resource "tencentcloud_clb_listener" "listener" {
  clb_id        = tencentcloud_clb_instance.internal_clb.id
  listener_name = var.listener_name
  port          = var.listener_port
  protocol      = var.listener_protocol
  health_check_switch        = true
  health_check_time_out      = 2
  health_check_interval_time = 5
  health_check_health_num    = 3
  health_check_unhealth_num  = 3
  session_expire_time        = 30
  scheduler                  = var.scheduler
}


resource "tencentcloud_clb_attachment" "foo" {
  clb_id      = tencentcloud_clb_instance.internal_clb.id
  listener_id = tencentcloud_clb_listener.listener.listener_id

  dynamic "targets" {
    for_each = [for instance in var.instance_ids : instance]
    content {
      instance_id = targets.value
      port        = var.backend_port
      weight      = var.backend_weight
    }
  }
}

?

2cabadc1c83944c08debfc90ff8edbbc.png

输出配置文件outputs.tf

output "clb_instance_id" {
    value = tencentcloud_clb_instance.internal_clb.id
}

output "clb_instance_vip" {
    value = tencentcloud_clb_instance.internal_clb.clb_vips
}

?

0e7205858a934ae9bcc2b1fea8ae82fb.png

变量配置文件cariables.tf

variable "clb_name" {
  
}

variable "vpc_id" {
  
}

variable "subnet_id" {
  
}

variable "env_name" {
  
}


variable "listener_name" {
  
}

variable "listener_port" {
  
}

variable "listener_protocol" {
  
}

variable "scheduler" {
  
}

variable "instance_ids" {
  
}
variable "backend_port" {
  
}

variable "backend_weight" {
  
}

?

7dd56f28f3fe42aba5486cf9dcc2c8ba.png

版本配置文件versions.tf

terraform {
  required_providers {
    tencentcloud = {
      source  = "tencentcloudstack/tencentcloud"
      version = "1.81.69"
    }
  }
}

?

2c2d9d2ad7444e3e96bec99626410795.png

(7)查看CLB模块

26aa552f50a243ceb37d5aa7bf9ffd58.png

(8) 创建CLB配置文件

clb.tf

locals {
  clb_name          = "dev-clb"
  vpc_ids           = data.terraform_remote_state.network-data.outputs.vpc_id
  subnet_ids        = data.terraform_remote_state.network-data.outputs.subnet_id
  env_name          = "dev"
  listener_name     = "dev-listener"
  listener_port     = 80
  listener_protocol = "TCP"
  scheduler         = "WRR"
  instance_ids      = module.dev-cvm.*.instance_id
  backend_port      = 80
  backend_weight    = 100
}

module "dev-clb" {
  source            = "../../../modules/clb"
  clb_name          = local.clb_name
  vpc_id            = local.vpc_ids
  subnet_id         = local.subnet_ids
  env_name          = local.env_name
  listener_name     = local.listener_name
  listener_port     = local.listener_port
  listener_protocol = local.listener_protocol
  scheduler         = local.scheduler
  instance_ids      = local.instance_ids
  backend_port      = local.backend_port
  backend_weight    = local.backend_weight
}

dd41b8c70d7d41f69d8bdd0122fea4a1.png

(9) 初始化

terraform init

528361e3c6614ccc8d41bd8921801935.png

(10)格式化代码

terraform fmt

893f580338134cfc8452f961b45325c0.png

(11)验证代码

terraform validate

75f451ef340d44e590941d921642f60d.png

(12)计划与预览

 terraform plan

3个资源将要被添加

20918df12a514070a0f035b426d7b9ee.png796b507319b547e18516e636a691021d.png

(13)申请资源

terraform apply

5d5509cf1234448e8d0cfbef91a683ee.pngc953cce126c74cc1b85aa892f21fdba5.png

yes

adec4fc7d6bb44268764b3403a58038e.png

(14)登录腾讯云查看

已新增负载均衡

0757d5de24684daf91de366688a6abe4.png

(15)访问地址

c6c657db5da14851bba38ac6a6f7c793.png

(16)查看监听器状态

3dde1713c4a7437e8d6ea6a432370038.png

(17)监听方式

WRR 加权轮询

9d009d0c6ef24b40b7db478ac3463267.png

?

7.申请DNS资源

(1)创建域名

ea48112432d54288adcb87404e314b1e.png

(2) 查看

e86c79ddd0934c6c974c54a56abed2ea.png

?

(3)创建DNS配置文件

dns.tf

resource "tencentcloud_dnspod_record" "tfdemo" {
  domain      = "ruwen.site"
  record_type = "CNAME"
  record_line = "默认"
  value       = "lb-eahy08p4-wyklophm18uf9sxj.clb.ap-nanjing.tencentclb.com"
  sub_domain = "tfdemo"
}

31d59e9aa5e245ce80fb77e601457d2c.png

(3)??计划与预览

 terraform plan

29d66cacb6ef456a82abea91289ea66d.png

(4) 申请资源

terraform apply

c1183ac682ea4aada99652cd93aae378.png

(5)登录腾讯云系统查看

云解析DNS

4a57c23253f04d2a994685aced178306.png

(6)测试

 dig tfdemo.ruwen.site

c159e7c991014b4382018b1645c8af4e.png

?

8.销毁资源

? (1) 销毁服务资源

a62b59ac6edc438e94296e6c12b0b85f.png3bf27f13e0834e59af1f408ffeeb6b82.png4c678691b29c47f984937175e77eaced.png39d7845d0a354edd99e98558d304fd03.png

yes ,6个资源将要被删除

5bd36f1c303b4a2ea8a93ed7bb5bcd80.png

(2)销毁网络资源

fffa564ebcbe4934b6f90a0081db6bc9.pngb8ab5c47cd8f4a4d98db54683f3e470f.png

yes,4个资源将要被删除

5ef151c313b84448b32ac1c15519e4aa.png

(3)登录腾讯云系统查看

云主机CVM 已删除

cfd60bb154f74100b7033ca060202f92.png

DNS云解析已移除

cb7740e2c5a64380b2c985bb544a6565.png

CLB负载均衡已删除

cfb5f36597e34d5ea8600f81d7b5f805.png

存储桶

3e95a500eee346cc961589586e84af6c.png

(4)查看完整目录

5a9c547c47044149be653e6c603e1390.png

?

二、问题

1. Terraform申请安全组资源失败

(1)报错

?
│ Warning: Deprecated Resource
│
│   with module.dev-sec-group.tencentcloud_security_group_rule.web,
│   on ..\..\..\modules\security_group\main.tf line 7, in resource "tencentcloud_security_group_rule" "web":
│    7: resource "tencentcloud_security_group_rule" "web" {
│
│ This resource will be offline and no longer supported, beacause single security rule is hardly ordered. Please use 'tencentcloud_security_group_lite_rule' instead.
│
│ (and 2 more similar warnings elsewhere)
?
?
│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to module.dev-sec-group.tencentcloud_security_group_rule.ssh, provider "provider[\"registry.terraform.io/tencentcloudstack/tencentcloud\"]" produced an unexpected new value: Root object was present, but now absent.
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

09436f59bcc44cc3985414b30100b309.png

(2)原因分析

Terraform Registry

resource "tencentcloud_security_group" "foo" {
  name = "ci-temp-test-sg"
}

resource "tencentcloud_security_group_lite_rule" "foo" {
  security_group_id = tencentcloud_security_group.foo.id

  ingress = [
    "ACCEPT#192.168.1.0/24#80#TCP",
    "DROP#8.8.8.8#80,90#UDP",
    "ACCEPT#0.0.0.0/0#80-90#TCP",
    "ACCEPT#sg-7ixn3foj#80-90#TCP",
    "ACCEPT#ipm-epjq5kn0#80-90#TCP",
    "ACCEPT#ipmg-3loavam6#80-90#TCP",
    "ACCEPT#0.0.0.0/0##ppm-xxxxxxxx"
    "ACCEPT#0.0.0.0/0##ppmg-xxxxxxxx"
  ]

  egress = [
    "ACCEPT#192.168.0.0/16#ALL#TCP",
    "ACCEPT#10.0.0.0/8#ALL#ICMP",
    "DROP#0.0.0.0/0#ALL#ALL",
  ]
}

df125855a6d7456a8700332f6b3019d6.png

安全组规则采用最新的字段:tencentcloud_security_group_lite_rule

(3)解决方法

修改配置文件。

修改前:

# Create security group
resource "tencentcloud_security_group" "default" {
  name        = var.security_group_name
  description = var.security_group_desc
}

resource "tencentcloud_security_group_rule" "web" {
  security_group_id = tencentcloud_security_group.default.id
  type              = "ingress"
  cidr_ip           = "0.0.0.0/0"
  ip_protocol       = "tcp"
  port_range        = "80,8080"
  policy            = "accept"
}

resource "tencentcloud_security_group_rule" "ssh" {
  security_group_id = tencentcloud_security_group.default.id
  type              = "ingress"
  cidr_ip           = "0.0.0.0/0"
  ip_protocol       = "tcp"
  port_range        = "22"
  policy            = "accept"
}

resource "tencentcloud_security_group_rule" "all" {
  security_group_id = tencentcloud_security_group.default.id
  type              = "egress"
  cidr_ip           = "0.0.0.0/0"
  policy            = "accept"
}

?

23d48ae0f253427381676bf22ec5ac6b.png

修改后:

# Create security group
resource "tencentcloud_security_group" "default" {
  name        = var.security_group_name
  description = var.security_group_desc
}

resource "tencentcloud_security_group_lite_rule" "web" {
  security_group_id = tencentcloud_security_group.default.id

  ingress = [
    "ACCEPT#0.0.0.0/0#80#TCP",
    "ACCEPT#0.0.0.0/0#8080#TCP",
    "ACCEPT#0.0.0.0/0#22#TCP"
  ]

  egress = [
    "ACCEPT#0.0.0.0/0#ALL#ALL",
  ]
}

4494562e8138445fb976d06bd525b72e.png45b055222a444b418757f7f109a5cb37.png

?计划与预览

 terraform plan

29ec7decc2da420c9798cf2c10c339b1.png

申请资源

terraform apply

先删除旧的

acbfee373029436e825808ecb4e06ffc.png

yes

4dbe2d0de02a4dc2a317d4e941e43c2e.png

?

2.Terraform验证云主机资源报错

(1)报错

598372fe232d4adf95f0795366cc0c10.png

(2)原因分析

security_groups 已被弃用,现在使用的是?orderly_security_groups

(3)解决方法

修改配置文件。

  orderly_security_groups    =  var.security_group_id

dbdc64f7268740189e072d05d83fbae1.png

成功:

9fc5dd0287e347328984d59bd0818613.png


3. A记录和CNAME的区别

(1)区别

1)区别一
A 记录直接将域名映射到一个 IPv4 地址,而 CNAME 记录将域名映射到另一个域名。

2)区别二
A 记录速度较快,因为它直接映射到 IP 地址,不会引入额外的查询步骤。CNAME 记录可能稍微减慢解析速度,因为它需要额外的查询步骤以查找目标域名的 IP 地址。

3)区别三
A 记录适用于需要直接映射到 IP 地址的情况,而 CNAME 记录适用于创建别名或者需要更灵活管理目标位置的情况。

4. 存储桶无法删除

(1)查看

c26d9219eabb40fc80c24f1910850460.png

(2)删除

010345c915914c659514149e8b41cf1b.png

(3)清空

ed31db9bf1fa4adebe624615b1370fa3.png

(4)确定

467b0aa50a6e470eb3ff1e9f5e08628f.png

(5)再次删除

335241f28f5541c29e2156721523d1aa.png

(6)成功

eb2f9ae1fc0f4af790c96779cb4a508c.png

?

文章来源:https://blog.csdn.net/cronaldo91/article/details/135819379
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。