{"id":21677001,"url":"https://github.com/pogy-bot/redis-cluster-example","last_synced_at":"2026-05-21T05:38:00.064Z","repository":{"id":240745283,"uuid":"596304754","full_name":"Pogy-Bot/redis-cluster-example","owner":"Pogy-Bot","description":"A simple way to cluster Redis on production and on development without breaking your brain!","archived":false,"fork":false,"pushed_at":"2023-05-18T20:49:35.000Z","size":7099,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-20T09:44:20.546Z","etag":null,"topics":["cluster","clustering","distributed","redis","redis-cluster"],"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/Pogy-Bot.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-01T22:25:36.000Z","updated_at":"2023-02-05T17:02:57.000Z","dependencies_parsed_at":"2024-05-20T19:23:09.516Z","dependency_job_id":null,"html_url":"https://github.com/Pogy-Bot/redis-cluster-example","commit_stats":null,"previous_names":["pogy-bot/redis-cluster-example"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Pogy-Bot/redis-cluster-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pogy-Bot%2Fredis-cluster-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pogy-Bot%2Fredis-cluster-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pogy-Bot%2Fredis-cluster-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pogy-Bot%2Fredis-cluster-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Pogy-Bot","download_url":"https://codeload.github.com/Pogy-Bot/redis-cluster-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pogy-Bot%2Fredis-cluster-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33289935,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-21T02:57:32.698Z","status":"ssl_error","status_checked_at":"2026-05-21T02:57:31.990Z","response_time":62,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["cluster","clustering","distributed","redis","redis-cluster"],"created_at":"2024-11-25T14:17:19.182Z","updated_at":"2026-05-21T05:38:00.050Z","avatar_url":"https://github.com/Pogy-Bot.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Redis Cluster with RedisJSON + RedisSearch but for production\n\nThis is meant if you wanna do redis clustering on production, it will open up redis on different services.\n\nIf you want to do it locally on development, here is the branch for it [https://github.com/Pogy-Bot/redis-cluster-example/tree/clustering-development](https://github.com/Pogy-Bot/redis-cluster-example/tree/clustering-development)\n\n## Notes\n\n- If you wanna build the plugins, make sure you have the language rust installed\n- You should be using systemd to manage your services or it will not work\n\n## Summary of Steps\n\n_Step 1 and 2 are incase plugins cannot somehow work in the plugins folder in this repo._\n\n- Download RedisJSON plugin - optional\n- Download Redis Search plugin - optional\n- Initializing\n- Run the redis command to link the clusters\n\n### 1- Download RedisJSON plugin - optional\n\nIf you decided to build it from source, here are the commands to do so:\n\n```bash\ngit clone https://github.com/RedisJSON/RedisJSON\ncd RedisJSON\ncargo build --release\ncd .. # go back to where you started\n```\n\nthen go to each redis.conf and change the path to\n\n```bash\nloadmodule /path/to/RedisJSON/target/release/librejson.so\n```\n\n### 2- Download Redis Search plugin - optional\n\nIf you decided to build it from source, here are the commands to do so:\n\n```bash\ngit clone --recursive https://github.com/RediSearch/RediSearch.git\ncd RediSearch\nmake setup\nmake build\ncd .. # go back to where you started\n```\n\nthen go to each redis.conf and change the path. To find the path run:\n\n```bash\nfind . -name \"redisearch.so\"\n```\n\nand use the path that is returned.\n\n### 3- Initializing\n\nInstall `redis-server` and disable the service\n\n```bash\nsudo apt-get update # update the package list\nsudo apt-get install redis-server # install redis\nsudo systemctl disable redis-server.service # disable the service\n```\n\nCreate and edit the /etc/rc.local file by running the following command:\n\n```\nsudo nano /etc/rc.local\n```\n\nand add to its content, press CTRL + X then Y to save and exit\n\n```\n #!/bin/sh -e\n #\n # rc.local\n #\n # This script is executed at the end of each multiuser runlevel.\n # Make sure that the script will \"exit 0\" on success or any other\n # value on error.\n #\n # In order to enable or disable this script just change the execution\n # bits.\n #\n # By default this script does nothing.\n echo never \u003e /sys/kernel/mm/transparent_hugepage/enabled\n sysctl -w net.core.somaxconn=65535\n\n exit 0\n```\n\nGive executable permissions to the `/etc/rc.local` file by running the following command:\n\n```bash\nsudo chmod +x /etc/rc.local\n```\n\nEdit the `/etc/sysctl.conf` by running the following command:\n\n```bash\nsudo nano /etc/sysctl.conf\n```\n\nAdd the following line at the end of the file:\n\n```bash\nvm.overcommit_memory=1\n```\n\nclone the current repo and CD to it\n\n```bash\ngit clone https://github.com/Pogy-Bot/redis-cluster-example\ncd redis-cluster-example\n```\n\nCustomize anything you want then copy the files to `/etc/redis/` and `/var/lib/redis/`\n\n```bash\nsudo cp -r * /etc/redis/\nsudo cp -r * /var/lib/redis/\n```\n\nCreate a redis user and a redis group for the Redis Server services and give them the correct permissions by running the following commands:\n\n```bash\nsudo chown redis:redis -R /var/lib/redis\nsudo chmod 770 -R /var/lib/redis\nsudo chown redis:redis -R /etc/redis\n```\n\nNow, we will have create the `systemd` services.\nLet's start by giving `create.sh` execution permissions\n\n```bash\nchmod +x create.sh\n```\n\nand run it\n\n```bash\nsudo sh ./create.sh\n```\n\nNow let's enable all the services\n\n```bash\nchmod +x enable.sh # give execution permissions\nsudo sh ./enable.sh # enable the services\n```\n\nnow start all the services\n\n```bash\nchmod +x start.sh # give execution permissions\nsudo sh ./start.sh # start the services\n```\n\nto check the status of any services\n\n```bash\nsystemctl status redis_node_\u003cport\u003e\n\n#or to see all\nsystemctl list-units --type=service\n```\n\nto get logs:\n```\nsudo tail -n 100 /var/log/redis/redis_node_\u003cport\u003e.log\n```\n\n### 4- Run the redis command to link the clusters\n\nThe command is used to create a Redis cluster.\n\n`redis-cli` is the Redis command line interface.\n\nThe `--cluster create` option is used to create a new Redis cluster.\n\nThe IP addresses and port numbers provided in the command 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 127.0.0.1:7006 etc specify the nodes that will be part of the cluster. The IP address 127.0.0.1 is the localhost address, which means the nodes are running on the same machine as the Redis client. The port numbers specify the individual nodes of the cluster.\n\nThe `--cluster-replicas 1` option sets the number of replicas for each key in the cluster to 1. This means that for each key, there will be one additional copy stored in another node in the cluster to provide redundancy in case of a node failure.\n\nIn conclusion, this command creates a Redis cluster with the specified nodes, with each key having one replica stored in another node.\n\n```console\nredis-cli --cluster create \\\n  127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 \\\n  127.0.0.1:7004 127.0.0.1:7005 127.0.0.1:7006 \\\n  127.0.0.1:7007 127.0.0.1:7008 127.0.0.1:7009 \\\n  127.0.0.1:7010 127.0.0.1:7011 127.0.0.1:7012 \\\n  --cluster-replicas 1\n```\n\n### Extra\n\nyou can use the `redis-cli` to connect to the cluster and run commands\n\nex, checking your clusters:\n\n```console\nredis-cli -c -p 7001\n```\n\nthen\n\n```\nCLUSTER NODES\n```\n\nIf you want to purge the main redis server:\n\n```bash\nsudo apt-get --purge remove redis-server\nsudo rm -rf /etc/redis/dump.rdb\n```\n\nTo reinstall\n\n```bash\nsudo apt-get update\nsudo apt-get install redis-server\n```\n### Commands\n```bash\n# start\nsudo systemctl start redis_node_\u003cport\u003e.service\n\n# stop\nsudo systemctl stop redis_node_\u003cport\u003e.service\n\n# restart\nsudo systemctl restart redis_node_\u003cport\u003e.service\n\n# enable\nsudo systemctl enable redis_node_\u003cport\u003e.service\n\n# disable\nsudo systemctl disable redis_node_\u003cport\u003e.service\n\n# status\nsystemctl status redis_node_\u003cport\u003e.service\n```\n\n### Mass Commands\n```bash\nsudo sh create.sh # create all services\nsudo sh start.sh # start all services\nsudo sh stop.sh # stop all services\nsudo sh restart.sh # restart all services\nsudo sh enable.sh # enable all services\n```\n\n### Errors\n\n- If you get cluster formatting errors use\n\n```bash\ntr -d '\\r' \u003c filename.sh \u003e filename_fixed.sh\n```\n\nand then run `./filename_fixed.sh` instead.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpogy-bot%2Fredis-cluster-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpogy-bot%2Fredis-cluster-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpogy-bot%2Fredis-cluster-example/lists"}