Skip to content

Commit 17f31fc

Browse files
committed
sentinels with docker network host
1 parent 6c78cea commit 17f31fc

File tree

7 files changed

+35
-96
lines changed

7 files changed

+35
-96
lines changed

docker-compose.yml

Lines changed: 28 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -37,69 +37,50 @@ services:
3737
- all-stack
3838
- all
3939

40-
sentinel1:
41-
image: ${REDIS_IMAGE:-redis:7.4.1}
42-
container_name: redis-sentinel1
43-
depends_on:
44-
- redis
45-
entrypoint: "redis-sentinel /etc/redis-conf/sentinels/sentinel1.conf --port 26379"
46-
ports:
47-
- 26379:26379
48-
volumes:
49-
- "./dockers:/etc/redis-conf"
50-
profiles:
51-
- sentinel
52-
- all-stack
53-
- all
54-
55-
sentinel2:
56-
image: ${REDIS_IMAGE:-redis:7.4.1}
57-
container_name: redis-sentinel2
58-
depends_on:
59-
- redis
60-
entrypoint: "redis-sentinel /etc/redis-conf/sentinels/sentinel2.conf --port 26380"
61-
ports:
62-
- 26380:26380
63-
volumes:
64-
- "./dockers:/etc/redis-conf"
65-
profiles:
66-
- sentinel
67-
- all-stack
68-
- all
69-
70-
sentinel3:
71-
image: ${REDIS_IMAGE:-redis:7.4.1}
72-
container_name: redis-sentinel3
73-
depends_on:
74-
- redis
75-
entrypoint: "redis-sentinel /etc/redis-conf/sentinels/sentinel3.conf --port 26381"
76-
ports:
77-
- 26381:26381
78-
volumes:
79-
- "./dockers:/etc/redis-conf"
80-
profiles:
81-
- sentinel
82-
- all-stack
83-
- all
84-
8540
sentinel-cluster:
8641
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:rs-7.4.0-v2}
8742
container_name: redis-sentinel-cluster
43+
network_mode: "host"
8844
environment:
8945
- NODES=3
9046
- TLS_ENABLED=yes
9147
- REDIS_CLUSTER=no
9248
- PORT=9121
9349
command: ${REDIS_EXTRA_ARGS:---enable-debug-command yes --enable-module-command yes --tls-auth-clients optional --save ""}
94-
ports:
95-
- "9121-9123:9121-9123"
50+
#ports:
51+
# - "9121-9123:9121-9123"
9652
volumes:
9753
- "./dockers/sentinel-cluster:/redis/work"
9854
profiles:
9955
- sentinel
10056
- all-stack
10157
- all
10258

59+
sentinel:
60+
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:rs-7.4.0-v2}
61+
container_name: redis-sentinel
62+
depends_on:
63+
- sentinel-cluster
64+
environment:
65+
- REDIS_CLUSTER=no
66+
- NODES=3
67+
- PORT=26379
68+
command: ${REDIS_EXTRA_ARGS:---sentinel}
69+
network_mode: "host"
70+
#ports:
71+
# - 26379:26379
72+
# - 26380:26380
73+
# - 26381:26381
74+
volumes:
75+
- "./dockers/sentinel.conf:/redis/config-default/redis.conf"
76+
- "./dockers/sentinel:/redis/work"
77+
profiles:
78+
- sentinel
79+
- all-stack
80+
- all
81+
82+
83+
10384
redisRing1:
10485
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:rs-7.4.0-v2}
10586
container_name: redis-ring-1

dockers/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ ring2/
44
ring3/
55
standalone/
66
sentinel-cluster/
7+
sentinel/
78

dockers/sentinel.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
sentinel resolve-hostnames yes
2+
sentinel monitor go-redis-test 127.0.0.1 9121 2
3+
sentinel down-after-milliseconds go-redis-test 2000
4+
sentinel failover-timeout go-redis-test 1000
5+
sentinel parallel-syncs go-redis-test 1

dockers/sentinels/sentinel1.conf

Lines changed: 0 additions & 16 deletions
This file was deleted.

dockers/sentinels/sentinel2.conf

Lines changed: 0 additions & 16 deletions
This file was deleted.

dockers/sentinels/sentinel3.conf

Lines changed: 0 additions & 16 deletions
This file was deleted.

main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ var (
4646
)
4747

4848
var (
49-
sentinelAddrs = []string{":" + sentinelPort1, ":" + sentinelPort2, ":" + sentinelPort3}
49+
sentinelAddrs = []string{"127.0.0.1:" + sentinelPort1, "127.0.0.1:" + sentinelPort2, "127.0.0.1:" + sentinelPort3}
5050

5151
ringShard1, ringShard2, ringShard3 *redis.Client
5252
sentinelMaster, sentinelSlave1, sentinelSlave2 *redis.Client

0 commit comments

Comments
 (0)