我是Elastic搜索的新手。我想知道群集故障转移在使用NEST的ES中如何工作。我浏览了可用链接http://nest.azurewebsites.net/elasticsearch-net/cluster-failover.html和http://nest.azurewebsites.net/elasticsearch-net/connecting.html。但这对我来说还不是很清楚。
假设我有两个节点。节点1(10.20.2.1:9203)和节点2(10.20.2.2:9204)。两个节点都连接到单个群集“ TestCluster”。我的要求是,如果任何节点出现故障,我想从活动节点中获取数据。
我的Node1(10.20.2.1:9203)的配置文件如下
cluster.name: TestCluster
node.name: "Node1"
node.master: true
node.data: true
network.host: 10.20.2.1
http.port: 9203
我的Node2(10.20.2.2:9204)配置文件如下
cluster.name: TestCluster
node.name: "Node2"
node.master: false
node.data: true
network.host: 10.20.2.2
http.port: 9204
我正在按如下方式访问ES客户端
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);
}
}
我正在使用此ES客户端进行如下搜索
var result = ElasticClientNew.Search<Attendance>(s => s
.From(0)
.Size(5000)
.Index("attendance").Type("Worker"));
我正在从node1运行MVS应用程序,并且弹性搜索服务已在此计算机上停止。但是ES服务正在node2中运行。当我尝试搜索时,出现如下错误
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
请建议如何在我的应用程序中实现群集故障转移。
问题是只有一个节点具有
node.master: true
设置为当该节点发生故障时另一个节点也处于masterless
关闭状态。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句