redis命令

[root@17 bin]# redis-cli
127.0.0.1:6379> client list
id=2 addr=127.0.0.1:43108 fd=6 name= age=71426 idle=0 flags=S db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=replconf
id=9 addr=127.0.0.1:22668 fd=7 name= age=12 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=client
127.0.0.1:6379> client getname
(nil)
127.0.0.1:6379> client setname ‘test’
OK
127.0.0.1:6379> client getname
“test”
127.0.0.1:6379> client list;
(error) ERR Syntax error, try CLIENT (LIST | KILL ip:port | GETNAME | SETNAME connection-name)
127.0.0.1:6379> client list
id=2 addr=127.0.0.1:43108 fd=6 name= age=71545 idle=1 flags=S db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=replconf
id=9 addr=127.0.0.1:22668 fd=7 name=test age=131 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=client
127.0.0.1:6379> command count
(error) ERR unknown command ‘command’
127.0.0.1:6379> COMMAND COUNT
(error) ERR unknown command ‘COMMAND’
127.0.0.1:6379> COMMAND INFO get set eval
(error) ERR unknown command ‘COMMAND’
127.0.0.1:6379> exit
[root@017 bin]# redis-cli -v
redis-cli 2.8.12
[root@4017 bin]# redis-cli
127.0.0.1:6379> CONFIG GET *
1) “dbfilename”
2) “dump.rdb”
3) “requirepass”
4) “”
5) “masterauth”
6) “”
7) “unixsocket”
8) “”
9) “logfile”
10) “”
11) “pidfile”
12) “/var/run/redis.pid”
13) “maxmemory”
14) “0”
15) “maxmemory-samples”
16) “3”
17) “timeout”
18) “0”
19) “tcp-keepalive”
20) “0”
21) “auto-aof-rewrite-percentage”
22) “100”
23) “auto-aof-rewrite-min-size”
24) “67108864”
25) “hash-max-ziplist-entries”
26) “512”
27) “hash-max-ziplist-value”
28) “64”
29) “list-max-ziplist-entries”
30) “512”
31) “list-max-ziplist-value”
32) “64”
33) “set-max-intset-entries”
34) “512”
35) “zset-max-ziplist-entries”
36) “128”
37) “zset-max-ziplist-value”
38) “64”
39) “hll-sparse-max-bytes”
40) “3000”
41) “lua-time-limit”
42) “5000”
43) “slowlog-log-slower-than”
44) “10000”
45) “slowlog-max-len”
46) “128”
47) “port”
48) “6379”
49) “tcp-backlog”
50) “511”
51) “databases”
52) “16”
53) “repl-ping-slave-period”
54) “10”
55) “repl-timeout”
56) “60”
57) “repl-backlog-size”
58) “1048576”
59) “repl-backlog-ttl”
60) “3600”
61) “maxclients”
62) “10000”
63) “watchdog-period”
64) “0”
65) “slave-priority”
66) “100”
67) “min-slaves-to-write”
68) “0”
69) “min-slaves-max-lag”
70) “10”
71) “hz”
72) “10”
73) “no-appendfsync-on-rewrite”
74) “no”
75) “slave-serve-stale-data”
76) “yes”
77) “slave-read-only”
78) “yes”
79) “stop-writes-on-bgsave-error”
80) “yes”
81) “daemonize”
82) “no”
83) “rdbcompression”
84) “yes”
85) “rdbchecksum”
86) “yes”
87) “activerehashing”
88) “yes”
89) “repl-disable-tcp-nodelay”
90) “no”
91) “aof-rewrite-incremental-fsync”
92) “yes”
93) “appendonly”
94) “no”
95) “dir”
96) “/data/redis/bin”
97) “maxmemory-policy”
98) “volatile-lru”
99) “appendfsync”
100) “everysec”
101) “save”
102) “3600 1 300 100 60 10000”
103) “loglevel”
104) “notice”
105) “client-output-buffer-limit”
106) “normal 0 0 0 slave 268435456 67108864 60 pubsub 33554432 8388608 60”
107) “unixsocketperm”
108) “0”
109) “slaveof”
110) “”
111) “notify-keyspace-events”
112) “”
113) “bind”
114) “”
CONFIG SET SAVE “900 1 300 10”立即生效

127.0.0.1:6379> dbsize 返回当前数据库的键数量
flush all删除所有库的所有键
flush db删除当前库的所有键
info返回统计信息
redis-cli monitor监控server正在干什么,有性能消耗
role查看角色
save保存快照,会阻塞客户端,通常使用bgsave,在执行完后,可以执行lastsave来看下是否执行成功
shutdown 关闭所有的客户端,有2个参数,代表是否save
SLOWLOG LEN
slowlog get 2
杀掉客户端
Available since 2.4.0.
Time complexity: O(N) where N is the number of client connections
The CLIENT KILL command closes a given client connection. Up to Redis 2.8.11 it was possible to close a connection only by client address, using the following form:
CLIENT KILL addr:port
The ip:port should match a line returned by the CLIENT LIST command (addr field).
However starting with Redis 2.8.12 or greater, the command accepts the following form:
CLIENT KILL … …
With the new form it is possible to kill clients by different attributes instead of killing just by address. The following filters are available:
CLIENT KILL ADDR ip:port. This is exactly the same as the old three-arguments behavior.
CLIENT KILL ID client-id. Allows to kill a client by its unique ID field, which was introduced in the CLIENT LIST command starting from Redis 2.8.12.
CLIENT KILL TYPE type, where type is one of normal, master, slave and pubsub (the master type is available from v3.2). This closes the connections of all the clients in the specified class. Note that clients blocked into the MONITOR command are considered to belong to the normal class.
CLIENT KILL SKIPME yes/no. By default this option is set to yes, that is, the client calling the command will not get killed, however setting this option to no will have the effect of also killing the client calling the command.
查看所有的key
keys *
redis默认的情况下是有16个数据库,通过select n来选择使用哪个
redis-cli –stat显示连接状态信息
redis-cli –bigkeys查找大键
查看延时
redis-cli –latency

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值