Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed explanation of redis debug command

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Redis debug command provides several very useful debug functions. This article introduces debug command under redis.

debug segment

Make redis generate segment errors, and if coredump is turned on, a core file will be generated. This command is very simple to implement, write data directly to an illegal address.

*((char*)-1) = 'x';

debug oom

Request a large block of memory, directly let zmalloc trigger oom error

void *ptr = zmalloc(ULONG_MAX); /* Should trigger an out of memory. */

zfree(ptr);

addReply(c,shared.ok);

debug assert

No more explanations.

redisAssertWithInfo(c,c->argv[0],1 == 2);

debug reload

save the current rdb file, and empty the current database, reload rdb, loading is similar to loading at startup, loading process can only serve some read-only requests (such as info, ping, etc.)

rdbSave();

emptyDb();

rdbLoad();

debug loadaof

Empty current database and reload database from aof file

emptyDb();

loadAppendOnlyFile();

debug object

Check the internal information of a key, such as refcount, encoding, serializedlength, etc. The result is as follows

Value at:0x7f21b9479850 refcount:1 encoding:raw serializedlength:6 lru:8462202 lru_seconds_idle:215

debug sdslen

View the current information of an SDS, the current SDS length, and the available memory length. The result is as follows

key_sds_len:3, key_sds_avail:0, val_sds_len:5, val_sds_avail:0

debug populate

Test sharp tools, quickly generate a large number of keys

127.0.0.1:6379> debug populate 10000

OK

127.0.0.1:6379> dbsize

(integer) 10000

debug digest

Generate a summary of the entire database data, which can be used to verify whether the data in two redis databases is consistent.

127.0.0.1:6379> debug digest

7164ae8b6730c8bcade46532e5e4a8015d4cccfb

127.0.0.1:6379> debug digest

7164ae8b6730c8bcade46532e5e4a8015d4cccfb

debug sleep

Test tool, used to simulate a command with a certain time cost, such as debug sleep 0.1 is equivalent to executing a command with a cost of 100 ms.

127.0.0.1:6379> debug sleep 1

OK

(1.00s)

debug error

Test tool, simulate a command execution failure, send debug error, redis will directly return an error response

127.0.0.1:6379> debug error "test"

(error) test

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report