{"id":18123312,"url":"https://github.com/jay-johnson/docker-redis-cluster","last_synced_at":"2025-04-14T23:05:19.931Z","repository":{"id":72596182,"uuid":"47230466","full_name":"jay-johnson/docker-redis-cluster","owner":"jay-johnson","description":"Running a distributed 6-node Redis Cluster with Docker Swarm, Docker Compose, and Supervisor","archived":false,"fork":false,"pushed_at":"2015-12-06T05:19:19.000Z","size":15,"stargazers_count":49,"open_issues_count":0,"forks_count":21,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-28T11:05:37.222Z","etag":null,"topics":["docker","redis","redis-cluster","redis-nodes","sentinel"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jay-johnson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-02T02:05:42.000Z","updated_at":"2024-04-02T12:56:31.000Z","dependencies_parsed_at":"2023-02-26T21:00:36.383Z","dependency_job_id":null,"html_url":"https://github.com/jay-johnson/docker-redis-cluster","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jay-johnson%2Fdocker-redis-cluster","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jay-johnson%2Fdocker-redis-cluster/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jay-johnson%2Fdocker-redis-cluster/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jay-johnson%2Fdocker-redis-cluster/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jay-johnson","download_url":"https://codeload.github.com/jay-johnson/docker-redis-cluster/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246301963,"owners_count":20755512,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","redis","redis-cluster","redis-nodes","sentinel"],"created_at":"2024-11-01T07:09:13.845Z","updated_at":"2025-03-30T09:32:43.778Z","avatar_url":"https://github.com/jay-johnson.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"## A Distributed Redis Cluster using Docker Swarm, Docker Compose, and Supervisor\n\n### Overview\n\nThis repository will start a distributed 6-node Redis Cluster using Docker Swarm with Docker Compose and Supervisor for high availability. The redis instances listen on the host node ports: 6379-6384. There are 3 master nodes and 3 replica nodes. If you are running a local Docker Swarm you can run the entire 6-node cluster locally.\n\n### How to Install\n\n1. Make sure Swarm is installed \n\n  ```\n  docker-redis-cluster $ sudo ./1_install_core.sh\n  ```\n\n1. Restart the local consul, docker daemon, swarm manager, and swarm join\n\n  ```\n  docker-redis-cluster $ sudo ./boot_local_docker_services.sh\n  ``` \n\n1. Point to the Docker Swarm\n\n  Please set the terminal environment to use the running Docker Swarm \n  \n  ```\n  $ export DOCKER_HOST=localhost:4000\n  $ env | grep DOCKER\n  DOCKER_HOST=localhost:4000\n  $\n  ```\n\n1. Confirm the Docker Swarm Membership\n\n  Running the swarm locally you should see only 1 node with something similar:\n\n  ```\n  $ docker info\n  Containers: 0\n  Images: 0\n  Role: primary\n  Strategy: spread\n  Filters: health, port, dependency, affinity, constraint\n  Nodes: 1\n   localhost.localdomain: localhost:2375\n    └ Containers: 0\n    └ Reserved CPUs: 0 / 2\n    └ Reserved Memory: 0 B / 4.053 GiB\n    └ Labels: executiondriver=native-0.2, kernelversion=4.1.7-200.fc22.x86_64, operatingsystem=Fedora 22 (Twenty Two), storagedriver=devicemapper\n  CPUs: 2\n  Total Memory: 4.053 GiB\n  Name: localhost.localdomain\n  $\n  ```\n\n### Start the Redis Cluster \n\nAssuming consul, docker daemon, swarm manager, and swarm join are running with something similar to:\n\n```\n$ ps auwwx | grep consul | grep -v grep\nroot     29447  0.4  0.4 34110388 19204 pts/4  Sl   19:39   0:14 consul agent -server -data-dir=/tmp/consul -bind=0.0.0.0 -bootstrap-expect 1\nroot     31650 12.9  1.2 1329604 51208 pts/4   Sl   20:00   3:42 /usr/local/bin/docker daemon -H localhost:2375 --cluster-advertise 0.0.0.0:2375 --cluster-store consul://localhost:8500/developmentswarm\nroot     31738  0.0  0.5 488084 20512 pts/1    Sl   20:02   0:01 /usr/local/bin/swarm manage -H tcp://localhost:4000 --advertise localhost:4000 consul://localhost:8500/developmentswarm\nroot     31749  0.0  0.3 128416 14304 pts/1    Sl   20:02   0:00 /usr/local/bin/swarm join --addr=localhost:2375 consul://localhost:8500/developmentswarm\n$\n```\n \n1. Make sure no other Redis nodes are running\n\n  ```\n  $ docker ps -a\n  CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES\n  $ \n  ```\n\n1. Start the Redis Cluster\n\n  ```\n  docker-redis-cluster $ ./start_cluster.sh \n  Starting the Cluster on Docker Swarm\n  Creating redismaster1\n  Creating redismaster3\n  Creating redismaster2\n  Creating redisreplica1\n  Creating redisreplica2\n  Creating redisreplica3\n  Done\n  docker-redis-cluster $\n  ```\n\n1. Confirm the Containers are running\n\n  ```\n  $ docker ps\n  CONTAINER ID        IMAGE                          COMMAND                  CREATED             STATUS              PORTS                                                                              NAMES\n  89f8ab731348        jayjohnson/redis-clusterable   \"/bin/sh -c '. /bin/s\"   4 minutes ago       Up 4 minutes        127.0.0.1:6384-\u003e6379/tcp, 127.0.0.1:16384-\u003e16379/tcp, 127.0.0.1:26384-\u003e26379/tcp   localhost.localdomain/redisreplica3\n  6ff759f42bb6        jayjohnson/redis-clusterable   \"/bin/sh -c '. /bin/s\"   4 minutes ago       Up 4 minutes        127.0.0.1:6383-\u003e6379/tcp, 127.0.0.1:16383-\u003e16379/tcp, 127.0.0.1:26383-\u003e26379/tcp   localhost.localdomain/redisreplica2\n  fe97da8b920a        jayjohnson/redis-clusterable   \"/bin/sh -c '. /bin/s\"   4 minutes ago       Up 4 minutes        127.0.0.1:6382-\u003e6379/tcp, 127.0.0.1:16382-\u003e16379/tcp, 127.0.0.1:26382-\u003e26379/tcp   localhost.localdomain/redisreplica1\n  8ed2a60663f6        jayjohnson/redis-clusterable   \"/bin/sh -c '. /bin/s\"   4 minutes ago       Up 4 minutes        127.0.0.1:6380-\u003e6379/tcp, 127.0.0.1:16380-\u003e16379/tcp, 127.0.0.1:26380-\u003e26379/tcp   localhost.localdomain/redismaster2\n  3a779ae52bd7        jayjohnson/redis-clusterable   \"/bin/sh -c '. /bin/s\"   4 minutes ago       Up 4 minutes        127.0.0.1:6381-\u003e6379/tcp, 127.0.0.1:16381-\u003e16379/tcp, 127.0.0.1:26381-\u003e26379/tcp   localhost.localdomain/redismaster3\n  085b750909d5        jayjohnson/redis-clusterable   \"/bin/sh -c '. /bin/s\"   4 minutes ago       Up 4 minutes        127.0.0.1:6379-\u003e6379/tcp, 127.0.0.1:16379-\u003e16379/tcp, 127.0.0.1:26379-\u003e26379/tcp   localhost.localdomain/redismaster1\n  $\n  ```\n\n### Confirm the Redis Cluster using the Command Line Tool\n\n\n```\n$ redis-cli -h 127.0.0.1 -p 6384 cluster nodes\naa81e0dc13f4985dd0b70647d338f899454326af :6379 myself,master - 0 0 6 connected\n$ \n```\n\n### Inspect the Redis Cluster Details\n\n```\n$ ./cst.sh \n\nPrinting Redis Cluster Status:\n\nredismaster1(6379):\n399de28f4b010ae4395db704887bfdea92aa2144 :6379 myself,master - 0 0 1 connected 0-5460\n\nredismaster2(6380):\n1c62661d9235463b5f3906a687ddc4010444f4ac :6379 myself,master - 0 0 2 connected 5461-10922\n\nredismaster3(6381):\n6fc1dda1fec41b4fbb0654d926dbfe17700c412b :6379 myself,master - 0 0 3 connected 10923-16383\n\nredisreplica1(6382):\nfffa24ec3a9d8485e63bf4e0d09bb2428ca7851b :6379 myself,master - 0 0 4 connected\n\nredisreplica2(6383):\nbb6844f7b7a3ccc1c0bc392461d342037916b903 :6379 myself,master - 0 0 5 connected\n\nredisreplica3(6384):\nc05e9a770e8aa11d82793f2d1076b7a94334d83c :6379 myself,master - 0 0 6 connected\n\n\nDone\n$\n```\n\n### Stop the Redis Cluster\n\n```\n$ ./stop_cluster.sh \nStopping the Cluster on Docker Swarm\nStopping redisreplica3 ... done\nStopping redisreplica2 ... done\nStopping redisreplica1 ... done\nStopping redismaster2 ... done\nStopping redismaster3 ... done\nStopping redismaster1 ... done\nCleaning up old containers for ports\nDone\n$\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjay-johnson%2Fdocker-redis-cluster","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjay-johnson%2Fdocker-redis-cluster","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjay-johnson%2Fdocker-redis-cluster/lists"}