Redis 服务器

小柒博客 Redis评论59.3K1字数 4310阅读14分22秒阅读模式

Redis 服务器

Redis 服务器命令主要是用于管理redis服务。

实例

以下实例演示了如何获取redis服务器的统计信息:

[root@localhost ~]# redis-cli

127.0.0.1:6379> info

# Server

redis_version:5.0.7

redis_git_sha1:00000000

redis_git_dirty:0

redis_build_id:743b8244b8e27193

redis_mode:standalone

os:Linux 3.10.0-693.el7.x86_64 x86_64

arch_bits:64

multiplexing_api:epoll

atomicvar_api:atomic-builtin

gcc_version:4.8.5

process_id:8153

run_id:72ee9108ccfa7ea74bcf41c9b7575f327c3d64fd

tcp_port:6379

uptime_in_seconds:65985

uptime_in_days:0

hz:10

configured_hz:10

lru_clock:12275032

executable:/usr/local/redis/redis-server

config_file:/usr/local/redis/redis.conf

# Clients

connected_clients:1

client_recent_max_input_buffer:2

client_recent_max_output_buffer:0

blocked_clients:0

# Memory

used_memory:855648

used_memory_human:835.59K

used_memory_rss:4173824

used_memory_rss_human:3.98M

used_memory_peak:874960

used_memory_peak_human:854.45K

used_memory_peak_perc:97.79%

used_memory_overhead:841904

used_memory_startup:791392

used_memory_dataset:13744

used_memory_dataset_perc:21.39%

allocator_allocated:1295824

allocator_active:1576960

allocator_resident:12136448

total_system_memory:1040953344

total_system_memory_human:992.73M

used_memory_lua:40960

used_memory_lua_human:40.00K

used_memory_scripts:152

used_memory_scripts_human:152B

number_of_cached_scripts:1

maxmemory:0

maxmemory_human:0B

maxmemory_policy:noeviction

allocator_frag_ratio:1.22

allocator_frag_bytes:281136

allocator_rss_ratio:7.70

allocator_rss_bytes:10559488

rss_overhead_ratio:0.34

rss_overhead_bytes:-7962624

mem_fragmentation_ratio:5.13

mem_fragmentation_bytes:3360176

mem_not_counted_for_evict:322

mem_replication_backlog:0

mem_clients_slaves:0

mem_clients_normal:49694

mem_aof_buffer:322

mem_allocator:jemalloc-5.1.0

active_defrag_running:0

lazyfree_pending_objects:0

# Persistence

loading:0

rdb_changes_since_last_save:4

rdb_bgsave_in_progress:0

rdb_last_save_time:1589332535

rdb_last_bgsave_status:ok

rdb_last_bgsave_time_sec:0

rdb_current_bgsave_time_sec:-1

rdb_last_cow_size:294912

aof_enabled:1

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

aof_last_cow_size:0

aof_current_size:1945

aof_base_size:0

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:23

total_commands_processed:112

instantaneous_ops_per_sec:0

total_net_input_bytes:3907

total_net_output_bytes:269171

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

expired_stale_perc:0.00

expired_time_cap_reached_count:0

evicted_keys:0

keyspace_hits:14

keyspace_misses:3

pubsub_channels:0

pubsub_patterns:0

latest_fork_usec:354

migrate_cached_sockets:0

slave_expires_tracked_keys:0

active_defrag_hits:0

active_defrag_misses:0

active_defrag_key_hits:0

active_defrag_key_misses:0

# Replication

role:master

connected_slaves:0

master_replid:c6b33e7fa147d50f8e1b1c7c774c3e8b47f6919d

master_replid2:0000000000000000000000000000000000000000

master_repl_offset:0

second_repl_offset:-1

repl_backlog_active:0

repl_backlog_size:1048576

repl_backlog_first_byte_offset:0

repl_backlog_histlen:0

# CPU

used_cpu_sys:37.448751

used_cpu_user:44.879583

used_cpu_sys_children:0.020942

used_cpu_user_children:0.001411

# Cluster

cluster_enabled:0

# Keyspace

db0:keys=7,expires=0,avg_ttl=0

Redis 服务器命令

下表列出了redis服务器的相关命令:

序号

命令及描述
1 BGREWRITEAOF
异步执行一个 AOF(AppendOnly File) 文件重写操作
2 BGSAVE
在后台异步保存当前数据库的数据到磁盘
3 CLIENT KILL [ip:port] [ID client-id]
关闭客户端连接
4 CLIENT LIST
获取连接到服务器的客户端连接列表
5 CLIENT GETNAME
获取连接的名称
6 CLIENT PAUSE timeout
在指定时间内终止运行来自客户端的命令
7 CLIENT SETNAME connection-name
设置当前连接的名称
8 CLUSTER SLOTS
获取集群节点的映射数组
9 COMMAND
获取 Redis 命令详情数组
10 COMMAND COUNT
获取 Redis 命令总数
11 COMMAND GETKEYS
获取给定命令的所有键
12 TIME
返回当前服务器时间
13 COMMAND INFO command-name [command-name ...]
获取指定 Redis 命令描述的数组
14 CONFIG GET parameter
获取指定配置参数的值
15 CONFIG REWRITE
对启动 Redis 服务器时所指定的 redis.conf 配置文件进行改写
16 CONFIG SET parameter value
修改 redis 配置参数,无需重启
17 CONFIG RESETSTAT
重置 INFO 命令中的某些统计数据
18 DBSIZE
返回当前数据库的 key 的数量
19 DEBUG OBJECT key
获取 key 的调试信息
20 DEBUG SEGFAULT
让 Redis 服务崩溃
21 FLUSHALL
删除所有数据库的所有key
22 FLUSHDB
删除当前数据库的所有key
23 INFO [section]
获取 Redis 服务器的各种信息和统计数值
24 LASTSAVE
返回最近一次 Redis 成功将数据保存到磁盘上的时间,以 UNIX 时间戳格式表示
25 MONITOR
实时打印出 Redis 服务器接收到的命令,调试用
26 ROLE
返回主从实例所属的角色
27 SAVE
同步保存数据到硬盘
28 SHUTDOWN [NOSAVE] [SAVE]
异步保存数据到硬盘,并关闭服务器
29 SLAVEOF host port
将当前服务器转变为指定服务器的从属服务器(slave server)
30 SLOWLOG subcommand [argument]
管理 redis 的慢日志
31

SYNC
用于复制功能(replication)的内部命令

若文章图片、下载链接等信息出错,请在评论区留言反馈,博主将第一时间更新!如本文“对您有用”,欢迎随意打赏,谢谢!

继续阅读
Wechat
微信扫一扫,加我!
weinxin
微信公众号
微信扫一扫,关注我!
weinxin
Redis最后更新:2024-1-24
小柒博客
  • 本文由 小柒博客 发表于 2020年5月13日10:55:41
  • 声明:本站所有文章,如无特殊说明或标注,本站文章均为原创。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。转载请务必保留本文链接:https://www.yangxingzhen.com/7013.html
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

拖动滑块以完成验证