Elasticsearch集群在UFW防火墙后面

时间:2014-09-30 18:14:17

标签: elasticsearch firewall ubuntu-14.04 digital-ocean

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

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

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

我在这里缺少什么?

2 个答案:

答案 0 :(得分:2)

默认情况下首选IPV6。您可以通过将java.net.preferIPv4Stack系统属性设置为true来更改此行为 此外,您必须看到默认ES绑定到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

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

# 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正确配置。

希望这有帮助

答案 1 :(得分:0)

如果您签出下面的文档,则表示ES传输默认使用端口9300-9400。我会尝试打开那个范围,然后看看你是否可以进一步锁定它。

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-transport.html