Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
IMAGE=redislabs/redis:latest
RE_USERNAME=test@test.com
RE_PASS=12345
#Cluster Name field pattern: ^[-a-zA-Z0-9.]*$
RE_CLUSTER_NAME=test
RE_USE_OSS_CLUSTER=false
RE_DB_PORT=12000
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ export $(cat .env.credentials | xargs)
```

### Build RE cluster ###

```shell
./build.sh
```
It will create the 3 nodes, have the two nodes joining the master node and create the DB

By default, RE cluster supports single endpoint and relies on DMC proxy to calculate hash slot.
Multiple endpoints (OSS cluster mode) could be enabled by setting env variable `RE_USE_OSS_CLUSTER=true`.

Expand All @@ -25,4 +31,7 @@ All standard RE ports available from your local network:
In DMC mode only 12000 port is available, with OSS Cluster API you can connect to each node.
- `6372-6374, 6379` - Additional ports accessible from local network.
- `9443 - 9445` - REST API connections
- `8443 - 8445` - RE Cluster management UI's
- `8443 - 8445` - RE Cluster management UI's

Web UI :
https://localhost:8443
31 changes: 30 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,40 @@
#!/bin/bash

docker compose down --rmi all --volumes --remove-orphans

# Récupère tous les ports locaux (ceux avant le ':') dans le fichier
ports=$(grep -E '^[[:space:]]+- "[0-9]+:[0-9]+"' docker-compose.yml | sed -E 's/.*"([0-9]+):[0-9]+".*/\1/')

# Liste des ports déjà utilisés
used_ports=()

# Vérifie chaque port
for port in $ports; do
if lsof -iTCP:"$port" -sTCP:LISTEN -Pn > /dev/null; then
used_ports+=("$port")
fi
done

# Affiche uniquement si au moins un est utilisé
if [ ${#used_ports[@]} -gt 0 ]; then
echo "The following ports are already in use. Stop the program that use them."
for port in "${used_ports[@]}"; do
echo " - $port"
done
exit 1
fi


if [[ -n "${DOCKER_ACCESS_TOKEN}" ]]; then
echo $DOCKER_ACCESS_TOKEN | docker login --username=$DOCKER_USERNAME --password-stdin
fi



docker compose pull

## Build infrastructure ##
docker compose up -d
docker compose up -d --force-recreate --renew-anon-volumes

## Create cluster ##
docker compose exec -T master-node "/opt/setup_cluster.sh"
Expand Down
48 changes: 29 additions & 19 deletions create_db.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
#!/bin/bash

curl -u $RE_USERNAME:$RE_PASS -H "Content-type: application/json" \
-d '{
"name": "db",
"port": '$RE_DB_PORT',
"memory_size": 1273741824,
"replication": false,
"eviction_policy": "volatile-lru",
"sharding": true, "shards_count": 3,
"module_list": [
{"module_args": "","module_name": "ReJSON"},
{"module_args": "", "module_name": "search"},
{"module_args": "", "module_name": "timeseries"},
{"module_args": "", "module_name": "redisgears_2"},
{"module_args": "", "module_name": "bf"}],
"oss_cluster": '$RE_USE_OSS_CLUSTER',
"proxy_policy": "all-nodes",
"shards_placement": "sparse",
"shard_key_regex": [{"regex": ".*\\{(?<tag>.*)\\}.*"},{"regex": "(?<tag>.*)"}]}' \
-k -X POST -f https://localhost:9443/v1/bdbs
# {"module_args": "", "module_name": "redisgears_2"},
payload='{
"name": "db",
"port": '"$RE_DB_PORT"',
"memory_size": 1273741824,
"replication": false,
"eviction_policy": "volatile-lru",
"sharding": true, "shards_count": 3,
"module_list": [
{"module_args": "", "module_name": "ReJSON"},
{"module_args": "", "module_name": "search"},
{"module_args": "", "module_name": "timeseries"},
{"module_args": "", "module_name": "bf"}],
"oss_cluster": '"$RE_USE_OSS_CLUSTER"',
"proxy_policy": "all-nodes",
"shards_placement": "sparse",
"shard_key_regex": [{"regex": ".*\\{(?<tag>.*)\\}.*"}, {"regex": "(?<tag>.*)"}]}'


curl -u $RE_USERNAME:$RE_PASS \
-H "Content-type: application/json" \
-d "$payload" \
-k -sS -X POST \
-f https://localhost:9443/v1/bdbs || {
echo "Database creation failed"
exit 1
}

echo "Database creation... ok"
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3.9"
services:
master-node:
image: "${IMAGE}"
Expand Down