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

时间:2018-09-10 17:08:50

标签: redis

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

此问题仅在最近才开始发生。我使用DB 1已有一段时间了,没有任何问题。下例中的服务器是由Sentinel管理的一组三台服务器的主服务器。

clf = LogisticRegression(penalty='l2', multi_class = 'multinomial',solver ='newton-cg')

#Then train the classifier over training data
clf.fit(X_train, y_train)

#Then use predict function to make predictions
y_pred = clf.predict(X_test)

这是INFO命令的输出:

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)

在这里配置:

# 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

2 个答案:

答案 0 :(得分:0)

Redis集群不支持

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

答案 1 :(得分:0)

这是在本地运行,但我没有使用 redis-cli SELECT 1,而是运行了 redis-cli -n 1。一旦我这样做了,我就可以设置密钥并在该数据库上成功检索它们。

以这种方式在多个数据库之间切换似乎对我有用。

请记住,它在我的本地机器上运行。