Server & Infra

AWS EC2에 설치해둔 Redis에 GUI툴로 접속하기, Java에서 접속하기

2021. 1. 24. 18:50
목차
  1. AWS EC2에 설치한 Redis에 GUI 툴로 접속하기
  2. AWS EC2에 설치한 Redis에 Java로 접속하기

AWS EC2에 설치한 Redis에 GUI 툴로 접속하기

 

Release Medis for Windows · x2jia/medis

Medis a Redis client for Windows platform. Medis 是一个可视化的 Redis 客户端,这是它的 Windows 安装包。最新版本是 MedisForWin171028。 下载详情以及其他下载链接: http://www.waketu.com/article/59f3bdbe36e8b71f1b1badd2

github.com

위 링크로 가서 exe 파일을 다운 받아 설치한다.
설치 후 실행하면 SSH Tunnel을 지원하는 Redis GUI툴을 사용할 수 있다.

SSH Tunnel 쪽에는 EC2에 접속한다 생각하고 설정을 넣어주면 되고
Redis Host쪽에는 EC2 내부에서 Redis를 접속하면 localhost니까 
포트를 건드리지 않았다면 그대로 두면 된다.

무료로 이렇게 멋진 Remote Redis GUI툴을 사용할 수 있다.
Terminal 탭으로 이동해서 CLI 환경으로 명령어를 날릴 수 도 있고
GUI 환경에서 클릭으로 키를 지우거나 키 값을 조회할 수도 있다.

이전에는 RDM 이라는 게 만힝 쓰였던 것 같은데 안타깝게도 현재는 유료로 바뀌었다.
CLI보다 GUI를 훨씬 좋아하는 나로서는 꼭 이 툴이 필요했다 ㅋㅋ 아 그러고보니 이름이 뭐지.
아 Medis 인가보다.

어쨋든 이렇게 EC2에 설치해뒀던 Redis에다가 원격 + GUI로 접속하기를 마쳤다.


AWS EC2에 설치한 Redis에 Java로 접속하기

spring-boot-starter-data-redis 를 사용한다.

SSH Tunnel을 이용한 접속방법은 확인하지 못해서
window용 Redis를 설치 후 로컬에서 테스트한다.
Eureka Client로 활용할 경우 해당 Host에 Redis를 설치하면 local에서 활용 가능하므로
그대로 진행해도 괜찮을 것 같다. 이하는 윈도우용 Redis 설치 링크

github.com/microsoftarchive/redis/releases

 

Releases · microsoftarchive/redis

Redis is an in-memory database that persists on disk. The data model is key-value, but many different kind of values are supported: Strings, Lists, Sets, Sorted Sets, Hashes - microsoftarchive/redis

github.com

 

build.gradle

// Redis
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-redis
compile 'org.springframework.boot:spring-boot-starter-data-redis:2.3.1.RELEASE'

 

application.properties

# Redis Configuration
spring.redis.host=localhost
spring.redis.port=6379

 

RedisConfiguration.java

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
import org.springframework.data.redis.serializer.StringRedisSerializer;

@Configuration
@EnableRedisRepositories
public class RedisConfiguration {

    @Bean
    public RedisConnectionFactory redisConnectionFactory() {
        LettuceConnectionFactory lettuceConnectionFactory = new LettuceConnectionFactory();
        return lettuceConnectionFactory;
    }

    @Bean
    public RedisTemplate<String, Object> redisTemplate() {
        RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
        redisTemplate.setConnectionFactory(redisConnectionFactory());
        redisTemplate.setKeySerializer(new StringRedisSerializer());
        redisTemplate.setValueSerializer(new StringRedisSerializer());
        return redisTemplate;
    }

    @Bean
    public StringRedisTemplate stringRedisTemplate() {
        StringRedisTemplate stringRedisTemplate = new StringRedisTemplate();
        stringRedisTemplate.setKeySerializer(new StringRedisSerializer());
        stringRedisTemplate.setValueSerializer(new StringRedisSerializer());
        stringRedisTemplate.setConnectionFactory(redisConnectionFactory());
        return stringRedisTemplate;
    }

    @Bean
    public ValueOperations<String, String> redis() {
        return stringRedisTemplate().opsForValue();
    }
}

 

RichController.java

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class RichController {

    @Autowired
    private ValueOperations<String, String> redis;
    
    @PostMapping(path="/redisTest")
    public String redisTest(@RequestBody String redisKey) {
    	        
        if(redis.get(redisKey) == null) redis.set(redisKey, "valueFor"+redisKey);
        
        return redis.get(redisKey);
        
    }
    
}

 

redis 객체로 간단하게 set, get 등의 명령어를 테스트해봤다.

저작자표시 (새창열림)

'Server & Infra' 카테고리의 다른 글

Github Actions 를 이용한 CI 테스트 자동화  (2) 2022.07.27
AWS EC2에 오라클 설치, 접속, Scott&HR 활성화  (0) 2021.01.24
AWS EC2에 Redis 설치하기  (0) 2021.01.24
AWS RDS MySQL 서버 시간 변경  (0) 2020.08.07
EC2 t2.micro 인스턴스 재부팅 후 jupyter notebook 재설정  (0) 2020.08.07
  1. AWS EC2에 설치한 Redis에 GUI 툴로 접속하기
  2. AWS EC2에 설치한 Redis에 Java로 접속하기
'Server & Infra' 카테고리의 다른 글
  • Github Actions 를 이용한 CI 테스트 자동화
  • AWS EC2에 오라클 설치, 접속, Scott&HR 활성화
  • AWS EC2에 Redis 설치하기
  • AWS RDS MySQL 서버 시간 변경
리차드
리차드
리차드
화음을 좋아하는 리차드🎶
리차드
전체
오늘
어제
  • 전체 게시글 보기 (200)
    • Portfolio (0)
    • Thoughts & Records (17)
    • 우아한테크코스 4기 (43)
    • Java & Spring (36)
    • JPA & QueryDSL (2)
    • Database (18)
    • Server & Infra (21)
    • Network (0)
    • Algorithm (11)
    • IDE (12)
    • HTML & CSS (4)
    • JavaScript (11)
    • Life (13)

블로그 메뉴

  • Github

공지사항

인기 글

태그

  • 알고리즘
  • aws
  • 스프링
  • 스프링부트
  • EC2
  • oracle
  • git
  • IntelliJ
  • SQL
  • java
  • 우테코
  • javascript
  • 자바
  • 우아한테크코스
  • 오라클
  • 리차드
  • Spring
  • 웹 백엔드 4기
  • 화음을 좋아하는
  • 자바스크립트

최근 댓글

최근 글

hELLO · Designed By 정상우.
리차드
AWS EC2에 설치해둔 Redis에 GUI툴로 접속하기, Java에서 접속하기
상단으로

티스토리툴바

개인정보

  • 티스토리 홈
  • 포럼
  • 로그인

단축키

내 블로그

내 블로그 - 관리자 홈 전환
Q
Q
새 글 쓰기
W
W

블로그 게시글

글 수정 (권한 있는 경우)
E
E
댓글 영역으로 이동
C
C

모든 영역

이 페이지의 URL 복사
S
S
맨 위로 이동
T
T
티스토리 홈 이동
H
H
단축키 안내
Shift + /
⇧ + /

* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.