Exception in thread "main" java.nio.file.AccessDeniedException


(Sahil Ahmed) #1

I get this error when i tried to run elasticsearch.

Exception in thread "main" java.nio.file.AccessDeniedException: /home/supportdev/elasticsearch-6.5.4/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:60)

Any help appreciated.

Thanks in advance.


(Sahil Ahmed) #2

Chown worked!!


(Aadil Hussain) #3

@sahil_ahmed please tell me the solution, do I need to update something in jvm.options file?


(Aadil Hussain) #4

here is the error while running elasticsearch server...

[aadil@oc4733723867 elasticsearch-6.6.0]$ ./bin/elasticsearch
Exception in thread "main" java.nio.file.AccessDeniedException: /home/aadil/Downloads/Elastic_Stack/elasticsearch-6.6.0/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:60)


(Sahil Ahmed) #5

@Aadil672 try changing the ownership of the file by using the command "chown"


(Aadil Hussain) #6

@sahil_ahmed bhai plz full command, as I have myself and root users in Redhat.


(Sahil Ahmed) #7

chown "username" "filename"


(Aadil Hussain) #8

nothing worked :frowning:

[aadil@oc4733723867 elasticsearch-6.6.0] chown aadil ./bin/elasticsearch chown: changing ownership of ‘./bin/elasticsearch’: Operation not permitted [aadil@oc4733723867 elasticsearch-6.6.0] chown
chown: missing operand
Try 'chown --help' for more information.
[aadil@oc4733723867 elasticsearch-6.6.0] chown aadil ./config/jvm.options chown: changing ownership of ‘./config/jvm.options’: Operation not permitted [aadil@oc4733723867 elasticsearch-6.6.0] chown aadil ./bin/elasticsearch
chown: changing ownership of ‘./bin/elasticsearch’: Operation not permitted
[aadil@oc4733723867 elasticsearch-6.6.0] cd .. [aadil@oc4733723867 Elastic_Stack] chown aadil elasticsearch-6.6.0
chown: changing ownership of ‘elasticsearch-6.6.0’: Operation not permitted


(Sahil Ahmed) #9

chown aadil elasticsearch-6.6.0


(Aadil Hussain) #10

[aadil@oc4733723867 Elastic_Stack]$ chown aadil elasticsearch-6.6.0
chown: changing ownership of ‘elasticsearch-6.6.0’: Operation not permitted


(Sahil Ahmed) #11

sudo su
and then try it


(Aadil Hussain) #12

will try but I dont think It will work because it says, we can not perform on root users
[aadil@oc4733723867 Elastic_Stack]$ sudo su
[sudo] password for aadil:
[root@oc4733723867 Elastic_Stack]# chown aadil elasticsearch-6.6.0
[root@oc4733723867 Elastic_Stack]# cd elasticsearch-6.6.0/
[root@oc4733723867 elasticsearch-6.6.0]# ./bin/elasticsearch
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000d4cc0000, 724828160, 0) failed; error='Cannot allocate memory' (errno=12)

There is insufficient memory for the Java Runtime Environment to continue.

Native memory allocation (mmap) failed to map 724828160 bytes for committing reserved memory.

An error report file with more information is saved as:

logs/hs_err_pid27624.log

[root@oc4733723867 elasticsearch-6.6.0]#


(Aadil Hussain) #13

@sahil_ahmed bhai,
I gave permission (chown "username" "filename"). I tried all the way, Could you please help to get fix this issue. :slight_smile:

