其他命令
SHUTDOWN
# SHUTDOWN [NOSAVE|SAVE]
[root@cloudhost ~]# ps -ef | grep redis
redis 14722 1 0 22:10 ? 00:00:00 /usr/bin/redis-server 127.0.0.1:6379
root 14839 14321 0 22:12 pts/1 00:00:00 grep --color=auto redis
[root@cloudhost ~]# redis-cli
# 异步保存数据到硬盘,并关闭服务器
# 可选参数SAVE(强制保存后关闭) NOSAVE(强制不保存关闭)
127.0.0.1:6379> SHUTDOWN
not connected> exit
[root@cloudhost ~]# ps -ef | grep redis
root 14887 14321 0 22:13 pts/1 00:00:00 grep --color=auto redis
INFO
# INFO [Section]
# 获取 Redis 服务器的各种信息和统计数值
# 获取全部
127.0.0.1:6379> INFO
# Server
redis_version:3.2.12 # Redis版本
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:7897e7d0e13773f
redis_mode:standalone # 模式,当前为单机运行
os:Linux 3.10.0-1160.119.1.el7.x86_64 x86_64 # 内核信息
arch_bits:64
multiplexing_api:epoll
gcc_version:4.8.5
process_id:17252 # 进程id
run_id:0f0445514ecab58555f6c44d6fc4473a1acc8535
tcp_port:6379 # 端口
uptime_in_seconds:586 # 启动时长
uptime_in_days:0 # 启动时长
hz:10
lru_clock:2696232
executable:/usr/bin/redis-server # 二进制可执行文件位置
config_file:/etc/redis.conf # 配置文件位置
# Clients
connected_clients:1 # 当前连接该服务器的客户端数量
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0
# Memory
used_memory:813528
used_memory_human:794.46K
used_memory_rss:5918720
used_memory_rss_human:5.64M
used_memory_peak:813528
used_memory_peak_human:794.46K
total_system_memory:1841668096 # 系统内存大小
total_system_memory_human:1.72G # 系统内存大小
used_memory_lua:37888
used_memory_lua_human:37.00K
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
mem_fragmentation_ratio:7.28
mem_allocator:jemalloc-3.6.0
# Persistence
loading:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1747526110
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:-1
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:1
total_commands_processed:2
instantaneous_ops_per_sec:0
total_net_input_bytes:60
total_net_output_bytes:9991
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.21
used_cpu_user:0.15
used_cpu_sys_children:0.00
used_cpu_user_children:0.00
# Cluster
cluster_enabled:0
# Keyspace
# 获取指定部分
127.0.0.1:6379> INFO Server
# Server
redis_version:3.2.12
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:7897e7d0e13773f
redis_mode:standalone
os:Linux 3.10.0-1160.119.1.el7.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.8.5
process_id:17252
run_id:0f0445514ecab58555f6c44d6fc4473a1acc8535
tcp_port:6379
uptime_in_seconds:633
uptime_in_days:0
hz:10
lru_clock:2696279
executable:/usr/bin/redis-server
config_file:/etc/redis.conf
CLIENT LIST
# 获取连接到服务器的客户端连接列表
127.0.0.1:6379> CLIENT LIST
id=2 addr=127.0.0.1:54824 fd=5 name= age=61 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=3 addr=127.0.0.1:54836 fd=6 name= age=4 idle=4 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=command
CLIENT SETNAME|CLIENT GETNAME
127.0.0.1:6379> CLIENT SETNAME redis01
OK
127.0.0.1:6379> CLIENT GETNAME
"redis01"
DEBUG SEGFAULT
# 让 Redis 服务崩溃
127.0.0.1:6379> DEBUG SEGFAULT
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected> QUIT
TIME
# 获取服务器时间戳
127.0.0.1:6379> TIME
1) "1747526185"
2) "884419"
其他命令
CLIENT PAUSE 在指定时间内终止运行来自客户端的命令
COMMAND 获取 Redis 命令详情数组
COMMAND COUNT 获取 Redis 命令总数
COMMAND GETKEYS 获取给定命令的所有键
COMMAND INFO 获取指定 Redis 命令描述的数组
CONFIG RESETSTAT 重置 INFO 命令中的某些统计数据
DEBUG OBJECT 获取 key 的调试信息
MONITOR 实时打印出 Redis 服务器接收到的命令,调试用
SLOWLOG 管理 redis 的慢日志
#redis##java#Redis 文章被收录于专栏
此专栏由于更新观看不便,不会保持及时更新,最新更新见计算机合集专栏https://www.nowcoder.com/creation/manager/columnDetail/04yp33