$ cd bin
$ mkdir nodes
conf 파일에서 설정
cluster-enabled yes
실행 시 옵션으로 설정
--cluster-enabled yes --cluster-config-file ./nodes/node_1111.conf
$ ./redis-server ./conf/redis_1113.conf --bind 0.0.0.0 --port 1113 --pidfile ./pid/redis_1113.pid --dir ./data --logfile ./logs/redis_1113.log --loglevel notice --appendfilename append_1113.aof --maxmemory "0"
--cluster-enabled yes --cluster-config-file ./nodes/node_1111.conf
$ ps -ef | grep redis
root 95021 1 0 12:28 ? 00:00:04 ./redis-server 0.0.0.0:1111 [cluster]
root 95106 1 0 12:28 ? 00:00:04 ./redis-server 0.0.0.0:1112 [cluster]
root 95168 1 0 12:28 ? 00:00:04 ./redis-server 0.0.0.0:1113 [cluster]
확인 redis-cli 명령어
$ ./redis-cli -p 1111 -c cluster nodes
묶여있지 않으면
$ ./redis-cli -p 1111 -c cluster nodes
1a3867468ecef3511f5a8e97ba444375733c1b68 :1111@11111 myself,master - 0 0 0 connected
묶여있으면
$ ./redis-cli -p 1111 -c cluster nodes
c495801a7be18b251ade5acfe2e30a68cd352cb7 192.168.124.xxx:1112@11112 master - 0 1640141935321 0 connected
b054593fdd1b3183b70ed262b2525dbf0ccf333e 192.168.124.xxx:1111@11111 myself,master - 0 1640141933000 1 connected
3ba4750956e7c9d31ae0f81e8d59eda2f4d427ea 192.168.124.xxx:1113@11113 master - 0 1640141934317 2 connected
$ ./redis-cli -h 192.168.124.xxx -p 1111 cluster meet 192.168.124.xxx 1112
OK
$ ./redis-cli -h 192.168.124.xxx -p 1111 cluster meet 192.168.124.xxx 1113
OK
$ ./redis-cli -p 1111 -c cluster nodes
c495801a7be18b251ade5acfe2e30a68cd352cb7 192.168.124.xxx:1112@11112 master - 0 1640141935321 0 connected
b054593fdd1b3183b70ed262b2525dbf0ccf333e 192.168.124.xxx:1111@11111 myself,master - 0 1640141933000 1 connected
3ba4750956e7c9d31ae0f81e8d59eda2f4d427ea 192.168.124.xxx:1113@11113 master - 0 1640141934317 2 connected
해시함수
로 적용하여 나온 값을 지정한 각 서버에 매핑하여 저정할 수 있게 해주기 위해 설정한다.분산되서 저장
하기 위해 사용기본 슬롯 범위
node1 : 0-5460
node2 : 5461-10922
node3 : 10923-16383
node slot 설정
각 각 범위를 지정해서 해주면 된다.
$ ./redis-cli -h 192.168.124.238 -p 1111 cluster addslots
{0..5460}
slots {0..5460}
OK
$ ./redis-cli -p 1111 cluster nodes
b054593fdd1b3183b70ed262b2525dbf0ccf333e 192.168.124.xxx:1111@11111 myself,master - 0 1640143816000 1 connected 0-5460
c495801a7be18b251ade5acfe2e30a68cd352cb7 192.168.124.xxx:1112@11112 master - 0 1640143819362 0 connected 5461-10922
3ba4750956e7c9d31ae0f81e8d59eda2f4d427ea 192.168.124.xxx:1113@11113 master - 0 1640143818359 2 connected 10923-16383
📌 여담
📚 참고