switched from rds to i5 ec2 for nvme disk read/write speeds
This commit is contained in:
parent
c93d1736fe
commit
bf8b932cdc
4 changed files with 233 additions and 48 deletions
|
|
@ -30,22 +30,31 @@ git clone <your-repo-url> ~/everytab
|
|||
cd ~/everytab
|
||||
```
|
||||
|
||||
## 5. Database Setup
|
||||
## 5. Database Instance (i3.large)
|
||||
|
||||
On the EC2 instance:
|
||||
Spin up an i3.large in the same AZ as the compute instance. This provides 475GB local NVMe with 100K+ IOPS for Postgres — eliminates the EBS/RDS IOPS bottleneck.
|
||||
|
||||
```bash
|
||||
# Add to .bashrc (get the URL from: terraform output -raw database_url)
|
||||
echo "export DATABASE_URL='postgres://everytab:PASS@ENDPOINT:5432/everytab'" >> ~/.bashrc
|
||||
# Launch i3.large (same subnet/AZ, same key pair, allow port 5432 from compute SG)
|
||||
# Then SSH in and run:
|
||||
bash ~/everytab/infra/db-setup.sh
|
||||
```
|
||||
|
||||
This formats the NVMe, installs Postgres on it with aggressive write settings (`fsync=off`), creates the database, and applies the schema.
|
||||
|
||||
On the **compute instance** (c5.2xlarge):
|
||||
|
||||
```bash
|
||||
# Use the private IP printed by db-setup.sh
|
||||
echo "export DATABASE_URL='postgres://everytab@<i3-private-ip>:5432/everytab'" >> ~/.bashrc
|
||||
source ~/.bashrc
|
||||
|
||||
# Test connection
|
||||
# Test connectivity
|
||||
psql $DATABASE_URL -c 'SELECT 1;'
|
||||
|
||||
# Create schema
|
||||
psql $DATABASE_URL -f ~/everytab/pipeline/01_cc_index/schema.sql
|
||||
```
|
||||
|
||||
Note: the i3's local NVMe is ephemeral — data is lost on stop/terminate. Always `pg_dump` before teardown.
|
||||
|
||||
## Pinning the EC2 AMI
|
||||
|
||||
The `data.aws_ami` lookup fetches the latest Amazon Linux 2023 AMI. If Amazon publishes a new one between applies, Terraform will want to replace your EC2 instance.
|
||||
|
|
@ -67,7 +76,15 @@ Remove the `ec2_ami` line from tfvars when you want a fresh instance with the la
|
|||
|
||||
## Teardown (after backup)
|
||||
|
||||
Switch to serving-only mode (destroys EC2, RDS, icons bucket):
|
||||
```bash
|
||||
# Back up the database first
|
||||
pg_dump -U everytab -Fc everytab > ~/everytab_dump.pgfc
|
||||
|
||||
# Back up icons
|
||||
rsync -avP ~/icons/ homelab:/backups/everytab/icons/
|
||||
```
|
||||
|
||||
Switch to serving-only mode (destroys EC2, icons bucket):
|
||||
|
||||
```bash
|
||||
terraform apply -var="scanning=false"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue