iT邦幫忙

2023 iThome 鐵人賽

DAY 22
0
DevOps

大家都在用 Terraform 實作 IaC 為什麼不將程式寫得更簡潔易讀呢?系列 第 22

實作 AWS 常用服務之 Terraform 模組系列 - Using Packer to Create an AMI 篇以建置 Cassandra Cluster 為例子

  • 分享至 

  • xImage
  •  

Using Packer to Create an AMI 篇以建置 Cassandra Cluster 為例子

本篇將會使用 Packer 來建立一 Cassandra Cluster AMI 例子,完整的專案程式碼分享在我的 Github 上。

  1. 建立目錄放置 packer/apache-cassandra 來建置 Custom AMI,以下將以建置 Cassandra Cluster 為例子:
├── configs
│   ├── cloudfront
│   │   └── distributions.yaml
│   ├── cloudwatch
│   │   └── loggroups.yaml
│   ├── iam
│   │   ├── assume_role_policies
│   │   │   ├── eks-cluster.json
│   │   │   ├── eks-fargate-pod-execution-role.json
│   │   │   └── eks-node-group.json
│   │   ├── iam.yaml
│   │   ├── role_policies
│   │   │   └── eks-cluster-cloudwatch-metrics.json
│   │   └── user_policies
│   │       └── admin_access.json
│   ├── kinesis
│   │   └── streams.yaml
│   ├── kms
│   │   ├── keys.yaml
│   │   └── policies
│   │       └── my-key-policy.json
│   ├── s3
│   │   ├── policies
│   │   │   └── my-bucket.json
│   │   └── s3.yaml
│   ├── subnet
│   │   └── my-subnets.yaml
│   └── vpc
│       └── my-vpcs.yaml
├── example.tfvars
├── locals.tf
├── main.tf
├── modules
│   ├── my_cloudfront
│   ├── my_cloudwatch
│   ├── my_eips
│   ├── my_eventbridge
│   ├── my_iam
│   ├── my_igw
│   ├── my_instances
│   ├── my_kinesis_stream
│   ├── my_kms
│   ├── my_msk
│   ├── my_nacls
│   ├── my_route_tables
│   ├── my_s3
│   ├── my_subnets
│   └── my_vpc
├── packer
│   └── apache-cassandra
│       ├── Makefile
│       ├── amazon-ebs.cassandra.pkr.hcl
│       ├── build.pkr.hcl
│       ├── example.pkrvars.hcl
│       ├── install-cassandra-exporter-standalone.sh
│       ├── install-cassandra-exporter.sh
│       ├── install-cassandra.sh
│       ├── install-cqlsh-standalone-tool.sh
│       ├── install-node-exporter.sh
│       ├── optimize-cassandra.sh
│       ├── values.auto.pkrvars.hcl
│       └── variables.pkr.hcl
└── variables.tf
  1. 以下將一一說明每一個檔案的目的
  • packer/apache_cassandra/Makefile: 利用 make 方式簡易建置 AMI 指令。
PACKER ?= packer

var_file=example.pkrvars.hcl

.PHONY: build

build:
	@echo build $$ENV
	$(PACKER) build -var-file=$(var_file) .	 

  • packer/apache_cassandra/amazon-ebs.cassandra.pkr.hcl: 描述建置 Cassandra AMI 相關的設定參數。
locals {
  timestamp_sanitized = "${formatdate("YYYYMMDDhhmmss", timestamp())}"
}

