Skip to content

Commit 20a94bd

Browse files
Update Redis configurations and initialization scripts (#50)
Modify main.yml for Redis 7.2.1 cluster configuration
1 parent 1792c3b commit 20a94bd

2 files changed

Lines changed: 18 additions & 36 deletions

File tree

compose/data-lake/redis/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ services:
1111
- ${HOME_DIR}/workload/supervisor/conf/server.conf:/etc/supervisord.conf
1212
- ${HOME_DIR}/workload/redis/${DATA_LAKE_REDIS_VERSION}/cluster/conf/supervisor.ini:/opt/redis/system/supervisor.ini
1313
- ${HOME_DIR}/workload/redis/${DATA_LAKE_REDIS_VERSION}/cluster/conf/server.conf:/opt/redis/conf/server.conf
14-
depends_on:
15-
- redis-1
14+
# depends_on:
15+
# - redis-1
1616
networks:
1717
- common
1818
redis-2:
Lines changed: 16 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,23 @@
11
#!/bin/bash
22

3-
LOGFILE="/opt/redis/log/redis-cluster-init.log"
4-
5-
touch $LOGFILE
6-
7-
# Function to log messages
8-
log() {
9-
echo "$(date +'%Y-%m-%d %H:%M:%S') - $1" | tee -a $LOGFILE
3+
function wait_for_redis_node() {
4+
local node=$1;
5+
until redis-cli -h $node -p 3000 ping > /dev/null 2>&1; do
6+
printf "Waiting for $node...\n";
7+
sleep 5;
8+
done;
9+
printf "$node is ready.\n";
1010
}
1111

12-
log "Starting Redis cluster initialization..."
13-
14-
# Wait for all Redis nodes to be ready
15-
while ! (redis-cli -h redis-1 -p 3000 ping && \
16-
redis-cli -h redis-2 -p 3000 ping && \
17-
redis-cli -h redis-3 -p 3000 ping && \
18-
redis-cli -h redis-4 -p 3000 ping && \
19-
redis-cli -h redis-5 -p 3000 ping && \
20-
redis-cli -h redis-6 -p 3000 ping); do
21-
log "Waiting for Redis nodes to be ready..."
22-
sleep 5
23-
done
24-
25-
log "All Redis nodes are ready. Creating cluster..."
26-
27-
# Create the Redis cluster
28-
{
29-
yes yes | redis-cli --cluster create redis-1:3000 redis-2:3000 redis-3:3000 redis-4:3000 redis-5:3000 redis-6:3000 --cluster-replicas 1
30-
} 2>&1 | tee -a $LOGFILE
31-
32-
log "Redis cluster creation complete."
33-
34-
# Waiting for cluster creation:
35-
sleep 20
12+
function create_redis_cluster() {
13+
yes yes | redis-cli --cluster create redis-{1..6}:3000 --cluster-replicas 1;
14+
printf "Redis cluster started.\n";
15+
}
3616

37-
# Start Redis server with cluster enabled
38-
redis-server --port 3000 --cluster-enabled yes --cluster-config-file nodes.conf --cluster-node-timeout 5000 --appendonly yes 2>&1 | tee -a $LOGFILE
17+
printf "Starting Redis cluster initialization...\n";
3918

40-
log "Redis server started with cluster enabled."
19+
for node in redis-{1..6}; do
20+
wait_for_redis_node $node;
21+
done;
4122

23+
create_redis_cluster;

0 commit comments

Comments
 (0)