-
[Redis] 맥북에 redis 설치하기IT/삽질 2023. 11. 15. 21:21
신규 프로젝트를 검토하면서 세션 관리를 위한 방안 중 redis 를 활용하는 방안이 대두 되었다.
사실 redis 에 대해 막연히 알고 있었는데, 이번 기회를 통해 redis 를 로컬에 설치하고 간단하게 살펴보고자 한다.
다중서버에서 세션 관리에 대해 정리가 잘 된 글이 있어 남긴다.
https://developer111.tistory.com/69
다중서버에서 세션 관리(Redis 세션 클러스터링, Sticky Session)
안녕하세요. 오늘은 다중 서버 환경에서 세션을 어떻게 관리하는지에 대해 알아보겠습니다. 세션 관리는 크게 3가지 방식이 있습니다. sticky session과 세션 클러스터링 그리고 redis를 이용한 세션
developer111.tistory.com
Homebrew 를 사용한 redis 설치
설치하기
맥북을 사용하고 있다면 Homebrew 를 통해 간단히 설치 및 서비스 기동/종료를 할 수 있다.
# 설치할 패키지 검색 brew search redis # redis 설치 brew install redis # redis 기동 brew services start redis # redis 종료 brew services stop redis # redis 삭제 brew uninstall redis # redis 재기동 brew services restart redis
설치 진행 후, 콘솔에서 간단한 명령을 출력하길래 남겨 본다..
아래 음영 처리한 부분이 중요할 것 같아 남긴 건데,
사실 Homebrew 로 설치했다면 이후 info 명령어로 해당 패키지 정보를 확인 가능하다.
==> Downloading https://ghcr.io/v2/homebrew/core/redis/manifests/7.2.3
#################################################################################################################################### 100.0%
==> Fetching redis
==> Downloading https://ghcr.io/v2/homebrew/core/redis/blobs/sha256:0d92f5556242d47cf5ff0414dd547428e871a2a51ac9ce201797528597a391ac
#################################################################################################################################### 100.0%
==> Pouring redis--7.2.3.sonoma.bottle.tar.gz
==> Caveats
To start redis now and restart at login:
brew services start redis
Or, if you don't want/need a background service you can just run:
/usr/local/opt/redis/bin/redis-server /usr/local/etc/redis.conf
==> Summary
🍺 /usr/local/Cellar/redis/7.2.3: 14 files, 2.4MB
==> Running `brew cleanup redis`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).# 설치한 패키지(redis)에 대한 정보 확인 $ brew info redis # 출력 정보 ==> redis: stable 7.2.3 (bottled), HEAD Persistent key-value database, with built-in net interface https://redis.io/ /usr/local/Cellar/redis/7.2.3 (14 files, 2.4MB) * Poured from bottle using the formulae.brew.sh API on 2023-11-15 at 21:12:30 From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/r/redis.rb License: BSD-3-Clause ==> Dependencies Required: openssl@3 ✔ ==> Options --HEAD Install HEAD version ==> Caveats To start redis now and restart at login: brew services start redis Or, if you don't want/need a background service you can just run: /usr/local/opt/redis/bin/redis-server /usr/local/etc/redis.conf
비밀번호 설정하기
설정을 위해 2개 파일을 수정한다.
- /usr/local/etc/redis.conf
- /usr/local/etc/redis-sentinel.conf
redis.conf 파일을 열어서 "#requirepass foobared" 로 기록된 주석을 찾아 원하는 비밀번호로 변경한다.
여기서는 abcd1234 로 변경함.
requirepass abcd1234
redis-sentinel.conf 파일을 찾아 위에서 설정한 값으로 동일하게 수정한다.
서비스 기동하기
brew services start redis
redis에 접속해서 인증하기 (using redis-cli command)
# redis 접속 $ redis-cli -h localhost -p 6379 localhost:6379> auth abcd1234 OK # ping 명령어 수행 localhost:6379> ping PONG
만약 비밀번호를 잘못 입력하면 접속은 되지만 인증 실패한다.
AUTH failed: WRONGPASS invalid username-password pair or user is disabled.
'IT > 삽질' 카테고리의 다른 글
[OCI] 인스턴스 삭제 후 재생성하기 (1) 2024.02.12 [AWS] EC2 인스턴스 행(hang) 현상 & 스왑메모리 할당 (0) 2024.01.04 [SpringBoot] @RequestBody, @ResponseBody 어노테이션 (0) 2023.10.31 [SpringBoot] Spring Security, custom login 반응없음 (1) 2023.05.09 [SpringBoot] Security 관련 에러 - Error creating bean with name 'webSecurityConfig' (0) 2023.05.05