동작 방법
MySQL (is source that replicating)
> Orchestrator (will be actively polling mysql for information & pulling it into its own space)
> as updates are done,it will push infromation into Consul (Key-value store)
> other processes take data from the Consul and update to ProxySQL (proxy application) almost immediate
SPOF 요소 제거를 위해 Orchestrator 사용
Orchestrator: MySQL 복제 운영 및 복구 실행
automatically recover replication
holistic recovery
MHA monitor resource server, handle replication recovery
alternate network (network paritioning issue 가 발생할 수 있다.)
subnet, switch 등 네트워크와 관련된 이슈가 발생
Orchestrator는 MHA 의 SPOF 를 피할 수 있는 대안
Orchestrator v3.x 이후 부터 Orchestrator-on-Raft로 raft consensus protocole 이 추가되었다.
- leader node 선출
- leader node 가 선출권을 갖는다.
- Orchestrator 가 공유 DB backend 없이 운영될 수 있도록 한다.
- sqllite 백엔드로 실행될 수 있도록 한다.
ProxySQL 과 Orchestrator 의 Communication
- ProxySQL 의 mysql_replication_hostgroup 테이블에 추가함으로써 read only flag 를 모니터링 할 수 있다. (monitoring user 설정 필요)
- Default 상태에서의 문제점!
- Network partition (네트워크 장애로 각 서브넷이 연결 불가, 독립 상태가 되는 것) 발생 시 Orchestrator 는 master 를 사용불가로 판단하여 리플리카를 새로운 마스터로 승격 시킨다.
- Orchestrator 가 접근할 수 없지만 하지만 구 마스터는 아직 쓰기가 가능한 상태이다.
- ProxySQL 은 신 마스터를 writer hostgroup 으로 옮길 것이고 구 마스터를 제외시킬 것이다.
- Network partition 문제가 해결되어도 구 마스터는 여전히 write 가 가능한 상태이므로 ONLINE되면서 Split brain 현상이 발생된다.
- 해결 방안
- Orchestrator hooks
- Orchestrator hooks 는 이벤트와 같아서 사용자가 설정한대로 스크립트에서 실행 시킬 수 있다.
- default configuration 결과는 /tmp/recovery.log 에 남는다.
- scripting 을 위해서가 아니라면 alert 또는 notify 할 수 있도록 hooks 를 설정하자.
- ProxySQL 의 read-only flag 모니터링에 의존하는 대신 hooks 를 이용해 변경을 상태를 저장할 수 있다.
- 예정된 혹은 예정되지 않은 마스터 변경에 대해서도 ProxySQL 에 업데이트 할 수 있다.
- Pre-failover : writer hostgroup 에서 삭제
- Post-failover : 정상 복구가 되었다면 writer hostgroup 에 추가
- Orchestrator 와 ProxySQL 사이의 Communication 이 불가능 하다면?
- 알아야 할 부분
- Hooks 는 한번만 실행된다.
- Orchestrator 에서 ProxySQL admin 이 사용 가능해야 한다.
- Orchestrator 와 ProxySQL 사이에 Consul 이 추가된다.
- Consul 에 Orchestrator 정보 저장
- "KVClusterMasterPrefix" : "mysql/master"
- "ConsulAddress": "127.0.0.1:8500"
- "ZkAddress": "srv-a, srv-b:12181,srv-c"
- 알아야 할 부분
- Orchestrator hooks
Consul
- Orchestrator 는 Consul 을 위한 native support 기능이 있다.
- RAFT protocol 을 사용하며 여러 지역에서 데이터에 접근 가능한 agent, server 컴포넌트를 갖고 있다.
- 향상된 보안을 위해 ACL을 지원한다.
- SPOF 를 방지하기 위해
- 3개의 Consul 노드가 RAFT 프로토콜로 통신하며, Orchestrator 과 Consul 은 같은 호스트를 공유한다
Architecture
참조
https://blog.pythian.com/mysql-high-availability-with-proxysql-consul-and-orchestrator/
'Database > MySQL, MariaDB' 카테고리의 다른 글
[MY-000068] [Server] unknown option '---'. (0) | 2022.09.13 |
---|---|
MySQL Group Replication 설정 순서 (0) | 2022.09.04 |
ProxySQL 2.3 - 향상된 Group 복제 운영 방식 (0) | 2022.09.04 |
ProxySQL과 Orchestrator의 simple STONITH (0) | 2022.09.03 |
MySQL 백업, 복원 비교 (xtrabackup/mysqldump) (0) | 2019.03.28 |