介绍
方便自己查询使用
常用命令
登录查询命令
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| ./redis-cli -h 主机IP -a 密码 -p 端口 [可执行命令]
info
info Replication
flush db
flush all
keys *
keys prefix_*
exists key
set key value
get key
del key
type key
keys pattern
random key
key rename oldname newname
db size
select index
move key dbindex
set key value ex 120
redis-cli -h 192.168.10.71 -p 6379 keys "Mpos:base:user:info:key:*" | xargs redis-cli -h 192.168.10.71 -p 6379 del
|
持久化存储命令
1 2 3 4 5 6 7 8
| 127.0.0.1:6379> SAVE
127.0.0.1:6379> BGSAVE
127.0.0.1:6379> BGREWRITEAOF
|
客户端连接命令
1 2 3 4 5
| redis-cli -h 192.168.77.100 -p 7000 client list
redis-cli client list|sed 's/\r//'|awk -F' |:' '{print $1,$2,$5,$6,$9,$19}'|column -t
|
参数命令
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| cat token.txt |awk '{print "redis-cli del""\t"$1 }'| sh
redis-cli -h 192.168.77.100 -p 7000 CONFIG GET "*"
redis-cli -h 192.168.77.100 -p 7000 CONFIG GET maxmemory
redis-cli -h 192.168.77.100 -p 7000 CONFIG SET maxmemory 7000000000 redis-cli -h 192.168.77.100 -p 7000 CONFIG GET maxmemory
cat redis_7000.conf |grep ^maxmemory
redis-cli -h 192.168.77.100 -p 7000 CONFIG REWRITE cat redis_7000.conf |grep ^maxmemory
redis-cli -h 192.168.77.100 -p 7000 CONFIG RESETSTAT
|
底层命令
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| redis-cli -h 192.168.77.100 -p 7000 COMMAND
redis-cli -h 192.168.77.100 -p 7000 COMMAND COUNT
redis-cli -h 192.168.77.100 -p 7000 COMMAND GETKEYS SET key value redis-cli -h 192.168.77.100 -p 7000 COMMAND GETKEYS MSET k1 v1 k2 v2 k3 v3
redis-cli -h 192.168.77.100 -p 7000 COMMAND INFO del set
|
清楚库命令
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| echo -e "select 2\nflushdb"|sed 's/$/\r/'|redis-cli -h 192.168.77.100 -p 7000 --pipe
redis-cli -h 192.168.77.100 -p 7000 FLUSHALL
redis-cli -h 192.168.77.100 -p 7000 SHUTDOWN
redis-cli -h 192.168.77.100 -p 7000 SHUTDOWN SAVE
redis-cli -h 192.168.77.100 -p 7000 DEBUG SEGFAULT
|
服务状态命令
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| TIME
DBSIZE
LASTSAVE
DEBUG OBJECT key
redis-cli -c -h 192.168.21.101 -p 7000 SLOWLOG LEN
redis-cli -c -h 192.168.21.101 -p 7000 SLOWLOG GET 1
redis-cli -c -h 192.168.21.101 -p 7000 SLOWLOG GET
redis-cli -c -h 192.168.21.101 -p 7000 SLOWLOG RESET
redis-cli -c -h 192.168.77.100 -p 7000 MONITOR
date -d@1523933983.091873 +%F_%T_%N
|
redis 客户端工具
redisinsight:是web版连接工具,可以连接redis单机和集群模式、可以实时显示redis性能,分析内存等功能
1 2
| docker run -d --name redisinsight -v /data/redisinsight/:/db -p 8001:8001 -u root redislabs/redisinsight:latest
|