gpt4 book ai didi

UFW 防火墙后的 Elasticsearch 集群

转载 作者:行者123 更新时间:2023-11-29 02:48:39 25 4
gpt4 key购买 nike

我有一个在两个不同的 Digital Ocean droplet 上运行的 Elasticsearch 集群。它们都是为专用网络设置的,我有一个运行良好的 Mongo DB 副本集,UFW 规则设置为仅接受来自液滴的特定(专用)IP 地址的相关端口上的连接。

但是我无法使用相同的方法获得绿色的 Elasticsearch 集群运行状况,只能获得黄色。这意味着节点无法相互连接。

在 elasaticsearch.yml(在两台机器上)中,我禁用了多播并使用单播连接到 Droplet 的内部 IP 地址。当我将防火墙设置为接受端口 9300 上的所有连接时(ufw 允许 9300)这工作正常,并且集群健康状况报告为绿色。但是,当我将规则限制为仅允许来自实际 IP 地址时,就像 Mongo DB 副本集一样,它不起作用。我尝试过公共(public)地址和私有(private)地址,以及 IPv4 和 IPv6。

我在这里错过了什么?

最佳答案

默认首选 IPV6。您可以通过设置 java.net.preferIPv4Stack 来更改此行为系统属性为 true
您还必须看到,默认情况下 ES 绑定(bind)到 anyLocalAddress(通常是 0.0.0.0::0)。您可以通过使用正确的 IP 地址设置 network.bind_host 来更改此设置。

Reference [1.3] » Modules » Network Settings


更新:

首先,我建议您在您的 SO 中禁用 ipv6,您可以按照以下步骤执行此操作:

/etc/sysctl.conf中:

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1

在运行系统中禁用:

echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6
echo 1 > /proc/sys/net/ipv6/conf/default/disable_ipv6

sysctl -w net.ipv6.conf.all.disable_ipv6=1
sysctl -w net.ipv6.conf.default.disable_ipv6=1

之后,您必须在 elasticsearch.yml 中更改两个节点中 network.bind_host 的值及其各自的 IP

# Elasticsearch, by default, binds itself to the 0.0.0.0 address, and listens
# on port [9200-9300] for HTTP traffic and on port [9300-9400] for node-to-node
# communication. (the range means that if the port is busy, it will automatically
# try the next port).
# Set the bind address specifically (IPv4 or IPv6):
#
network.bind_host: 10.0.0.1
# Set the address other nodes will use to communicate with this node. If not
# set, it is automatically derived. It must point to an actual IP address.
#
network.publish_host: 10.0.0.1

或设置

# Set both 'bind_host' and 'publish_host':
#
network.host: 10.0.0.1

最后,您必须验证网络适配器的配置,两者都必须使用您之前使用的 IP 进行正确配置。

希望对你有帮助

关于UFW 防火墙后的 Elasticsearch 集群,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26127388/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com