카이도스의 Tech Blog

Redis 설치 본문

DB

Redis 설치

카이도스 2024. 2. 4. 14:45
728x90
반응형

환경 : ubuntu 22.04

  • 설치
# 설치 및 확인
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
sudo apt-get update
sudo apt-get install -y redis
redis-server --version
Redis server v=7.2.1 sha=00000000:0 malloc=jemalloc-5.3.0 bits=64 build=95712a67f5005c28

# 시작 및 확인
sudo systemctl --now enable redis-server
sudo systemctl status redis-server.service

# 설정 변경
sudo vi /etc/redis/redis.conf
bind 0.0.0.0
protected-mode yes
requirepass PASSWD
dir /data/redis
port 6379

# 디렉터리 복사
sudo cp -av /var/lib/redis /data/

# 추가 설정
sudo vi /etc/sysctl.conf
vm.overcommit_memory=2
vm.swappiness=1
vm.overcommit_ratio=90

net.core.netdev_max_backlog=30000
net.ipv4.tcp_max_syn_backlog=30000

net.ipv4.tcp_syn_retries=2
net.ipv4.tcp_retries1=2

net.core.rmem_max=268435456
net.core.wmem_max=268435456
net.core.rmem_default=10485760
net.core.wmem_default=10485760
net.ipv4.tcp_rmem=4096 87380 134217728
net.ipv4.tcp_wmem=4096 87380 134217728

net.core.somaxconn=65535
net.ipv4.tcp_fin_timeout=12
vm.max_map_count=262144
net.ipv4.ip_local_port_range=1024 61000
net.ipv4.tcp_max_tw_buckets=540000

# 추가 설정
sudo vi /etc/systemd/system/redis.service
ReadWriteDirectories=-/data/redis

# 재시작 후 확인
sudo systemctl restart redis-server.service
sudo systemctl status redis-server.service

  • 명령어 테스트
# 접속
redis-cli -h IP -p PORT

# 패스워드 입력 후 명령어 테스트
IP:6379> AUTH passwd
OK
IP:6379> set samplekey samplevlaue
OK
IP:6379> get samplekey
"samplevlaue"
728x90
반응형
Comments