一、生成大文件测试数据

[root@db3 ~]# redis-cli set txt $(cat txt.txt)
OK

二、用redis-cli查看大文件

[root@db3 ~]# redis-cli --bigkeys

# Scanning the entire keyspace to find biggest 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).

[00.00%] Biggest string found so far 't' with 2 bytes
[00.00%] Biggest string found so far 'txt' with 8568 bytes

-------- summary -------

Sampled 7 keys in the keyspace!
Total key length in bytes is 9 (avg len 1.29)

Biggest string found 'txt' has 8568 bytes

0 lists with 0 items (00.00% of keys, avg size 0.00)
0 hashs with 0 fields (00.00% of keys, avg size 0.00)
7 strings with 8575 bytes (100.00% of keys, avg size 1225.00)
0 streams with 0 entries (00.00% of keys, avg size 0.00)
0 sets with 0 members (00.00% of keys, avg size 0.00)
0 zsets with 0 members (00.00% of keys, avg size 0.00)
[root@db3 ~]# redis-cli --memkeys

# Scanning the entire keyspace to find biggest 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).

[00.00%] Biggest string found so far 't' with 43 bytes
[00.00%] Biggest string found so far 'txt' with 8619 bytes

-------- summary -------

Sampled 7 keys in the keyspace!
Total key length in bytes is 9 (avg len 1.29)

Biggest string found 'txt' has 8619 bytes

0 lists with 0 bytes (00.00% of keys, avg size 0.00)
0 hashs with 0 bytes (00.00% of keys, avg size 0.00)
7 strings with 8877 bytes (100.00% of keys, avg size 1268.14)
0 streams with 0 bytes (00.00% of keys, avg size 0.00)
0 sets with 0 bytes (00.00% of keys, avg size 0.00)
0 zsets with 0 bytes (00.00% of keys, avg size 0.00)

三、安装第三方工具

[root@db3 ~]# yum install python-pip gcc python-devel -y
[root@db3 ~]# cd /opt/
[root@db3 opt]# git clone https://github.com/sripathikrishnan/redis-rdb-tools
[root@db3 opt]# cd redis-rdb-tools
[root@db3 redis-rdb-tools]# pip install --upgrade pip 
[root@db3 redis-rdb-tools]# pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple
[root@db3 redis-rdb-tools]# pip install rdbtools python-lzf -i https://pypi.tuna.tsinghua.edu.cn/simple
[root@db3 redis-rdb-tools]# python setup.py install

四、生成rdb文件

[root@db3 redis-rdb-tools]# redis-cli bgsave
Background saving started

五、使用工具解析rdb文件

[root@db3 redis-rdb-tools]# cd /data/redis_6379/
[root@db3 redis_6379]# rdb -c memory redis.rdb -f redis.rdb.csv

六、过滤分析

[root@db3 redis_6379]#  awk -F "," '{print $4,$3}' redis.rdb.csv |sort -r
size_in_bytes key
48 t
40 5
40 4
40 3
40 2
40 1
10288 txt

七、性能测试

[root@db3 redis_6379]# redis-benchmark -n 10000 -q
PING_INLINE: 57803.47 requests per second
PING_BULK: 62893.08 requests per second
SET: 38022.81 requests per second
GET: 59880.24 requests per second
INCR: 38759.69 requests per second
LPUSH: 38314.18 requests per second
RPUSH: 41666.67 requests per second
LPOP: 41322.31 requests per second
RPOP: 37735.85 requests per second
SADD: 51546.39 requests per second
HSET: 38022.81 requests per second
SPOP: 52910.05 requests per second
LPUSH (needed to benchmark LRANGE): 39525.69 requests per second
LRANGE_100 (first 100 elements): 31446.54 requests per second
LRANGE_300 (first 300 elements): 16103.06 requests per second
LRANGE_500 (first 450 elements): 11764.71 requests per second
LRANGE_600 (first 600 elements): 9363.30 requests per second
MSET (10 keys): 21881.84 requests per second
Categories: 数据库

0 Comments

发表评论

Avatar placeholder

邮箱地址不会被公开。 必填项已用*标注