首页 > 数据库 > Redis > 正文

redis常用命令小结

2020-03-17 12:44:50
字体:
来源:转载
供稿:网友

这篇文章主要介绍了redis的一些常用命令,需要的朋友可以参考下

1、redis-benchmark

redis基准信息,redis服务器性能检测

redis-benchmark -h localhost -p 6379 -c 100 -n 100000

100个并发连接,100000个请求,检测host为localhost 端口为6379的redis服务器性能

 

 
  1. [root@Architect redis-1.2.6]# redis-benchmark -h localhost -p 6379 -c 100 -n 100000 
  2. ====== PING ====== 
  3. 10001 requests completed in 0.41 seconds 
  4. 50 parallel clients 
  5. 3 bytes payload 
  6. keep alive: 1 
  7.  
  8. 0.01% <= 0 milliseconds 
  9. 23.09% <= 1 milliseconds 
  10. 85.82% <= 2 milliseconds 
  11. 95.60% <= 3 milliseconds 
  12. 97.20% <= 4 milliseconds 
  13. 97.96% <= 5 milliseconds 
  14. 98.83% <= 6 milliseconds 
  15. 99.41% <= 7 milliseconds 
  16. 99.70% <= 8 milliseconds 
  17. 99.99% <= 9 milliseconds 
  18. 100.00% <= 12 milliseconds 
  19. 24274.27 requests per second 

2、redis-cli

redis-cli -h localhost -p 6380 monitor

Dump all the received requests in real time;

监控host为localhost,端口为6380,redis的连接及读写操作

 

 
  1. [root@Architect redis-1.2.6]# redis-cli -h localhost -p 6380 monitor 
  2. +OK 
  3. +1289800615.808225 "monitor" 
  4. +1289800615.839079 "GET" "name" 
  5. +1289800615.853694 "PING" 
  6. +1289800615.853783 "PING" 
  7. +1289800615.854646 "PING" 
  8. +1289800615.854974 "PING" 
  9. +1289800615.857693 "PING" 
  10. +1289800615.866862 "PING" 
  11. +1289800615.871944 "PING" 

redis-cli -h localhost -p 6380 info

Provide information and statistics about the server ;

提供host为localhost,端口为6380,redis服务的统计信息

 

 
  1. [root@Architect redis-1.2.6]# redis-cli -h localhost -p 6380 info 
  2. redis_version:2.0.4 
  3. redis_git_sha1:00000000 
  4. redis_git_dirty:0 
  5. arch_bits:32 
  6. multiplexing_api:epoll 
  7. process_id:21990 
  8. uptime_in_seconds:490580 
  9. uptime_in_days:5 
  10. connected_clients:103 
  11. connected_slaves:0 
  12. blocked_clients:0 
  13. used_memory:4453240 
  14. used_memory_human:4.25M 
  15. changes_since_last_save:200 
  16. bgsave_in_progress:0 
  17. last_save_time:1290394640 
  18. bgrewriteaof_in_progress:0 
  19. total_connections_received:809 
  20. total_commands_processed:44094018 
  21. expired_keys:0 
  22. hash_max_zipmap_entries:64 
  23. hash_max_zipmap_value:512 
  24. pubsub_channels:0 
  25. pubsub_patterns:0 
  26. vm_enabled:0 
  27. role:slave 
  28. master_host:localhost 
  29. master_port:6379 
  30. master_link_status:up 
  31. master_last_io_seconds_ago:18 
  32. db0:keys=1319,expires=0 

3、redis-stat

redis-stat host localhost port 6380 overview

Print general information about a Redis instance;

实时打印出host为localhost,端口为6380,redis实例的总体信息

 

 
  1. [root@Architect redis-1.2.6]# redis-stat port 6380 overview 
  2. ------- data ------ ------------ load ----------------------------- - childs - 
  3. keys used-mem clients requests connections 
  4. 1319 5.37M 103 44108021 (+44108021) 810  
  5. 1319 5.38M 103 44108124 (+103) 810  
  6. 1319 5.38M 103 44108225 (+101) 810  
  7. 1319 5.39M 103 44108326 (+101) 810  
  8. 1319 5.40M 103 44108427 (+101) 810  
  9. 1319 5.41M 103 44108528 (+101) 810  

redis-stat host localhost port 6380 overview

Measure Redis server latency;

输出host为localhost,端口为6380,redis服务中每个请求的响应时长

 

 
  1. [root@Architect redis-1.2.6]# redis-stat port 6380 latency 
  2. 1: 0.16 ms 
  3. 2: 0.11 ms 
  4. 3: 0.15 ms 
  5. 4: 0.11 ms 
  6. 5: 0.18 ms 
  7. 6: 0.14 ms  

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表