Redis集群内存暴增,需要下集群中哪类key占用内存比较多,简述下我的思路和操作步骤
1.去找个slave,bgsave一下,生成rdb文件
2.使用rdb工具分析rdb文件生成csv文件
rdb -c memory redis6379.rdb --bytes 0 -f memory.csv
查看下csv文件
cat memory.csv
database,type,key,size_in_bytes,encoding,num_elements,len_largest_element
0,string,ops.073a7ae3d0fec21cd13c7a34d497cb70,304,string,210,210
0,string,test12,48,string,8,8
0,string,ops.5c8b7a27fd1597ef3202e9e4906cb630,304,string,194,194
0,hash,bach-price-dev.2ssku_inventory_price_100016002,5651,ziplist,323,9
0,set,monitor_device_list,83588,hashtable,920,37
0,string,ops.e58ccdb5730ae3dbdbcb7103747b228b,304,string,194,194
0,string,test4,48,string,8,8
0,string,ops.8bf1f83967a11fffb7ed55ac1f42fa10,304,string,213,213
0,string,test17,48,string,8,8
把第一行数据表头去了,方便导入MySQL分析
3.创建MySQL统计表
创建统计表
create table memory_count(
id int primary key auto_increment,
db int not null default 0 ,
key_type varchar(20) not null,
key_name varchar(200) not null,
key_size_in_bytes bigint not null,
key_encoding varchar(20) not null,
key_num_elements bigint not null,
key_len_largest_element bigint not null);
|
|
4.导入到MySQL
|
|