회원가입

로그인

아이디
비밀번호
ID/PW 찾기
아직 회원이 아니신가요? 회원가입 하기

AWS(EC2) - InnoDB buffer pool 을 작게 설정

Profile
맥노턴

logo-aws_title_aws.jpg

 

아마존웹서비스 AWS EC2 - MySQL 에는 기본값으로 InnoDB의 buffer pool size가 128M로 지정되어 있다.

그래서 InnoDB를 사용하는 유저라면, 처음에는 잘되던 DB가 어느 순간 다운되어 있는 현상이 생길 수 있는데...

로그를 한 번 열어보면,

 

# sudo vi /var/log/mysqld.log

 

  1. 160308 03:35:11 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
  2. 160308 09:29:46 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
  3. 160308  9:29:46 [Note] /usr/libexec/mysql55/mysqld (mysqld 5.5.46) starting as process 14488 ...
  4. 160308  9:29:46 [Note] Plugin 'FEDERATED' is disabled.
  5. 160308  9:29:46 InnoDB: The InnoDB memory heap is disabled
  6. 160308  9:29:46 InnoDB: Mutexes and rw_locks use GCC atomic builtins
  7. 160308  9:29:46 InnoDB: Compressed tables use zlib 1.2.8
  8. 160308  9:29:46 InnoDB: Using Linux native AIO
  9. 160308  9:29:46 InnoDB: Initializing buffer pool, size = 128.0M
  10. InnoDB: mmap(137363456 bytes) failed; errno 12  
  11. 160308  9:29:46 InnoDB: Completed initialization of buffer pool
  12. 160308  9:29:46 InnoDB: Fatal error: cannot allocate memory for the buffer pool
  13. 160308  9:29:46 [ERROR] Plugin 'InnoDB' init function returned error.
  14. 160308  9:29:46 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
  15. 160308  9:29:46 [ERROR] Unknown/unsupported storage engine: InnoDB
  16. 160308  9:29:46 [ERROR] Aborting

 

위와 같이 피지컬 메모리가 사용 가능한 용량을 넘기는 버퍼풀이 원인일 경우 해결 방법이다. (스왑을 늘린다 하더라도 MySQL이 스왑메모리를 사용하지 않는 것으로 보여진다)

MySQL의 환경설정을 수정하여 버퍼풀을 줄여주면 되는데...

 

# sudo vi /etc/my.cnf

 

으로 환경설정 파일을 열어,

 

innodb_buffer_pool_size = 16M

 

항목을 추가해주고, DB를 재시작하면 되겠다. 16M는 그냥 충분히 줄여주자는 의미다. 

정확한 설정값은 자신의 서비스에 맞게...

 

주의할 점은

  • 기우이겠지만, my.cnf 의 [mysqld] 항목 아래에 추가해 두어야 한다.
  • [mysqld_safe] 하위에 추가하면, safe 모드일 때만 반영되므로 주의.

 

물론, 제대로 값이 적용 되었는지 확인해봐야겠지?

 

# mysql -u root -p

Enter password : **********

...

mysql> show variables like "innodb_buffer_pool_size";
+-------------------------+-----------+
| Variable_name           | Value     |
+-------------------------+-----------+
| innodb_buffer_pool_size | 16777216 |
+-------------------------+-----------+
1 row in set (0.00 sec)

요렇게 보이면, 제대로 설정된 것이다.

 

:맥노턴.

Profile
맥노턴
레벨 31
367464/
-6%
McNorton & Education Lab.
Director
댓글
0
댓글 쓰기
권한이 없습니다.

로그인

아이디
비밀번호
ID/PW 찾기
아직 회원이 아니신가요? 회원가입 하기