Right now you can bind Elasticsearch to only a single address with either:
network.bind_host: "some_ip"
or
network.host: "some_ip"
It'd be convenient to be able to bind to multiple hosts like so:
network.bind_host: [ "some_ip", "some_other_ip" ]
In particular it'd allow the convenient configuration:
network.bind_host: [ "some_data_center_accessible_ip", "localhost" ]
network.publish_host: "some_data_center_accessible_ip"
Which would allow elasticsearch to respond to requests to localhost.
+1
When testing ES 2.0, I had to bind to 0.0.0.0 so that ES was accessible from both within and outside of my developer VM.
This should also apply to the http module.
I plan to look into this, the code should easily support it, we just have to deal with the configuration to accept it.
I really really do not like people being forced to bind to all addresses when they really just want maybe two or three or whatever.
Doesn't work on ElasticSearch 2.x
has not been released.
Ahh, so that's why. Thanks! Really looking forward to it.
Has this been fixed? Running 2.3.4 and unable to specify multiple interfaces/addresses.
@AseemKumar Yes, it works fine in 2.3.4:
11:40:45 [jason:~] $ elasticsearch -d --network.bind_host=192.168.1.8,192.168.1.9
11:40:47 [jason:~] $ curl -XGET 192.168.1.8:9200/
{
"name" : "Mutant X",
"cluster_name" : "elasticsearch_jason",
"version" : {
"number" : "2.3.4",
"build_hash" : "e455fd0c13dceca8dbbdbb1665d068ae55dabe3f",
"build_timestamp" : "2016-06-30T11:24:31Z",
"build_snapshot" : false,
"lucene_version" : "5.5.0"
},
"tagline" : "You Know, for Search"
}
11:40:55 [jason:~] $ curl -XGET 192.168.1.9:9200/
{
"name" : "Mutant X",
"cluster_name" : "elasticsearch_jason",
"version" : {
"number" : "2.3.4",
"build_hash" : "e455fd0c13dceca8dbbdbb1665d068ae55dabe3f",
"build_timestamp" : "2016-06-30T11:24:31Z",
"build_snapshot" : false,
"lucene_version" : "5.5.0"
},
"tagline" : "You Know, for Search"
}
Thanks @jasontedor . I specified the interfaces in my config and it only listens on the localhost
network.host: [_enp0s25_, _local_]
Do you know if only IPs can be provided or interface name as well?
@AseemKumar Do not specify as an array, but comma-delimited just as I showed above: network.host: _enp0s25_,_local_.
@jasontedor if you can't specify as an array, then that's a bug. we use arrays for a number of other settings. the comma-separated format is really for command line settings
@clintongormley I tested this, it does indeed work as an array, and it does work with interface names. I'm not sure why @AseemKumar reported an issue here.
@AseemKumar Can you share exactly what you entered for network.host, any other relevant settings from your configuration file, as well as the output of ifconfig?
also if you run with DEBUG logging it prints a "java ifconfig". This is ifconfig as java sees the world.
I wrestled with this too (trying various formats of specifying multiple values), but I got it working using the array notation, but I needed to quote the values. So I think @AseemKumar needs to quote the values in his array: network.host: ["_enp0s25_", "_local_"] and then it will work. Otherwise, you could use the more specific configs via something like network.bind_host: ["_enp0s25_", "_local_"] and network.publish_host: _enp0s25_
I'm running 5.1.1 and I couldn't get it to bind correctly unless I did network.host: [ '10.2.0.7', '_local_' ].
/sbin/ifconfig
eth0 Link encap:Ethernet HWaddr 00:0d:3a:10:55:07
inet addr:10.2.0.7 Bcast:10.2.0.255 Mask:255.255.255.0
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
lxcbr0 Link encap:Ethernet HWaddr 00:16:3e:00:00:00
inet addr:10.0.3.1 Bcast:0.0.0.0 Mask:255.255.255.0
I've never had to do this before in 1.7.5. Is this normal to bind just so you can access from localhost and 10.2.0.7 (local ip)
Yes. Elasticsearch binds to localhost only by default, and otherwise only what you explicitly configure.
I just tried out rayward's recommendation to ue 0.0.0.0 to bind to all available addresses and it works on ES 5.2.2
Just a quick note despite the issue being closed, I am not able to do something like (on 2.4.4). I am running under a coreos-kubernetes multi-vagrant setup.
network.host: [ '_local_' , '_site:ipv4_' ]
Getting an error like, and then the container fails.
Exception in thread "main" BindTransportException[Failed to resolve host null]; nested: UnknownHostException[[ '_local_': invalid IPv6 address];
Likely root cause: java.net.UnknownHostException: [ '_local_': invalid IPv6 address
@madchap I tested this and works fine. Are you sure that you input it correctly? I ask because the exception message indicates that it parsed whatever you input as [ '_local_'.
@jasontedor I tried to catch that to verify it, but could not really as the container is getting destroyed before I can actually get to what is being held in my env variable.
But I tend to believe you're right -- there must be something odd with the env variable interpolation I am missing. Thanks for your confirmation too. I've put 0.0.0.0 for now as I need to move on onto other stuff.
@madchap Did you could resolved that issue? I have a similar problem, I tried different things with no luck:
-network.host=_eth0_ #works
but
is not working. It tried with single quotes, double quotes around _eth0_.
@pvledoux, no I eventually did not after having tried what I think is every possibility. I haven't investigated any further. Maybe something related to the particular docker environment in my case?
@madchap Yes I'm docker too. I will investigate on at side when I have more time.
@madchap @pvledoux Please try:
-e network.host='_site_,_local_'
it works for me
v 7.0 network.host not work
this works for me in elastic 7
@lodinv
network.host: '_site_,_local_'
node.name: "node-1"
cluster.initial_master_nodes: ["node-1"]
http.host: 10.91.170.115
http.port: 9200
this works for me