From cc5fed2cc8819822f836546f7fdcd0aa1b786439 Mon Sep 17 00:00:00 2001 From: "Filipe Oliveira (Personal)" Date: Wed, 18 Sep 2024 09:43:41 +0100 Subject: [PATCH] Added simple 2 nodes setup (1DB with HA enabled) (#111) * Added default key to rts deployments * Added default key to rts deployments * Removed hcl spurious lock file * Removed hcl spurious lock file * Added simple 2 nodes setup (1DB with HA enabled) * Updated base image from redis 7.1 to 7.4.0 --- .../oss-standalone-redisearch-m5/README.md | 53 ------ .../oss-standalone-redisearch-m5/variables.tf | 7 +- .../common.tf | 12 ++ .../db-resources.tf | 76 +++++++++ .../install-re-7.4.sh | 22 +++ .../output.tf | 15 ++ .../prepare_ips.py | 25 +++ .../shared_resources.tf | 17 ++ .../variables.tf | 159 ++++++++++++++++++ 9 files changed, 330 insertions(+), 56 deletions(-) delete mode 100644 terraform/oss-standalone-redisearch-m5/README.md create mode 100644 terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/common.tf create mode 100644 terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/db-resources.tf create mode 100755 terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/install-re-7.4.sh create mode 100644 terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/output.tf create mode 100644 terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/prepare_ips.py create mode 100644 terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/shared_resources.tf create mode 100644 terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/variables.tf diff --git a/terraform/oss-standalone-redisearch-m5/README.md b/terraform/oss-standalone-redisearch-m5/README.md deleted file mode 100644 index 235482c..0000000 --- a/terraform/oss-standalone-redisearch-m5/README.md +++ /dev/null @@ -1,53 +0,0 @@ -# oss-timescaledb-m5d - -Deploy Multi-VM benchmark scenario, including 1 client and 1 DB machine. -- Cloud provider: AWS -- OS: Ubuntu 20.04 -- Client machine: m5d.8xlarge -- Benchmark machine: m5d.8xlarge. - -------- - -#### Deployment - -##### Required env variables - -The terraform and ansible scripts expect the following env variables to be filled: -``` -export EC2_REGION={ ## INSERT REGION ## } -export EC2_ACCESS_KEY={ ## INSERT EC2 ACCESS KEY ## } -export EC2_SECRET_KEY={ ## INSERT EC2 SECRET KEY ## } -export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES -``` - -##### Required private key - -The terraform script expects the following private key to be present on: -``` -/tmp/benchmarks.redislabs.pem -``` - -##### Deployment steps -within project repo - -```bash -cd terraform/oss-timescale-m5d -terraform plan -terraform apply -ansible-playbook --private-key -u ubuntu -i , ../deps/automata/ansible/mongodb.yml -K -``` - -### Benchmark steps - -Within the benchmark machine - -#### Install tsbs -``` -sudo apt update -sudo apt install default-jdk maven -y - -git clone http://github.com/RediSearch/YCSB.git -cd YCSB -mvn -pl site.ycsb:mongodb-binding -am clean package - -``` diff --git a/terraform/oss-standalone-redisearch-m5/variables.tf b/terraform/oss-standalone-redisearch-m5/variables.tf index 9d86c3a..7e912e9 100644 --- a/terraform/oss-standalone-redisearch-m5/variables.tf +++ b/terraform/oss-standalone-redisearch-m5/variables.tf @@ -61,10 +61,11 @@ variable "region" { } # (Ubuntu 20.04) -# ubuntu-bionic-20.04-amd64-server +# ubuntu-bionic-20.04-amd64-server with redis 7.4.0 and memtier 2.1.1 +# https://us-east-2.console.aws.amazon.com/ec2/home?region=us-east-2#ImageDetails:imageId=ami-0cfbc88a79665b192 variable "instance_ami" { - description = "AMI for aws EC2 instance - us-east-2 Ubuntu 20.04 - perf-cto-base-image-ubuntu20.04-redis-7.1.241-tuned-latency" - default = "ami-0e64e0b751414b32e" + description = "AMI for aws EC2 instance - us-east-2 Ubuntu 20.04 - perf-cto-base-image-ubuntu20.04-redis-7.4.0-tuned-latency" + default = "ami-0cfbc88a79665b192" } variable "instance_device_name" { diff --git a/terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/common.tf b/terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/common.tf new file mode 100644 index 0000000..8bf341e --- /dev/null +++ b/terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/common.tf @@ -0,0 +1,12 @@ + +################################################################################ +# This is the bucket holding this specific setup tfstate +################################################################################ +terraform { + backend "s3" { + bucket = "performance-cto-group" + region = "us-east-1" + key = "testing-infrastructure/terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge.tfstate" + } +} + diff --git a/terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/db-resources.tf b/terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/db-resources.tf new file mode 100644 index 0000000..367dff2 --- /dev/null +++ b/terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/db-resources.tf @@ -0,0 +1,76 @@ + +resource "aws_instance" "server" { + count = var.server_instance_count + ami = var.instance_ami + instance_type = var.server_instance_type + subnet_id = data.terraform_remote_state.shared_resources.outputs.subnet_public_id + vpc_security_group_ids = ["${data.terraform_remote_state.shared_resources.outputs.performance_cto_sg_id}"] + key_name = var.key_name + + root_block_device { + volume_size = var.instance_volume_size + volume_type = var.instance_volume_type + iops = var.instance_volume_iops + encrypted = var.instance_volume_encrypted + delete_on_termination = true + } + + volume_tags = { + Environment = "${var.environment}" + Project = "${var.environment}" + Name = "ebs_block_device-${var.setup_name}-DB-${count.index + 1}" + setup = "${var.setup_name}" + triggering_env = "${var.triggering_env}" + github_actor = "${var.github_actor}" + github_org = "${var.github_org}" + github_repo = "${var.github_repo}" + github_sha = "${var.github_sha}" + } + + tags = { + Environment = "${var.environment}" + Project = "${var.environment}" + Name = "${var.setup_name}-DB-${count.index + 1}" + setup = "${var.setup_name}" + triggering_env = "${var.triggering_env}" + github_actor = "${var.github_actor}" + github_org = "${var.github_org}" + github_repo = "${var.github_repo}" + github_sha = "${var.github_sha}" + } + + ################################################################################ + # This will ensure we wait here until the instance is ready to receive the ssh connection + ################################################################################ + provisioner "remote-exec" { + script = "./../scripts/wait_for_instance.sh" + connection { + host = self.public_ip # The `self` variable is like `this` in many programming languages + type = "ssh" # in this case, `self` is the resource (the server). + user = var.ssh_user + private_key = file(var.private_key) + #need to increase timeout to larger then 5m for metal instances + timeout = "5m" + agent = "false" + } + } + ################################################################################ + # Deployment related + ################################################################################ + + ################################################################################ + # Install RE + ################################################################################ + provisioner "remote-exec" { + script = "./install-re-7.4.sh" + connection { + host = self.public_ip # The `self` variable is like `this` in many programming languages + type = "ssh" # in this case, `self` is the resource (the server). + user = var.ssh_user + private_key = file(var.private_key) + #need to increase timeout to larger then 5m for metal instances + timeout = "10m" + agent = "false" + } + } +} diff --git a/terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/install-re-7.4.sh b/terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/install-re-7.4.sh new file mode 100755 index 0000000..d82adc3 --- /dev/null +++ b/terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/install-re-7.4.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# exit the script if any command fails. +set -e + +V=7.4.2 +FULL=$V-216 +FILENAME=/tmp/re.tar +OS="focal" + +wget -O $FILENAME https://s3.amazonaws.com/redis-enterprise-software-downloads/${V}/redislabs-${FULL}-${OS}-amd64.tar + +cd /tmp +tar vxf /tmp/re.tar +echo "DNSStubListener=no" | sudo tee -a /etc/systemd/resolved.conf +sudo mv /etc/resolv.conf /etc/resolv.conf.orig +sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf +sudo service systemd-resolved restart +sudo /tmp/install.sh -y + +# Cleanup +rm -f $FILENAME diff --git a/terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/output.tf b/terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/output.tf new file mode 100644 index 0000000..b01d7d0 --- /dev/null +++ b/terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/output.tf @@ -0,0 +1,15 @@ +output "server_public_ip" { + value = aws_instance.server[*].public_ip +} + +output "server_private_ip" { + value = aws_instance.server[*].private_ip +} + +output "server_instance_type" { + value = var.server_instance_type +} + +output "setup_name" { + value = var.setup_name +} diff --git a/terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/prepare_ips.py b/terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/prepare_ips.py new file mode 100644 index 0000000..321d984 --- /dev/null +++ b/terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/prepare_ips.py @@ -0,0 +1,25 @@ +import subprocess +import json + +# Run the "terraform output json" command +output = subprocess.run(["terraform", "output", "-json"], stdout=subprocess.PIPE) + +output_json = json.loads(output.stdout.decode()) +total_nodes = len(output_json["server_private_ip"]["value"]) + +print("#!/bin/bash\n") +print("TOTAL_NODES={}\n".format(total_nodes)) +suffix_len = len("perf-cto-RE-") +setup_name = output_json["setup_name"]["value"].replace(".", "_").replace("-", "_") +setup_name = setup_name[suffix_len:] +server_instance_type = output_json["server_instance_type"]["value"].replace(".", "_") + +print('CLUSTER_NAME="{}"\n'.format(setup_name)) +print("\n#internal IP addresses") +cleaned_json = {} +for keyn, v in enumerate(output_json["server_private_ip"]["value"], start=1): + print("B_M{}_I={}".format(keyn, v)) + +print("\n#external IP addresses") +for keyn, v in enumerate(output_json["server_public_ip"]["value"], start=1): + print("B_M{}_E={}".format(keyn, v)) diff --git a/terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/shared_resources.tf b/terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/shared_resources.tf new file mode 100644 index 0000000..824e6b9 --- /dev/null +++ b/terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/shared_resources.tf @@ -0,0 +1,17 @@ +# provider +provider "aws" { + region = var.region +} + +################################################################################ +# This is the shared resources bucket key -- you will need it across environments like security rules,etc... +# !! do not change this !! +################################################################################ +data "terraform_remote_state" "shared_resources" { + backend = "s3" + config = { + bucket = "performance-cto-group" + key = "benchmarks/infrastructure/shared_resources.tfstate" + region = "us-east-1" + } +} diff --git a/terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/variables.tf b/terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/variables.tf new file mode 100644 index 0000000..fb1b8ea --- /dev/null +++ b/terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/variables.tf @@ -0,0 +1,159 @@ +################################################################################ +# Variables used for deployment tag +################################################################################ + +variable "setup_name" { + description = "setup name" + default = "perf-cto-RE-re-2nodes-1dbs-25gb-7.4.0-r6i.2xlarge" +} + +variable "github_actor" { + description = "The name of the person or app that initiated the deployment." + default = "N/A" +} + +variable "github_repo" { + description = " The owner and repository name. For example, testing-infrastructure." + default = "N/A" +} + +variable "triggering_env" { + description = " The triggering environment. For example circleci." + default = "N/A" +} + +variable "environment" { + description = " The cost tag." + default = "N/A" +} + +variable "github_org" { + description = " The owner name. For example, RedisModules." + default = "N/A" +} + +variable "github_sha" { + description = "The commit SHA that triggered the deployment." + default = "N/A" +} + +variable "timeout_secs" { + description = "The maximum time to wait prior destroying the VM via the watchdog." + default = "3600" +} + + + +################################################################################ +# Access keys +################################################################################ +variable "private_key" { + description = "private key" + default = "/tmp/benchmarks.redislabs.pem" +} + +variable "key_name" { + description = "key name" + default = "perf-cto-us-east-2" +} + +variable "region" { + default = "us-east-2" +} + +# (Ubuntu 20.04) +variable "instance_ami" { + description = "AMI for aws EC2 instance - us-east-2 Ubuntu 20.04" + default = "ami-0119b1e7fe7303882" +} + +variable "instance_device_name" { + description = "EC2 instance device name" + default = "/dev/sda1" +} + +variable "redis_module" { + description = "redis_module" + default = "N/A" +} + +variable "instance_volume_size" { + description = "EC2 instance volume_size" + default = "1024" +} + +variable "instance_volume_type" { + description = "EC2 instance volume_type" + default = "gp3" +} + + +variable "instance_volume_iops" { + description = "EC2 instance volume_iops" + default = "3000" +} + +variable "client_instance_volume_size" { + description = "EC2 instance volume_size" + default = "256" +} + +variable "client_instance_volume_type" { + description = "EC2 instance volume_type" + default = "gp3" +} + + +variable "instance_volume_encrypted" { + description = "EC2 instance instance_volume_encrypted" + default = "false" +} + +variable "instance_root_block_device_encrypted" { + description = "EC2 instance instance_root_block_device_encrypted" + default = "false" +} + +variable "instance_cpu_threads_per_core" { + description = "CPU threads per core for aws EC2 instance" + default = 1 +} + +variable "instance_cpu_threads_per_core_hyperthreading" { + description = "CPU threads per core when hyperthreading is enabled for aws EC2 instance" + default = 2 +} + +variable "instance_network_interface_plus_count" { + description = "number of additional network interfaces to add to aws EC2 instance" + default = 0 +} + +variable "os" { + description = "os" + default = "ubuntu20.04" +} + +variable "ssh_user" { + description = "ssh_user" + default = "ubuntu" +} + +################################################################################ +# Specific DB machine variables +################################################################################ +# r6id.2xlarge 8 VCPUs ; 64 GB Memory ; 1x474 NVMe SSD +variable "server_instance_type" { + description = "type for aws EC2 instance" + default = "r6i.2xlarge" +} + + +variable "server_instance_count" { + default = "2" +} + +variable "server_instance_cpu_core_count" { + description = "CPU core count for aws EC2 instance" + default = 4 +}