Redis - Slave Note Cluster 구성하기
이번 포스팅에서는 Slave Note Cluster 구성 방법에 대해서 알아보도록 하겠습니다.
Redis 이전글 |
https://server-talk.tistory.com/471 - Redis - In-Memory - 알아보기
https://server-talk.tistory.com/472 - Redis - 서버 설치 및 기본설정 알아보기
https://server-talk.tistory.com/473 - Redis - Redis-cli 기본 사용법
https://server-talk.tistory.com/474 - Redis - Redis Desktop Manager Tool
https://server-talk.tistory.com/475 - phpredis 설치 알아보기
https://server-talk.tistory.com/502 - Cluster 알아보기
https://server-talk.tistory.com/503 - Redis - Cluster Master Node 구성하기
https://server-talk.tistory.com/504 - Redis - Cluster Master Node 관련 설정 알아보기
https://server-talk.tistory.com/504 - Redis - Cluster Master Node 관련 설정 알아보기
https://server-talk.tistory.com/505 - Redis - Master Node - Cluster 상태정보 확인
Redis - Slave Node Cluster 구성정보 |
Redis - Slave Node Cluster 설정하기 |
1. Redis - Clustering Slave 폴더 생성
mkdir redis-cluster-slave
cd redis-cluster-slave
2. Redis - Cluster Slave Node 설정파일 생성
# cp /etc/redis/redis.conf 8000-slave.conf
# cp /etc/redis/redis.conf 8100-slave.conf
# cp /etc/redis/redis.conf 8200-slave.conf
3. Redis - Cluster Slave Node1, Node2, Node3 설정파일 수정
3-1) Cluster - Slave Node1
vi 8000-slave.conf
port 8000
daemonize yes
cluster-enabled yes
cluster-config-file nodes-8000.conf
cluster-node-timeout 3000
appendonly yes
appendfilename appendonly_8000.aof
pidfile /var/run/redis_8000.pid
logfile logs/redis_8000.log
3-2) Cluster - Slave Node2
vi 8100-slave.conf
port 8100
daemonize yes
cluster-enabled yes
cluster-config-file nodes-8100.conf
cluster-node-timeout 3000
appendonly yes
appendfilename appendonly_8100.aof
pidfile /var/run/redis_8100.pid
logfile logs/redis_8100.log
3-3) Cluster - Slave Node3
vi 8200-slave.conf
port 8200
daemonize yes
cluster-enabled yes
cluster-config-file nodes-8200.conf
cluster-node-timeout 3000
appendonly yes
appendfilename appendonly_8200.aof
pidfile /var/run/redis_8200.pid
logfile logs/redis_8200.log
4. Redis - Slave Node1, Node2, Node3 - Cluster 실행
# redis-server 8000-slave.conf
# redis-server 8100-slave.conf
# redis-server 8200-slave.conf
5. Redis - Slave Cluster 프로세스 확인
# ps -ef | grep redis
root 212140 1 0 19:11 ? 00:00:03 redis-server 127.0.0.1:7000 [cluster]
root 212145 1 0 19:11 ? 00:00:03 redis-server 127.0.0.1:7100 [cluster]
root 212156 1 0 19:12 ? 00:00:03 redis-server 127.0.0.1:7200 [cluster]
root 214508 1 0 19:38 ? 00:00:00 redis-server 127.0.0.1:8000 [cluster]
root 214513 1 0 19:38 ? 00:00:00 redis-server 127.0.0.1:8100 [cluster]
root 214518 1 0 19:38 ? 00:00:00 redis-server 127.0.0.1:8200 [cluster
6. Redis - Slave Node와 Master Node 연결하기
사용법 : redis-cli --cluster add-node [Slave Node IP]:[Slave Node Port] [Master Node1 IP]:[Master Node1 Port] --cluster-slave
# redis-cli --cluster add-node 127.0.0.1:8000 127.0.0.1:7000 --cluster-slave
# redis-cli --cluster add-node 127.0.0.1:8100 127.0.0.1:7100 --cluster-slave
# redis-cli --cluster add-node 127.0.0.1:8200 127.0.0.1:7200 --cluster-slave
# redis-cli --cluster add-node 127.0.0.1:8000 127.0.0.1:7000 --cluster-slave
>>> Adding node 127.0.0.1:8000 to cluster 127.0.0.1:7000
>>> Performing Cluster Check (using node 127.0.0.1:7000)
M: 5c31b49ad1e4f561c0f371e1c59754da0d018e01 127.0.0.1:7000
slots:[0-5460] (5461 slots) master
M: 95078d7e470c125676dcdddc485bc5a6680286c2 127.0.0.1:7200
slots:[10923-16383] (5461 slots) master
M: 83250ff969fd5a00a950d826257f03f438aec567 127.0.0.1:7100
slots:[5461-10922] (5462 slots) master
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
Automatically selected master 127.0.0.1:7000
>>> Send CLUSTER MEET to node 127.0.0.1:8000 to make it join the cluster.
Waiting for the cluster to join
..
>>> Configure node as replica of 127.0.0.1:7000.
[OK] New node added correctly.
# redis-cli --cluster add-node 127.0.0.1:8100 127.0.0.1:7100 --cluster-slave
>>> Adding node 127.0.0.1:8100 to cluster 127.0.0.1:7100
>>> Performing Cluster Check (using node 127.0.0.1:7100)
M: 83250ff969fd5a00a950d826257f03f438aec567 127.0.0.1:7100
slots:[5461-10922] (5462 slots) master
S: b736062a03f3ff1469d4991b52eff2bd879ce753 127.0.0.1:8000
slots: (0 slots) slave
replicates 5c31b49ad1e4f561c0f371e1c59754da0d018e01
M: 5c31b49ad1e4f561c0f371e1c59754da0d018e01 127.0.0.1:7000
slots:[0-5460] (5461 slots) master
1 additional replica(s)
M: 95078d7e470c125676dcdddc485bc5a6680286c2 127.0.0.1:7200
slots:[10923-16383] (5461 slots) master
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
Automatically selected master 127.0.0.1:7100
>>> Send CLUSTER MEET to node 127.0.0.1:8100 to make it join the cluster.
Waiting for the cluster to join
>>> Configure node as replica of 127.0.0.1:7100.
[OK] New node added correctly.
# redis-cli --cluster add-node 127.0.0.1:8200 127.0.0.1:7200 --cluster-slave
>>> Adding node 127.0.0.1:8200 to cluster 127.0.0.1:7200
>>> Performing Cluster Check (using node 127.0.0.1:7200)
M: 95078d7e470c125676dcdddc485bc5a6680286c2 127.0.0.1:7200
slots:[10923-16383] (5461 slots) master
M: 83250ff969fd5a00a950d826257f03f438aec567 127.0.0.1:7100
slots:[5461-10922] (5462 slots) master
1 additional replica(s)
S: b736062a03f3ff1469d4991b52eff2bd879ce753 127.0.0.1:8000
slots: (0 slots) slave
replicates 5c31b49ad1e4f561c0f371e1c59754da0d018e01
S: 82fde8cd5d4cddd573c10a46effa05d3e6129429 127.0.0.1:8100
slots: (0 slots) slave
replicates 83250ff969fd5a00a950d826257f03f438aec567
M: 5c31b49ad1e4f561c0f371e1c59754da0d018e01 127.0.0.1:7000
slots:[0-5460] (5461 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.
Automatically selected master 127.0.0.1:7200
>>> Send CLUSTER MEET to node 127.0.0.1:8200 to make it join the cluster.
Waiting for the cluster to join
>>> Configure node as replica of 127.0.0.1:7200.
[OK] New node added correctly.
Slave Node와 Master Node 연동시 위 내용이 출력이 됩니다.