Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when i use the cluster(just one master node),it has an error #1296

Closed
ayamzh opened this issue Jan 10, 2018 · 8 comments
Closed

when i use the cluster(just one master node),it has an error #1296

ayamzh opened this issue Jan 10, 2018 · 8 comments

Comments

@ayamzh
Copy link

ayamzh commented Jan 10, 2018

I'm seeing this behaviour on

  • OS: centos7
  • Redis:
  • PHP: 7.1.9
  • phpredis: 3.1.6

mycode:
$redis = new \RedisCluster(NULL, ['127.0.0.1:6380']);

it will throw an exception
"Couldn't map cluster keyspace using any provided seed"

how to fix it

@michael-grunder
Copy link
Member

Hi,

It's really hard to say. I connect to a single cluster node as a matter of practice when testing new functionality and it works just fine for me.

You can try to connect via redis-cli to see if the issue is actually in phpredis:
redis-cli -p 6380 -c

Then make sure you're actually running in cluster mode by doing something like this:
127.0.0.1:6380>cluster info

Make sure that cluster is actually enabled and that it's in an ok state.

@TTMikeK
Copy link

TTMikeK commented Jan 24, 2019

Same problem here (PHP 7.2, Redis 5.0.3, phpredis 4.2.0, on Ubuntu 18.04). INFO says redis_mode is cluster and cluster_enabled is 1.

@TTMikeK
Copy link

TTMikeK commented Jan 24, 2019

Mkay. My problem that caused the above error was I didn't create the cluster.

I expected phpcli --cluster create 127.0.0.1:6379 to work, but that's invalid. The workaround was to mass-assign the slots: for i in {0..16383}; do redis-cli -h 127.0.0.1 -p 6379 CLUSTER ADDSLOTS $i; done, but even with slots assigned it failed to work (different error, node complaining it can't connect to its peers ... which is true because it doesn't have any).

@michael-grunder
Copy link
Member

Hey @TTSMike,

You don't need to do all of that. With a recent version of redis-server it's a lot easier to start up a cluster.

You can probably just use <phpredis_dir>/tests/make-cluster.sh along with redis-cli to get one up simply.

  1. Run make-cluster.sh start
  2. Run redis-cli --cluster create 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 127.0.0.1:7006 127.0.0.1:7007 127.0.0.1:7008 127.0.0.1:7009 127.0.0.1:7010 127.0.0.1:7011 127.0.0.1:7012 --cluster-replicas 3

https://asciinema.org/a/ADz6vxikqZQLts6QNJVY33XqN

@TTMikeK
Copy link

TTMikeK commented Jan 24, 2019

Cool, thanks for the tip. I was hoping to do it by hand initially just to better understand what was going on. Unfortunately that went badly so I aborted, and had to nuke my redis installation. I'll have to give that a try when I re-do our staging setup (I need to configure Live right now).

@michael-grunder
Copy link
Member

OK good luck with your configuration.

Here's the simplest by hand approach to spinning up a cluster that I can think of:

 …/cluster-config $ for p in $(seq 7000 7003); do redis-server --cluster-enabled yes --save "" --port $p --cluster-config-file node-$p.conf --daemonize yes; done
 …/cluster-config $ redis-cli --cluster create 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 --cluster-replicas 0

@TTMikeK
Copy link

TTMikeK commented Jan 24, 2019

Much appreciated. Thanks for all the tips. 😄

@michael-grunder
Copy link
Member

I'm going to close this issue since it doesn't seem to be a bug in phpredis. Feel free to reopen if I'm misunderstanding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants