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

use public ip for the replica #7

Merged
merged 1 commit into from
Jun 7, 2015
Merged

Conversation

BenoitCharret
Copy link
Contributor

use public ip of the docker container to create replica so that java client on docker image can use this cluster. Otherwise java redis cluster driver will got 127.0.0.1 when discovering cluster nodes.

@Grokzen
Copy link
Owner

Grokzen commented Jun 7, 2015

@BenoitCharret Thanks for this. I have been playing around with running multiple containers instead of having all redis servers inside one container, but this is much easier to work with :] I will push a new image to dockerhub shortly.

Grokzen added a commit that referenced this pull request Jun 7, 2015
use public ip for the replica
@Grokzen Grokzen merged commit 4f8a1c2 into Grokzen:master Jun 7, 2015
@sheats
Copy link

sheats commented Feb 17, 2017

I'm a little new to the docker and the clustered Redis worlds... but when I tried to use redis with redis-cli on my host machine all redirects timed out since the 172 IP address wasn't accessible from the host. Reverting this change fixed the issue for me. The timeout also happened when trying to use clustered redis from my code on my host machine. See below:

$ redis-cli -h localhost -p 7000 -c
localhost:7000> SET {1}a "b"
-> Redirected to slot [9842] located at 172.27.0.2:7001
Could not connect to Redis at 172.27.0.2:7001: Operation timed out
Could not connect to Redis at 172.27.0.2:7001: Operation timed out
(151.09s)

With my change:

$ redis-cli -h localhost -p 7000 -c
localhost:7000> SET {1}a "b"
-> Redirected to slot [9842] located at 127.0.0.1:7001
OK

@Grokzen
Copy link
Owner

Grokzen commented Feb 17, 2017

@sheats Cool that you got into redis and clustering :)

It is strange that you cluster is not connectable at all on the public IP address. A few controll questions that might help in solving this. What version of docker are you using to run the container? Are you using the latest commits in this repo when you build your cluster? How you are running the container? Are you running the Makefile commands that uses docker-compose. When you first connect to your cluster, what data do you get out if you run INFO and CLUSTER SLOTS ?? It feels like a docker-network issue tbh.

@sheats
Copy link

sheats commented Feb 18, 2017

I'm working on making this library work with clustered redis: https://github.com/Suor/django-cacheops -- just haven't been in the code for awhile.

I'm using the latest version of Docker for Mac and I'm using latest commit of this repo. I just ran docker-compose up, nothing special. Could definitely be a docker-network issue, just not sure how to troubleshoot that.

localhost:7000> INFO
# Server
redis_version:3.2.7
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:43be4f95f204841b
redis_mode:cluster
os:Linux 4.9.8-moby x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.9.2
process_id:42
run_id:814cc32ddda333e08338723f211945f75b1e1353
tcp_port:7000
uptime_in_seconds:130
uptime_in_days:0
hz:10
lru_clock:10991291
executable:/redis/src/redis-server
config_file:/redis-conf/7000/redis.conf

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

# Memory
used_memory:2418184
used_memory_human:2.31M
used_memory_rss:4722688
used_memory_rss_human:4.50M
used_memory_peak:2418184
used_memory_peak_human:2.31M
total_system_memory:2095988736
total_system_memory_human:1.95G
used_memory_lua:37888
used_memory_lua_human:37.00K
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
mem_fragmentation_ratio:1.95
mem_allocator:jemalloc-4.4.0

# Persistence
loading:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1487386176
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:0
rdb_current_bgsave_time_sec:-1
aof_enabled:1
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_current_size:0
aof_base_size:0
aof_pending_rewrite:0
aof_buffer_length:0
aof_rewrite_buffer_length:0
aof_pending_bio_fsync:0
aof_delayed_fsync:0

# Stats
total_connections_received:5
total_commands_processed:143
instantaneous_ops_per_sec:1
total_net_input_bytes:58348
total_net_output_bytes:11985408
instantaneous_input_kbps:0.04
instantaneous_output_kbps:0.00
rejected_connections:0
sync_full:1
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
evicted_keys:0
keyspace_hits:0
keyspace_misses:0
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:264
migrate_cached_sockets:0

# Replication
role:master
connected_slaves:1
slave0:ip=172.27.0.2,port=7003,state=online,offset=169,lag=0
master_repl_offset:169
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:2
repl_backlog_histlen:168

# CPU
used_cpu_sys:0.29
used_cpu_user:0.11
used_cpu_sys_children:0.00
used_cpu_user_children:0.00

# Cluster
cluster_enabled:1

# Keyspace


localhost:7000> CLUSTER SLOTS
1) 1) (integer) 0
   2) (integer) 5460
   3) 1) "172.27.0.2"
      2) (integer) 7000
      3) "0516ec277a6ee370e0ba9b4e5e4eb0ab1365ee3e"
   4) 1) "172.27.0.2"
      2) (integer) 7003
      3) "372f2d0949884b27c1288bb29e92fca16b8a9497"
2) 1) (integer) 5461
   2) (integer) 10922
   3) 1) "172.27.0.2"
      2) (integer) 7001
      3) "6b5a0190338033dc6f5d96e83ea051c10b825061"
   4) 1) "172.27.0.2"
      2) (integer) 7004
      3) "c99c8bf1b7c2ac8af5549d0da0b4df598e1f20e3"
3) 1) (integer) 10923
   2) (integer) 16383
   3) 1) "172.27.0.2"
      2) (integer) 7002
      3) "3df732b0625eed7eaeb49548cd8dc513912a930d"
   4) 1) "172.27.0.2"
      2) (integer) 7005
      3) "601dff56bb26507d86d7df1b2cdbf80e0ab26022"
localhost:7000>





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

Successfully merging this pull request may close these issues.

3 participants