Elasticsearch refuses to run

I've installed the .tar.gz package on a Rhel7.5 instance on Amazon Web Services with a RAM of 1GB and volume of 10GB but when I run it with this command "./bin/elasticsearch" I get this error despite reducing the heap size to 512MBs:

Exception in thread "main" java.nio.file.AccessDeniedException: /elasticsearch-6.3.1/config/jvm.options 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) at java.nio.file.Files.newByteChannel(Files.java:407) at java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:384) at java.nio.file.Files.newInputStream(Files.java:152) at org.elasticsearch.tools.launchers.JvmOptionsParser.main(JvmOptionsParser.java:58)
What could the issue be?

How did you install Elasticsearch?

I installed using the .tar.gz option

Right, but what did you do exactly?
What commands, what user?

I installed using root and the commands were as follows:

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.4.0.tar.gz wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.4.0.tar.gz.sha512 shasum -a 512 -c elasticsearch-6.4.0.tar.gz.sha512 !(https://www.elastic.co/guide/en/elasticsearch/reference/current/images/icons/callouts/1.png) tar -xzf elasticsearch-6.4.0.tar.gz cd elasticsearch-6.4.0/ !(https://www.elastic.co/guide/en/elasticsearch/reference/current/images/icons/callouts/2.png)

this is the link to the guide i followed...https://www.elastic.co/guide/en/elasticsearch/reference/current/zip-targz.html

What user are you trying to run Elasticsearch as?

ec2-user currently coz i tried running the process using root but it keeps on being killed

You cannot run Elasticsearch as root, ever, there are checks to stop that.

Which would probably explain this;

Why not use the rpm?

Does that mean reinstalling elasticsearch with rpm?

Yes, that creates the proper directory structures, users and service files.

can i uninstall the .tar.gz version?

Just rm -rf the directory you extracted.

Also, ideally, you should setup the repo, not just download the RPM. That way you are setup to allow easy upgrades as well.

Okay, do you think this guide will help me?...https://www.elastic.co/guide/en/elasticsearch/reference/current/rpm.html

Yep!

Thanks Mark you are awesome

Thanks for being sticking through to the end! :slight_smile:

1 Like

:slightly_smiling_face:

Blocked by another huddle....I installed Elasticsearch as adviced here:

but it sends this error when i try checking if it runs
curl: (7) Failed connect to localhost:9200; Connection refused

i checked if the service was runnning and i found out that it wasn't so i started it then it sent me this response

    ● elasticsearch.service - Elasticsearch
       Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: disabled)
       Active: active (running) since Wed 2018-09-19 07:21:43 UTC; 32s ago
         Docs: http://www.elastic.co
     Main PID: 5798 (java)
       CGroup: /system.slice/elasticsearch.service
               └─5798 /bin/java -Xms512m -Xmx512m -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headl...

    Sep 19 07:21:43 ip-172-31-7-139.us-east-2.compute.internal systemd[1]: Started Elasticsearch.
    Sep 19 07:21:43 ip-172-31-7-139.us-east-2.compute.internal systemd[1]: Starting Elasticsearch...

but on trying to test the Elasticsearch node it still sent me this error
curl: (7) Failed connect to localhost:9200; Connection refused
and on checking the status of the service, this is what it said

● elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: disabled)
   Active: failed (Result: signal) since Wed 2018-09-19 07:23:52 UTC; 9s ago
     Docs: http://www.elastic.co
  Process: 5798 ExecStart=/usr/share/elasticsearch/bin/elasticsearch -p ${PID_DIR}/elasticsearch.pid --quiet (code=killed, signal=KILL)
 Main PID: 5798 (code=killed, signal=KILL)

Sep 19 07:21:43 ip-172-31-7-139.us-east-2.compute.internal systemd[1]: Started Elasticsearch.
Sep 19 07:21:43 ip-172-31-7-139.us-east-2.compute.internal systemd[1]: Starting Elasticsearch...
Sep 19 07:23:52 ip-172-31-7-139.us-east-2.compute.internal systemd[1]: elasticsearch.service: main process exited, code=killed, status=9/KILL
Sep 19 07:23:52 ip-172-31-7-139.us-east-2.compute.internal systemd[1]: Unit elasticsearch.service entered failed state.
Sep 19 07:23:52 ip-172-31-7-139.us-east-2.compute.internal systemd[1]: elasticsearch.service failed.

Please help

Check /var/log/elasticsearch for something.