source "amazon-ebs" "cassandra" {
  ami_description             = "amazon cassandra AMI"
  ami_name                    = "cassandra-BASE-v${var.BUILD_NUMBER}-${local.timestamp_sanitized}-AMI-arm64"
  ami_users                   = var.ami_users
  ami_virtualization_type     = "hvm"
  associate_public_ip_address = var.associate_public_ip_address
  instance_type               = var.instance_type
  region                      = var.region
  run_tags = {
    Name        = "amazon-cassandra-packer"
    Application = "cassandra"
  }
  spot_price    = "auto"
  ssh_username  = "ec2-user"
  ssh_interface = var.ssh_interface

  subnet_id = var.subnet_id

  source_ami_filter {
    filters = {
      virtualization-type = "hvm"
      name                = "amzn2-ami-hvm-*-arm64-gp2"
      root-device-type    = "ebs"
    }
    most_recent = true
    owners      = ["amazon"]
  }

  temporary_key_pair_name = "amazon-packer-${local.timestamp_sanitized}"

  vpc_id = var.vpc_id

  tags = {
    OS_Version  = "Amazon 2 linux"
    Version     = var.BUILD_NUMBER
    Application = "Cassandra Image"
    Runner      = "EC2"
  }
}

  • packer/apache_cassandra/build.pkr.hcl: 描述建置 AMI 流程設定檔。
build {
  sources = [
    "source.amazon-ebs.cassandra"
  ]

  provisioner "shell" {
    script  = "${path.root}/install-node-exporter.sh"
    timeout = "90s"
  }

  provisioner "shell" {
    script  = "${path.root}/install-cassandra.sh"
    timeout = "380s"
  }

  provisioner "shell" {
    script  = "${path.root}/optimize-cassandra.sh"
    timeout = "90s"
  }

  provisioner "shell" {
    script  = "${path.root}/install-cassandra-exporter.sh"
    timeout = "90s"
  }

  provisioner "shell" {
    script  = "${path.root}/install-cassandra-exporter-standalone.sh"
    timeout = "90s"
  }

  provisioner "shell" {
    script  = "${path.root}/install-cqlsh-standalone-tool.sh"
    timeout = "60s"
  }

}

  • packer/apache_cassandra/example.pkrvars.hcl: 建置 AMI 使用的變數設定檔。
vpc_id    = "vpc-6d1fee0b"
region    = "ap-northeast-1"
subnet_id = "subnet-8cdb69c4"

  • packer/apache_cassandra/install-cassandra-exporter-standalone.sh: 安裝 Casssandra Exporter Standalone 腳本檔。
#!/bin/bash

# Create '/opt/cassandra_exporter_standalone' directory
sudo mkdir -p /opt/cassandra_exporter_standalone
sudo chmod 0755 /opt/cassandra_exporter_standalone

# Download cassandra-exporter-standalone.jar
sudo wget -O /opt/cassandra_exporter_standalone/cassandra-exporter-standalone.jar https://github.com/instaclustr/cassandra-exporter/releases/download/v0.9.10/cassandra-exporter-standalone-0.9.10.jar

  • packer/apache_cassandra/install-cassandra-exporter.sh: 安裝 Casssandra Exporter 腳本檔。
#!/bin/bash

# Create '/opt/cassandra_exporter' directory
sudo mkdir -p /opt/cassandra_exporter
sudo chmod 0755 /opt/cassandra_exporter

# Download cassandra_exporter.jar
sudo wget -O /opt/cassandra_exporter/cassandra_exporter.jar https://github.com/criteo/cassandra_exporter/releases/download/2.3.8/cassandra_exporter-2.3.8.jar

# Create cassandra_exporter systemd service unit
cat <<EOF | sudo tee -a /etc/systemd/system/cassandra_exporter.service
[Unit]
Description=Cassandra Exporter for Prometheus
After=cassandra.service

[Service]
Type=idle
WorkingDirectory=/opt/cassandra_exporter
ExecStart=/usr/bin/java -jar cassandra_exporter.jar config.yml

[Install]
WantedBy=multi-user.target

EOF
sudo chmod 0644 /etc/systemd/system/cassandra_exporter.service

# Reload systemd
sudo systemctl daemon-reload

