I’ve put together a list of procedures to follow and sample code to help you troubleshoot Redis when you run into problems.
- Check Redis logs:
To view the Redis logs, use the following command:
tail -f /var/log/redis/redis-server.log
- Review system logs:
Review system logs, including the syslog or journal, for any error messages, warnings, or critical events.
For example, for the syslog, use the following command:
tail -f /var/log/syslog
- Adjust file mode creation mask:
Check the output of umask:
umask
- Verify Supervisor process status:
Ensure all processes are in a RUNNING state:
supervisorctl status
- Verify DNS configuration:
On the client machine, check if the database endpoint can be resolved using the following command:
dig <endpoint>
- Check connectivity using redis-cli:
Test connectivity from the client machine to the database using redis-cli:
redis-cli -h <endpoint> -p <port> -a <password> INFO
If the client machine cannot connect, test connectivity from one of the cluster nodes:
redis-cli -h <node IP or hostname> -p <port> -a <password> PING
- Check memory usage:
Run vmstat:
vmstat
Stop any non-Redis related processes if the CPU or RAM consumption exceeds 80%.
- Sync host clock with a time server:
Check if time is synchronized with a time server:
ntpq -p
chronyc sources
timedatectl
- Manage environment variables:
Run printenv and check if https_proxy and http_proxy are configured as environment variables:
printenv | grep -i proxy
- Verify used disk space:
Check the host machine’s disk usage:
df -h
- Verify Redis resources:
Run rladmin status issues_only and verify that no issues appear.
For each shard, check the USED_MEMORY:
rladmin status shards
Ensure that the USED_MEMORY is less than 25 GB for each shard.
- Check for running tasks:
Run rladmin cluster running_actions and confirm that no tasks are currently running (active).
- Benchmark Redis:
Use the redis-benchmark utility to test Redis performance:
redis-benchmark -h <endpoint> -p <port> -a <password>
- Handle keys with large memory footprints:
Compare the keys returned by SLOWLOG GET with the output of the following commands:
redis-cli -h <endpoint> -p <port> -a <password> --memkeys
redis-cli -h <endpoint> -p <port> -a <password> --bigkeys
- Use alternative commands:
Consider using commands such as SCAN, SSCAN, HSCAN, and ZSCAN.
I hope this guide helps you effectively troubleshoot your Redis issues.Happy coding!