[aadil@oc4733723867 ~] cd Downloads/ [aadil@oc4733723867 Downloads] cd Elastic_Stack/
[aadil@oc4733723867 Elastic_Stack] cd elasticsearch-6.6.0/ [aadil@oc4733723867 elasticsearch-6.6.0] ls
bin config lib LICENSE.txt logs modules NOTICE.txt plugins README.textile
[aadil@oc4733723867 elasticsearch-6.6.0] ./bin/elasticsearch Exception in thread "main" java.nio.file.AccessDeniedException: /home/aadil/Downloads/Elastic_Stack/elasticsearch-6.6.0/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:60) [aadil@oc4733723867 elasticsearch-6.6.0] cd ..
[aadil@oc4733723867 Elastic_Stack] chown chown: missing operand Try 'chown --help' for more information. [aadil@oc4733723867 Elastic_Stack] chown aadil elasticsearch-6.6.0
[aadil@oc4733723867 Elastic_Stack] cd elasticsearch-6.6.0/ [aadil@oc4733723867 elasticsearch-6.6.0] ./bin/elasticsearch
Exception in thread "main" java.nio.file.AccessDeniedException: /home/aadil/Downloads/Elastic_Stack/elasticsearch-6.6.0/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:60)
[aadil@oc4733723867 elasticsearch-6.6.0]$ sudo su
[sudo] password for aadil:
[root@oc4733723867 elasticsearch-6.6.0]# ./bin/elasticsearch
[2019-02-13T17:08:47,817][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [unknown] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:163) ~[elasticsearch-6.6.0.jar:6.6.0]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-6.6.0.jar:6.6.0]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.6.0.jar:6.6.0]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.6.0.jar:6.6.0]
at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.6.0.jar:6.6.0]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:116) ~[elasticsearch-6.6.0.jar:6.6.0]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) ~[elasticsearch-6.6.0.jar:6.6.0]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:103) ~[elasticsearch-6.6.0.jar:6.6.0]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:170) ~[elasticsearch-6.6.0.jar:6.6.0]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-6.6.0.jar:6.6.0]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-6.6.0.jar:6.6.0]
... 6 more
[root@oc4733723867 elasticsearch-6.6.0]#


(Aadil Hussain) #14

Can I get in touch with you - my number: 7829191078


(Sahil Ahmed) #15

try ls -l /path/to/the/file and see the user of the file @Aadil672


(Aadil Hussain) #16

all are root user, please connect me over the call if possible - 7829191078

