docker compose部署redis-cluster集群
# linux服务器arm架构快速安装redis cluster集群
docker-compose.yaml文件如下
version: '3'
services:
redis-1:
image: redis:latest
container_name: "redis-1"
command: >
redis-server
--port 6379
--cluster-enabled yes
--cluster-config-file nodes.conf
--cluster-node-timeout 5000
--appendonly yes
--requirepass test@123
--masterauth test@456
ports:
- "6379:6379"
volumes:
- ./redis-1-data:/data
networks:
redis-net:
ipv4_address: 172.23.0.2
redis-2:
image: redis:latest
container_name: "redis-2"
command: >
redis-server
--port 6379
--cluster-enabled yes
--cluster-config-file nodes.conf
--cluster-node-timeout 5000
--appendonly yes
--requirepass test@123
--masterauth test@456
ports:
- "6380:6379"
volumes:
- ./redis-2-data:/data
networks:
redis-net:
ipv4_address: 172.23.0.3
redis-3:
image: redis:latest
container_name: "redis-3"
command: >
redis-server
--port 6379
--cluster-enabled yes
--cluster-config-file nodes.conf
--cluster-node-timeout 5000
--appendonly yes
--requirepass test@123
--masterauth test@456
ports:
- "6381:6379"
volumes:
- ./redis-3-data:/data
networks:
redis-net:
ipv4_address: 172.23.0.4
networks:
redis-net:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.23.0.0/16
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
创建集群: 由于现在有了密码,我们需要修改创建集群的命令:
docker exec -it redis-1 redis-cli -a test@123 --cluster create 172.23.0.2:6379 172.23.0.3:6379 172.23.0.4:6379 --cluster-replicas 0 --pass test@123
1
查看集群状态
docker exec -it $(docker ps -q -f name=redis-1) redis-cli -a test@123 cluster info
1
上次更新: 2024/09/25, 19:01:55