gpt4 book ai didi

Redis SET 命令不适用于默认数据库以外的任何数据库

转载 作者:可可西里 更新时间:2023-11-01 11:24:18 25 4
gpt4 key购买 nike

我遇到了一个问题,除了索引 0 处的默认数据库无法正常写入任何其他数据库。下面是使用 redis-cli 在默认数据库中创建 key 的快照,它是成功的。然后我切换到 DB 1 并运行相同的 SET 命令,但是当尝试获取它们的键时,它返回 (nil),并且当使用 KEYS 命令列出键时,它返回(空列表或集合)。任何大于 0 的 DB 都会发生相同的行为。

这个问题最近才开始出现。我使用 DB 1 已经有一段时间了,没有任何问题。以下示例中的服务器是一组由 Sentinel 管理的三台服务器中的主服务器。

redisprod01:6379> set testkey "test"
OK
redisprod01:6379> get testkey
"test"
redisprod01:6379> keys testkey
1) "testkey"
redisprod01:6379> select 1
OK
redisprod01:6379[1]> set testkey "test"
OK
redisprod01:6379[1]> get testkey
(nil)
redisprod01:6379[1]> keys testkey
(empty list or set)

这是 INFO 命令的输出:

# Server
redis_version:2.8.4
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:a44a05d76f06a5d9
redis_mode:standalone
os:Linux 3.16.0-30-generic x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.8.2
process_id:5172
run_id:c23834afdaf0e113f4cca368be9e88881fa82c91
tcp_port:6379
uptime_in_seconds:7762453
uptime_in_days:89
hz:10
lru_clock:567194
config_file:/etc/redis/redis.conf

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

# Memory
used_memory:2000000696
used_memory_human:1.86G
used_memory_rss:2173636608
used_memory_peak:2003080696
used_memory_peak_human:1.87G
used_memory_lua:33792
mem_fragmentation_ratio:1.09
mem_allocator:jemalloc-3.4.1

# Persistence
loading:0
rdb_changes_since_last_save:17067
rdb_bgsave_in_progress:0
rdb_last_save_time:1536592844
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:5
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

# Stats
total_connections_received:2617247
total_commands_processed:1810758972
instantaneous_ops_per_sec:1207
rejected_connections:0
sync_full:2
sync_partial_ok:0
sync_partial_err:2
expired_keys:2190259
evicted_keys:128303561
keyspace_hits:456747821
keyspace_misses:421644916
pubsub_channels:2
pubsub_patterns:0
latest_fork_usec:54236

# Replication
role:master
connected_slaves:2
slave0:ip=10.93.109.123,port=6379,state=online,offset=2166765462577,lag=0
slave1:ip=10.93.109.122,port=6379,state=online,offset=2166765336151,lag=0
master_repl_offset:2166765934628
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:2166764886053
repl_backlog_histlen:1048576

# CPU
used_cpu_sys:59513.46
used_cpu_user:50583.63
used_cpu_sys_children:25643.75
used_cpu_user_children:184819.30

# Keyspace
db0:keys=238726,expires=220772,avg_ttl=83043319

这是配置:

  1) "dbfilename"
2) "dump.rdb"
3) "requirepass"
4) ""
5) "masterauth"
6) ""
7) "unixsocket"
8) ""
9) "logfile"
10) "/var/log/redis/redis.log"
11) "pidfile"
12) "/var/run/redis/redis-server.pid"
13) "maxmemory"
14) "2000000000"
15) "maxmemory-samples"
16) "3"
17) "timeout"
18) "0"
19) "tcp-keepalive"
20) "0"
21) "auto-aof-rewrite-percentage"
22) "100"
23) "auto-aof-rewrite-min-size"
24) "67108864"
25) "hash-max-ziplist-entries"
26) "512"
27) "hash-max-ziplist-value"
28) "64"
29) "list-max-ziplist-entries"
30) "512"
31) "list-max-ziplist-value"
32) "64"
33) "set-max-intset-entries"
34) "512"
35) "zset-max-ziplist-entries"
36) "128"
37) "zset-max-ziplist-value"
38) "64"
39) "lua-time-limit"
40) "5000"
41) "slowlog-log-slower-than"
42) "10000"
43) "slowlog-max-len"
44) "1024"
45) "port"
46) "6379"
47) "databases"
48) "16"
49) "repl-ping-slave-period"
50) "10"
51) "repl-timeout"
52) "60"
53) "repl-backlog-size"
54) "1048576"
55) "repl-backlog-ttl"
56) "3600"
57) "maxclients"
58) "10000"
59) "watchdog-period"
60) "0"
61) "slave-priority"
62) "100"
63) "min-slaves-to-write"
64) "0"
65) "min-slaves-max-lag"
66) "10"
67) "hz"
68) "10"
69) "no-appendfsync-on-rewrite"
70) "no"
71) "slave-serve-stale-data"
72) "yes"
73) "slave-read-only"
74) "yes"
75) "stop-writes-on-bgsave-error"
76) "yes"
77) "daemonize"
78) "yes"
79) "rdbcompression"
80) "yes"
81) "rdbchecksum"
82) "yes"
83) "activerehashing"
84) "yes"
85) "repl-disable-tcp-nodelay"
86) "no"
87) "aof-rewrite-incremental-fsync"
88) "yes"
89) "appendonly"
90) "no"
91) "dir"
92) "/var/lib/redis"
93) "maxmemory-policy"
94) "allkeys-lru"
95) "appendfsync"
96) "everysec"
97) "save"
98) "900 1 300 10 60 10000"
99) "loglevel"
100) "notice"
101) "client-output-buffer-limit"
102) "normal 0 0 0 slave 268435456 67108864 60 pubsub 33554432 8388608 60"
103) "unixsocketperm"
104) "0"
105) "slaveof"
106) ""
107) "notify-keyspace-events"
108) ""
109) "bind"
110) "10.93.109.121"

最佳答案

Redis 集群不支持

select 命令。您最近是否从独立的 Redis 过渡到集群的 Redis?引用:https://redis.io/commands/select

关于Redis SET 命令不适用于默认数据库以外的任何数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52262513/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com