{"id":16352286,"url":"https://github.com/bugthesystem/redisetup","last_synced_at":"2025-10-26T02:31:30.514Z","repository":{"id":29045465,"uuid":"32573068","full_name":"bugthesystem/redisetup","owner":"bugthesystem","description":"Redis setup scripts","archived":false,"fork":false,"pushed_at":"2021-02-25T09:24:23.000Z","size":26,"stargazers_count":9,"open_issues_count":0,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-05T13:49:49.155Z","etag":null,"topics":["monit","redis","redis-sentinel","setup"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bugthesystem.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}},"created_at":"2015-03-20T08:50:23.000Z","updated_at":"2021-06-13T02:34:48.000Z","dependencies_parsed_at":"2022-08-22T04:10:40.026Z","dependency_job_id":null,"html_url":"https://github.com/bugthesystem/redisetup","commit_stats":null,"previous_names":["bugthesystem/redisetup"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugthesystem%2Fredisetup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugthesystem%2Fredisetup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugthesystem%2Fredisetup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugthesystem%2Fredisetup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bugthesystem","download_url":"https://codeload.github.com/bugthesystem/redisetup/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238247989,"owners_count":19440879,"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":["monit","redis","redis-sentinel","setup"],"created_at":"2024-10-11T01:25:36.806Z","updated_at":"2025-10-26T02:31:30.200Z","avatar_url":"https://github.com/bugthesystem.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Table of Contents\n* [Redis + Sentinel + Monit Setup](#redis--sentinel--monit-setup)\n    * [Redis Primary/Replica](#redis-primaryreplica)\n    * [Redis Sentinel](#redis-sentinel)\n    * [Monit](#monit)\n    * [Apply Redis and Sentinel Configurations into Monit](#apply-redis-and-sentinel-configurations-into-monit)\n* [System Side Settings](#system-side-settings)\n* [Shortcuts](#shortcuts)\n\n# Redis + Sentinel + Monit Setup\nRedis + Sentinel + Monit Setup Scripts\n\u003e _This configuration is now using small and middle sized production environments. To use it in production is up to you._\n\n_**Edited Version**_\n\n### Redis Primary/Replica\n\n**To Install Primary**  \nEdit ```master.sh``` file to set configurations (redis version,instance name, port);\n```sh\n# Defaults\nREDIS_VER=2.8.19\nUPDATE_LINUX_PACKAGES=false\nREDIS_INSTANCE_NAME=redis-server\nREDIS_INSTANCE_PORT=6379\n```\n\n```sh\nmkdir redisetup\ncd redisetup\nwget https://raw.githubusercontent.com/ziyasal/redisetup/master/master.sh\n\n# Run install script\nsudo sh master.sh \n```\n\n**To Install Replica**  \nEdit ```member.sh``` file to set configurations (redis version,instance name, port, primary ip, primary port);\n```sh\n# Defaults\nREDIS_VER=2.8.19\nUPDATE_LINUX_PACKAGES=false      #true|false\nREDIS_INSTANCE_NAME=redis-server\nREDIS_INSTANCE_PORT=6379         #Set another one if master node is on the same host\nREDIS_MASTER_IP=127.0.0.1\nREDIS_MASTER_PORT=6379\n```\n\n```sh\nmkdir redisetup\ncd redisetup\nwget https://raw.githubusercontent.com/ziyasal/redisetup/master/member.sh\n\n# Run install script\nsudo sh member.sh \n```\n\n_**Set somaxconn**_\n```sh\necho 65535 \u003e /proc/sys/net/core/somaxconn\n```\n_**redis.conf**_   [for more detail](http://redis.io/topics/config)\n```sh\ntcp-backlog 65535\n\n# **TODO**\n# To dump the dataset every 15 minutes (900 seconds) if at least one key changed, you can say:\n# save 900 1\n# **TODO**\n# Redis instantly writes to the log file so even if your machine crashes, it can still recover and have the latest data. #Similar to RDB, AOF log is represented as a regular file at var/lib/redis called appendonly.aof (by default).\n# appendonly yes\n\n# **TODO**\n# To tell OS to really really write the data to the disk, Redis needs to call the fsync() function right after the write call, #which can be slow.\n# appendfsync everysec\n```\n_**/etc/init.d/redis-server**_\n```sh\nsudo sh -c \"echo never \u003e /sys/kernel/mm/transparent_hugepage/enabled\"\nulimit -n 65535\nulimit -n \u003e\u003e /var/log/ulimit.log #Not required!\n```\n\n### Redis Sentinel\n_**install**_\n```sh\nwget https://raw.githubusercontent.com/ziyasal/redisetup/master/sentinel.sh\nsudo sh sentinel.sh  #Run install script\n```\n\n### Monit\n_**install**_\n```sh\nsudo apt-get install monit\n```\n_**update monit config file**_\n```sh\nnano /etc/monit/monitrc\n```\n_Add or update httpd settings_\n```sh\nset httpd port 8081 and\n    use address localhost  # only accept connection from localhost\n    allow localhost        # allow localhost to connect to the server and\n    allow admin:monit      # require user \"admin\" with password \"monit\"\n```\n### Apply Redis and Sentinel Configurations into Monit\n_**Create redis.conf**_\n```sh\nnano /etc/monit/conf.d/redis.conf\n```\nAdd following settings for more options [monit documentation](https://mmonit.com/monit/documentation/)\n```sh\n#Default settings\n#watch by pid\ncheck process redis-server\n    with pidfile \"/var/run/redis.pid\"\n    start program = \"/etc/init.d/redis-server start\"\n    stop program = \"/etc/init.d/redis-server stop\"\n    if failed host 127.0.0.1 port 6379 then restart\n    if 5 restarts within 5 cycles then timeout\n```\n\n_**Create sentinel.conf**_\n```sh\nnano /etc/monit/conf.d/redis-sentinel.conf\n```\nAdd following lines\n```sh\n#watch by process name TODO: pid file\ncheck process redis-sentinel\n    matching \"redis-sentinel\"\n    start program = \"/etc/init.d/redis-sentinel start\"\n    stop program = \"/etc/init.d/redis-sentinel stop\"\n    if failed host 127.0.0.1 port 26379 then restart\n    if 5 restarts within 5 cycles then timeout\n```\n\n## System Side Settings\n_**sysctl.conf**_\n```sh\nvm.overcommit_memory=1                # Linux kernel overcommit memory setting\nvm.swappiness=0                       # turn off swapping\nnet.ipv4.tcp_sack=1                   # enable selective acknowledgements\nnet.ipv4.tcp_timestamps=1             # needed for selective acknowledgements\nnet.ipv4.tcp_window_scaling=1         # scale the network window\nnet.ipv4.tcp_congestion_control=cubic # better congestion algorythm\nnet.ipv4.tcp_syncookies=1             # enable syn cookied\nnet.ipv4.tcp_tw_recycle=1             # recycle sockets quickly\nnet.ipv4.tcp_max_syn_backlog=65535    # backlog setting\nnet.core.somaxconn=65535              # up the number of connections per port\nfs.file-max=65535\n```\n\n_**/etc/security/limits.conf**_\n```sh\nredis soft nofile 65535\nredis hard nofile 65535\n```\nAdd following line\n```sh\nsession required pam_limits.so\n```\nto\n```sh\n/etc/pam.d/common-session\n/etc/pam.d/common-session-noninteractive\n```\n\n### Shortcuts\n\nAfter executing the command shown below \n\n```sh\nmonit monitor all\n```\n\nNow you can keep track of redis server and sentinel by monit \n\n```sh\nmonit status\n```\n\nGet Primary/Replica replication information\n\n```sh\nredis-cli -p 6379 info replication\n```\n\nGet Sentinel information\n\n```sh\nredis-cli -p 26379 info sentinel\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbugthesystem%2Fredisetup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbugthesystem%2Fredisetup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbugthesystem%2Fredisetup/lists"}