2017년 8월 14일 월요일

[EtC] Linux 에 redis 설치 및 설정


1. redis 설치 


공식 홈페이지 : https://redis.io/download


1-1. redis 다운로드 및 컴파일

[redis@localohst ~]$ wget http://download.redis.io/releases/redis-3.2.9.tar.gz
[redis@localohst ~]$ tar xzf redis-3.2.9.tar.gz
[redis@localohst ~]$ cd redis-3.2.9
[redis@localohst redis-3.2.9]$ make


1-2. 주요 명령어 사용을 위한 PATH 설정

redis-cli, redis-server 명령어의 경우 redis 압축 해제후 make 한 디렉토리 아래  src 에 위치 하고 있다.

어느 위치에서든 사용 가능 하도록 PATH 로 잡아 주도록 한다.

[redis@localohst redis-3.2.9]$ vi ~/.bashrc

export JAVA_HOME=/usr/local/jdk1.8.0_121
export REDIS_HOME=/home/freecatz/redis-3.2.9/src
export PATH=$PATH:$JAVA_HOME/bin:$REDIS_HOME


2. redis 설정

[redis@localohst redis-3.2.9]$ cp ./redis.conf ./redis.conf.ori
[redis@localohst redis-3.2.9]$ vi redis.conf

bind 0.0.0.0
protected-mode no
port 6379
timeout 0
logfile "/home/freecatz/redis-3.2.9/logs/redis.log"
requirepass myPassword



3. redis 실행 및 종료


3-1. redis 실행

[redis@localohst redis-3.2.9]$ redis-server ./redis.conf --protected-mode no & 


3-2. redis 실행 확인

[redis@localohst redis-3.2.9]$ redis-cli
127.0.0.1:6379> auth myPassword
OK
127.0.0.1:6379> ping
PONG


3-3. redis 종료

[redis@localohst redis-3.2.9]$ redis-cli
127.0.0.1:6379> auth myPassword
OK
127.0.0.1:6379> shutdown
11725:M 14 Aug 11:48:56.727 # User requested shutdown...
11725:M 14 Aug 11:48:56.727 * Saving the final RDB snapshot before exiting.
11725:M 14 Aug 11:48:56.732 * DB saved on disk
11725:M 14 Aug 11:48:56.732 * Removing the pid file.
11725:M 14 Aug 11:48:56.732 # Redis is now ready to exit, bye bye...
not connected> exit
[1]+  Done                    redis-server ./redis.conf --protected-mode no
[redis@localohst redis-3.2.9]$