Logstash can not find JAVA_HOME

Unable to install Logstash because it can not find JAVA_HOME

I did not install JAVA because it is included in ELK. Elasticsearch, Kibana and Logstash are on the same server.

Elacticsearh and Kibana works. But how to configure the installation of Logstash ?

I am on Ubuntu 18.04

ubuntu@monitoring-example-com:~$ sudo apt install logstash
 
 
Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following NEW packages will be installed:
  logstash
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 173 MB of archives.
After this operation, 299 MB of additional disk space will be used.
Get:1 https://artifacts.elastic.co/packages/7.x/apt stable/main amd64 logstash all 1:7.1.0-1 [173 MB]
Fetched 173 MB in 16s (11.0 MB/s)                                                                                                          
Selecting previously unselected package logstash.
(Reading database ... 166387 files and directories currently installed.)
Preparing to unpack .../logstash_1%3a7.1.0-1_all.deb ...
Unpacking logstash (1:7.1.0-1) ...
Setting up logstash (1:7.1.0-1) ...
could not find java; set JAVA_HOME or ensure java is in PATH
chmod: cannot access '/etc/default/logstash': No such file or directory
dpkg: error processing package logstash (--configure):
 installed logstash package post-installation script subprocess returned error exit status 1
E: Sub-process /usr/bin/dpkg returned an error code (1)

It's not though. You do need to install it.

I did not understand your answer. According to the documentation, JAVA is included in ELK and there is no need to install it

https://www.elastic.co/guide/en/elasticsearch/reference/current/setup.html

That's for Elasticsearch, not for Logstash.
So you either need to tell Logstash to use the bundled one in Elasticsearch - which I am not sure if we support - or install your own.

1 Like

ok. will i have the same problem with filebeat install on another instance?

Filebeat does not use java.

Is there an Ubuntu command to locate JAVA integrate with ES?

I found this but I do not know what I need to change

/usr/share/elasticsearch/jdk

ubuntu@monitoring-example-com:/usr/share/elasticsearch/jdk$ ls -l
total 28
drwxr-xr-x 2 root root 4096 May 24 21:56 bin
drwxr-xr-x 5 root root 4096 May 24 21:56 conf
drwxr-xr-x 3 root root 4096 May 24 21:56 include
drwxr-xr-x 2 root root 4096 May 24 21:56 jmods
drwxr-xr-x 72 root root 4096 May 24 21:55 legal
drwxr-xr-x 5 root root 4096 May 24 21:56 lib
-rw-r--r-- 1 root root 1190 May 16 02:52 release

Please export your JAVA_HOME
export JAVA_HOME={{ path_of_java_home}}

for example:

export JAVA_HOME=/usr/share/elasticsearch/jdk

It does not work

ubuntu@monitoring-revolutime-com:/usr/share/elasticsearch/jdk$ ls -l
total 28
drwxr-xr-x 2 root root 4096 May 24 21:56 bin
drwxr-xr-x 5 root root 4096 May 24 21:56 conf
drwxr-xr-x 3 root root 4096 May 24 21:56 include
drwxr-xr-x 2 root root 4096 May 24 21:56 jmods
drwxr-xr-x 72 root root 4096 May 24 21:55 legal
drwxr-xr-x 5 root root 4096 May 24 21:56 lib
-rw-r--r-- 1 root root 1190 May 16 02:52 release

ubuntu@monitoring-example-com:/usr/share/elasticsearch/jdk$ cd bin

ubuntu@monitoring-example-com:/usr/share/elasticsearch/jdk/bin$ ls -l
total 520
-rwxr-xr-x 1 root root 12952 May 16 02:53 jaotc
-rwxr-xr-x 1 root root 8736 May 16 02:53 jar
-rwxr-xr-x 1 root root 8736 May 16 02:53 jarsigner
-rwxr-xr-x 1 root root 8720 May 16 02:53 java
-rwxr-xr-x 1 root root 8784 May 16 02:53 javac
-rwxr-xr-x 1 root root 8784 May 16 02:53 javadoc
-rwxr-xr-x 1 root root 8736 May 16 02:53 javap
-rwxr-xr-x 1 root root 8736 May 16 02:53 jcmd
-rwxr-xr-x 1 root root 12904 May 16 02:53 jconsole
-rwxr-xr-x 1 root root 8736 May 16 02:53 jdb
-rwxr-xr-x 1 root root 8736 May 16 02:53 jdeprscan
-rwxr-xr-x 1 root root 8736 May 16 02:53 jdeps
-rwxr-xr-x 1 root root 8736 May 16 02:53 jfr
-rwxr-xr-x 1 root root 8736 May 16 02:53 jhsdb
-rwxr-xr-x 1 root root 8736 May 16 02:53 jimage
-rwxr-xr-x 1 root root 12880 May 16 02:53 jinfo
-rwxr-xr-x 1 root root 8784 May 16 02:53 jjs
-rwxr-xr-x 1 root root 8784 May 16 02:53 jlink
-rwxr-xr-x 1 root root 12880 May 16 02:53 jmap
-rwxr-xr-x 1 root root 8736 May 16 02:53 jmod
-rwxr-xr-x 1 root root 8736 May 16 02:53 jps
-rwxr-xr-x 1 root root 8792 May 16 02:53 jrunscript
-rwxr-xr-x 1 root root 8736 May 16 02:53 jshell
-rwxr-xr-x 1 root root 12880 May 16 02:53 jstack
-rwxr-xr-x 1 root root 8736 May 16 02:53 jstat
-rwxr-xr-x 1 root root 8736 May 16 02:53 jstatd
-rwxr-xr-x 1 root root 8736 May 16 02:53 keytool
-rwxr-xr-x 1 root root 8736 May 16 02:53 pack200
-rwxr-xr-x 1 root root 8736 May 16 02:53 rmic
-rwxr-xr-x 1 root root 8736 May 16 02:53 rmid
-rwxr-xr-x 1 root root 8744 May 16 02:53 rmiregistry
-rwxr-xr-x 1 root root 8736 May 16 02:53 serialver
-rwxr-xr-x 1 root root 117704 May 16 02:53 unpack200

ubuntu@example-revolutime-com:~$ export JAVA_HOME=/usr/share/elasticsearch/jdk

ubuntu@example-revolutime-com:~$ sudo apt install logstash
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be upgraded:
logstash
1 upgraded, 0 newly installed, 0 to remove and 6 not upgraded.
1 not fully installed or removed.
Need to get 173 MB of archives.
After this operation, 142 kB of additional disk space will be used.
Get:1 https://artifacts.elastic.co/packages/7.x/apt stable/main amd64 logstash all 1:7.1.1-1 [173 MB]
Fetched 173 MB in 15s (11.5 MB/s)
(Reading database ... 182520 files and directories currently installed.)
Preparing to unpack .../logstash_1%3a7.1.1-1_all.deb ...
Unpacking logstash (1:7.1.1-1) over (1:7.1.0-1) ...
Setting up logstash (1:7.1.1-1) ...
could not find java; set JAVA_HOME or ensure java is in PATH
chmod: cannot access '/etc/default/logstash': No such file or directory
dpkg: error processing package logstash (--configure):
installed logstash package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
logstash
E: Sub-process /usr/bin/dpkg returned an error code (1)

Can you please create the file:
etc/default/logstash

And out there java hine env?

And try again?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.