Skip to main content
NetApp Solutions
本繁體中文版使用機器翻譯,譯文僅供參考,若與英文版本牴觸,應以英文版本為準。

AWS FSX ONTAP 叢集和 EC2 執行個體資源配置

貢獻者

NetApp 解決方案工程團隊

目的

此工具套件可自動化 AWS FSX ONTAP 儲存叢集和 EC2 運算執行個體的資源配置工作、之後可用於資料庫部署。

本解決方案可解決下列使用案例:

  • 在預先定義的 VPC 子網路中、在 AWS 雲端中佈建 EC2 運算執行個體、並將 EC2 執行個體存取的 ssh 金鑰設為 EC2 使用者。

  • 在所需的可用性區域中佈建 AWS FSX ONTAP 儲存叢集、並設定儲存 SVM 並設定叢集管理使用者 fsxadmin 密碼。

目標對象

本解決方案適用於下列人員:

  • 管理 AWS EC2 環境中資料庫的 DBA 。

  • 對 AWS EC2 生態系統中的資料庫部署感興趣的資料庫解決方案架構設計師。

  • 管理支援資料庫的 AWS FSX ONTAP 儲存設備的儲存管理員。

  • 喜歡在 AWS EC2 生態系統中執行資料刪除資料庫的應用程式擁有者。

授權

存取、下載、安裝或使用此 GitHub 儲存庫中的內容、即表示您同意中所列的授權條款 "授權檔案"

註 對於與此 GitHub 儲存庫中的內容產生及 / 或共用任何衍生作品、有特定限制。使用內容前、請務必先閱讀授權條款。如果您不同意所有條款、請勿存取、下載或使用此儲存庫中的內容。

解決方案部署

部署的先決條件

Details

部署需要下列先決條件。

An Organization and AWS account has been setup in AWS public cloud
  An user to run the deployment has been created
  IAM roles has been configured
  IAM roles granted to user to permit provisioning the resources
VPC and security configuration
  A VPC has been created to host the resources to be provisioned
  A security group has been configured for the VPC
  A ssh key pair has been created for EC2 instance access
Network configuration
  Subnets has been created for VPC with network segments assigned
  Route tables and network ACL configured
  NAT gateways or internet gateways configured for internet access

下載工具組

Details
git clone https://github.com/NetApp/na_aws_fsx_ec2_deploy.git

連線與驗證

Details

此工具組應從 AWS 雲端 Shell 執行。AWS 雲端 Shell 是瀏覽器型的 Shell 、可讓您輕鬆安全地管理、探索及與 AWS 資源互動。CloudShell 已使用您的主控台認證預先驗證。一般的開發與作業工具已預先安裝、因此不需要進行本機安裝或組態。

Terraform provider .tf 和 main.tf 檔案組態

Details

provider .tf 定義 Terraform 透過 API 呼叫來配置資源的供應商。main.tf 定義要配置的資源的資源和屬性。以下是一些詳細資料:

provider.tf:
  terraform {
    required_providers {
      aws = {
        source  = "hashicorp/aws"
        version = "~> 4.54.0"
      }
    }
  }
main.tf:
  resource "aws_instance" "ora_01" {
    ami                           = var.ami
    instance_type                 = var.instance_type
    subnet_id                     = var.subnet_id
    key_name                      = var.ssh_key_name
    root_block_device {
      volume_type                 = "gp3"
      volume_size                 = var.root_volume_size
    }
    tags = {
      Name                        = var.ec2_tag
    }
  }
  ....

Terraform variables.tf 和 terraform.tfvars 組態

Details

variables.tf 會宣告將用於 main.tf 的變數。terraform.tfvars 包含變數的實際值。以下是一些範例:

variables.tf:
  ### EC2 instance variables ###
variable "ami" {
  type        = string
  description = "EC2 AMI image to be deployed"
}
variable "instance_type" {
  type        = string
  description = "EC2 instance type"
}

terraform.tfvars:
# EC2 instance variables


ami = "ami-06640050dc3f556bb" //RedHat 8.6 AMI
instance_type = "t2.micro"
ec2_tag = "ora_01"
subnet_id = "subnet-04f5fe7073ff514fb"
ssh_key_name = "sufi_new"
root_volume_size = 30


逐步程序 - 依序執行

Details
  1. 在 AWS 雲端 Shell 中安裝 Terraform 。

    git clone https://github.com/tfutils/tfenv.git ~/.tfenv
    mkdir ~/bin
    ln -s ~/.tfenv/bin/* ~/bin/
    tfenv install
    tfenv use 1.3.9
  2. 請從 NetApp GitHub 公用網站下載此工具套件

    git clone https://github.com/NetApp-Automation/na_aws_fsx_ec2_deploy.git
  3. 執行初始化以初始化 terraform

    terraform init
  4. 輸出執行計畫

    terraform plan -out=main.plan
  5. 套用執行計畫

    terraform apply "main.plan"
  6. 執行銷毀以移除完成後的資源

    terraform destroy

何處可找到其他資訊

若要深入瞭解 NetApp 解決方案自動化、請參閱下列網站 "NetApp解決方案自動化"