1. 서론
예전에 redis 2.8.6 설치에 대한 내용을 적은 적이 있다.
/index.php/nosql/63-redis-2-8-6
아마 관심있게 본 사람은 없을 것으로 생각된다.
redis 홈페이지인 redis.io에 가보니 stable 버전은 2.8.9 까지 발표되었다. 2.8.6이나 2.8.9나 설치에 있어 큰 차이는 없을 것 같고, stable은 아니고 3.0.0 Beta-3가 있어 한 번 도전해 보고자 한다.
2. 설치
https://github.com/antirez/redis/archive/3.0.0-beta3.tar.gz
서버에 wget이 있다면 서버에서 손쉽게 바로 다운로드 받을 수 있다. 참고로 아래 테스트 과정은 /home/redis3 이라는 디렉토리 내에서 수행했다.
# wget https://github.com/antirez/redis/archive/3.0.0-beta3.tar.gz --2014-05-07 20:39:33-- https://github.com/antirez/redis/archive/3.0.0-beta3.tar.gz Resolving github.com... 192.30.252.130 Connecting to github.com|192.30.252.130|:443... connected. HTTP request sent, awaiting response... 302 Found Location: https://codeload.github.com/antirez/redis/tar.gz/3.0.0-beta3 [following] --2014-05-07 20:39:34-- https://codeload.github.com/antirez/redis/tar.gz/3.0.0-beta3 Resolving codeload.github.com... 192.30.252.147 Connecting to codeload.github.com|192.30.252.147|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 1182948 (1.1M) [application/x-gzip] Saving to: `3.0.0-beta3.tar.gz' 100%[==============================================================================>] 1,182,948 329K/s in 3.5s 2014-05-07 20:39:40 (329 KB/s) - `3.0.0-beta3.tar.gz' saved [1182948/1182948]
다운로드 받은 파일의 압축을 해제한다.
# tar -xvzf 3.0.0-beta3.tar.gz redis-3.0.0-beta3/ redis-3.0.0-beta3/.gitignore redis-3.0.0-beta3/00-RELEASENOTES redis-3.0.0-beta3/BUGS redis-3.0.0-beta3/CONTRIBUTING redis-3.0.0-beta3/COPYING ... redis-3.0.0-beta3/utils/redis_init_script.tpl redis-3.0.0-beta3/utils/speed-regression.tcl redis-3.0.0-beta3/utils/whatisdoing.sh
그리고 redis-3.0.0-beta3 디렉토리에 들어가본다.
# ls -tlr 합계 120 drwxrwxr-x 4 root root 4096 2014-05-05 17:29 utils drwxrwxr-x 10 root root 4096 2014-05-05 17:29 tests drwxrwxr-x 2 root root 4096 2014-05-05 17:29 src -rw-rw-r-- 1 root root 5660 2014-05-05 17:29 sentinel.conf -rwxrwxr-x 1 root root 281 2014-05-05 17:29 runtest-sentinel -rwxrwxr-x 1 root root 280 2014-05-05 17:29 runtest-cluster -rwxrwxr-x 1 root root 271 2014-05-05 17:29 runtest -rw-rw-r-- 1 root root 33322 2014-05-05 17:29 redis.conf drwxrwxr-x 6 root root 4096 2014-05-05 17:29 deps -rw-rw-r-- 1 root root 4404 2014-05-05 17:29 README -rw-rw-r-- 1 root root 151 2014-05-05 17:29 Makefile -rw-rw-r-- 1 root root 4223 2014-05-05 17:29 MANIFESTO -rw-rw-r-- 1 root root 11 2014-05-05 17:29 INSTALL -rw-rw-r-- 1 root root 1487 2014-05-05 17:29 COPYING -rw-rw-r-- 1 root root 1439 2014-05-05 17:29 CONTRIBUTING -rw-rw-r-- 1 root root 52 2014-05-05 17:29 BUGS -rw-rw-r-- 1 root root 8984 2014-05-05 17:29 00-RELEASENOTES
이제 컴파일을 해본다.
# make
cd src && make all
make[1]: Entering directory `/home/redis3/redis-3.0.0-beta3/src'
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-dump redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html
(cd ../deps && make distclean)
make[2]: Entering directory `/home/redis3/redis-3.0.0-beta3/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
make[2]: Leaving directory `/home/redis3/redis-3.0.0-beta3/deps'
(rm -f .make-*)
...
정말 많이 넘어간다.
...
db.c: In function ‘scanGenericCommand’:
db.c:429: warning: ‘pat’ may be used uninitialized in this function
db.c:430: warning: ‘patlen’ may be used uninitialized in this function
CC replication.o
CC rdb.o
CC t_string.o
CC t_list.o
CC t_set.o
CC t_zset.o
CC t_hash.o
CC config.o
CC aof.o
CC pubsub.o
CC multi.o
CC debug.o
CC sort.o
CC intset.o
CC syncio.o
CC cluster.o
CC crc16.o
CC endianconv.o
CC slowlog.o
CC scripting.o
CC bio.o
CC rio.o
CC rand.o
CC memtest.o
CC crc64.o
CC bitops.o
CC sentinel.o
CC notify.o
CC setproctitle.o
CC blocked.o
CC hyperloglog.o
LINK redis-server
INSTALL redis-sentinel
CC redis-cli.o
LINK redis-cli
CC redis-benchmark.o
LINK redis-benchmark
CC redis-check-dump.o
LINK redis-check-dump
CC redis-check-aof.o
LINK redis-check-aof
Hint: To run 'make test' is a good idea ;)
make[1]: Leaving directory `/home/redis3/redis-3.0.0-beta3/src'
컴파일이 잘 된 것인지 확인하자.
# make test
cd src && make test
make[1]: Entering directory `/home/redis3/redis-3.0.0-beta3/src'
Cleanup: may take some time... OK
Starting test server at port 11111
[ready]: 6723
Testing unit/printver
[ready]: 6722
Testing unit/dump
[ready]: 6724
Testing unit/auth
[ready]: 6725
Testing unit/protocol
[ready]: 6726
Testing unit/basic
[ready]: 6727
Testing unit/scan
[ready]: 6728
Testing unit/type/list
[ready]: 6729
Testing unit/type/list-2
[ready]: 6730
Testing unit/type/list-3
[ready]: 6731
Testing unit/type/set
[ready]: 6732
Testing unit/type/zset
[ready]: 6734
Testing unit/type/hash
[ready]: 6733
Testing unit/sort
[ready]: 6735
Testing unit/expire
[ready]: 6737
Testing unit/other
[ready]: 6736
Testing unit/multi
[ok]: Handle an empty query
...
정말 많이 넘어간다.
...
[ok]: Memory efficiency with values in range 16384
[36/36 done]: unit/memefficiency (340 seconds)
The End
Execution time of different units:
1 seconds - unit/printver
1 seconds - unit/quit
2 seconds - unit/auth
2 seconds - unit/multi
3 seconds - unit/scan
6 seconds - unit/protocol
11 seconds - unit/expire
23 seconds - unit/type/list
27 seconds - integration/replication
6 seconds - integration/aof
3 seconds - integration/rdb
30 seconds - unit/aofrw
3 seconds - integration/convert-zipmap-hash-on-load
1 seconds - unit/pubsub
2 seconds - unit/slowlog
1 seconds - unit/introspection
3 seconds - unit/limits
39 seconds - unit/dump
19 seconds - unit/scripting
54 seconds - unit/type/list-2
46 seconds - integration/replication-psync
65 seconds - unit/type/hash
73 seconds - unit/other
55 seconds - unit/maxmemory
92 seconds - unit/type/set
96 seconds - integration/replication-2
100 seconds - unit/type/zset
62 seconds - unit/bitops
117 seconds - unit/type/list-3
118 seconds - unit/sort
124 seconds - unit/basic
96 seconds - unit/hyperloglog
158 seconds - integration/replication-3
158 seconds - integration/replication-4
131 seconds - unit/obuf-limits
340 seconds - unit/memefficiency
!!! WARNING The following tests failed:
*** [err]: EVAL processes writes from AOF in read-only slaves in tests/unit/scripting.tcl
Expected '102' to equal or match '100'
Cleanup: may take some time... OK
make[1]: *** [test] 오류 1
make[1]: Leaving directory `/home/redis3/redis-3.0.0-beta3/src'
make: *** [test] 오류 2
그런데 위에 make test에서 오류가 발생했는데, 무시하고 다음 단계를 진행한다.
# make install
cd src && make install
make[1]: Entering directory `/home/redis3/redis-3.0.0-beta3/src'
Hint: To run 'make test' is a good idea ;)
INSTALL install
INSTALL install
INSTALL install
INSTALL install
INSTALL install
make[1]: Leaving directory `/home/redis3/redis-3.0.0-beta3/src'
된 것 같기도 하다. src 디렉토리에 들어가서 파일을 확인해본다.
# ls -tlr redis* -rw-rw-r-- 1 root root 2274 2014-05-05 17:29 redisassert.h -rw-rw-r-- 1 root root 66310 2014-05-05 17:29 redis.h -rw-rw-r-- 1 root root 135854 2014-05-05 17:29 redis.c -rwxrwxr-x 1 root root 36954 2014-05-05 17:29 redis-trib.rb -rw-rw-r-- 1 root root 63081 2014-05-05 17:29 redis-cli.c -rw-rw-r-- 1 root root 22155 2014-05-05 17:29 redis-check-dump.c -rw-rw-r-- 1 root root 6328 2014-05-05 17:29 redis-check-aof.c -rw-rw-r-- 1 root root 27418 2014-05-05 17:29 redis-benchmark.c -rw-r--r-- 1 root root 230512 2014-05-07 20:42 redis.o -rwxr-xr-x 1 root root 5906259 2014-05-07 20:42 redis-server -rwxr-xr-x 1 root root 5906259 2014-05-07 20:42 redis-sentinel -rw-r--r-- 1 root root 167720 2014-05-07 20:42 redis-cli.o -rwxr-xr-x 1 root root 4271737 2014-05-07 20:42 redis-cli -rw-r--r-- 1 root root 60448 2014-05-07 20:42 redis-benchmark.o -rwxr-xr-x 1 root root 4177274 2014-05-07 20:42 redis-benchmark -rw-r--r-- 1 root root 45432 2014-05-07 20:42 redis-check-dump.o -rwxr-xr-x 1 root root 45419 2014-05-07 20:42 redis-check-dump -rw-r--r-- 1 root root 20688 2014-05-07 20:42 redis-check-aof.o -rwxr-xr-x 1 root root 22185 2014-05-07 20:42 redis-check-aof
redis-server를 실행하면 redis를 띄울 수 있다.
# ./redis-server
[8478] 07 May 21:00:51.977 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
[8478] 07 May 21:00:51.979 * Increased maximum number of open files to 10032 (it was originally set to 1024).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 2.9.52 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in stand alone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 8478
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
[8478] 07 May 21:00:51.981 # Server started, Redis version 2.9.52
[8478] 07 May 21:00:51.982 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
[8478] 07 May 21:00:51.982 * The server is now ready to accept connections on port 6379
정상적으로 기동된 것 같다. pid가 8478 이라고 하는데 정말 맞는지 창을 하나 더 띄워서 확인하자.
# ps -ef | grep 8478 root 8478 4115 0 21:00 pts/1 00:00:00 ./redis-server *:6379
redis-cli를 이용하여 redis-server에 붙어 간단히 값을 넣은 후 조회한다. redis-cli는 위 redis-server와 같은 src 디렉토리 내에 있다.
# ./redis-cli 127.0.0.1:6379> set sarc_name victok OK 127.0.0.1:6379> get sarc_name "victok" 127.0.0.1:6379>
set으로 sarc_name이라는 키에 vickor라는 값을 넣고, get으로 sarc_name을 조회하니 vickor가 잘 조회된다. 그럼 정의하지 않은 키를 조회하면 어떻게 될까?
127.0.0.1:6379> get tomcat (nil)
역시 nil이다.
오늘은 Redis 3.0.0 Beta 3를 설치하고 간단히 테스트 하는 것을 살펴보았다.