Redis Cluster Formation Failure
Redis Cluster Formation Failure in Redis Issues.
Redis Cluster Formation Failure#
Case 1: Node Formation Issue#
-
Navigate to the HEAL Redis server.
-
Navigate to the installation path by executing the command:
Directory
a1homeExpected Output:
Directory
[root@localhost ~]# a1home [root@localhost heal]#
-
-
Set the value of the consul key as 1.
consul kv put service/redis/replication/status 1Expected Output:
[root@localhost heal]# consul kv put service/redis/replication/status 1 Success! Data written to: service/redis/replication/status -
Check if the consul key value is updated
consul kv get service/redis/replication/status 1Expected Output:
[root@localhost heal]# consul kv get service/redis/replication/status 1 -
Start the Redis service, using the below script:
sh startServices.sh redis -
List all the redis containers running in the server,
podman ps | grep -i redis-nodeExpected Output:
0e3a1a102811 support.heal:8091/redis:7.0.5 /etc/redis.conf 11 days ago Up 11 days redis-node1-d51bd462-beb5-bd9b- bf2b-3664a59b1e67 91a87d3d454a support.heal:8091/redis:7.0.5 /etc/redis.conf 11 days ago Up 11 days redis-node4-d51bd462-beb5-bd9b- bf2b-3664a59b1e67 e6fd866e8474 support.heal:8091/redis:7.0.5 /etc/redis.conf 11 days ago Up 11 days redis-node2-d51bd462-beb5-bd9b- bf2b-3664a59b1e67 93ad8f14d8f7 support.heal:8091/redis:7.0.5 /etc/redis.conf 11 days ago Up 11 days redis-node3-d51bd462-beb5-bd9b- bf2b-3664a59b1e67 7415b143ee6b support.heal:8091/redis:7.0.5 /etc/redis.conf 11 days ago Up 11 days redis-node6-d51bd462-beb5-bd9b- bf2b-3664a59b1e67 cb815373ff67 support.heal:8091/redis:7.0.5 /etc/redis.conf 11 days ago Up 11 days redis-node5-d51bd462-beb5-bd9b- bf2b-3664a59b1e67Collect the container name from the output and follow the below process
-
Login to container
podman exec -it redis-node1-d51bd462-beb5-bd9b-bf2b-3664a59b1e67 bashExpected Output:
[root@support-n1 ~]# podman exec -it redis-node1-d51bd462-beb5-bd9b- bf2b-3664a59b1e67 bash root@support-n1:/data# -
Execute inside the container, to login to redis cli
root@support-n1:/data# redis-cli -c --tls --cert /etc/redis.crt --key /etc/redis.key --cacert /etc/appnomic-rootca.crt -h <redis IP> -p <redis port> -a <password>For Example:
root@support-n1:/data# redis-cli -c --tls --cert /etc/redis.crt --key /etc/redis.key --cacert /etc/appnomic-rootca.crt -h 203.0.113.69 -p 7001 -a <password>Expected Output:
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. 203.0.113.69:7001> -
Check the cluster nodes,
192.0.2.17:5001> cluster nodesExpected Output:
0bb5cf31757dca410979f10f1b0b9e9d5d20bcce 192.0.2.17:5003@17003 master - 0 1694510667855 3 connected 10923-16383 36bdf9a9b2d6c26b5c5c08ad94b877da362e9033 192.0.2.17:5004@17004 slave d0a04g0bdd6875f238f7595edab689bcbd61ec66 0 1694510663000 2 connected 30d9e3c0b1c3c8b5988e72ef557a476a5100ee38 192.0.2.17:5006@17006 slave 2ea5a19d6c0ecd5807abg012705695fffe285463 0 1694510662000 1 connected 2ea5a19d6b0ecd5807abd092705695fffe285463 192.0.2.17:5001@17001 myself,master - 0 1694510662000 1 connected 0-5460 eb0915793b6f59f8a38262d11cd70e129f23ce43 192.0.2.17:5005@17005 slave 0bb5cf31757eca410979f10f1b0a9e9d5d20bcce 0 1694510663553 3 connected d0a04f0bdd6675f238f7595edac689bcbd61ec66 192.0.2.17:5002@17002 master - 0 1694510678000 2 connected 5461-10922Check if there are 3 master and 3 slave nodes.
- If all the nodes are present, then there is no issues with the cluster formation.
- If there is absence of any one of the node, then the cluster formation is incomplete, hence further troubleshooting is required.
Case 2: Redis Cluster formation Issue in UAT Environment#
Issue : The Redis cluster was not formed correctly.
-
Navigate to each Redis node directory and backup existing data:
cd redis-node1/ llFor Example:
[HEAL@SITDRHEAL02 data]$ cd redis-node1/ [HEAL@SITDRHEAL02 redis-node1]$ ll total 1000 -rw-r--r-- 1 HEAL 1018119 Feb 28 10:10 dump.rdb -rw-r--r-- 1 HEAL 802 Feb 27 13:26 nodes.conf [HEAL@SITDRHEAL02 redis-node1]$ pwd /HEAL/example/Appsone_Service/data/redis-node1 -
Remove all data in relevant folders for each Redis node.
-
Restart Redis and its microservices to resolve the issue.
Note: Data deletion was performed as this is a UAT setup.
Redis Master-slave replication#
Identifying the issues with master-slave replication helps to prevent good performance, downtime, and potential data inconsistency (this is caused due to the load on the redis because of master-slave). Also, UI screen performance is poor and delayed.
Follow the below steps inside the redis container to find the issues:
-
Connect to redis-cli by executing the below command.
redis-cli -c --tls --cert /etc/redis.crt --key /etc/redis.key --cacert /etc/appnomic-rootca.crt -h <redis_ip> -p <redis_port> -
Execute the info command.
<redis_ip>: <redis_port>> info -
In the slave node, check for the replication section in the output (#Replication):
role:slave master_host:? master_port:6379 master_link_status:down master_last_io_seconds_ago:-1 master_sync_in_progress:0 master_link_down_since_seconds:1379450797 slave_priority:100 slave_read_only:1 connected_slaves:0If the value for the 'master_host ' parameter is empty (as in the above output), it indicates an issue with redis replication.
-
To check for the replication status in the master node, execute the 'sync ' command as below:
<redis_ip>: <redis_port>> syncIf the status is : 'replication not allowed' (It means, there is an issue with the redis replication setup)
Note: To resolve the master-slave replication issue, follow the below section 'Enable Master-Slave Replication'.
Enable Master-Slave Replication
Enabling master-slave replication helps the redis to perform HA, and improve scalability and performance.
To enable master-slave replication inside the redis container, connect the redis slave server with its slave IP by executing the below command:
redis-node1.example:7001> cluster replicate <master-id>
Note: After executing the above command, the issue will be resolved.