Redis CONFIG RESETSTAT 命令

返回上一级

Redis CONFIG RESETSTAT 命令用于重置 INFO 命令中的某些统计数据

( Redis >= 2.0.0 )

重置的统计项包括:

  • Keyspace hits (键空间命中次数)
  • Keyspace misses (键空间不命中次数)
  • Number of commands processed (执行命令的次数)
  • Number of connections received (连接服务器的次数)
  • Number of expired keys (过期key的数量)
  • Number of rejected connections (被拒绝的连接数量)
  • Latest fork(2) time(最后执行 fork(2) 的时间)
  • Theaof_delayed_fsynccounter(aof_delayed_fsync计数器的值)

语法

Redis CONFIG RESETSTAT 命令语法如下:

127.0.0.1:6379> CONFIG RESETSTAT

返回值

总是返回 OK

范例

重置前 INFO 命令输出信息:

127.0.0.1:6379> INFO
# Server
redis_version:3.0.7
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:aa27a151289c9b98
redis_mode:standalone
os:Darwin 16.7.0 x86_64
arch_bits:64
multiplexing_api:kqueue
gcc_version:4.2.1
process_id:711
run_id:8f913d7ab320cc71443218a76d9a8c04beda6f68
tcp_port:6379
uptime_in_seconds:2256955
uptime_in_days:26
hz:10
lru_clock:10230461
config_file:/usr/local/etc/redis.conf

# Clients
connected_clients:1
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0

# Memory
used_memory:2057488
used_memory_human:1.96M
used_memory_rss:512000
used_memory_peak:2082896
used_memory_peak_human:1.99M
used_memory_lua:36864
mem_fragmentation_ratio:0.25
mem_allocator:libc

# Persistence
loading:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1503401928
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:8
total_commands_processed:502
instantaneous_ops_per_sec:0
total_net_input_bytes:20165
total_net_output_bytes:8412
instantaneous_input_kbps:0.00
instantaneous_output_kbps:0.00
rejected_connections:0
sync_full:4
sync_partial_ok:0
sync_partial_err:0
expired_keys:5
evicted_keys:0
keyspace_hits:141
keyspace_misses:18
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:610
migrate_cached_sockets:0

# Replication
role:master
connected_slaves:0
master_repl_offset:4424
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:2
repl_backlog_histlen:4423

# CPU
used_cpu_sys:365.73
used_cpu_user:161.94
used_cpu_sys_children:0.08
used_cpu_user_children:0.02

# Cluster
cluster_enabled:0

# Keyspace
db0:keys=1,expires=0,avg_ttl=0
127.0.0.1:6379> clear
127.0.0.1:6379> DBSIZE
(integer) 1
127.0.0.1:6379> FLUSHDB
OK
127.0.0.1:6379> dbsize
(integer) 0
127.0.0.1:6379> set name "luoyemo"
OK
127.0.0.1:6379> set site "www.twle.cn"
OK
127.0.0.1:6379> site age "28"
(error) ERR unknown command 'site'
127.0.0.1:6379> set age 28
OK
127.0.0.1:6379> save
OK
127.0.0.1:6379> DBSIZE
(integer) 3
127.0.0.1:6379> SELECT 1
OK
127.0.0.1:6379[1]> DBSIZE
(integer) 0
127.0.0.1:6379[1]> SADD  language PHP
(integer) 1
127.0.0.1:6379[1]> SADD  language Python27
(integer) 1
127.0.0.1:6379[1]> SADD  language JAVA
(integer) 1
127.0.0.1:6379[1]> DBSIZE
(integer) 1
127.0.0.1:6379[1]> FLUSHALL
OK
127.0.0.1:6379[1]> DBSIZE
(integer) 0
127.0.0.1:6379[1]> SELECT 0
OK
127.0.0.1:6379> DBSIZE
(integer) 0
127.0.0.1:6379> DEBUG SEGFAULT
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected> exit

