I am trying to connect to redis sentinel using JedisSentinelPool
private static final JedisSentinelPool pool = new JedisSentinelPool("mymaster", getSentinels());
private static Set<String> getSentinels(){
Set<String> mysentinels = new HashSet<>();
mysentinels.add(new HostAndPort("localhost", 26379).toString());
return mysentinels;
}
This gives me following error :
Caused by: redis.clients.jedis.exceptions.JedisConnectionException: All sentinels down, cannot determine where is mymaster master is running...
However, I can see that my sentinel is running. So referring to this post:
https://github.com/luin/ioredis/issues/64
I tried the below command on my redis master server
./redis-cli -h redis-1 -p 26379
I got following error:
Could not connect to Redis at redis-1:26379: nodename nor servname provided, or not known
What is the issue here?
Use localhost instead of 127.0.0.1 works for me.
By default Sentinel will not be reachable from interfaces different than
localhost, either use the 'bind' directive to bind to a list of network
interfaces, or disable protected mode with "protected-mode no" by
adding it to this configuration file.
Make sure that protected-mode is set to no in sentinel.conf file. This solved issue for me.
Related
I am getting this error when I run celery beat -S redbeat.RedBeatScheduler.
beat raised exception : ConnectionError('Error -2 connecting to redis-sentinel:26379. Name or service not known.',)
How can I create a service_name and password in redis-sentinel
I am not trying to use redis as a message broker. I am using celery-redbeat to store celerybeat data in redis-sentinel cluster from this page.https://pypi.org/project/celery-redbeat/
and
from this configuration
redbeat_redis_url = 'redis-sentinel://redis-sentinel:26379/0'
redbeat_redis_options = {
'sentinels': [('192.168.1.1', 26379),
('192.168.1.2', 26379),
('192.168.1.3', 26379)],
'socket_timeout': 0.1,
}
I add 192.168.1.1:26379 instead of redis-sentinel:/26379 but when master node down in redis-sentinel cluster beat is down too.
redbeat_redis_url = 'redis-sentinel://192.168.1.1:26379/0'
redbeat_redis_options = {
'sentinels': [('192.168.1.2', 26379),
('192.168.1.3', 26379)],
'socket_timeout': 0.1,
}
Unless you have redis-sentinel in your /etc/hosts file it will not be able to resolve it to a correct IP address. You may try to replace redis-sentinel with an IP address of your Redis server. Furthermore, it does not look like a proper Redis Sentinel configuration. Redis Configuration section explains how to connect to Redis Sentinel, please read it.
So i'm trying to create a cluster using the default redis guide.
but when running ruby /usr/share/doc/redis-tools/examples/redis-trib.rb create .... i get stuck forever in "Waiting for the cluster to join".
Each redis conf is bound to their respective static ip address (Not only 127)
My nodes are all located on an separate instance of ubuntu 16.04 in a Exsi envoirment without ANY firewall between them.
Each host is not created separatly, I just copied the first and changed hostnames + static iface for the other two, if that could cause something?
Master-slave replication works, so i doubt there is an connection issue?
Here is a print, if that can help in some way: http://i.imgur.com/LrNOrut.png
Any ideas?
UPDATE
I have checked all hosts from another physical interface and I have connected to them successfully with cluster-enabled no
Both 6379 and 16379 are accepting connections on both 127.0.0.1 and 192....
And all hosts can reach each other with telnet <host> <16379>
Try to keep only one IP in "bind " configuration directive in /etc/redis/redis.conf or even comment it out
I had same problem when there was following string in my config :
bind 127.0.0.1 172.19.2.10Х
Removed loopback interface on all the nodes and passed that obstacle.
I have a simple redis cluster on my local machine that consists of:
master on port 3679
slave on port 6380
sentinel on port 26379
I am using ServiceStack.Redis to connect with no problems so far. Today I added a password to each of them using the requirepass 42 setting. I can connect to all of them using Redis Desktop Manager fine and everything works as expected.
Using the following code, I get an error when I attempt to connect. Removing the password works as expected.
var config = RedisConfiguration.Instance;
Func<string, string> hostFilter = host => string.IsNullOrEmpty(config.SecurityKey)
? $"{host}?db={config.Database}"
: $"{config.SecurityKey}#{host}?db={config.Database}";
var sentinelHosts = config.SentinelHosts.Select(hostFilter);
var sentinel = new RedisSentinel(sentinelHosts, config.ServiceName)
{
HostFilter = hostFilter,
RedisManagerFactory = (master, slaves) => new RedisManagerPool(master)
};
sentinel.OnFailover += manager => Logger?.Warn($"Redis fail over to {sentinel.GetMaster()}");
sentinel.Start()
This code throw a RedisException "No Redis Sentinels were available" with an inner exception of "unknown command 'AUTH'".
I am not clear if I am using the ServiceStack.Redis library improperly or my Redis cluster configuration is incorrect.
Can some one point me in the right direction?
You can use HostFilter to specify the password:
sentinel.HostFilter = host => $"{config.SecurityKey}#{host}?db={config.Database}";
But when using a password, it needs to be configured everywhere, i.e. in both Master and Slave configurations using:
requirepass password
masterauth password
The Redis Sentinels also need to be configured to use the same password so it can control the redis instances it's monitoring, which can be configured in your sentinel.conf with:
sentinel auth-pass mymaster pasword
The windows-password folder in the redis-config project shows an example of a password-protected Redis Sentinel configuration.
I started a redis instance using rc.local script.
su - ec2-user -c redis-server /home/ec2-user/redis.conf
Even in the configuration file I provided(/home/ec2-user/redis.conf) I specified
protected-mode no
Connection to the redis instance still generates the following error message:
Error: Ready check failed: DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent. 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server. 3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 4) Setup a bind address or an authentication password. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.
What can I do to check current configuration of a running redis?
connect localy to your redis and run :
127.0.0.1:6379> CONFIG GET protected-mode
You'll get current running value.
You can run your server with more log :
redis-server /etc/myredis.conf --loglevel verbose
Regards,
I am trying to execute the container named redis which is running right now.But the error Could not connect to Redis at redis:6379: Name or service not known. Any one please hell me to figure out the issue and fix it.
This is because both the containers are not in same network, Add a network property inside service name and make sure its same for both
redis:
networks:
- redis-net
Naming the container doesn't alter your hosts file or DNS, and depending on how you ran the container it may not be accessible via the standard port as Docker does port translation.
Run docker inspect redis and examine the ports output, it will tell you what port it is accessible on as well as the IP. Note, however, that this will only be connectable over that IP from that host. To access it from off of the host you will need to use the port from the above command and the host's IP address. That assumes your local firewall rules allow it, which are beyond the scope of this site.
Try below command
src/redis-cli -h localhost -p 6379