简体   繁体   English

如何使用Spring Boot访问VPN中的Elasticsearch Cluster

[英]How to access Elasticsearch Cluster in VPN with Spring Boot

I have an Elasticsearch cluster in a VPN. 我在VPN中有一个Elasticsearch集群。

How can my Spring Boot application access the cluster securely if it is located on a separate server outside of the VPN and how can I configure it in the Spring boot configuration (application.yml/application.properties)? 如果我的Spring Boot应用程序位于VPN之外的单独服务器上,那么我该如何安全地访问该集群?如何在Spring Boot配置(application.yml / application.properties)中对其进行配置?

I also want the application to connect to the cluster i an way so that if i have eg 2 Master eligible nodes and one fails, the connection remains intact. 我还希望应用程序以某种方式连接到群集,以便如果我有2个符合条件的主节点,而其中一个失败,则连接保持不变。

  1. if you have only 2 master eligble nodes, you are at risk of the "split brain problem". 如果您只有2个主合格节点,则存在“裂脑问题”的风险。 there is a easy formula for the calculation of the required number of master nodes: 有一个简单的公式可以计算所需的主节点数:

    M = 2F +1 ( m=master node count, f=number of master nodes possible to fail at same time) M = 2F +1(m =主节点数,f =可能同时发生故障的主节点数)

  2. in your application define all master nodes as target for the elasticsearch client. 在您的应用程序中,将所有主节点定义为elasticsearch客户端的目标。 The client will handle the failover. 客户端将处理故障转移。 see elasticsearc client documentation or https://qbox.io/blog/rest-calls-made-easy-part-2-sniffing-elasticsearch for a example 有关示例,请参见elasticsearc客户文档或https://qbox.io/blog/rest-calls-made-easy-part-2-sniffing-elasticsearch

  3. the vpn should not be handled by your application. 该VPN不应该由您的应用程序处理。 the infrastructure (server, firewall) is the right place to address it. 基础结构(服务器,防火墙)是解决它的正确位置。 try to develop your application environment agnostic. 尝试开发不可知的应用程序环境。 this will make your app easier to develop, maintain and make it more robust to infrastructure changes 这将使您的应用程序更易于开发,维护和增强,以适应基础架构的变化

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM