Ubuntu
우분투(Ubuntu) 스왑 메모리(Swap Memory) 설정
AWS EC2 인스턴스에서 메모리가 부족할때 스왑 메모리를 이용해 디스크 용량을 메모리로 취급할 수 있다.

Ubuntu 환경에서라면 아래 Bash 명령어로 바로 실행해볼 수 있다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$ free -m
// check memory size
 
$ sudo dd if=/dev/zero of=/swapfile bs=1M count=1024
//t3a.nano memory 512MB *2 =  Swap file size 1024MB(bs*1024)
 
$ sudo chmod 600 /swapfile
$ sudo mkswap /swapfile
$ sudo swapon /swapfile
 
$ free -m
// check attached swap memory size
 
$ sudo nano /etc/fstab
 
/swapfile swap swap defaults 0 0
// Write above line to fstab for set swapfile when the instance is reboot.
cs

스왑 메모리는 실제 메모리의 최대 2배까지만 설정해두는게 좋다고 한다. (너무 오래되서 레퍼런스를 못찾겠...)

t3a.nano의 메모리가 512MB니까 스왑메모리는 최대 1024MB까지 설정하는게 좋겠죠.
bs 디폴트를 128M로 잡는다면 8개 쌓으면 1024니까 bs=128M count=8로 설정하면 됩니다.

뭐 이런 내용은 다른데에서 더 정확하게 다룰것이고 나중에 내가 볼 기록이니까 이쯤하면 될것같다.
D.2023-06-02 V.1,678