Redis 사용

과녁스·2021년 9월 29일
0

Extra

목록 보기
1/4
post-thumbnail

개요


캐시 서버의 사용을 고려하고 검색을 하던 중 많이 검색 된 Redis를 학습해보기로 하였다.

Redis는 오픈소스 기반의 데이터베이스, 캐시 및 메시지 브로커로 사용되는 in-memory data structure store이다.(메모리 기반의 데이터 저장소?) Redis는 strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, geospatial indexes, and streams과 같은 데이터 구조를 제공합니다. Redis에는 복제, Lua 스크립팅, LRU 제거, 트랜잭션 및 다양한 수준의 Disk 지속성이 내장되어 있으며 Redis Sentinel과 Redis Cluster를 통한 자동 파티셔닝을 통해 고가용성을 제공합니다.(하단 문장은 추가로 확인이 필요)

Redis Windows install

설치


다운로드

Make

  • cd deps
  • make hiredis jemalloc linenoise lua
  • redis 디렉토리로 이동
  • make && make install

log 경로 설정

  • mkdir /{LOG_HOME}/redis

conf 설정

  • vi /usr/lib/tmpfiles.d/redis.conf
# redis.conf
d /run/redis 710 root root
  • cp redis.conf /etc/redis/

  • cd /etc/redis/

  • cp redis.conf 6379.conf

  • vi 6379.conf

# 6379.conf

bind 127.0.0.1
protected-mode yes
port 6379
tcp-backlog 511
unixsocket /tmp/redis_6379.sock
unixsocketperm 700
timeout 0
tcp-keepalive 300
daemonize yes
supervised systemd
pidfile /var/run/redis/redis-server.pid
loglevel debug
logfile /home/system/logs/redis/redis_6379.log
databases 16
always-show-logo yes
save 900 1
save 300 10
save 60 10000

systemd 등록

  • vi /etc/systemd/system/redis.service
# redis.service

[Unit]
Description=Redis data structure server 6379
After=network.target


[Service]
#User=redisuser
#Group=redisuser
ExecStart=/usr/local/bin/redis-server /etc/redis/6379.conf
ExecStop=/usr/local/bin/redis-cli shutdown
Restart=always
Type=forking


[Install]
WantedBy=multi-user.target

실행

systemctl enable redis
systemctl daemon-reload
systemctl start redis
systemctl status redis
systemctl restart redis
systemctl stop redis
profile
ㅎㅅㅎ

0개의 댓글