目录
-
Redis命令
本地安装redis,通过安装目录下的redis客户端程序可以连接任意Redis服务(只要服务端是启动着的),命令 redis-cli -h ip -p port。如果服务端要求认证资格,可能还要输入用户名密码等参数。
Redis命令十分丰富,包括的命令组有Cluster、Connection、Geo、Hashes、HyperLogLog、Keys、Lists、Pub/Sub、Scripting、Server、Sets、Sorted Sets、Strings、Transactions一共14个redis命令组两百多个redis命令。这么多命令十分难记。或者我们需要连接服务器之后,在客户端可以通过比较灵活的一套逻辑快速找到想要的命令和命令使用说明。
1)先输入"help @"(也就是help+空格+@),然后按Tab键,客户端会提示所有的组。
2)通过1),可得出所有的group(组),然后想查哪个组下的命令,再用help @<group>,如connection是redis命令的一个group,即查看其下的命令为:help @connection。这样可得到该组下的所有命令。
3)根据2)所有命令都可以找到,help <command>(如 help keys)可以查看命令使用方法。
通过1)2)3)达到了通过比较灵活的一套逻辑快速找到想要的命令和命令使用说明的目的。这样无需借助其他资料,也可以得到一部命令字典。
全部的group命令
help @generic
help @connection
help @string
help @list
help @set
help @sorted_set
help @hash
help @pubsub
help @transactions
help @server
help @scripting
help @hyperloglog
help @cluster
help @geo
-
redis中文网站
![](https://i-blog.csdnimg.cn/blog_migrate/fdae68ecf64a126a824d3e90f781c20e.png)
-
Redis查看连接数量
- Linux
xshell连接linux系统
1)连接:Redis-cli -h ip -p port
2)授权:auth 密码
3)查看连接信息命令:client list
样例
[hw@helloworld ~]$ redis-cli -h 10.10.0.102 -p 6380
10.10.0.102:6380> auth hw@redis
OK
10.10.0.102:6380> client list
id=576 addr=10.10.14.178:53961 fd=6 name= age=85 idle=28 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=ping
id=577 addr=10.10.0.160:39276 fd=7 name= age=43 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
id=578 addr=10.10.0.160:39294 fd=8 name= age=27 idle=2 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=expire
id=579 addr=10.10.14.224:60253 fd=9 name= age=13 idle=12 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=get
id=580 addr=10.10.14.224:60255 fd=10 name= age=13 idle=13 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=get
id=582 addr=10.10.14.224:60262 fd=12 name= age=13 idle=12 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=expire
id=581 addr=10.10.14.224:60256 fd=11 name= age=13 idle=13 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=get
10.10.0.102:6380>
info可以查看整体信息,包括连接数
- window
基本上和linux系统一样,不同的是,需要在redis的安装目录下打开cmd,然后进行后续操作。
-
查看最大连接数
登录及授权同1
10.10.0.11:6380> config get maxclients
1) "maxclients"
2) "20000"
3、查看客户端信息
登录及授权同1
10.10.0.11:6380> info clients
# Clients
connected_clients:868
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0
10.10.0.11:6380>
-
client list 详解
https://www.jianshu.com/p/70f3b68a7fd7
https://www.cnblogs.com/yeahwell/p/5330012.html
-
info
10.10.2.222:6379> info
# Server
redis_version:3.2.9
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:d837dd4aae3a6933
redis_mode:standalone
os:Linux 3.10.0-1062.9.1.el7.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.9.2
process_id:1
run_id:d8dd4559fe43368ee740e2ab1a2cac5bff2e0822
tcp_port:6379
uptime_in_seconds:13884961
uptime_in_days:160
hz:10
lru_clock:5855588
executable:/data/redis-server
config_file:# Clients
connected_clients:711
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0# Memory
used_memory:63534464
used_memory_human:60.59M
used_memory_rss:70426624
used_memory_rss_human:67.16M
used_memory_peak:274283624
used_memory_peak_human:261.58M
total_system_memory:16656986112
total_system_memory_human:15.51G
used_memory_lua:41984
used_memory_lua_human:41.00K
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
mem_fragmentation_ratio:1.11
mem_allocator:jemalloc-4.0.3# Persistence
loading:0
rdb_changes_since_last_save:45
rdb_bgsave_in_progress:0
rdb_last_save_time:1616468232
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:0
rdb_current_bgsave_time_sec:-1
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok# Stats
total_connections_received:77274665
total_commands_processed:194704121
instantaneous_ops_per_sec:20
total_net_input_bytes:68399634770
total_net_output_bytes:2967590516124
instantaneous_input_kbps:0.51
instantaneous_output_kbps:2889.74
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:792957
evicted_keys:0
keyspace_hits:16105845
keyspace_misses:1793269
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:4795
migrate_cached_sockets:0# Replication
role:master
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0# CPU
used_cpu_sys:74255.44
used_cpu_user:37991.11
used_cpu_sys_children:2141.03
used_cpu_user_children:11538.22# Cluster
cluster_enabled:0# Keyspace
db0:keys=197,expires=197,avg_ttl=194109082