redis debug命令詳解
redis debug命令提供了幾個非常實用的debug功能,本文介紹下redis下的debug命令。
debug segment
讓redis發生段錯誤,如果開啟了coredump,則會產生core檔案。這個命令實現很簡單,直接往一個非法地址上寫資料。
*((char*)-1) = 'x';
debug oom
申請一大片記憶體,直接讓zmalloc觸發oom錯誤
void *ptr = zmalloc(ULONG_MAX); /* Should trigger an out of memory. */
zfree(ptr);
addReply(c,shared.ok);
debug assert
不多解釋
redisAssertWithInfo(c,c->argv[0],1 == 2);
debug reload
save當前的rdb檔案,並清空當前資料庫,重新載入rdb,載入與啟動時載入類似,載入過程中只能服務部分只讀請求(比如info、ping等)
rdbSave();
emptyDb();
rdbLoad();
debug loadaof
清空當前資料庫,重新從aof檔案里載入資料庫
emptyDb();
loadAppendOnlyFile();
debug object
檢視一個key內部資訊,比如refcount、encoding、serializedlength等,結果如下
Value at:0x7f21b9479850 refcount:1 encoding:raw serializedlength:6 lru:8462202 lru_seconds_idle:215
debug sdslen
檢視某個sds當前的資訊,當前sds長度,以及可用記憶體長度,結果如下
key_sds_len:3, key_sds_avail:0, val_sds_len:5, val_sds_avail:0
debug populate
測試利器,快速產生大量的key
127.0.0.1:6379> debug populate 10000
OK
127.0.0.1:6379> dbsize
(integer) 10000
debug digest
對整個資料庫的資料,產生一個摘要,可用於驗證兩個redis資料庫資料是否一致
127.0.0.1:6379> debug digest
7164ae8b6730c8bcade46532e5e4a8015d4cccfb
127.0.0.1:6379> debug digest
7164ae8b6730c8bcade46532e5e4a8015d4cccfb
debug sleep
測試利器,用於模擬某個時間開銷的命令,比如debug sleep 0.1就相當於執行了一條開銷為100ms的命令。
127.0.0.1:6379> debug sleep 1
OK
(1.00s)
debug error
測試利器,模擬一條命令執行失敗,傳送debug error,redis直接會返回一個錯誤應答
127.0.0.1:6379> debug error "test"
(error) test
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15498/viewspace-2286238/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Redis命令詳解:HashsRedis
- Redis命令參考之INFO命令詳解Redis
- Redis 有序集合(zset)命令詳解Redis
- redis-trib.rb命令詳解Redis
- redis4.0之MEMORY命令詳解Redis
- Redis4.0 info命令彙總詳解Redis
- Redis有序集合命令ZREVRANGEBYSCORE詳解與應用RedisVR
- redis string結構及命令詳解【三】Redis
- Redis詳解Redis
- Redis系列之key操作命令與Redis中的事務詳解(六)Redis
- tomcat遠端debug配置詳解Tomcat
- redis info詳解Redis
- redis info命令詳細說明Redis
- Redis有序集合詳解Redis
- Redis 持久化詳解Redis持久化
- redis 4.0 info詳解Redis
- Redis 中 Bitmap 詳解Redis
- Redis協議詳解Redis協議
- Dockerfile 命令詳解Docker
- tcpdump命令詳解TCP
- getsebool命令詳解
- w命令詳解
- GCC命令詳解GC
- echo命令詳解
- brctl 命令詳解
- rsync命令詳解
- echo 命令詳解
- date 命令詳解
- free 命令詳解
- NPM命令詳解NPM
- docker命令詳解Docker
- ps命令詳解
- lsof命令詳解
- SVN命令詳解
- 命令模式 詳解模式
- Ethtool命令詳解
- find命令詳解
- test命令詳解