{"id":21020802,"url":"https://github.com/xutl/docker-redis-cluster","last_synced_at":"2025-06-13T16:03:47.119Z","repository":{"id":95977280,"uuid":"113571627","full_name":"xutl/docker-redis-cluster","owner":"xutl","description":"HA Redis Cluster with Sentinel by Docker Compose","archived":false,"fork":false,"pushed_at":"2017-12-08T12:27:53.000Z","size":8,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-20T13:19:01.544Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xutl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-08T12:22:09.000Z","updated_at":"2017-12-20T08:01:46.000Z","dependencies_parsed_at":"2023-04-26T12:00:25.712Z","dependency_job_id":null,"html_url":"https://github.com/xutl/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/xutl%2Fdocker-redis-cluster","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xutl%2Fdocker-redis-cluster/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xutl%2Fdocker-redis-cluster/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xutl%2Fdocker-redis-cluster/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xutl","download_url":"https://codeload.github.com/xutl/docker-redis-cluster/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243450932,"owners_count":20293033,"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":[],"created_at":"2024-11-19T10:43:29.084Z","updated_at":"2025-03-13T17:42:04.032Z","avatar_url":"https://github.com/xutl.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# redis-cluster \n**Redis cluster with Docker Compose** \n\nUsing Docker Compose to setup a redis cluster with sentinel.\n\nThis project is inspired by the project of [https://github.com/mdevilliers/docker-rediscluster][1]\n\n## Prerequisite\n\nInstall [Docker][4] and [Docker Compose][3] in testing environment\n\nIf you are using Windows, please execute the following command before \"git clone\" to disable changing the line endings of script files into DOS format\n\n```\ngit config --global core.autocrlf false\n```\n\n## Docker Compose template of Redis cluster\n\nThe template defines the topology of the Redis cluster\n\n```\nmaster:\n  image: redis:3\nslave:\n  image: redis:3\n  command: redis-server --slaveof redis-master 6379\n  links:\n    - master:redis-master\nsentinel:\n  build: sentinel\n  environment:\n    - SENTINEL_DOWN_AFTER=5000\n    - SENTINEL_FAILOVER=5000    \n  links:\n    - master:redis-master\n    - slave\n```\n\nThere are following services in the cluster,\n\n* master: Redis master\n* slave:  Redis slave\n* sentinel: Redis sentinel\n\n\nThe sentinels are configured with a \"mymaster\" instance with the following properties -\n\n```\nsentinel monitor mymaster redis-master 6379 2\nsentinel down-after-milliseconds mymaster 5000\nsentinel parallel-syncs mymaster 1\nsentinel failover-timeout mymaster 5000\n```\n\nThe details could be found in sentinel/sentinel.conf\n\nThe default values of the environment variables for Sentinel are as following\n\n* SENTINEL_QUORUM: 2\n* SENTINEL_DOWN_AFTER: 30000\n* SENTINEL_FAILOVER: 180000\n\n\n\n## Play with it\n\nBuild the sentinel Docker image\n\n```\ndocker-compose build\n```\n\nStart the redis cluster\n\n```\ndocker-compose up -d\n```\n\nCheck the status of redis cluster\n\n```\ndocker-compose ps\n```\n\nThe result is \n\n```\n         Name                        Command               State          Ports        \n--------------------------------------------------------------------------------------\nrediscluster_master_1     docker-entrypoint.sh redis ...   Up      6379/tcp            \nrediscluster_sentinel_1   docker-entrypoint.sh redis ...   Up      26379/tcp, 6379/tcp \nrediscluster_slave_1      docker-entrypoint.sh redis ...   Up      6379/tcp     \n```\n\nScale out the instance number of sentinel\n\n```\ndocker-compose scale sentinel=3\n```\n\nScale out the instance number of slaves\n\n```\ndocker-compose scale slave=2\n```\n\nCheck the status of redis cluster\n\n```\ndocker-compose ps\n```\n\nThe result is \n\n```\n         Name                        Command               State          Ports        \n--------------------------------------------------------------------------------------\nrediscluster_master_1     docker-entrypoint.sh redis ...   Up      6379/tcp            \nrediscluster_sentinel_1   docker-entrypoint.sh redis ...   Up      26379/tcp, 6379/tcp \nrediscluster_sentinel_2   docker-entrypoint.sh redis ...   Up      26379/tcp, 6379/tcp \nrediscluster_sentinel_3   docker-entrypoint.sh redis ...   Up      26379/tcp, 6379/tcp \nrediscluster_slave_1      docker-entrypoint.sh redis ...   Up      6379/tcp            \nrediscluster_slave_2      docker-entrypoint.sh redis ...   Up      6379/tcp            \n```\n\nExecute the test scripts\n```\n./test.sh\n```\nto simulate stop and recover the Redis master. And you will see the master is switched to slave automatically. \n\nOr, you can do the test manually to pause/unpause redis server through\n\n```\ndocker pause rediscluster_master_1\ndocker unpause rediscluster_master_1\n```\nAnd get the sentinel infomation with following commands\n\n```\ndocker exec rediscluster_sentinel_1 redis-cli -p 26379 SENTINEL get-master-addr-by-name mymaster\n```\n\n## References\n\n[https://github.com/mdevilliers/docker-rediscluster][1]\n\n[https://registry.hub.docker.com/u/joshula/redis-sentinel/] [2]\n\n[1]: https://github.com/mdevilliers/docker-rediscluster\n[2]: https://registry.hub.docker.com/u/joshula/redis-sentinel/\n[3]: https://docs.docker.com/compose/\n[4]: https://www.docker.com\n\n## License\n\nApache 2.0 license \n\n## Contributors\n\n* Li Yi (\u003cdenverdino@gmail.com\u003e)\n* Ty Alexander (\u003cty.alexander@gmail.com\u003e)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxutl%2Fdocker-redis-cluster","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxutl%2Fdocker-redis-cluster","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxutl%2Fdocker-redis-cluster/lists"}