redis 监控

1.连接数分析

  根据redis.config中设置的maxclients的设置值分析

  查看客户端的连接信息

xxx.23.66.xxx:0>info clients
"# Clients
connected_clients:190  #连接数
cluster_connections:0
maxclients:512  #最在连接数
client_recent_max_input_buffer:56
client_recent_max_output_buffer:0
blocked_clients:0 #阻塞连接数
tracking_clients:0
clients_in_timeout_table:0
"

  查看客户端的连接数(如idle=64498 代表空闲时长约17小时)

xxx.23.66.xxx:0>client list
"id=6853 addr=14.153.172.190:55180 laddr=172.18.0.156:6379 fd=195 name= age=64498 idle=64498 flags=N db=2 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 argv-mem=0 obl=0 oll=0 omem=0 tot-mem=20504 events=r cmd=get user=default redir=-1
id=749388 addr=14.153.172.190:39024 laddr=172.18.0.156:6379 fd=165 name= age=3766 idle=3766 flags=N db=1 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 argv-mem=0 obl=0 oll=0 omem=0 tot-mem=20496 events=r cmd=role user=default redir=-1
id=2552 addr=47.106.160.176:38700 laddr=172.18.0.156:6379 fd=44 name= age=65148 idle=9 flags=N db=2 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 argv-mem=0 obl=0 oll=0 omem=0 tot-mem=20504 events=r cmd=get user=default redir=-1
...

  查看空闲超时时间,如果客户端过多连接数,可以设置空闲超时时间,默认为0不开启

xxx.23.66.xxx:0>config get timeout
 1)  "timeout"
 2)  "0"

  设置空闲时间执行:config set timeout 60  , 为60秒

  设置连接数:config set maxclients 1000

  执行: CONFIG REWRITE  保存,可在redis.conf 配置文件中修改。

2. 内存分析

自建119.23.66.199:0>info memory
"# Memory
used_memory:24008816    
used_memory_human:22.90M  #使用的内存总量
used_memory_rss:32399360
used_memory_rss_human:30.90M #redis进程占用的内存总量
used_memory_peak:33167672   
used_memory_peak_human:31.63M  #内存消耗的历史峰值
used_memory_peak_perc:72.39%
used_memory_overhead:14939392
used_memory_startup:305216
used_memory_dataset:9069424
used_memory_dataset_perc:38.26%
allocator_allocated:24323464
allocator_active:28205056
allocator_resident:30609408
total_system_memory:16319328256
total_system_memory_human:15.20G  #操作系统总内存
used_memory_lua:30720
used_memory_lua_human:30.00K
used_memory_scripts:0
used_memory_scripts_human:0B
number_of_cached_scripts:0
maxmemory:4294967296
maxmemory_human:4.00G    #分配的redis的总内存
maxmemory_policy:noeviction
allocator_frag_ratio:1.16
allocator_frag_bytes:3881592
allocator_rss_ratio:1.09
allocator_rss_bytes:2404352
rss_overhead_ratio:1.06
rss_overhead_bytes:1789952
mem_fragmentation_ratio:1.35
mem_fragmentation_bytes:8369688
mem_not_counted_for_evict:0
mem_replication_backlog:0
mem_clients_slaves:0
mem_clients_normal:2727272
mem_aof_buffer:0
mem_allocator:jemalloc-5.1.0
active_defrag_running:0
lazyfree_pending_objects:0
lazyfreed_objects:0

 

 

可以考虑监控的参数

  ClientConnectedLimit--客户端连接数上限<br />
  RejectedConnectionsLimit--服务端拒绝连接数上限<br />
  ShowlogLimit--慢查询最大耗时上限(毫秒)<br />
  OpsPerSecondLimit--每秒执行指令数上限<br />
  UsedMemoryRssLimit--占用内存数上限(kb)<br />
  HashBigKeyFieldsLimit--hash结构最大key上限(Fields)<br />
  ListBigKeyItemsLimit--list结构的最大key上限(items)<br />
  StringBigKeyKBLimit --string结构的最大key上限(kb)<br />
  ZSetBigKeyMembersLimit --zset结构的最大key上限(members)<br />
  SetBigKeyMembersLimit --set结构的最大key上限(members)<br />

  



posted on 2022-12-27 10:45  花阴偷移  阅读(5)  评论(0编辑  收藏  举报

导航