This section describes how to deploy three node Redis Cache 5.0.5 Cluster Deployment. Execute all the steps in each node to install Redis Cache in cluster mode. Redis Cluster setup require atleast three primary nodes.
Redis Cluster becomes nonoperational if any one redis primary process goes down. For primary failover, additional 3 redis replica processes can be configured.
You can install Redis in the following three ways:
- Use Redis documentation to install Redis.
- Use Redis install script to install Redis, which has below procedure automated in the script. You can refer KB article from https://kb.vmware.com/s/article/70718.
- Use below manual procedure to install Redis.
Procedure
- Stop firewall on all 3 nodes or open ports 6379, 16379, 6380 and 16380 on all 3 nodes.
- Set the system configuration parameters by executing below commands:
- echo 'sysctl -w net.core.somaxconn=65535' >> /etc/rc.local
- sysctl -w net.core.somaxconn=65535
- echo never > /sys/kernel/mm/transparent_hugepage/enabled
- echo 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' >> /etc/rc.local
- chmod +x /etc/rc.local
- echo 'vm.overcommit_memory = 1' >> /etc/sysctl.conf
- sysctl vm.overcommit_memory=1
- Install Epel-Release, by invoking below command:
- Install Yum utilities, by invoking below command:
yum install -y yum-utils
- Install Remi release, by using below commands:
- Enable Remi, using below command:
yum-config-manager --enable remi
- Install Redis, by invoking below command:
yum install -y redis
- Verify the Redis version is 5.0.5, by using below command:
redis-server --version
- Copy redis.conf under /etc directory as redis-6379.conf, by using below command:
cp /etc/redis.conf /etc/redis-6379.conf
- Change Owner of /etc/redis-6379.conf to redis, by using below command:
chown redis:root /etc/redis-6379.conf
- Edit /etc/redis-6379.conf file with below configurations:
- Change "bind 127.0.0.1" to "bind <IPAddress>"
- Change "port 6379" to "port 6379"
- Change 'logfile ""' to 'logfile /var/log/redis/redis-6379.log'
- Change "dbfilename dump.rdb" to "dbfilename dump-6379.rdb"
- Change '# cluster-enabled yes' to 'cluster-enabled yes'
- Change '# cluster-config-file nodes-6379.conf' to 'cluster-config-file redis-6379.conf'
- Change '# cluster-node-timeout 15000' to 'cluster-node-timeout 5000'
- Change '#requirepass' to 'requirepass <password>'
- Change '# masterauth <master-password>' to 'masterauth <password>'
Note: Password for masterauth must be same as requirepass.
- For Rhel 7.5 or 7.6, create /usr/lib/systemd/system/redis-6379.service file:
- Copy /usr/lib/systemd/system/redis.service to /usr/lib/systemd/system/redis-6379.service and, edit /usr/lib/systemd/system/redis-6379.service file.
- Replace 'ExecStart=/usr/bin/redis-server /etc/redis.conf --supervised systemd' with 'ExecStart=/usr/bin/redis-server /etc/redis-6379.conf --supervised systemd'
- Replace 'ExecStop=/usr/libexec/redis-shutdown' with 'ExecStop=/usr/libexec/redis-shutdown redis-6379'
For Rhel 6.9 or 6.10, create
/etc/init.d/redis-6379 service file:
- Copy /etc/init.d/redis to /etc/init.d/redis-6379 and, edit /etc/init.d/redis-6379 file.
- Replace 'shut="/usr/libexec/redis-shutdown"' with 'shut="/usr/libexec/redis-shutdown redis-6379"'
- Replace 'pidfile="/var/run/redis/redis.pid"' with 'pidfile="/var/run/redis/redis-6379.pid"'
- Replace 'REDIS_CONFIG="/etc/redis.conf"' with 'REDIS_CONFIG="/etc/redis-6379.conf"'
- Replace '[ -e /etc/sysconfig/redis ] && . /etc/sysconfig/redis' with '[ -e /etc/sysconfig/redis-6379 ] && . /etc/sysconfig/redis-6379'
- Replace 'lockfile=/var/lock/subsys/redis' with 'lockfile=/var/lock/subsys/redis-6379'
- Replace '[ -x $shut ] && $shut' with '$shut'
- Enable the service:
- Start the service:
- For RHEL 7.5 or 7.6 command is : systemctl start redis-6379
- For RHEL 6.9 or 6.10 command is : service redis-6379 start
- Verify service status:
- For RHEL 7.5 or 7.6 command is : systemctl status redis-6379 (service should be running)
- For RHEL 6.9 or 6.10 command is : service redis-6379 status (service should be running)
- Check the redis logs /var/log/redis/redis-6379.log. The log must contains "Ready to accept connections".
- Execute step 1 to 15 on all 3 cluster nodes.
- Create redis cluster without replication by executing below command from any one cluster node:
redis-cli -a <password> --cluster create <IP1>:6379 <IP2>:6379 <IP3>:6379
Enter "Yes" when prompted
Expected output: "[OK] All 16384 slots covered."
- Validate Redis cluster by running below command:
redis-cli -a <password> -h <IP> -p 6379 cluster nodes
Output: Should show all primary nodes
What to do next
You must create atleast 1 replica for each primary for failover.