Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ElasticsearchException failed to bind service error

I really wana start elasticsearch for connect opencart. I have set network.host: 0.0.0.0 (also try to my local IP), http.port: 9200, and give executive authority to my new account. I use centOs6, Java 1.8, and don't use root account. I want to use elasticsearch on my server, but I have some issue.

my error log is that

[2019-03-21T18:12:27,970][INFO ][o.e.p.PluginsService     ] [gxhuK_x] loaded module [x-pack-watcher]
[2019-03-21T18:12:27,971][INFO ][o.e.p.PluginsService     ] [gxhuK_x] no plugins loaded
[2019-03-21T18:12:32,061][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [gxhuK_x] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: ElasticsearchException[failed to bind service]; nested: AccessDeniedException[/etc/system-release];
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:163) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.6.2.jar:6.6.2]
        at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.6.2.jar:6.6.2]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:116) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) ~[elasticsearch-6.6.2.jar:6.6.2]
Caused by: org.elasticsearch.ElasticsearchException: failed to bind service
        at org.elasticsearch.node.Node.<init>(Node.java:626) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.node.Node.<init>(Node.java:265) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:212) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:212) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-6.6.2.jar:6.6.2]
        ... 6 more
Caused by: java.nio.file.AccessDeniedException: /etc/system-release
        at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84) ~[?:?]
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102) ~[?:?]
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107) ~[?:?]
        at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214) ~[?:?]
        at java.nio.file.Files.newByteChannel(Files.java:361) ~[?:1.8.0_131]
        at java.nio.file.Files.newByteChannel(Files.java:407) ~[?:1.8.0_131]
        at java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:384) ~[?:1.8.0_131]
        at java.nio.file.Files.newInputStream(Files.java:152) ~[?:1.8.0_131]
        at java.nio.file.Files.newBufferedReader(Files.java:2784) ~[?:1.8.0_131]
        at java.nio.file.Files.readAllLines(Files.java:3202) ~[?:1.8.0_131]
        at java.nio.file.Files.readAllLines(Files.java:3242) ~[?:1.8.0_131]
        at org.elasticsearch.monitor.os.OsProbe.readOsRelease(OsProbe.java:591) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.monitor.os.OsProbe.getPrettyName(OsProbe.java:546) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.monitor.os.OsProbe.osInfo(OsProbe.java:533) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.monitor.os.OsService.<init>(OsService.java:48) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.monitor.MonitorService.<init>(MonitorService.java:47) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.node.Node.<init>(Node.java:397) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.node.Node.<init>(Node.java:265) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:212) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:212) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-6.6.2.jar:6.6.2]
        ... 6 more

I have installed by tar.gz. and I changed something of config/elasticsearch.yml I didn't change anything else someone know this error? please help me.

# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /var/data/elasticsearch
#
# Path to log files:
#
path.logs: /var/logs/elasticsearch
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 0.0.0.0
#
# Set a custom port for HTTP:
#
http.port: 9200
#
# For more information, consult the network module documentation.
#
bootstrap.system_call_filter: false
like image 347
jun Avatar asked Mar 21 '19 11:03

jun


3 Answers

You need to make sure that the directory on the host machine is owned by 1000:1000. Run the following command.

sudo chown 1000:1000 <directory you wish to mount>

Source

like image 116
amitasviper Avatar answered Sep 23 '22 01:09

amitasviper


Please check the following:

  1. Did you create /var/data/elasticsearch and /var/logs/elasticsearch directories in your filesystem?
  2. Did you set the directories above to be writable with your user permission?

Update:

Read the source code of elasticsearch in Github. Link Here It seemed that there some problem when the code is trying to access /etc/system-release. You might to take a look at that file. Also It mentioned that it is fallback for older Red Hat-like OS. So you might want to use another OS if possible.

like image 40
Fei Avatar answered Sep 24 '22 01:09

Fei


In my variant trouble was in a permissions of data directory. Data directory was not default and changed to /elk-data/

To resolve the issue I make 'chmod -R elasticsearch:wheel /elk-data'

like image 37
Виталий Энгель Avatar answered Sep 24 '22 01:09

Виталий Энгель