# Copy cassandra_exporter config
cat <<EOF | sudo tee -a /opt/cassandra_exporter/config.yml
host: localhost:7199
ssl: False
user:
password:
listenAddress: 0.0.0.0
listenPort: 8080
blacklist:
   # Unaccessible metrics (not enough privilege)
   - java:lang:memorypool:.*usagethreshold.*

   # Leaf attributes not interesting for us but that are presents in many path (reduce cardinality of metrics)
   - .*:999thpercentile
   - .*:95thpercentile
   - .*:fifteenminuterate
   - .*:fiveminuterate
   - .*:durationunit
   - .*:rateunit
   - .*:stddev
   - .*:meanrate
   - .*:mean
   - .*:min

   # Path present in many metrics but uninterresting
   - .*:viewlockacquiretime:.*
   - .*:viewreadtime:.*
   - .*:cas[a-z]+latency:.*
   - .*:colupdatetimedeltahistogram:.*

   # Mostly for RPC, do not scrap them
   - org:apache:cassandra:db:.*

   # columnfamily is an alias for Table metrics in cassandra 3.x
   # https://github.com/apache/cassandra/blob/8b3a60b9a7dbefeecc06bace617279612ec7092d/src/java/org/apache/cassandra/metrics/TableMetrics.java#L162
   #- org:apache:cassandra:metrics:columnfamily:.*

   # Should we export metrics for system keyspaces/tables ?
   - org:apache:cassandra:metrics:[^:]+:system[^:]*:.*

   # Don't scrape us
   - com:criteo:nosql:cassandra:exporter:.*

maxScrapFrequencyInSec:
  50:
    - .*

  # Refresh those metrics only every hour as it is costly for cassandra to retrieve them
  3600:
    - .*:snapshotssize:.*
    - .*:estimated.*
    - .*:totaldiskspaceused:.*

EOF
sudo chmod 0644 /opt/cassandra_exporter/config.yml

# Enable cassandra_exporter service
sudo systemctl enable cassandra_exporter

  • packer/apache_cassandra/install-cassandra.sh: 安裝 Casssandra 主程式腳本檔。
#!/bin/bash
sudo yum install java-1.8.0-openjdk -y

cat <<EOF | sudo tee -a /etc/yum.repos.d/cassandra40x.repo
[cassandra]
name=Apache Cassandra
baseurl=https://www.apache.org/dist/cassandra/redhat/40x/
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://www.apache.org/dist/cassandra/KEYS
EOF

sudo yum update -y

# sudo yum install cassandra -y
sudo wget -O /tmp/cassandra.noarch.rpm https://downloads.apache.org/cassandra/redhat/40x/cassandra-4.0.5-1.noarch.rpm
sudo rpm -i --nodeps /tmp/cassandra.noarch.rpm
sudo rm /tmp/cassandra.noarch.rpm

# reload systemd files
sudo systemctl daemon-reload
sudo service cassandra stop

