redis-cli -h 192.168.1.114 -a test123 --bigkeys
hotkeys命令需要redis 4.0以上的版本才支持
/usr/local/redis/src/redis-cli -h 192.168.1.50 -a test123 --hotkeys
分析热key报错误:
[hxl@test-prd ~]$ /usr/local/services/redis/bin/redis-cli -h 192.168.1.100 -a test123 -p 6379 --hotkeys
Warning: Using a password with '-a' option on the command line interface may not be safe.
# Scanning the entire keyspace to find hot keys as well as
# average sizes per key type. You can use -i 0.1 to sleep 0.1 sec
# per 100 SCAN commands (not usually needed).
Error: ERR An LFU maxmemory policy is not selected, access frequency not tracked. Please note that when switching between policies at runtime LRU and LFU data will take some time to adjust.
[yeemiao@zjs-redis-210v001-prd ~]$
解决办法:
查看当前的配置maxmemory-policy
config get maxmemory-policy
config set maxmemory-policy allkeys-lfu
该参数的设置:
noeviction:不淘汰键,当内存空间满后再进行写入会返回错误.
allkeys-lru:最近最少使用方式,当内存空间满后,会淘汰内存中最近最少使用的键,即最长时间未被访问的键.
volatile-lru:和最近最少使用类似,不过是当内存空间满后,在设置了过期时间的键中淘汰最近最少使用的键.
allkeys-lfu:最近最不常用方式,当内存满后,会淘汰内存中被访问次数最少的键.
volatile-lru:和上面类似,当内存满后,在设置了过期时间的键中淘汰访问次数最少的键.
allkeys-random:当内存使用满后,随机淘汰内存中的键,它可以是任意的键,不管你是常使用的还是不常使用的.
volatile-random:类似,内存使用满后,在设置了过期时间的键中淘汰任意的键.
volatile-ttl:在设置了过期时间的键中,淘汰即将过期的键.