-
2024.03.31 MMM galera clusterTIL 2024. 3. 31. 16:20
회사에서 DB이중화 구조로 MMM을 사용 중임.
galera cluster를 통해 구현되어 있음.
문제
많은 양의 row 업데이트가 일어난 트랜잭션이 다른 노드에게 전파되는데 좀 오래걸리는 거 같음.
해당 기능은 순차적으로 일어남 (1트랜잭션이 끝나고 2트랜잭션 시작 [트랜잭션은 각자 5000개 row를 CUD함])
다른 노드에 업데이트가 오래걸리니 읽기 시에 노든간의 데이터가 일치하지 않음. (어쩔때는 일치함)
테스트 DB는 단일 DB여서 이런 문제가 발생하지 않았지만 실DB는 이중화가 되어 있기 때문에 이런 문제가 발견되었음.
galera cluster는 논리적으로 동기화 구조이지만 실제로는 동기적으로 동작하지 않는다고함.https://dba.stackexchange.com/questions/203956/mysql-galera-cluster-mass-update-delay
(여기도 대규모 업데이트가 다른 노드까지 복제되는데 몇 초가 걸린다고 함. 해결로는 작은 청크 단위로 많은 요청을 할 것을 추천하고 있음 또는 wsrep_causal_reads 설정을 켜서 트랜잭션 커밋이 될 때의 복제가 이뤄지는 이벤트를 다른 노드가 기다릴 수 있음. 다만 이것은 응답의 속도를 저하시킴)
궁금한 점은 MMM구조이지만 쓰기는 한대의 마스터에게만 될 텐데 쓰기가 있는 트랜잭션에서 읽기가 달라지는 이유가 궁금함. active-active 구조라서 모든 노드가 읽기 쓰기가 가능함인증 기반의 복제를 설명도 함
문서나 읽어보면서 더 원인 파악을 해봐야할 거 같음.
mysql 이중화 도움 동영상
master이지만 stand by일 경우 양방향 복제라고 불리는 이유는?
- failover 시 active로 변하게 되기 때문에 양방향이라고 봐야한다.
master slave와 active stand by의 차이점은 무엇인가
- active: 요청을 처리할 수 있는 시스템
- stand by (=passive = backup): active 장애 시 요청을 대신 처리하는 시스템
- master: write를 처리하는 active 시스템
- slave: master를 복제하며 read를 처리하는 active 시스템
master인데 stand by이면 read write가 가능한데 대기 상태
MySQL Replication
https://serverfault.com/questions/30605/how-fast-is-mysql-replication
기존 master slave구조의 mysql replication에서는 master의 빈로그를 보고 slave가 replayed되는 것으로 알고 있다. master와 slave가 socket으로 연결되어 있고. mysql의 mmm에서도 같은 구조로 된다고 한다.
많은 양의 CUD는 재동기화를 유발할 수 있고 복제까지 시간이 걸릴 수 있다.
active-active 구조에서 pk 순번은?노드끼리 pk는 곂칠 수 있으니 다르게 해야한다.
1번 노드는 1,3,5,7로 증가한다면 2번 노드는 2,4,6,8로 증가해야한다
galera cluster에서는 pk값이 모든 테이블에 필요하다고 한다.
복제때문이라는데 auto increament 값을 추천하고 있다.
Write-Set Replication API란?
많은 양의 update transaction이 여러 노드로 들어갈 때 dead lock이 발생하는 이유도 있다.
old mysql 과 무엇이 다를까?https://galeracluster.com/2015/09/support-for-mysql-transaction-isolation-levels-in-galera-cluster/
https://sightstudio.tistory.com/59
write-set이란?
Waits for InnoDB lock .. 의 의미?
https://galeracluster.com/library/training/tutorials/supporting-transaction-isolation-levels.html
MMM이지만 하나만 write하게 하는 방법 중 하나는 lb를 사용하는 방법이 있을 수 있다.
https://scoutapm.com/blog/from-mysql-mmm-to-mariadb-galera-cluster-a-high-availability-makeover
[ MARIA ] Galera Cluster 구성
'TIL' 카테고리의 다른 글
2024.04.16 Multitenancy환경에서의 auth gateway (0) 2024.04.17 2024.04.06 spring kafka transaction isolation level, L4L7 (0) 2024.04.06 2024.02.25 AuthorizationManager (0) 2024.02.25 2024.02.23 DLT logging custom (0) 2024.02.23 2024.02.03 spring security Authorization Manager Method Security (0) 2024.02.03