# clear out data
sudo rm -rf /var/lib/cassandra/data/system/*

  • packer/apache_cassandra/install-cqlsh-standalone-tool.sh: 安裝 Cqlsh Standalone Tool 腳本檔。
#!/bin/bash

echo "Install CQLSH standalone tool"

# Download CQLSH standalone tool
sudo wget -O /opt/cqlsh-astra.tar.gz https://downloads.datastax.com/enterprise/cqlsh-astra.tar.gz

# Decompress cqlsh-astra.tar.gz
cd /opt
sudo tar xvfz /opt/cqlsh-astra.tar.gz

# Install geomet plugin 
cd /opt/cqlsh-astra/zipfiles/
sudo unzip ./geomet-0.1.0.zip
sudo mv ./geomet-0.1.0/geomet ../pylib/

sudo rm /opt/cqlsh-astra.tar.gz

  • packer/apache_cassandra/install-node-exporter.sh: 安裝 Node Exporter 腳本檔。
#!/bin/bash

# Download node_exporter
cd /tmp
sudo wget https://github.com/prometheus/node_exporter/releases/download/v1.3.1/node_exporter-1.3.1.linux-arm64.tar.gz
sudo tar xvfz node_exporter-1.3.1.linux-arm64.tar.gz

# Move node_exporter to /usr/local/bin
sudo mv ./node_exporter-1.3.1.linux-arm64/node_exporter /usr/local/bin/node_exporter
sudo chmod 0755 /usr/local/bin/node_exporter

# Install node_exporter sysconfig
cat <<EOF | sudo tee -a /etc/sysconfig/node_exporter
OPTIONS="--collector.diskstats --collector.cpu --collector.filesystem --collector.loadavg --collector.meminfo --collector.netdev --collector.stat --collector.time --collector.uname --collector.vmstat --collector.processes --collector.conntrack"

EOF
sudo chmod 0644 /etc/sysconfig/node_exporter
# Install node_exporter systemd file
cat <<EOF | sudo tee -a /etc/systemd/system/node_exporter.service
[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target

[Service]
User=prometheus
EnvironmentFile=-/etc/sysconfig/node_exporter
ExecStart=/usr/local/bin/node_exporter $OPTIONS

[Install]
WantedBy=default.target

EOF
sudo chmod 0644 /etc/systemd/system/node_exporter.service

# Reload systemd
sudo systemctl daemon-reload

# Add user "prometheus"
sudo groupadd --system prometheus
sudo useradd -s /sbin/nologin --system -g prometheus prometheus

# Enable node_exporter service
sudo systemctl enable node_exporter

  • packer/apache_cassandra/optimize-cassandra.sh:
#!/bin/bash

# Set user resource limits
cat <<EOF | sudo tee -a /etc/sysctl.conf
vm.max_map_count=1048575

EOF

# TCP settings
cat <<EOF | sudo tee -a /etc/sysctl.conf
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.core.rmem_default = 16777216
net.core.wmem_default = 16777216
net.core.optmem_max = 40960
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216

EOF
sudo sysctl -p /etc/sysctl.conf

# Disable swap
sudo swapoff --all

  • packer/apache_cassandra/variables.pkr.hcl: 建置變數描述檔。
variable "vpc_id" {
  description = "The VPC you're building AMI's in"
  type        = string
}

variable "region" {
  description = "The AWS region you're using"
  type        = string
}

variable "subnet_id" {
  description = "The Subnet to build the AMI inm that's ssh'able"
  type        = string
}

variable "BUILD_NUMBER" {
  description = "The build number"
  type        = string
  default     = "1"
}

variable "instance_type" {
  default     = "t4g.micro"
  description = "The AMI build instance"
  type        = string
}

variable "ami_users" {
  default = []
}

variable "associate_public_ip_address" {
  type    = bool
  default = true
}

variable "ssh_interface" {
  type    = string
  default = "public_ip"
}

  1. packer/apache_cassandra 目錄下執行 make 來建置 Custom Cassandra AMI:
build
packer build -var-file=example.pkrvars.hcl .     
amazon-ebs.cassandra: output will be in this color.

==> amazon-ebs.cassandra: Prevalidating any provided VPC information
==> amazon-ebs.cassandra: Prevalidating AMI Name: cassandra-BASE-v1-20230923031614-AMI-arm64
    amazon-ebs.cassandra: Found Image ID: ami-0c5c5218676cecc56
==> amazon-ebs.cassandra: Creating temporary keypair: amazon-packer-20230923031614
==> amazon-ebs.cassandra: Creating temporary security group for this instance: packer_650e5880-77d9-226a-f3ca-753d9a918551
==> amazon-ebs.cassandra: Authorizing access to port 22 from [0.0.0.0/0] in the temporary security groups...
==> amazon-ebs.cassandra: Launching a spot AWS instance...
==> amazon-ebs.cassandra: Interpolating tags for spot instance...
==> amazon-ebs.cassandra: Using SSH communicator to connect: 18.181.199.111
==> amazon-ebs.cassandra: Waiting for SSH to become available...
==> amazon-ebs.cassandra: Connected to SSH!
==> amazon-ebs.cassandra: Setting a 1m30s timeout for the next provisioner...
==> amazon-ebs.cassandra: Provisioning with shell script: ./install-node-exporter.sh
==> amazon-ebs.cassandra: --2023-09-23 03:16:37--  https://github.com/prometheus/node_exporter/releases/download/v1.3.1/node_exporter-1.3.1.linux-arm64.tar.gz
==> amazon-ebs.cassandra: Resolving github.com (github.com)... 20.27.177.113
==> amazon-ebs.cassandra: Connecting to github.com (github.com)|20.27.177.113|:443... connected.
==> amazon-ebs.cassandra: HTTP request sent, awaiting response... 302 Found
==> amazon-ebs.cassandra: Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/9524057/b94645a1-6c86-4474-bf67-60d4a50107dd?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230923%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230923T031637Z&X-Amz-Expires=300&X-Amz-Signature=cf0b6fecc26eb63593b3ea9ff413014cf82a9387b48a305b8e5c26082f361085&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=9524057&response-content-disposition=attachment%3B%20filename%3Dnode_exporter-1.3.1.linux-arm64.tar.gz&response-content-type=application%2Foctet-stream [following]
==> amazon-ebs.cassandra: --2023-09-23 03:16:37--  https://objects.githubusercontent.com/github-production-release-asset-2e65be/9524057/b94645a1-6c86-4474-bf67-60d4a50107dd?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230923%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230923T031637Z&X-Amz-Expires=300&X-Amz-Signature=cf0b6fecc26eb63593b3ea9ff413014cf82a9387b48a305b8e5c26082f361085&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=9524057&response-content-disposition=attachment%3B%20filename%3Dnode_exporter-1.3.1.linux-arm64.tar.gz&response-content-type=application%2Foctet-stream
==> amazon-ebs.cassandra: Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.111.133, 185.199.109.133, 185.199.110.133, ...
==> amazon-ebs.cassandra: Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.111.133|:443... connected.
==> amazon-ebs.cassandra: HTTP request sent, awaiting response... 200 OK
==> amazon-ebs.cassandra: Length: 8339932 (8.0M) [application/octet-stream]
==> amazon-ebs.cassandra: Saving to: ‘node_exporter-1.3.1.linux-arm64.tar.gz’
==> amazon-ebs.cassandra: 2023-09-23 03:16:38 (37.2 MB/s) - ‘node_exporter-1.3.1.linux-arm64.tar.gz’ saved [8339932/8339932]
==> amazon-ebs.cassandra:
==> amazon-ebs.cassandra: Created symlink from /etc/systemd/system/default.target.wants/node_exporter.service to /etc/systemd/system/node_exporter.service.
==> amazon-ebs.cassandra: Setting a 6m20s timeout for the next provisioner...
==> amazon-ebs.cassandra: Provisioning with shell script: ./install-cassandra.sh
==> amazon-ebs.cassandra: https://www.apache.org/dist/cassandra/redhat/40x/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
==> amazon-ebs.cassandra: Trying other mirror.
==> amazon-ebs.cassandra:
==> amazon-ebs.cassandra:
==> amazon-ebs.cassandra:  One of the configured repositories failed (Apache Cassandra),
==> amazon-ebs.cassandra:  and yum doesn't have enough cached data to continue. At this point the only
==> amazon-ebs.cassandra:  safe thing yum can do is fail. There are a few ways to work "fix" this:
==> amazon-ebs.cassandra:
==> amazon-ebs.cassandra:      1. Contact the upstream for the repository and get them to fix the problem.
==> amazon-ebs.cassandra:
==> amazon-ebs.cassandra:      2. Reconfigure the baseurl/etc. for the repository, to point to a working
==> amazon-ebs.cassandra:         upstream. This is most often useful if you are using a newer
==> amazon-ebs.cassandra:         distribution release than is supported by the repository (and the
==> amazon-ebs.cassandra:         packages for the previous distribution release still work).
==> amazon-ebs.cassandra:
==> amazon-ebs.cassandra:      3. Run the command with the repository temporarily disabled
==> amazon-ebs.cassandra:             yum --disablerepo=cassandra ...
==> amazon-ebs.cassandra:
==> amazon-ebs.cassandra:      4. Disable the repository permanently, so yum won't use it by default. Yum
==> amazon-ebs.cassandra:         will then just ignore the repository until you permanently enable it
==> amazon-ebs.cassandra:         again or use --enablerepo for temporary usage:
==> amazon-ebs.cassandra:
==> amazon-ebs.cassandra:             yum-config-manager --disable cassandra
==> amazon-ebs.cassandra:         or
==> amazon-ebs.cassandra:             subscription-manager repos --disable=cassandra
==> amazon-ebs.cassandra:
==> amazon-ebs.cassandra:      5. Configure the failing repository to be skipped, if it is unavailable.
==> amazon-ebs.cassandra:         Note that yum will try to contact the repo. when it runs most commands,
==> amazon-ebs.cassandra:         so will have to try and fail each time (and thus. yum will be be much
==> amazon-ebs.cassandra:         slower). If it is a very temporary problem though, this is often a nice
==> amazon-ebs.cassandra:         compromise:
==> amazon-ebs.cassandra:
==> amazon-ebs.cassandra:             yum-config-manager --save --setopt=cassandra.skip_if_unavailable=true
==> amazon-ebs.cassandra:
==> amazon-ebs.cassandra: failure: repodata/repomd.xml from cassandra: [Errno 256] No more mirrors to try.
==> amazon-ebs.cassandra: https://www.apache.org/dist/cassandra/redhat/40x/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
==> amazon-ebs.cassandra: --2023-09-23 03:17:04--  https://downloads.apache.org/cassandra/redhat/40x/cassandra-4.0.5-1.noarch.rpm
==> amazon-ebs.cassandra: Resolving downloads.apache.org (downloads.apache.org)... 135.181.214.104, 88.99.95.219, 2a01:4f9:3a:2c57::2, ...
==> amazon-ebs.cassandra: Connecting to downloads.apache.org (downloads.apache.org)|135.181.214.104|:443... connected.
==> amazon-ebs.cassandra: HTTP request sent, awaiting response... 404 Not Found
==> amazon-ebs.cassandra: 2023-09-23 03:17:05 ERROR 404: Not Found.
==> amazon-ebs.cassandra:
==> amazon-ebs.cassandra: error: /tmp/cassandra.noarch.rpm: not an rpm package (or package manifest):
==> amazon-ebs.cassandra: Redirecting to /bin/systemctl stop cassandra.service
==> amazon-ebs.cassandra: Failed to stop cassandra.service: Unit cassandra.service not loaded.
==> amazon-ebs.cassandra: Setting a 1m30s timeout for the next provisioner...
==> amazon-ebs.cassandra: Provisioning with shell script: ./optimize-cassandra.sh
==> amazon-ebs.cassandra: Setting a 1m30s timeout for the next provisioner...
==> amazon-ebs.cassandra: Provisioning with shell script: ./install-cassandra-exporter.sh
==> amazon-ebs.cassandra: --2023-09-23 03:17:07--  https://github.com/criteo/cassandra_exporter/releases/download/2.3.8/cassandra_exporter-2.3.8.jar
==> amazon-ebs.cassandra: Resolving github.com (github.com)... 20.27.177.113
==> amazon-ebs.cassandra: Connecting to github.com (github.com)|20.27.177.113|:443... connected.
==> amazon-ebs.cassandra: HTTP request sent, awaiting response... 302 Found
==> amazon-ebs.cassandra: Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/116794779/59281245-9a04-4e7b-8b2c-3019d908b7a6?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230923%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230923T031707Z&X-Amz-Expires=300&X-Amz-Signature=dac26f83f6204dceaf94f7cb2bdfca70b9fe7cc7491fe3d3e49430d94705c62e&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=116794779&response-content-disposition=attachment%3B%20filename%3Dcassandra_exporter-2.3.8.jar&response-content-type=application%2Foctet-stream [following]
==> amazon-ebs.cassandra: --2023-09-23 03:17:07--  https://objects.githubusercontent.com/github-production-release-asset-2e65be/116794779/59281245-9a04-4e7b-8b2c-3019d908b7a6?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230923%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230923T031707Z&X-Amz-Expires=300&X-Amz-Signature=dac26f83f6204dceaf94f7cb2bdfca70b9fe7cc7491fe3d3e49430d94705c62e&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=116794779&response-content-disposition=attachment%3B%20filename%3Dcassandra_exporter-2.3.8.jar&response-content-type=application%2Foctet-stream
==> amazon-ebs.cassandra: Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.108.133, 185.199.110.133, 185.199.109.133, ...
==> amazon-ebs.cassandra: Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.108.133|:443... connected.
==> amazon-ebs.cassandra: HTTP request sent, awaiting response... 200 OK
==> amazon-ebs.cassandra: Length: 5686304 (5.4M) [application/octet-stream]
==> amazon-ebs.cassandra: Saving to: ‘/opt/cassandra_exporter/cassandra_exporter.jar’
==> amazon-ebs.cassandra:
==> amazon-ebs.cassandra: 2023-09-23 03:17:07 (241 MB/s) - ‘/opt/cassandra_exporter/cassandra_exporter.jar’ saved [5686304/5686304]
==> amazon-ebs.cassandra:
==> amazon-ebs.cassandra: Created symlink from /etc/systemd/system/multi-user.target.wants/cassandra_exporter.service to /etc/systemd/system/cassandra_exporter.service.
==> amazon-ebs.cassandra: Setting a 1m30s timeout for the next provisioner...
==> amazon-ebs.cassandra: Provisioning with shell script: ./install-cassandra-exporter-standalone.sh
==> amazon-ebs.cassandra: --2023-09-23 03:17:08--  https://github.com/instaclustr/cassandra-exporter/releases/download/v0.9.10/cassandra-exporter-standalone-0.9.10.jar
==> amazon-ebs.cassandra: Resolving github.com (github.com)... 20.27.177.113
==> amazon-ebs.cassandra: Connecting to github.com (github.com)|20.27.177.113|:443... connected.
==> amazon-ebs.cassandra: HTTP request sent, awaiting response... 302 Found
==> amazon-ebs.cassandra: Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/146508722/12ee1780-3ece-11ea-8e11-5d984ce382a0?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230923%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230923T031708Z&X-Amz-Expires=300&X-Amz-Signature=20afc953aaad5d85c277cb7f56d5452737a4d0798e2cf00ad3be46a344bc5271&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=146508722&response-content-disposition=attachment%3B%20filename%3Dcassandra-exporter-standalone-0.9.10.jar&response-content-type=application%2Foctet-stream [following]
==> amazon-ebs.cassandra: --2023-09-23 03:17:08--  https://objects.githubusercontent.com/github-production-release-asset-2e65be/146508722/12ee1780-3ece-11ea-8e11-5d984ce382a0?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230923%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230923T031708Z&X-Amz-Expires=300&X-Amz-Signature=20afc953aaad5d85c277cb7f56d5452737a4d0798e2cf00ad3be46a344bc5271&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=146508722&response-content-disposition=attachment%3B%20filename%3Dcassandra-exporter-standalone-0.9.10.jar&response-content-type=application%2Foctet-stream
==> amazon-ebs.cassandra: Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.111.133, 185.199.108.133, 185.199.110.133, ...
==> amazon-ebs.cassandra: Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.111.133|:443... connected.
==> amazon-ebs.cassandra: HTTP request sent, awaiting response... 200 OK
==> amazon-ebs.cassandra: Length: 9204824 (8.8M) [application/octet-stream]
==> amazon-ebs.cassandra: Saving to: ‘/opt/cassandra_exporter_standalone/cassandra-exporter-standalone.jar’
==> amazon-ebs.cassandra: 2023-09-23 03:17:09 (26.0 MB/s) - ‘/opt/cassandra_exporter_standalone/cassandra-exporter-standalone.jar’ saved [9204824/9204824]
==> amazon-ebs.cassandra:
==> amazon-ebs.cassandra: Setting a 1m0s timeout for the next provisioner...
==> amazon-ebs.cassandra: Provisioning with shell script: ./install-cqlsh-standalone-tool.sh
    amazon-ebs.cassandra: Install CQLSH standalone tool
==> amazon-ebs.cassandra: --2023-09-23 03:17:10--  https://downloads.datastax.com/enterprise/cqlsh-astra.tar.gz
==> amazon-ebs.cassandra: Resolving downloads.datastax.com (downloads.datastax.com)... 100.20.35.108, 54.68.205.189, 34.218.36.108
==> amazon-ebs.cassandra: Connecting to downloads.datastax.com (downloads.datastax.com)|100.20.35.108|:443... connected.
==> amazon-ebs.cassandra: HTTP request sent, awaiting response... 302 Found
==> amazon-ebs.cassandra: Location: https://downloads.datastax.com/enterprise/cqlsh-astra-20221114-bin.tar.gz [following]
==> amazon-ebs.cassandra: --2023-09-23 03:17:10--  https://downloads.datastax.com/enterprise/cqlsh-astra-20221114-bin.tar.gz
==> amazon-ebs.cassandra: Reusing existing connection to downloads.datastax.com:443.
==> amazon-ebs.cassandra: HTTP request sent, awaiting response... 200 OK
==> amazon-ebs.cassandra: Length: 482603 (471K) [application/x-gzip]
==> amazon-ebs.cassandra: Saving to: ‘/opt/cqlsh-astra.tar.gz’
==> amazon-ebs.cassandra: 2023-09-23 03:17:11 (967 KB/s) - ‘/opt/cqlsh-astra.tar.gz’ saved [482603/482603]
==> amazon-ebs.cassandra:
==> amazon-ebs.cassandra: Creating AMI cassandra-BASE-v1-20230923031614-AMI-arm64 from instance i-04b8baec032d2e1b5
==> amazon-ebs.cassandra: Waiting for AMI to become ready...
==> amazon-ebs.cassandra: Skipping Enable AMI deprecation...
==> amazon-ebs.cassandra: Modifying attributes on AMI (ami-06737cc831127768d)...
==> amazon-ebs.cassandra: Modifying attributes on snapshot (snap-096a07cac25e522cd)...
==> amazon-ebs.cassandra: Adding tags to AMI (ami-06737cc831127768d)...
==> amazon-ebs.cassandra: Tagging snapshot: snap-096a07cac25e522cd
==> amazon-ebs.cassandra: Creating AMI tags
==> amazon-ebs.cassandra: Creating snapshot tags
==> amazon-ebs.cassandra: Terminating the source AWS instance...
==> amazon-ebs.cassandra: Cleaning up any extra volumes...
==> amazon-ebs.cassandra: No volumes to clean up, skipping
==> amazon-ebs.cassandra: Deleting temporary security group...
==> amazon-ebs.cassandra: Deleting temporary keypair...
Build 'amazon-ebs.cassandra' finished after 5 minutes 20 seconds.

==> Wait completed after 5 minutes 20 seconds

==> Builds finished. The artifacts of successful builds are:
--> amazon-ebs.cassandra: AMIs were created:
ap-northeast-1: ami-06737cc831127768d

下一篇文章將會展示實作如何 launch Cassandra Cluster 使用本篇建置 Custom Cassandra AMI 之 Terraform 模組。


上一篇
實作 AWS 常用服務之 Terraform 模組系列 - MSK 篇
下一篇
實作 AWS 常用服務之 Terraform 模組系列 - Launch an Custom AMI of Cassandra Cluster 篇
系列文
大家都在用 Terraform 實作 IaC 為什麼不將程式寫得更簡潔易讀呢?30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言