◎ 가상머신 2대 준비 ◎ CentOS 8
→ Master : 200.200.200.134
→ Slave : 200.200.200.135
[ 공통 설정 ]
● 설치 + 설정
# 설치
yum -y install redis
# 파일 설정
vi /etc/redis.conf
# 69번 라인 : bind 0.0.0.0
# 재시작
systemctl restart redis
[ Master 설정 ]
● /etc/redis.conf 파일 설정 (주석 해제)
daemonize yes # daemon process 로 동작
min-replicas-to-write 1 # 최소 복제본 수
min-replicas-max-lag 10 # 복제 성공 시간
requirepass [password] # 패스워드 설정
● 재시작
systemctl restart redis
[ Slave 설정 ]
● /etc/redis.conf 파일 설정 (주석 해제)
daemonize yes
replicaof [master ip] [port] # redis port = 6379
masterauth [master password]
replica-read-only yes
● 재시작
systemctl restart redis
☞ 확인 ☜
① Redis 정보로 확인
》 Redis 접속
》 info Replication 입력 시 정보 출력
② Django 에서 로그인 해보기
》 settings.py 수정
SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.redis.RedisCache',
'LOCATION': 'redis://redis:[master password]@[master ip]:6379',
}
}
》 로그인 기능 수행
》 Redis Master 서버 Cache 확인
》 Redis Slave 서버 Cache 확인
'CLOUD > IaC' 카테고리의 다른 글
[Redis] Master - Slave - Sentinel (0) | 2023.03.28 |
---|---|
[Shell Programming] 쉘 스크립트 안에서 쉘 스크립트 실행하기 (0) | 2023.03.27 |
[Shell Programming] 시작하기 (0) | 2023.03.27 |
[Redis] Master Clustering(3) - Slave Clustering(3) (0) | 2023.03.24 |
[Redis] 시작하기 (0) | 2023.03.24 |