REDIS 설치 및 테스트

REDIS 설치하기

REDIS는 홈페이지에서 다운받을 수 있다.


FTP를 사용하는 방법

FTP(File Tranfer Protocol)을 이용해 파일을 설치할 사람은 아래의 홈페이지 주소로 들어가 파일을 다운로드 받도록 하자.

REDIS 홈페이지


redisHomepage.PNG

우측 상단에 Download를 클릭하면 아래의 화면이 나오게 된다.


redisDownload.PNG

Stable 버전을 다운받고 FTP를 사용하여 자신의 서버에 실행파일을 옮기도록 하자.


1
2
3
1
2
3
$ tar -xvzf redis-3.0.7.tar.gz
$ cd redis-3.0.7/
$ make

옮긴 이후에 압축을 해제하고 make를 실행해주면 설치가 완료된다.


SSH를 사용하는 방법

Putty와 같은 SSH(Secure Shell)을 사용하여 다운받으려면 아래의 주소를 입력해 wget으로 받아오면 된다.

1
$ wget http://redis.googlecode.com/files/redis-3.0.7.tar.gz


1
2
3
1
2
3
$ tar -xvzf redis-3.0.7.tar.gz
$ cd redis-3.0.7/
$ make

마찬가지로 받아온 파일을 압축풀기하고 make를 실행해주면 설치가 완료된다.


REDIS 실행하기

REDIS의 실행은 src/redis-server로 실행할 수 있다.

1
2
3
4
5
$ src/redis-server
[12925] 25 Mar 20:06:20 # Warning: no config file specified, using the default config. In order to specify a config file use 'redis-server /path/to/redis.conf'
[12925] 25 Mar 20:06:20 * Server started, Redis version 2.4.9
[12925] 25 Mar 20:06:20 * The server is now ready to accept connections on port 6379
[12925] 25 Mar 20:06:20 - 0 clients connected (0 slaves), 922304 bytes in use


redis-server로 실행한 후 redis-cli 명령어를 통해 클라이언트로 테스트를 진행할 수 있다.

1
2
3
4
5
6
7
$ src/redis-cli
redis 127.0.0.1:6379> ping
PONG
redis 127.0.0.1:6379> set name Junyoung
OK
redis 127.0.0.1:6379> get name
"Junyoung"


번외

1
2
3
4
5
6
127.0.0.1:6379> keys *
1) "\xac\xed\x00\x05t\x00\x03jun"
2) "\xac\xed\x00\x05t\x00\x02oh"
127.0.0.1:6379> get "\xac\xed\x00\x05t\x00\x03jun"
"\xac\xed\x00\x05t\x00\x05young"

"\xac\xed\x00\x05t\x00\x05young"으로 나오는 이유?

=> 이유는 자바 클래스와 필드정보가 부가적으로 저장되어 있기 때문!

StringRedisSerializer를 사용하여 jdk처럼 지저분한 값을 붙이지 않고 저장하도록 하자.