728x90
반응형
구성도
작업 순서
1. Redis 다운로드 및 설치
wget http://download.redis.io/releases/redis-5.0.5.tar.gz
gzip -d redis-5.0.5.tar.gz
tar xvf redis-5.0.5.tar
cd redis-5.0.5
redis-5.0.5]# make
mv redis-5.0.5 /usr/local/redis
2. Redis 유저 / 그룹 생성
-- redis 유저 / 그룹 생성 공통
groupadd redis
adduser -g redis redis
2-1 폴더 생성
mkdir -p /usr/local/redis/cluster/7000
mkdir -p /usr/local/redis/cluster/conf
cd /usr/local/redis/cluster/conf
3. config 파일 생성
vi redis.7000.conf
################################## INCLUDES ###################################
# include /path/to/local.conf
# include /path/to/other.conf
################################## MODULES #####################################
# loadmodule /path/to/my_module.so
# loadmodule /path/to/other_module.so
################################## NEkrORK #####################################
bind 1.1.1.1 127.0.0.1
protected-mode yes
port 7000
tcp-backlog 511
# unixsocket /tmp/redis.sock
# unixsocketperm 700
timeout 0
tcp-keepalive 300
################################# GENERAL #####################################
dir /usr/local/redis/cluster/7000
daemonize yes
supervised no
pidfile redis.pid
loglevel notice
logfile redis.log
# syslog-enabled no
# syslog-ident redis
# syslog-facility local0
# databases 16
always-show-logo yes
################################ SNAPSHOTTING ################################
save ""
# save 900 1
# save 300 10
# save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.cluster.rdb
################################# REPLICATION #################################
#masterauth 비밀번호 # 설정 안함
replica-serve-stale-data yes
replica-read-only yes
repl-diskless-sync yes
repl-diskless-sync-delay 5
# repl-ping-replica-period 10
repl-timeout 60
repl-disable-tcp-nodelay no
# repl-backlog-size 1mb
# repl-backlog-ttl 3600
replica-priority 100
# min-replicas-to-write 3
# min-replicas-max-lag 10
# min-replicas-max-lag is set to 10.
# replica-announce-ip 5.5.5.5
# replica-announce-port 1234
################################## SECURITY ###################################
#requirepass 비밀번호 # 설정 안함
# rename-command CONFIG ""
################################### CLIENTS ####################################
# maxclients 10000
############################## MEMORY MANAGEMENT ################################
# maxmemory <bytes>
# maxmemory-policy noeviction
# maxmemory-samples 5
# replica-ignore-maxmemory yes
############################# LAZY FREEING ####################################
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no
############################## APPEND ONLY MODE ###############################
appendonly no
appendfilename "appendonly.aof"
# appendfsync always
appendfsync everysec
# appendfsync no
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble yes
################################ LUA SCRIPTING ###############################
lua-time-limit 5000
################################ REDIS CLUSTER ###############################
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
# cluster-replica-validity-factor 10
# cluster-migration-barrier 1
# cluster-require-full-coverage yes
# cluster-replica-no-failover no
########################## CLUSTER DOCKER/NAT support ########################
# cluster-announce-ip 10.1.1.5
# cluster-announce-port 6379
# cluster-announce-bus-port 6380
################################## SLOW LOG ###################################
slowlog-log-slower-than 10000
slowlog-max-len 128
################################ LATENCY MONITOR ##############################
latency-monitor-threshold 0
############################# EVENT NOTIFICATION ##############################
notify-keyspace-events ""
############################### ADVANCED CONFIG ###############################
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
stream-node-max-bytes 4096
stream-node-max-entries 100
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
# client-query-buffer-limit 1gb
# proto-max-bulk-len 512mb
hz 10
dynamic-hz yes
aof-rewrite-incremental-fsync yes
rdb-save-incremental-fsync yes
# lfu-log-factor 10
# lfu-decay-time 1
########################### ACTIVE DEFRAGMENTATION #######################
# activedefrag yes
# active-defrag-ignore-bytes 100mb
# active-defrag-threshold-lower 10
# active-defrag-threshold-upper 100
# active-defrag-cycle-min 5
# active-defrag-cycle-max 75
# active-defrag-max-scan-fields 1000
4. Redis 실행
- 경로이동
cd /usr/local/redis/cluster
# 실행 스크립트 생성
vi redis_start.sh
#!/bin/bash
/usr/local/redis/src/redis-server /usr/local/redis/cluster/conf/redis.7000.conf &
chmod +x redis_start.sh
chown -R redis:redis /usr/local/redis
5. 클러스터 생성
# 클러스터 생성
# 1.1.1.2:7000를 1.1.1.1:7000의 슬레이브로 지정
./redis-cli --cluster create 1.1.1.1:7000 1.1.2.1:7000 1.1.3.1:7000
./redis-cli --cluster add-node 1.1.1.2:7000 1.1.1.1:7000 --cluster-slave
./redis-cli --cluster add-node 1.1.2.2:7000 1.1.2.1.213:7000 --cluster-slave
./redis-cli --cluster add-node 1.1.3.2:7000 1.1.3.1:7000 --cluster-slave
728x90
5-1 유저 스위칭 후 수행
# redis 유저로 변경하여 실행
sudo su redis
./redis_start.sh
6. 클러스터 확인
cd /usr/local/redis/src
./redis-cli --cluster check 1.1.1.1:7000
1.1.1.1:7000 (c6643cb1...) -> 0 keys | 5461 slots | 1 slaves.
1.1.2.1:7000 (1c9669af...) -> 0 keys | 5461 slots | 1 slaves.
1.1.3.1:7000 (f20cc469...) -> 0 keys | 5462 slots | 1 slaves.
[OK] 0 keys in 3 masters.
0.00 keys per slot on average.
>>> Performing Cluster Check (using node xxxx:7000)
M: c6643cb1d0d1ab962b501a2264e6d9ee9083a39b xxxxx:7000
slots:[0-5460] (5461 slots) master
1 additional replica(s)
S: 6fe1fa03f42054304913f5214478be2254116736 xxxxx:7000
slots: (0 slots) slave
replicates f20cc469580f924916132db20b4b655bec216e0d
S: 390e2fe2dd4945f0498cbcf505c2d8a0c5c8b566 xxxxx:7000
slots: (0 slots) slave
replicates c6643cb1d0d1ab962b501a2264e6d9ee9083a39b
S: b56ba5e6b439c30e1aa12859690dd94d511e6d77 xxxx:7000
slots: (0 slots) slave
replicates 1c9669af8a75ffdd9a82e23be6bc78db1c38027f
M: 1c9669af8a75ffdd9a82e23be6bc78db1c38027f xxxxx:7000
slots:[10923-16383] (5461 slots) master
1 additional replica(s)
M: f20cc469580f924916132db20b4b655bec216e0d xxxxx:7000
slots:[5461-10922] (5462 slots) master
1 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
728x90
300x250
'IT > Redis' 카테고리의 다른 글
Redis Cluster 서로 간 통신 할 때 오픈 포트 (0) | 2021.08.12 |
---|---|
Redis 4 설치 및 구성 (0) | 2021.07.29 |
Redis 6 설치 (0) | 2021.07.29 |
Redis 메모리 설명 (0) | 2021.07.22 |