반응형

MySQL/MariaDB Binlog Cache and Binlog Cache Size

 

·      Version : MySQL 5.7.21, Ubuntu 16.0.4

 

MySQL 서버는 바이너리 로그(Binlog) 내용을 바로 디스크에 쓰지 않고 메모리의 임시 공간을 활용해 버퍼링 한다. 공간을 바이너리 로그 캐시 (Binlog Cache)라고 한다. 트랜잭션이 시작 될때 binlog_cache_size 설정된 용량만큼 메모리를 미리 확보해두고 트랜잭션이 종료(COMMIT, ROLLBACK)되기 전까지 해당 메모리 영역에 트랜잭션을 다음 트랜잭션이 정상적으로 종료되면 바이너리 로그에 해당 트랜잭션을 쓴다.

 

Binlog Cache 상태 정보는 아래 스크립트로 확인 있다.

show status like ‘%bin%’;

 

 

Variable Name

Comment

Binlog_cache_use

Binlog  Cache 사용한 초당 트랜잭션

Binlog_cache_disk_use

Binlog Cache 디스크로 사용한 초당 트랜잭션

Binlog stmt_cache_disk_use

Binlog Cache 디스크로 사용한 초당 비트랜잭션

Binllog_stmt_cache_use

Binlog Cache 사용한 초당 비트랜잭션

 

binlog_cache_use 대비 binlog_cache_disk_use 비율이 높다면 바이너리 로그 캐시 크기(binlog_cache_size) 초과하는 트랜잭션 수가 많다는 이다. 경우 binlog_cache_size 시스템 변수의 용량을 늘리는 것을 검토해야 한다. binlog_cache_size 크기는 아래 스크립트로 확인 있다.

select @@binlog_cache_size, @@max_binlog_cache_size, @@binlog_format;

 

 

Binlog_cache_size 수정은 my.cnf 파일에서 아래 코드를 추가 하여 수정할 있다.

binlog_cache_size = 16M

  



2018-03-29 / 강성욱 / http://sqlmvp.kr / http://sqlangeles.com

 

MySQL, binlog_cache_use, binlog_cache_disk_use, binlog_cache_log_size, max_binlog_cache_size, binlog_format, 바이너리 로그, 바이너리 로그 캐시


반응형

+ Recent posts