Hi,
I would like to use this plugin to balance my redis instances.
https://github.com/openresty/redis2-nginx-module#redis2_pass
I’m having some hard time in balancing redis and I would really appreciate any help you could give me.
I installed the module and I have added this to my nginx configuration:
upstream redis_cluster {
server 127.0.0.1:6379;
server 127.0.0.1:6380;
}
server {
listen 6370;
server_name 0.0.0.0;
location = /redis {
redis2_next_upstream error timeout invalid_response;
redis2_query get foo;
redis2_pass redis_cluster;
}
}
As you can see I have two instances of redis, one on 6379 (master) and one on 6380 (slave), they are configured for replication.
As far as I understood this configuration should open a port 6370, the 6370 port will be balanced by nginx.
6379 should serve every request to redis and 6380 should serve every request in case of master timeout error ecc…
Unfortunantly if I try to ping the 6370 using redis-cli I have this error:
root@as301ouc:/app/nginx/sites-enabled# redis-cli -p 6370
127.0.0.1:6370> ping
Error: Protocol error, got "H" as reply type byte
Any help will be really appreciated.
Thanks
$ redis-server --port 6379
$ redis-server --port 6380 --slaveof 127.0.0.1 6379
$ redis-cli set foo bar
$ redis-cli -p 6380 get foo
"bar"
stream {
upstream redis {
server 127.0.0.1:6379;
server 127.0.0.1:6380;
}
server {
listen 127.0.0.1:6370;
proxy_pass redis;
}
}
$ redis-cli -p 6370 get foo
"bar"
This setup works only for read operations.