AWS의 무료 Instance (EC2, T2.micro)에 blog, mysql, webServer(tomcat) 등을 운영하려 하니
Memory Size가 1GB 밖에 되지 않아 메모리 문제가 발생한다. (cannot allocate memory)
-
linux swap 할당 (기본적으로 AWS의 경우 swap이 할당되지 않은 상태로 instance가 생성된다.)
> swap 할당 (2GB)
root# dd if=/dev/zero of=/mnt/swapfile bs=1M count=2048 2048+0 records in 2048+0 records out 2147483648 bytes (2.1 GB, 2.0 GiB) copied, 30.9018 s, 69.5 MB/s root# sudo mkswap /mnt/swapfile Setting up swapspace version 1, size = 2 GiB (2147479552 bytes) no label, UUID=afb41407-0fa8-4e9f-a8ad-c05987b94518 root# swapon /mnt/swapfile swapon: /mnt/swapfile: insecure permissions 0644, 0600 suggested.
> 할당 상태 확인
root# free total used free shared buff/cache available Mem: 1014540 280952 73624 27388 659964 536124 Swap: 2097148 0 2097148
-
MYSQL (innodb buffer size 조정)
> /etc/mysql/my.cnf (or) /etc/mysql/mysql.conf.d/mysqld.cnf
[mysqld] … innodb_buffer_pool_size = 64M …
> MYSQL 재시작 후 적용 확인 (/var/log/mysql/error.log)
2018-03-20T06:18:17.509059Z 0 [Note] InnoDB: Initializing buffer pool, total size = 64M, instances = 1, chunk size = 64M