1. 개요

잊을만하면 찾아오는 Redis 설치이다.


2. 다운로드

http://download.redis.io/releases/redis-4.0.6.tar.gz


3. 설치

  • make
  • make install

4. 실행

4-1. 위치

make install 하면 /usr/local/bin에 설치된다.

$ pwd
/usr/local/bin
$ ls -l
total 21820
-rwxr-xr-x 1 root root 2448808 Jan 24 01:34 redis-benchmark
-rwxr-xr-x 1 root root 5754952 Jan 24 01:34 redis-check-aof
-rwxr-xr-x 1 root root 5754952 Jan 24 01:34 redis-check-rdb
-rwxr-xr-x 1 root root 2613928 Jan 24 01:34 redis-cli
lrwxrwxrwx 1 root root      12 Jan 24 01:34 redis-sentinel -> redis-server
-rwxr-xr-x 1 root root 5754952 Jan 24 01:34 redis-server

4-2. 실행

$ redis-server
6469:C 24 Jan 01:41:14.843 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
6469:C 24 Jan 01:41:14.843 # Redis version=4.0.6, bits=64, commit=00000000, modified=0, pid=6469, just started
6469:C 24 Jan 01:41:14.843 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
6469:M 24 Jan 01:41:14.844 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
6469:M 24 Jan 01:41:14.844 # Server can't set maximum open files to 10032 because of OS error: Operation not permitted.
6469:M 24 Jan 01:41:14.844 # Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
                _._
           _.-``__ ''-._
      _.-``    `.  `_.  ''-._           Redis 4.0.6 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 6469
  `-._    `-._  `-./  _.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |           http://redis.io
  `-._    `-._`-.__.-'_.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |
  `-._    `-._`-.__.-'_.-'    _.-'
      `-._    `-.__.-'    _.-'
          `-._        _.-'
              `-.__.-'

6469:M 24 Jan 01:41:14.844 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
6469:M 24 Jan 01:41:14.845 # Server initialized
6469:M 24 Jan 01:41:14.845 # 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.
6469:M 24 Jan 01:41:14.845 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
6469:M 24 Jan 01:41:14.845 * DB loaded from disk: 0.000 seconds
6469:M 24 Jan 01:41:14.845 * Ready to accept connections

4-3. redis.conf 지정 & maxclient 설정 변경 후 실행

7584:C 24 Jan 07:47:37.619 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
7584:C 24 Jan 07:47:37.619 # Redis version=4.0.6, bits=64, commit=00000000, modified=0, pid=7584, just started
7584:C 24 Jan 07:47:37.619 # Configuration loaded
7584:M 24 Jan 07:47:37.621 # You requested maxclients of 25600 requiring at least 25632 max file descriptors.
7584:M 24 Jan 07:47:37.621 # Server can't set maximum open files to 25632 because of OS error: Operation not permitted.
7584:M 24 Jan 07:47:37.621 # Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
                _._
           _.-``__ ''-._
      _.-``    `.  `_.  ''-._           Redis 4.0.6 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 7584
  `-._    `-._  `-./  _.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |           http://redis.io
  `-._    `-._`-.__.-'_.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |
  `-._    `-._`-.__.-'_.-'    _.-'
      `-._    `-.__.-'    _.-'
          `-._        _.-'
              `-.__.-'

7584:M 24 Jan 07:47:37.621 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
7584:M 24 Jan 07:47:37.621 # Server initialized
7584:M 24 Jan 07:47:37.622 # 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.
7584:M 24 Jan 07:47:37.622 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
7584:M 24 Jan 07:47:37.622 * DB loaded from disk: 0.000 seconds
7584:M 24 Jan 07:47:37.622 * Ready to accept connections
  • maxclient + 32 만큼 ulimit -n 시도
  • 실패하면 (maxclient + 32) - 16*n 만큼 ulimit -n 재시도

5. 오류

5-1. jemalloc/jemalloc.h

make 과정에서 오류가 발생했다.

In file included from adlist.c:34:0:
zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory
 #include &lgt;jemalloc/jemalloc.h>

구글링하면 deps 하위에서 make hiredis jemalloc linenoise lua geohash-int 하라는 내용이 나온다. 그러나 이때는 진행 중 다음과 같은 문제가 발생했다.

make[1]: Leaving directory `/sw/redis-4.0.6/deps/lua/src'
make: *** No rule to make target `geohash-int'.  Stop.

그래서 아예 yum install jemalloc 한 후 다시 make를 실행했더니 성공했다.

Hint: It's a good idea to run 'make test' ;)