Print
카테고리: [ NoSQL ]
조회수: 37858

redis 는 in-memory + key / value 방식의 DB입니다.
모든 데이터는 메모리에 저장되고 데이터 access 도 메모리에서 일어나는 만큼 굉장히 빠른 r/w 성능을 보장하고
memcached에 비해 더 큰 데이터 사이즈, 다양한 data type 등을 지원하며
redis가 down 되는 등 데이터 유실에 대비하여 disk 를 persistance store 로 사용하는 안정성 또한 갖춘 nosql db 입니다.

redis installation


[root@c013fdc0ddc4 engn001]# wget http://download.redis.io/redis-stable.tar.gz
[root@c013fdc0ddc4 engn001]# tar xvzf redis-stable.tar.gz
[root@c013fdc0ddc4 engn001]# cd redis-stable
[root@c013fdc0ddc4 redis-stable]# make
cd src && make all
make[1]: Entering directory `/engn001/redis-stable/src'
    CC Makefile.dep
make[1]: Leaving directory `/engn001/redis-stable/src'
make[1]: Entering directory `/engn001/redis-stable/src'
    CC adlist.o
In file included from adlist.c:34:0:
zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory
 #include <jemalloc/jemalloc.h>
                               ^
compilation terminated.
make[1]: *** [adlist.o] Error 1
make[1]: Leaving directory `/engn001/redis-stable/src'
make: *** [all] Error 2

=> complie 과정에서 에러가 발생한다면 아래 과정 추가 수행

[root@c013fdc0ddc4 redis-stable]# yum -y install epel-release
[root@c013fdc0ddc4 redis-stable]# yum -y install varnish
[root@c013fdc0ddc4 redis-stable]# 

[root@c013fdc0ddc4 deps]# make hiredis  jemalloc  linenoise  lua
MAKE hiredis
cd hiredis && make static
.
.
.
[root@c013fdc0ddc4 redis-stable]# make
cd src && make all
make[1]: Entering directory `/engn001/redis-stable/src'
    LINK redis-cli
    CC redis-benchmark.o
    LINK redis-benchmark
    INSTALL redis-check-rdb
    INSTALL redis-check-aof

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

make[1]: Leaving directory `/engn001/redis-stable/src'

[root@c013fdc0ddc4 redis-stable]# make install
cd src && make install
make[1]: Entering directory `/engn001/redis-stable/src'

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

    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
make[1]: Leaving directory `/engn001/redis-stable/src'
[root@c013fdc0ddc4 src]# ./redis-server /engn001/redis-stable/redis.conf 
[1] 5022
[root@c013fdc0ddc4 src]# 5022:C 24 Nov 2019 05:23:41.762 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
5022:C 24 Nov 2019 05:23:41.762 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=5022, just started
5022:C 24 Nov 2019 05:23:41.762 # Configuration loaded
                _._
           _.-``__ ''-._
      _.-``    `.  `_.  ''-._           Redis 5.0.7 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 5022
  `-._    `-._  `-./  _.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |           http://redis.io
  `-._    `-._`-.__.-'_.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |
  `-._    `-._`-.__.-'_.-'    _.-'
      `-._    `-.__.-'    _.-'
          `-._        _.-'
              `-.__.-'

5022:M 24 Nov 2019 05:23:41.766 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
5022:M 24 Nov 2019 05:23:41.767 # Server initialized
5022:M 24 Nov 2019 05:23:41.767 # 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.
5022:M 24 Nov 2019 05:23:41.770 * Ready to accept connections

=> 기동 시의 로그로 알 수 있는 내용

[root@c013fdc0ddc4 engn001]# cat /proc/sys/net/core/somaxconn
128
[root@c013fdc0ddc4 engn001]# sudo sysctl -w net.core.somaxconn=4096
[root@c013fdc0ddc4 engn001]# vi /etc/sysctl.conf
net.core.somaxconn = 4096
[root@c013fdc0ddc4 engn001]# cat /sys/kernel/mm/transparent_hugepage/enabled
always [madvise] never
[root@c013fdc0ddc4 engn001]# echo never > /sys/kernel/mm/transparent_hugepage/enabled
[root@c013fdc0ddc4 engn001]# cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]

[root@c013fdc0ddc4 engn001]# vi /etc/rc.local
echo never > /sys/kernel/mm/transparent_hugepage/enabled
[root@c013fdc0ddc4 engn001]# chmod u+x /etc/rc.d/rc.local
[root@c013fdc0ddc4 engn001]# systemctl start rc-local 
67:C 24 Nov 2019 06:58:47.511 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
67:C 24 Nov 2019 06:58:47.511 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=67, just started
67:C 24 Nov 2019 06:58:47.511 # Configuration loaded
 .
 .

68:M 24 Nov 2019 06:58:47.513 # Server initialized
68:M 24 Nov 2019 06:58:47.514 * DB loaded from disk: 0.000 seconds
68:M 24 Nov 2019 06:58:47.514 * Ready to accept connections
[root@c013fdc0ddc4 src]# ps -ef | grep redis
root      5022    14  0 05:23 pts/1    00:00:00 ./redis-server 127.0.0.1:6379
root      5027    14  0 05:23 pts/1    00:00:00 grep --color=auto redis

[root@c013fdc0ddc4 data]# ps -eLf | grep redis
root      5052    14  5052  0    4 05:39 pts/1    00:00:01 redis-server 127.0.0.1:6379
root      5052    14  5053  0    4 05:39 pts/1    00:00:00 redis-server 127.0.0.1:6379
root      5052    14  5054  0    4 05:39 pts/1    00:00:00 redis-server 127.0.0.1:6379
root      5052    14  5055  0    4 05:39 pts/1    00:00:00 redis-server 127.0.0.1:6379

=> redis 서버의 file I/O 를 위한 thread 가 돌고 있음