redis查看有多少个库
时间: 2023-08-16 10:06:08 浏览: 206
可以使用Redis的`INFO`命令来查看当前Redis实例的信息,其中包括了`databases`字段,它表示当前Redis实例支持的数据库数量。例如,如果该字段的值为16,则表示当前Redis实例支持16个数据库。你可以使用以下命令查看:
```
127.0.0.1:6379> INFO
# Server
redis_version:6.2.5
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:6c9bb770f6d7b1f5
redis_mode:standalone
os:Linux 4.15.0-112-generic x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:7.5.0
process_id:1
run_id:1f4fd6f0e61cbecf1e8b5b4e5abd1b2252a0c8a2
tcp_port:6379
uptime_in_seconds:161
uptime_in_days:0
hz:10
configured_hz:10
lru_clock:13321857
executable:/data/redis-server
config_file:/etc/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:870672
used_memory_human:850.86K
used_memory_rss:1048576
used_memory_rss_human:1.00M
used_memory_peak:870672
used_memory_peak_human:850.86K
used_memory_peak_perc:100.00%
used_memory_overhead:858752
used_memory_startup:799760
used_memory_dataset:11920
used_memory_dataset_perc:13.70%
allocator_allocated:1048576
allocator_active:1048576
allocator_resident:1048576
total_system_memory:4194304
total_system_memory_human:4.00M
used_memory_lua:36864
used_memory_lua_human:36.00K
used_memory_scripts:0
used_memory_scripts_human:0B
number_of_cached_scripts:0
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
allocator_frag_ratio:1.00
allocator_frag_bytes:0
allocator_rss_ratio:1.00
allocator_rss_bytes:0
rss_overhead_ratio:1.00
rss_overhead_bytes:0
mem_fragmentation_ratio:1.20
mem_fragmentation_bytes:1.00M
mem_not_counted_for_evict:0
mem_replication_backlog:0
mem_clients_slaves:0
mem_clients_normal:0
mem_aof_buffer:0
mem_allocator:libc
active_defrag_running:0
lazyfree_pending_objects:0
# Persistence
loading:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1661912220
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:-1
rdb_current_bgsave_time_sec:-1
rdb_last_cow_size:0
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
aof_last_cow_size:0
# Stats
total_connections_received:1
total_commands_processed:1
instantaneous_ops_per_sec:0
total_net_input_bytes:34
total_net_output_bytes:23
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:0
keyspace_misses:0
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:0
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:fbf62977e2c7d4f9da6d4c7d0d2e4d484f5825d6
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:0
second_repl_offset:-1
repl_backlog_active:0
repl_backlog_size:0
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
# CPU
used_cpu_sys:0.010000
used_cpu_user:0.010000
used_cpu_sys_children:0.000000
used_cpu_user_children:0.000000
# Modules
# Cluster
cluster_enabled:0
# Keyspace
db0:keys=1,expires=0,avg_ttl=0
```
在输出的结果中,可以看到`databases`字段的值为16。
阅读全文