-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
61 lines (55 loc) · 1.34 KB
/
run.sh
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
#!/bin/bash
# cria a rede overlay na swarm
docker network create -d overlay --attachable rediscluster_net
network=rediscluster_net
SWARM_MASTER=192.168.99.100
# Configuração do Master
docker service create \
--name redis-master \
--network=rediscluster_net \
--publish 7000:6379 \
--replicas 1 \
redis:alpine redis-server \
--port 6379 \
--maxmemory 2gb;
# Configuração do Slave1
docker service create \
--name redis-slave-1 \
--network=rediscluster_net \
--publish 7001:6380 \
--replicas 1 \
redis:alpine redis-server \
--slaveof redis-master 6379 \
--port 6380 \
--maxmemory 2gb \
--slave-announce-ip $SWARM_MASTER
# Configuração do Slave2
docker service create \
--name redis-slave-2 \
--network=rediscluster_net \
--publish 7002:6381 \
--replicas 1 \
redis:alpine redis-server \
--slaveof redis-master 6379 \
--port 6381 \
--maxmemory 2gb \
--slave-announce-ip $SWARM_MASTER
# Configuração dos Redis Sentinels
docker service create \
--replicas 3 \
--name redis-sentinel \
--publish 7010:26379 \
redis:alpine \
sh -c "\
echo -e 'port 26379\n\
dir /tmp \n\
sentinel monitor mymaster $SWARM_MASTER 7000 2\n\
sentinel down-after-milliseconds mymaster 5000\n\
sentinel parallel-syncs mymaster 1\n\
sentinel failover-timeout mymaster 10000\n\
sentinel announce-ip $SWARM_MASTER\n\
' > sentinel.conf; \
redis-server \
sentinel.conf \
--sentinel \
";