Lightsail RDS를 사용한다면 절대로 보지 않을 수 있는 오류이지만, Lightsail RDS의 비용이 최소 15$/월
인 관계로, 3.5$/월
인 Lightsail 기본 Instance보다 훨씬 비싸 그냥 Lightsail 기본 Instance를 MySql Server로 사용하고자 했고, 그 과정에서 시행착오가 발생하였다.
다음 링크를 참조하여 mysql-server를 설치 후, systemctl start하는 중에 발생한 오류이다.
2022-12-11T07:40:43.508064Z 0 [ERROR] InnoDB: mmap(137428992 bytes) failed; errno 12
2022-12-11T07:40:43.508072Z 0 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2022-12-11T07:40:43.508076Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2022-12-11T07:40:43.508082Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2022-12-11T07:40:43.508086Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2022-12-11T07:40:43.508090Z 0 [ERROR] Failed to initialize builtin plugins.
2022-12-11T07:40:43.508093Z 0 [ERROR] Aborting
Cannot allocate memory for the buffer pool 이라는 오류가 InnoDB의 Plugin Initialization을 막는다.
이로 인하여 mysql-server Daemon이 구동되지 않는다.
현재 Lightsail 최소사양 (Ram 512MB)로 구동중이다. 최소사양인만큼, RAM 사이즈가 너무 작아서 Pool memory를 확보할 수 없기 때문에 발생하는 오류이다.
Mysql 설정에서 사용하는 innoDB Buffer Pool 사이즈를 줄여야 한다.
Mysql이라는 키워드와 위 오류 내용을 적당히 조합하면 설정파일을 수정하라는 조언을 어렵지 않게 발견할 수 있다.
그리고 그런 조언에서는 이 설정파일의 경로가 /etc/mysql/my.cnf
라고 한다.
하지만, 실제로 저 경로로 가면 다음과 같은 내용밖에 없다.
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
#
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
주석에 유저가 어떤 특정한 옵션을 설정할 수 있다고 적혀 있지만, 결국 무엇을 하라는 것인지 직관적으론 이해하기 힘들다.
다음 링크를 참조하면, 기본적으로 실행할 수 있는 어떤 정보를 준다.
The latter of the two directories should contain mysqld.cnf. In other words, the appropriate configuration file should be:
/etc/mysql/mysql.conf.d/mysqld.cnf
상기 기재된 링크를 vim따위로 오픈해보면 실제로 mysql-server에서 사용하는 설정이 나온다.
설정에서 적당한 곳 ([mysqld] 하위 -> 잘 찾아보면 InnoDB에 대한 설명이 있다.)에 다음과 같은 설정을 추가하면 된다.
innodb_buffer_pool_size = {원하는 용량}M
추가 제약 사항)
64M으로 설정시 (64MB) free -m
명령어 기준 다음과 같은 메모리를 갖는다.
사용가능한 용량은 available
86MB이다.
다음과 같은 좋은 글이 있어 추가로 첨부한다.
상기 옵션을 수정함으로서 변경할 수는 있지만, RAM용량이 너무 조금 남았다.
이것은 HW적인 문제이므로 어쩔 수 없이 RAM용량이 더 큰 인스턴스를 구축하여야 할 것 같다.
1GB 인스턴스를 새로 만들고 같은 환경에서 메모리를 체크하였을 때의 결과는 다음과 같다.
Available은 479MB이다. 이 정도면 1개의 ASPNET Core App을 구동할 수 있다.