Forked from Richard-Mathie/Redis Cluster Setup with Docker Swarm.md
Created
April 20, 2019 14:39
-
-
Save si9ma/5c48d47a83b6836222902dfb77a294fd to your computer and use it in GitHub Desktop.
Revisions
-
Richard Mathie revised this gist
Mar 29, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,7 @@ test the redis cluster docker run -it --rm --net mynet redis:3.2.6 redis-cli -c -h redis -p 6379 ``` ``` 10.0.0.7:6379> set mykey1 1 OK 10.0.0.7:6379> set mykey2 2 -
Richard Mathie renamed this gist
Mar 29, 2017 . 1 changed file with 8 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,18 @@ # Redis Cluster Setup with Docker Swarm ## Setup ```bash ./redis.sh ``` ## Test test the redis cluster ``` docker run -it --rm --net mynet redis:3.2.6 redis-cli -c -h redis -p 6379 ``` > ``` 10.0.0.7:6379> set mykey1 1 OK 10.0.0.7:6379> set mykey2 2 -
Richard Mathie revised this gist
Jan 12, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ test the redis cluster ``` docker run -it --rm --net mynet redis:3.2.6 redis-cli -c -h redis -p 6379 ``` ``` -
Richard Mathie revised this gist
Jan 12, 2017 . 1 changed file with 27 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ test the redis cluster ``` docker run -it --rm --net redis:3.2.6 redis-cli -c -h redis -p 6379 ``` ``` 10.0.0.7:6379> set mykey1 1 OK 10.0.0.7:6379> set mykey2 2 -> Redirected to slot [14119] located at 10.0.0.6:6379 OK 10.0.0.6:6379> set mykey3 3 -> Redirected to slot [9990] located at 10.0.0.4:6379 OK 10.0.0.4:6379> get mykey1 -> Redirected to slot [1860] located at 10.0.0.7:6379 "1" 10.0.0.7:6379> get mykey2 -> Redirected to slot [14119] located at 10.0.0.6:6379 "2" 10.0.0.6:6379> get mykey3 -> Redirected to slot [9990] located at 10.0.0.4:6379 "3" 10.0.0.4:6379> ``` -
Richard Mathie created this gist
Jan 12, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ #!/bin/bash REDIS_CONFIG='port 6379 cluster-enabled yes cluster-config-file nodes.conf cluster-node-timeout 5000 appendonly yes' network=mynet docker service create --name redis \ --network $network \ --replicas=6 \ -e REDIS_CONFIG="$REDIS_CONFIG" \ -e REDIS_CONFIG_FILE="/usr/local/etc/redis/redis.conf" \ redis:3.2.6-alpine sh -c 'mkdir -p $(dirname $REDIS_CONFIG_FILE) && echo "$REDIS_CONFIG" > $REDIS_CONFIG_FILE && cat $REDIS_CONFIG_FILE && redis-server $REDIS_CONFIG_FILE' sleep 2 docker service ps redis --no-trunc # run the redis-trib.rb script (the docker inspect runs on the host and the echo output is passed the along to the ruby container) docker run -it --rm --net $network ruby sh -c "\ gem install redis --version 3.2 \ && wget http://download.redis.io/redis-stable/src/redis-trib.rb \ && ruby redis-trib.rb create --replicas 1 \ \$(getent hosts tasks.redis | awk '{print \$1 \":6379\"}') "