当前位置: 首页 > article >正文

024 elasticsearch集群

文章目录

    • 搭建集群

在这里插入图片描述

cp elasticsearch-7.10.2 escloud -R
cd escloud/
rm -rf data
cd logs/
rm -rf *
tar zcf escloud.tar.gz escloud

tar zxf escloud.tar.gz
mv escloud a
mv escloud b
mv escloud c
cd config
vim elasticsearch.yml
curl ifconfig.me
netstat -tulnp | grep 9300
Test-NetConnection -ComputerName [服务器的IP地址或域名] -Port [端口号]
sudo yum install telnet -y
telnet <目标IP地址> <端口号>

搭建集群

http.publish_host 和 transport.publish_host 是 Elasticsearch 配置文件中的两个重要参数,它们用于指定 Elasticsearch 节点对外发布的 HTTP 和传输层(Transport)地址。
http.publish_host:这个参数用于指定 Elasticsearch 节点在 HTTP 层面上对外发布的地址。当客户端(如 Kibana、Logstash 或其他应用程序)尝试通过 HTTP 协议连接到 Elasticsearch 时,它们会使用这个地址。如果未设置,Elasticsearch 会自动选择一个合适的地址。
transport.publish_host:这个参数用于指定 Elasticsearch 节点在集群内部通信(即传输层通信)时对外发布的地址。Elasticsearch 集群中的节点通过传输层协议相互通信,以协调集群状态、分发索引数据等。如果未设置,Elasticsearch 同样会自动选择一个合适的地址。
当你有三个 Elasticsearch 节点,并且它们都不在同一个内网中时,要使它们组成一个集群,你需要确保这些节点能够通过某种方式相互通信。这通常涉及到配置节点的网络设置,以便它们能够识别并连接到彼此。

在这种情况下,http.publish_host 和 transport.publish_host 可以帮助你指定每个节点应该使用哪个地址来对外发布其服务。然而,更重要的是确保这些地址在网络上是可达的,并且没有防火墙或安全组规则阻止节点间的通信。

以下是一个简化的配置示例,假设你有三个 Elasticsearch 节点,分别位于不同的内网中,但它们都有公网 IP 地址,并且你可以通过配置 NAT 或 VPN 来使它们相互通信:

节点1(位于内网A,公网IP为1.1.1.1)

http.cors.enabled: true
http.cors.allow-origin: "*"

cluster.name: my-cross-network-cluster  
node.name: node1  
network.host: 0.0.0.0  # 监听所有网络接口  
http.port: 9200  
transport.tcp.port: 9300  
http.publish_host: 1.1.1.1  # 对外发布的HTTP地址  
transport.publish_host: 1.1.1.1  # 对外发布的传输层地址  
discovery.seed_hosts: ["2.2.2.2:9300", "3.3.3.3:9300"]  # 其他节点的公网地址和端口  
cluster.initial_master_nodes: ["node1", "node2", "node3"]  # 初始主节点列表
节点2(位于内网B,公网IP为2.2.2.2)
http.cors.enabled: true
http.cors.allow-origin: "*"

cluster.name: my-cross-network-cluster  
node.name: node2  
network.host: 0.0.0.0  
http.port: 9200  
transport.tcp.port: 9300  
http.publish_host: 2.2.2.2  
transport.publish_host: 2.2.2.2  
discovery.seed_hosts: ["1.1.1.1:9300", "3.3.3.3:9300"]  
cluster.initial_master_nodes: ["node1", "node2", "node3"]
节点3(位于内网C,公网IP为3.3.3.3)
http.cors.enabled: true
http.cors.allow-origin: "*"

cluster.name: my-cross-network-cluster  
node.name: node3  
network.host: 0.0.0.0  
http.port: 9200  
transport.tcp.port: 9300  
http.publish_host: 3.3.3.3  
transport.publish_host: 3.3.3.3  
discovery.seed_hosts: ["1.1.1.1:9300", "2.2.2.2:9300"]  
cluster.initial_master_nodes: ["node1", "node2", "node3"]

在这个配置中,每个节点都使用其公网 IP 地址作为 http.publish_host 和 transport.publish_host。这样,无论客户端还是集群中的其他节点,都可以通过这些公网 IP 地址来访问和通信。

然而,请注意以下几点:

确保所有节点的公网 IP 地址都是可达的,并且没有防火墙或安全组规则阻止它们之间的通信。
如果你的网络环境使用了 NAT 或 VPN,请确保它们正确配置,以便节点间的通信能够顺利进行。
考虑到安全性和性能,你可能不希望将 Elasticsearch 节点直接暴露在公网上。在这种情况下,你可以考虑使用反向代理、负载均衡器或 VPN 来更安全地管理对 Elasticsearch 服务的访问。
在生产环境中,强烈建议使用 SSL/TLS 来加密节点间的通信,以保护数据的安全。


http://www.kler.cn/news/356390.html

相关文章:

  • 生财合伙人推荐 - 鞠海深-群控
  • 霍夫圆型硬币检测Matlab程序
  • GitHub与GitCode
  • vuefor循环动态展示图片不显示
  • ARM指令集和汇编语言的关联学习
  • 设计模式——代理模式(6)
  • 408算法题leetcode--第33天
  • 【概率论】泊松分布
  • Gorm操作数据库,有和没有WithContext的区别
  • 【设计模式】深入理解 Python 单例模式:从原理到实现
  • 第8篇:网络安全基础
  • Docker 安装sql server 登陆失败
  • .NET Sqlite加密
  • Golang | Leetcode Golang题解之第475题供暖器
  • 飞控开发软件有哪些?技术详解
  • HCIP--1实验DNS,VLAN,静态路由,浮动静态,动态路由协议,Telnet
  • Scala大数据开发
  • Java—类和对象习题讲解
  • UNI VFX Missiles Explosions for Visual Effect Graph
  • SpringBoot Data JPA基本使用