Comments (5)
Hello Nikita,
Redis cluster requires at least 3 master nodes to work as expected:
Note that the minimal cluster that works as expected requires to contain at least three master nodes. For your first tests it is strongly suggested to start a six nodes cluster with three masters and three slaves.
(https://redis.io/topics/cluster-tutorial)
The problem with a single node running in cluster mode is that the CLUSTER SLOTS
command that redisc uses to detect the topology returns an empty set, so there is absolutely no information as to what node address handles what key, and CUSTER INFO
goes a step further, it returns:
cluster_state:fail
cluster_slots_assigned:0
Even if I wanted to allow a special mode where it's ok to have a single node, redis will just refuse to serve anything that touches keys:
127.0.0.1:6379> set x a
(error) CLUSTERDOWN Hash slot not served
127.0.0.1:6379> get x
(error) CLUSTERDOWN Hash slot not served
So there's not much that can be done. It's relatively easy to spin up a redis cluster with a bash script, though, if you want to go that way.
Hope this helps,
Martin
from redisc.
Actually it could be easily fixed like that -
redis-cli CLUSTER ADDSLOTS $(for i in {0..16383}; do echo $i; done | xargs echo)
Redis starts working in cluster mode only with one node.
from redisc.
๐ cool, even better.
from redisc.
I think you didn't understand me. CLUSTER ADDSLOTS is a necessary command to create cluster, so you can create a cluster from one redis master node. Without it redis will work in standalone mode. Your examples in previous comment relate to standalone redis.
from redisc.
CLUSTER ADDSLOTS is a necessary command to create cluster
:D thanks I totally forgot about that, haven't used redis cluster in a long time. Yeah, I thought you meant that the reason your standalone mode did not work was because you did not run this command. Did you try starting the standalone redis server and running that CLUSTER ADDSLOTS command? It does work for me, i.e. this program returns the value of the key correctly:
func main() {
// create the cluster
cluster := redisc.Cluster{
StartupNodes: []string{":6379"},
DialOptions: []redis.DialOption{redis.DialConnectTimeout(5 * time.Second)},
CreatePool: createPool,
}
defer cluster.Close()
// initialize its mapping
if err := cluster.Refresh(); err != nil {
log.Fatalf("Refresh failed: %v", err)
}
// grab a connection from the pool
conn := cluster.Get()
defer conn.Close()
// call commands on it
s, err := redis.String(conn.Do("GET", "some-key"))
if err != nil {
log.Fatalf("GET failed: %v", err)
}
log.Println(s)
}
I start the single redis-server instance with this config:
port 6379
cluster-enabled yes
cluster-config-file nodes.0.out
cluster-node-timeout 5000
appendonly no
And I run the CLUSTER ADDSLOTS
command exactly as you mentioned. If that doesn't work for you there may be some specific command you're using that maybe fails in that scenario, or you're having unrelated connection problems, you'll have to give me more details with reproducible and runnable code.
from redisc.
Related Issues (20)
- Send PSUBSCRIBE failed HOT 1
- concurrent map iteration and map write HOT 3
- Refresh failed: redisc: all nodes failed HOT 2
- Separate pool for masters and slaves? HOT 9
- is HMSET operation supported, when using redis clustermode enabled? HOT 1
- Does it support pipeline in cluster mode HOT 5
- High Connection Churn HOT 25
- does it handle nodes master-slave failover? HOT 6
- Pls Help HOT 1
- Add support for Pipeline and multi operation commands HOT 5
- Proposal: add `Cluster` method to wait for stable Redis cluster HOT 1
- Proposal: add `Cluster` method to split keys by nodes
- Proposal: relax the constraints on pipeline for the `RetryConn`
- Proposal: support Redis 7+ Cluster changes
- READONLY command on every requests HOT 3
- Proposal: improve handling of read-only connections HOT 3
- Does it support redis module command? HOT 2
- Support address mapping for nodes HOT 7
- Can redisc recover from master-slave node failover๏ผ HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from redisc.