정화 코딩

[Back-end] Window 환경 로컬에 WSL(Ubuntu)로 Redis 설치하기 본문

Web Development

[Back-end] Window 환경 로컬에 WSL(Ubuntu)로 Redis 설치하기

jungh150c 2025. 5. 16. 19:19

WSL(Windows Subsystem for Linux) 설치 및 실행

WSL: Windows에서 리눅스를 실행할 수 있게 해주는 기능

wsl --install

 


Ubuntu에서 Redis 설치 및 실행

sudo apt update
sudo apt install redis-server -y
sudo service redis-server start

 


Redis 시작 후 정상 작동하는지 확인

redis-cli
SET hello "hello world"
GET hello

 


Spring Boot에서 Redis 연결 설정

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-redis'
}

build.gradle 파일에 위와 같이 Redis 관련 의존성을 추가한다. 그리고 다시 빌드한다.

spring:
  data:
    redis:
      host: localhost
      port: 6379

application.yml에 위와 같은 설정을 추가한다. (Redis는 WSL 안에서 실행 중이지만, 같은 PC이기 때문에 localhost 로 접근 가능)

 

Comments