Elasticsearch集群在UFW防火墙后面

Axe*_*ran 6 firewall elasticsearch digital-ocean ubuntu-14.04

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

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

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

我在这里错过了什么?

Fed*_*rra 2

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

\n\n

参考 [1.3] \xc2\xbb 模块 \xc2\xbb 网络设置

\n\n
\n\n

更新:

\n\n

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

\n\n

/etc/sysctl.conf

\n\n
net.ipv6.conf.all.disable_ipv6 = 1\nnet.ipv6.conf.default.disable_ipv6 = 1\n
Run Code Online (Sandbox Code Playgroud)\n\n

要在正在运行的系统中禁用:

\n\n
echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6\necho 1 > /proc/sys/net/ipv6/conf/default/disable_ipv6\n
Run Code Online (Sandbox Code Playgroud)\n\n

或者

\n\n
sysctl -w net.ipv6.conf.all.disable_ipv6=1\nsysctl -w net.ipv6.conf.default.disable_ipv6=1\n
Run Code Online (Sandbox Code Playgroud)\n\n

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

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

或设置

\n\n
# Set both \'bind_host\' and \'publish_host\':\n#\nnetwork.host: 10.0.0.1\n
Run Code Online (Sandbox Code Playgroud)\n\n

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

\n\n

希望这可以帮助

\n