Skip to content

Commit

Permalink
[HotFix] Extend EBS volume and configure MongoDB data directory
Browse files Browse the repository at this point in the history
  • Loading branch information
ahnsugyeong committed May 25, 2024
1 parent d4a5641 commit 09e050c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
14 changes: 11 additions & 3 deletions .ebextensions-dev/02-ebs-extend.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# .ebextensions/01-ebs-extend.config
commands:
01_mount_tmpfs:
command: "sudo mount -o size=10M,rw,nodev,nosuid -t tmpfs tmpfs /tmp"
Expand All @@ -16,6 +15,15 @@ commands:
fi
ignoreErrors: true

04_unmount_tmpfs:
command: "sudo umount /tmp"
04_create_new_partition:
command: |
echo -e "n\np\n2\n\n+20G\nw" | sudo fdisk /dev/nvme0n1
ignoreErrors: true

05_format_new_partition:
command: "sudo mkfs.ext4 /dev/nvme0n1p2"
ignoreErrors: true

06_unmount_tmpfs:
command: "sudo umount /tmp"
ignoreErrors: true
12 changes: 8 additions & 4 deletions .ebextensions-dev/03-mount-ebs.config
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
commands:
01_create_directory:
command: "mkdir -p /mnt/ebs"
command: "mkdir -p /mnt/mongodb_data"

02_check_device:
command: "lsblk | grep nvme0n1"
command: "lsblk | grep nvme0n1p2"
ignoreErrors: false

03_mount_volume:
command: "sudo mount /dev/nvme0n1p1 /mnt/ebs"
command: "sudo mount /dev/nvme0n1p2 /mnt/mongodb_data"
ignoreErrors: false

04_change_permissions:
command: "sudo chown -R ec2-user:ec2-user /mnt/ebs"
command: "sudo chown -R ec2-user:ec2-user /mnt/mongodb_data"

05_add_fstab_entry:
command: "echo '/dev/nvme0n1p2 /mnt/mongodb_data ext4 defaults 0 0' | sudo tee -a /etc/fstab"
ignoreErrors: true
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ services:
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: 12345678
volumes:
- /mnt/ebs/mongo:/data/db
- /mnt/ebs/mongodb_data:/data/db

application:
image: 471112861132.dkr.ecr.ap-northeast-2.amazonaws.com/waggle-dev:latest
Expand Down

0 comments on commit 09e050c

Please sign in to comment.