I am new in Elastic search. I want to know how the cluster failover works in ES using NEST. I went through available links http://nest.azurewebsites.net/elasticsearch-net/cluster-failover.html and http://nest.azurewebsites.net/elasticsearch-net/connecting.html. But it is not much clear for me.
Suppose i have two nodes. Node1(10.20.2.1:9203) and node2(10.20.2.2:9204). Both nodes are connected to single cluster 'TestCluster'. My requirement is that, if any of the node is down, i want to get the data from live node.
My config file for Node1(10.20.2.1:9203) is as follows
cluster.name: TestCluster
node.name: "Node1"
node.master: true
node.data: true
network.host: 10.20.2.1
http.port: 9203
My config file for Node2(10.20.2.2:9204) is as follows
cluster.name: TestCluster
node.name: "Node2"
node.master: false
node.data: true
network.host: 10.20.2.2
http.port: 9204
I am accessing the ES client as follows
private static ElasticClient ElasticClientNew
{
get
{
var node = new Uri("http://10.20.2.1:9203");
var node1 = new Uri("http://10.20.2.2:9204");
var connectionPool = new SniffingConnectionPool(new[] { node, node1 });
var setting = new ConnectionSettings(connectionPool)
.SniffOnConnectionFault(false)
.SniffOnStartup(false)
.SniffLifeSpan(TimeSpan.FromMinutes(1));
return new ElasticClient(setting);
}
}
I am using this ES client for searching as follows
var result = ElasticClientNew.Search<Attendance>(s => s
.From(0)
.Size(5000)
.Index("attendance").Type("Worker"));
I am running the MVS application from node1, and elasticsearch service is stopped in this machine. But the ES service is running in node2. When i try to search, am getting error as follows
Failed after retrying 1 times: 'POST attendance/Worker/_search'.
InnerException: PingException, InnerMessage: Pinging http://10.20.2.1:9203 caused an exception, InnerStackTrace: at Elasticsearch.Net.Connection.Transport.Ping(ITransportRequestState requestState) in c:\Users\gmarz\code\elasticsearch-net\src\Elasticsearch.Net\Connection\Transport.cs:line 96
at Elasticsearch.Net.Connection.Transport.DoRequest[T](TransportRequestState`1 requestState) in c:\Users\gmarz\code\elasticsearch-net\src\Elasticsearch.Net\Connection\Transport.cs:line 334
Please suggest how the cluster failover can be achieved in my application.
StaticConnectionPoolover theSniffingConnectionPool. That aside this may be a bug, will investigate further trying with the exact same setup as you. - Martijn Laarmannode.master: false, which means that if you take node1 down, node2 will close as well because it sees no active masters anymore. - Martijn Laarman