# luojianguo @ lie in ~ [21:49:46]
$ redis-cli
127.0.0.1:6379> DEBUG OBJECT my_pc
(error) ERR no such key
127.0.0.1:6379> DEBUG OBJECT your_pc
(error) ERR no such key
127.0.0.1:6379> SET site "www.twle.cn"
OK
127.0.0.1:6379> DEBUG OBJECT site
Value at:0x7ff20c50a490 refcount:1 encoding:embstr serializedlength:12 lru:10237964 lru_seconds_idle:11
127.0.0.1:6379> FLUSHALL
OK
127.0.0.1:6379> FLUSHALL
OK
127.0.0.1:6379> DBSIZE
(integer) 0
127.0.0.1:6379> SET site "www.twle.cn"
OK
127.0.0.1:6379> DBSIZE
(integer) 1
127.0.0.1:6379> SET site_url "https://wwww.twle.cn/"
OK
127.0.0.1:6379> DBSIZE
(integer) 2
127.0.0.1:6379> CONFIG GET slowlog-max-len
1) "slowlog-max-len"
2) "128"
127.0.0.1:6379> CONFIG SET slowlog-max-len 10010
OK
127.0.0.1:6379> CONFIG GET slowlog-max-len
1) "slowlog-max-len"
2) "10010"
127.0.0.1:6379> CONFIG GET appendonly
1) "appendonly"
2) "no"
127.0.0.1:6379> CONFIG SET appendonly yes
OK
127.0.0.1:6379> CONFIG GET appendonly
1) "appendonly"
2) "yes"
127.0.0.1:6379> clear
127.0.0.1:6379> INFO
# Server
redis_version:3.0.7
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:aa27a151289c9b98
redis_mode:standalone
os:Darwin 16.7.0 x86_64
arch_bits:64
multiplexing_api:kqueue
gcc_version:4.2.1
process_id:93638
run_id:ab7d112e682c61869b55110b81dca4ebb00beabd
tcp_port:6379
uptime_in_seconds:2114
uptime_in_days:0
hz:10
lru_clock:10239661
config_file:/usr/local/etc/redis.conf

# Clients
connected_clients:1
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0

# Memory
used_memory:1010256
used_memory_human:986.58K
used_memory_rss:1032192
used_memory_peak:1010256
used_memory_peak_human:986.58K
used_memory_lua:36864
mem_fragmentation_ratio:1.02
mem_allocator:libc

# Persistence
loading:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1503411410
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:0
rdb_current_bgsave_time_sec:-1
aof_enabled:1
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:0
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok
aof_current_size:119
aof_base_size:119
aof_pending_rewrite:0
aof_buffer_length:0
aof_rewrite_buffer_length:0
aof_pending_bio_fsync:0
aof_delayed_fsync:0

# Stats
total_connections_received:1
total_commands_processed:17
instantaneous_ops_per_sec:0
total_net_input_bytes:637
total_net_output_bytes:320
instantaneous_input_kbps:0.00
instantaneous_output_kbps:0.00
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
evicted_keys:0
keyspace_hits:0
keyspace_misses:0
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:719
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:0.89
used_cpu_user:0.41
used_cpu_sys_children:0.00
used_cpu_user_children:0.00

# Cluster
cluster_enabled:0

# Keyspace
db0:keys=2,expires=0,avg_ttl=0

重置后查看 INFO 命令输出信息:

127.0.0.1:6379> CONFIG RESETSTAT
OK
127.0.0.1:6379> INFO
# Server
redis_version:3.0.7
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:aa27a151289c9b98
redis_mode:standalone
os:Darwin 16.7.0 x86_64
arch_bits:64
multiplexing_api:kqueue
gcc_version:4.2.1
process_id:93638
run_id:ab7d112e682c61869b55110b81dca4ebb00beabd
tcp_port:6379
uptime_in_seconds:2189
uptime_in_days:0
hz:10
lru_clock:10239736
config_file:/usr/local/etc/redis.conf

# Clients
connected_clients:1
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0

# Memory
used_memory:1010256
used_memory_human:986.58K
used_memory_rss:1101824
used_memory_peak:1010256
used_memory_peak_human:986.58K
used_memory_lua:36864
mem_fragmentation_ratio:1.09
mem_allocator:libc

# Persistence
loading:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1503411410
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:0
rdb_current_bgsave_time_sec:-1
aof_enabled:1
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:0
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok
aof_current_size:119
aof_base_size:119
aof_pending_rewrite:0
aof_buffer_length:0
aof_rewrite_buffer_length:0
aof_pending_bio_fsync:0
aof_delayed_fsync:0

# Stats
total_connections_received:0
total_commands_processed:1
instantaneous_ops_per_sec:0
total_net_input_bytes:14
total_net_output_bytes:5
instantaneous_input_kbps:0.00
instantaneous_output_kbps:0.00
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
evicted_keys:0
keyspace_hits:0
keyspace_misses:0
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:0
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:0.92
used_cpu_user:0.42
used_cpu_sys_children:0.00
used_cpu_user_children:0.00

# Cluster
cluster_enabled:0

# Keyspace
db0:keys=2,expires=0,avg_ttl=0

返回上一级

Redis 基础教程

关于   |   FAQ   |   我们的愿景   |   广告投放   |  博客

  简单教程,简单编程 - IT 入门首选站

Copyright © 2013-2022 简单教程 twle.cn All Rights Reserved.