Handy terraform scripts for running TiDB on AWS
- git clone this project,and execute
terraform init
- modify variables.tf, fill with your aws_access_key and aws_secret_key, and the cluster topology
- execute
terraform plan
- Make sure terraform generates right plan, and execute
terraform apply
- After Step 4, you can see the public IP of relay-server,ssh to the replay-server, the tidb-ansible directory will be on /home/ec2-user/tidb-ansible
- find
# ssh_args = -i aws.key -C -o ControlMaster=auto -o ControlPersist=60s
, remove the comment mark, and deploy tidb using tidb-ansible. - execute
terraform destroy
to destroy all resources when you do not need to use these resources
-
Deploy region
- us-east-1
-
Default EC2 instance type
type instanceType counts typeOfSubnet bastion t2.micro 1 public tidb c4.4xlarge 3 priveta tikv i3.2xlarge 3 private pd i3.xlarge 3 private monitor t2.xlarge 1 private -
Network resource
- 1 VPC
- 1 public subnet
- 1 private subnet
- 1 internet gateway
- 1 nat gateway
-
ELB resrouce
- tidb provides ELB, expose port 4000
- tidb monitor ELB,expose port 3000
ELB is in public subnet
-
Security group
- All the ports TiDB needs
-
Storage resource
- monitor node has a 200GB EBS, tikv nodes have 1.7T NVMe SSD, pd nodes have 880 GB NVMe SSD
-
AWS key pair
-
Generating Template File for TiDB ansible
- Generate TiDB-Ansible 's inventory.ini
- First refer to this document to install the AWS cli tool.
- Configure the local AWS cli tool, ~/.aws/config is configured as follows:
[default]
region=us-east-1 # Fill in the name of region you need to operate.
output=json
touch ~/.aws/credentials, fill with your aws_access_key and aws_secret_key as follows:
[default]
aws_access_key_id=xxx
aws_secret_access_key=xxx
- Execute the following command after the above steps are completed.
aws ec2 describe-images --filters "Name=name,Values=amzn2-ami-hvm-*" "Name=virtualization-type,Values=hvm"
Select an AMI from the returned AMI list, modify main.tf file and fill in the OwnerId
value in the list of owners fields in the data "aws_ami" "distro"
.