sudo apt update
sudo apt install -y make build-essential pkg-config libssl-dev
wget https://download.redis.io/redis-stable.tar.gz
tar -zxvf redis-stable.tar.gz
cd redis-stable/deps
make hdr_histogram hiredis jemalloc linenoise lua
cd ..
make
cd ..
make BUILD_TLS=yes
만약 정상적으로 빌드되지 않고 에러 발생 시 아래 명령어 입력 후 재 컴파일 및 빌드 진행
make distclean
vi redis.conf
...
bind 0.0.0.0
...
requirepass <패스워드 지정>
...
vi redis.conf
bind 0.0.0.0
...
# port 6379
...
port 0
tls-port 6379
...
tls-cert-file <.crt 파일 경로>
tls-key-file <.key 파일 경로>
...
tls-ca-cert-file <CA .crt 파일 경로>
...
requirepass <패스워드 지정>
port 6379로 설정되어 있던 기존 port를 주석 처리port 0, tls-port 6379 주석 해제sudo vi /lib/systemd/system/redis-server.service
[Unit]
Description=Advanced key-value store
After=network.target
Documentation=http://redis.io/documentation, man:redis-server(1)
[Service]
ExecStart=/home/ubuntu/redis-stable/src/redis-server /home/ubuntu/redis-stable/redis.conf
ExecStop=/home/ubuntu/redis-stable/src/redis-cli shutdown
Restart=always
User=root
Group=root
[Install]
WantedBy=multi-user.target
Alias=redis.service
ExecStart와 ExecStop의 경로는 Redis Soruce 파일 설치 경로로 지정sudo systemctl daemon-reload
sudo systemctl start redis-server.service
/home/ubuntu/redis-stable/src/redis-cli
auth <패스워드>
hello
아래 내용이 출력된다면 정상적으로 Redis Server가 실행된 것
1) "server"
2) "redis"
3) "version"
4) "7.0.12"
5) "proto"
6) (integer) 2
7) "id"
8) (integer) 3
9) "mode"
10) "standalone"
11) "role"
12) "master"
13) "modules"
14) (empty array)
/home/ubuntu/redis-stable/src/redis-cli --tls --cert <.crt 경로> --key <.key 경로> --cacert <CA .crt 경로>
auth <패스워드>
hello
아래 내용이 출력된다면 정상적으로 Redis Server가 실행된 것
1) "server"
2) "redis"
3) "version"
4) "7.0.12"
5) "proto"
6) (integer) 2
7) "id"
8) (integer) 3
9) "mode"
10) "standalone"
11) "role"
12) "master"
13) "modules"
14) (empty array)
set <Key> <Value>
set test-key test-value
OK
get <Key>
get test-key
"test-value"
[nx]
set test-key nx-test nx
(nil)
데이터 입력 시, nx를 붙이게 되면 이미 존재하는 Value가 있을 경우 에러 출력 후 새로운 Value로 수정하지 않음
[xx]
set test-key xx-test xx
get test-key
"xx-test"
데이터 입력 시, xx를 붙이게 되면 이미 존재하는 Value가 있을 경우에만 새로운 Value로 덮어씀
유익한 글이었습니다.