일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Rocky Linux
- 자작 NAS
- Windows 10 Home
- MySQL
- LattePanda Ubuntu
- CentOS 8
- LattePanda NAS
- Openstack Rocky
- 라떼판다
- WireGuard
- MSA
- LattePanda
- Packstack
- ubuntu
- 라떼판다 NAS
- centos 7
- PostgreSQL
- RHEL 7
- haproxy
- MariaDB
- CentOS
- Rocky Linux 8
- RDP Wrap
- nextcloud
- Kubernetes
- RHEL 8
- 라떼판다 우분투
- RHEL
- podman
- openstack
Archives
- Today
- Total
간마늘작업소
[Redis] 이중화 구성 (Redis-Sentinel 이용) 본문
0.개요
- 고객사에 납품된 솔루션 중에 Redis를 사용하는 물건이 있음.
- 이중화 구성을 하는데 Redis-Sentinel을 이용함.
1.기본 정보
- OS 방화벽(Firewalld, iptables)과 SELinux는 비활성화 상태로 설정.
- DB Node 정보
- 192.168.0.17 - RD Node 1, Hostname : ha001
- 192.168.0.18 - RD Node 2, Hostname : ha002
- 192.168.0.19 - RD Node 3, Hostname : ha003
- Redis와 Redis-Sentinel은 사전에 설치되어 있는 것으로 가정.
- 하단 명령어 중 적색 글씨는 Active Node 에만 적용.
- 하단 명령어 중 청색 글씨는 Standby Node에만 적용.
- Redis-Sentinel에는 별도의 VIP가 할당되지 않음.
- HAProxy 또는 L4 스위치를 이용하여 VIP를 할당하고 Failover 상황에서 전환되는 Active Node를 인식하기 위한 조치를 해야함.
2.Redis 설정
cd /etc/redis
sudo cp -rp redis.conf redis.conf_normal
- Redis 기본 설정 백업.
- Redis는 서비스가 실행된 이후에도 상황에 따라 설정 파일이 자동으로 수정됨.
- 따라서, 편집이 필요할 때나 재기동을 진행할 때는 원본을 백업해두고 이를 복원하면서 진행해야할 수도 있음.
2.1.Redis - Active Node 설정
sudo vi redis.conf
bind 0.0.0.0
- RD Node 1을 Active Node로 지정.
- RD Node 1의 Bind 설정 지정.
- 설정 지정 후 저장.
sudo cp -rp redis.conf redis.conf_active_first
- Active Node의 설정 백업.
sudo systemctl restart redis
- Redis 서비스 실행.
sudo systemctl status redis
- Redis 서비스 실행 확인.
2.2.Redis - Standby Node 설정
sudo vi redis.conf
bind 0.0.0.0
(최 하단 이동)
replicaof @@Active Node IP@@ 6379
- 나머지 RD Node 2와 RD Node 3을 Standby Node로 지정.
- Bind 설정 지정
- Active Node 설정 지정.
- 설정 지정 후 저장.
sudo cp -rp redis.conf redis.conf_standby_first
- Standby Node의 설정 백업.
sudo systemctl restart redis
- Redis 서비스 실행.
sudo systemctl status redis
- Redis 서비스 실행 확인.
redis-cli info replication
- Standby Node에서 Redis Replication 상태 확인.
redis-cli info replication
- Active Node에서 Redis Replication 상태 확인.
3.Redis-Sentinel 설정
cd /etc/redis
sudo cp -rp sentinel.conf sentinel.conf_normal
- Redis-Sentinel 기본 설정 백업.
- Redis-Sentinel 서비스가 실행된 이후에도 상황에 따라 설정 파일이 자동으로 수정됨.
- 따라서, 편집이 필요할 때나 재기동을 진행할 때는 원본을 백업해두고 이를 복원하면서 진행해야할 수도 있음.
3.1.Redis-Sentinel - Active Node 설정
sudo vi sentinel.conf
bind 0.0.0.0
(중략)
#sentinel myid @@@@@@@@@@@@@@@@@@@ ## 주석처리
(중략)
sentinel monitor mymaster 192.168.0.17 6379 2
sentinel down-after-milliseconds mymaster 5000
sentinel parallel-syncs mymaster 1
sentinel failover-timeout mymaster 180000
- Active Node 설정 지정.
- RD Node 1의 Bind 설정 지정.
- 기존에 생성된 myid 정보를 삭제 혹은 주석처리. 모니터링할 Active Node를 지정.
- Redis-Sentinel이 Active Node와 통신이 끊겼다는 것을 인지하기 위한 최소시간 지정. (5000 = 5)
- Active Node로부터 한번에 동기화할 수 있는 Standby Node 수 지정.
- Failover 작업 시간의 Timout 시간 지정. (180000 = 3분)
- 설정 지정 후 저장.
sudo cp -rp sentinel.conf sentinel.conf_active_first
- Active Node의 설정 백업.
sudo systemctl restart redis-sentinel
- Redis-Sentinel 서비스 실행.
sudo systemctl status redis-sentinel
- Redis-Sentinel 서비스 실행 확인.
3.2.Redis-Sentinel - Standby Node 설정
sudo vi sentinel.conf
bind 0.0.0.0
(중략)
#sentinel myid @@@@@@@@@@@@@@@@@@@ ## 주석처리
(중략)
sentinel monitor mymaster 192.168.0.17 6379 2
sentinel down-after-milliseconds mymaster 5000
sentinel parallel-syncs mymaster 1
sentinel failover-timeout mymaster 180000
- Active Node 설정 지정.
- RD Node 1의 Bind 설정 지정.
- 기존에 생성된 myid 정보를 삭제 혹은 주석처리. 모니터링할 Active Node를 지정.
- Redis-Sentinel이 Active Node와 통신이 끊겼다는 것을 인지하기 위한 최소시간 지정. (5000 = 5)
- Active Node로부터 한번에 동기화할 수 있는 Standby Node 수 지정.
- Failover 작업 시간의 Timout 시간 지정. (180000 = 3분)
- 설정 지정 후 저장.
sudo cp -rp sentinel.conf sentinel.conf_standby_first
- Standby Node의 설정 백업.
sudo systemctl restart redis-sentinel
- Redis-Sentinel 서비스 실행.
sudo systemctl status redis-sentinel
- Redis-Sentinel 서비스 실행 확인.
redis-cli -p 26379 info sentinel
- Standby Node에서 Redis-Sentinel 상태 확인.
redis-cli -p 26379 info sentinel
- Active Node에서 Redis-Sentinel 상태 확인.
Comments