Force elasticsearch ipv4 on ubuntu

While installing an elastic search server on debian one might come accross the following problem where whatever you do the service keeps binding on ipv6.
You can change the IP to listen on in the config yml.
# Set the bind address specifically (IPv4 or IPv6):
#
#network.bind_host:192.168.1.0
# 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:192.168.1.0
# Set both 'bindhost' and 'publish_host':
#
network.host: _non_loopback:ipv4_
non_loopback:ipv4 just means use the first non loopback device and force ipv4.
When you do that you might get this akward result:
root@log:/data/elasticsearch/bin# netstat -plnt
tcp 0 0 0.0.0.0:50697 0.0.0.0:* LISTEN 5457/beam.smp
tcp6 0 0 10.20.10.1:9200 :::* LISTEN 7010/java
tcp6 0 0 :::80 :::* LISTEN 3571/apache2
tcp6 0 0 10.20.10.1:9300 :::* LISTEN 7010/java
tcp6 0 0 :::22 :::* LISTEN 1206/sshd
The solution is to go into your bin/ folder of your elasticsearch folder and change your elasticsearch.in.sh file
# Force the JVM to use IPv4 stack
JAVA_OPTS="$JAVA_OPTS -Djava.net.preferIPv4Stack=true"
After that you restart your service and everything binds normally.
Hope I save somebody some frustration with this :)


Source: http://slacklabs.be/2012/04/02/force-Elastic-search-on-ipv4-debian/

Related Posts

Post a Comment

Subscribe Our Newsletter