[root@oc4733723867 elasticsearch-6.6.0]# ls -l
total 448
drwxr-xr-x. 3 root root 4096 Feb 4 03:01 bin
drwxr-xr-x. 2 root root 4096 Feb 5 02:11 config
drwxr-xr-x. 3 root root 4096 Jan 24 16:59 lib
-rw-r--r--. 1 root root 13675 Jan 24 16:54 LICENSE.txt
drwxr-xr-x. 2 root root 4096 Feb 13 17:08 logs
drwxr-xr-x. 29 root root 4096 Jan 24 16:59 modules
-rw-r--r--. 1 root root 403816 Jan 24 16:59 NOTICE.txt
drwxr-xr-x. 2 root root 4096 Jan 24 16:59 plugins
-rw-r--r--. 1 root root 8519 Jan 24 16:54 README.textile
[root@oc4733723867 elasticsearch-6.6.0]# cd bin/
[root@oc4733723867 bin]# ls -l
total 18504
-rwxr-xr-x. 1 root root 1777 Jan 24 16:54 elasticsearch
-rw-r--r--. 1 root root 1534 Jan 24 16:54 elasticsearch.bat
-rwxr-xr-x. 1 root root 491 Jan 24 16:59 elasticsearch-certgen
-rwxr-xr-x. 1 root root 586 Jan 24 16:59 elasticsearch-certgen.bat
-rwxr-xr-x. 1 root root 483 Jan 24 16:59 elasticsearch-certutil
-rwxr-xr-x. 1 root root 578 Jan 24 16:59 elasticsearch-certutil.bat
-rwxr-xr-x. 1 root root 766 Jan 24 16:54 elasticsearch-cli
-rw-r--r--. 1 root root 614 Jan 24 16:54 elasticsearch-cli.bat
-rwxr-xr-x. 1 root root 433 Jan 24 16:59 elasticsearch-croneval
-rwxr-xr-x. 1 root root 528 Jan 24 16:59 elasticsearch-croneval.bat
-rwxr-xr-x. 1 root root 2153 Jan 24 16:54 elasticsearch-env
-rw-r--r--. 1 root root 1897 Jan 24 16:54 elasticsearch-env.bat
-rwxr-xr-x. 1 root root 121 Jan 24 16:54 elasticsearch-keystore
-rw-r--r--. 1 root root 224 Jan 24 16:54 elasticsearch-keystore.bat
-rwxr-xr-x. 1 root root 440 Jan 24 16:59 elasticsearch-migrate
-rwxr-xr-x. 1 root root 535 Jan 24 16:59 elasticsearch-migrate.bat
-rwxr-xr-x. 1 root root 172 Jan 24 16:54 elasticsearch-plugin
-rw-r--r--. 1 root root 276 Jan 24 16:54 elasticsearch-plugin.bat
-rwxr-xr-x. 1 root root 431 Jan 24 16:59 elasticsearch-saml-metadata
-rwxr-xr-x. 1 root root 526 Jan 24 16:59 elasticsearch-saml-metadata.bat
-rw-r--r--. 1 root root 7524 Jan 24 16:54 elasticsearch-service.bat
-rw-r--r--. 1 root root 118184 Jan 24 16:54 elasticsearch-service-mgr.exe
-rw-r--r--. 1 root root 114600 Jan 24 16:54 elasticsearch-service-x64.exe
-rwxr-xr-x. 1 root root 438 Jan 24 16:59 elasticsearch-setup-passwords
-rwxr-xr-x. 1 root root 533 Jan 24 16:59 elasticsearch-setup-passwords.bat
-rwxr-xr-x. 1 root root 118 Jan 24 16:54 elasticsearch-shard
-rw-r--r--. 1 root root 221 Jan 24 16:54 elasticsearch-shard.bat
-rwxr-xr-x. 1 root root 427 Jan 24 16:59 elasticsearch-sql-cli
-rwxr-xr-x. 1 root root 18546213 Jan 24 16:59 elasticsearch-sql-cli-6.6.0.jar
-rwxr-xr-x. 1 root root 628 Jan 24 16:59 elasticsearch-sql-cli.bat
-rwxr-xr-x. 1 root root 426 Jan 24 16:59 elasticsearch-syskeygen
-rwxr-xr-x. 1 root root 521 Jan 24 16:59 elasticsearch-syskeygen.bat
-rwxr-xr-x. 1 root root 124 Jan 24 16:54 elasticsearch-translog
-rw-r--r--. 1 root root 227 Jan 24 16:54 elasticsearch-translog.bat
-rwxr-xr-x. 1 root root 426 Jan 24 16:59 elasticsearch-users
-rwxr-xr-x. 1 root root 521 Jan 24 16:59 elasticsearch-users.bat
drwxr-xr-x. 2 root root 4096 Jan 24 16:59 x-pack
-rwxr-xr-x. 1 root root 306 Jan 24 16:59 x-pack-env
-rwxr-xr-x. 1 root root 303 Jan 24 16:59 x-pack-env.bat
-rwxr-xr-x. 1 root root 354 Jan 24 16:59 x-pack-security-env
-rwxr-xr-x. 1 root root 307 Jan 24 16:59 x-pack-security-env.bat
-rwxr-xr-x. 1 root root 353 Jan 24 16:59 x-pack-watcher-env
-rwxr-xr-x. 1 root root 306 Jan 24 16:59 x-pack-watcher-env.bat


(Tim Vernum) #17

Here's what you need to do, at a high level:

  • Decide which user (not root) is going to run your Elasticsearch process. It looks like you are using aadil
  • Make sure all the necessary files are owned by that user
  • Run the process as that user

To do this, in your case:

  1. login as aadil
  2. cd Downloads/elasticsearch-6.6.0/
  3. sudo chown -R aadil .
  4. ./bin/elasticsearch

(Aadil Hussain) #18

Hi TimV,
Hope you are doing well!

Thanks a lot for your effort, It worked for me, I am able to run **elasticsearch (./bin/elasticsearch) **server.
but again I got an error (node js incompatibility) while trying to run kibana (./bin/kibana). Could you please help me to get back to older version of Node js in RedHat 7.5 ?

Thanks in advance!

[aadil@oc4733723867 ~]$ cd Downloads/

[aadil@oc4733723867 Downloads]$ cd Elastic_Stack/

[aadil@oc4733723867 Elastic_Stack]$ cd kibana-6.6.0-linux-x86_64/

[aadil@oc4733723867 kibana-6.6.0-linux-x86_64]$ ls

bin data LICENSE.txt NOTICE.txt package.json README.txt target

config dlls node_modules optimize plugins src webpackShims

[aadil@oc4733723867 kibana-6.6.0-linux-x86_64]$ ./bin/kibana

Kibana does not support the current Node.js version v11.9.0. Please use Node.js v10.14.1.

[aadil@oc4733723867 kibana-6.6.0-linux-x86_64]$

Thanks,

Aadil Hussain
Learner!