I have an ubuntu server 16.0.4. I was installed elastic and kibana (both 6.2.2) with Debian file package. Now I want to install logstash 6.2.2 with .deb file, but some error occurred.
elk@elk:~$sudo dpkg --install logstash-6.2.2.deb
(Reading database ... 130938 files and directories currently installed.)
Preparing to unpack logstash-6.2.2.deb ...
Unpacking logstash (1:6.2.2-1) over (1:6.2.2-1) ...
Setting up logstash (1:6.2.2-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 (--install):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
logstash
but java was installed on this machine before and JAVA_HOME variable was set.
elk@elk:~$ java -version
java version "1.8.0_162"
Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)
elk@elk:~$ echo $JAVA_HOME
/usr/local/java/jdk1.8.0_162
elk@elk:~$ sudo java -version
sudo: java: command not found
elk@elk:~$ sudo env | grep jAVA_HOME
elk@elk:~$
But I Try this way:
sudo vi /etc/environment
At the end of this file, I add the following line
JAVA_HOME="/usr/local/java/jdk1.8.0_162"
Save and exit the file, and reload it.
source /etc/environment
After this way I got a new error:
elk@elk:~$ sudo dpkg --install logstash-6.2.2.deb
Selecting previously unselected package logstash.
(Reading database ... 116903 files and directories currently installed.)
Preparing to unpack logstash-6.2.2.deb ...
Unpacking logstash (1:6.2.2-1) ...
Setting up logstash (1:6.2.2-1) ...
Using provided startup.options file: /etc/logstash/startup.options
/usr/share/logstash/vendor/jruby/bin/jruby: line 401: /usr/bin/java: No such file or directory
Unable to install system startup script for Logstash.
chmod: cannot access '/etc/default/logstash': No such file or directory
dpkg: error processing package logstash (--install):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
logstash
Not sure what's up here. I'd have to dig into the startup scripts and I don't have time for that. Can't you just install the JVM from a regular Debian package?
and finally,
I found my problem! on this result of installation:
elk@elk:~$ sudo dpkg --install logstash-6.2.2.deb
Selecting previously unselected package logstash.
(Reading database ... 116903 files and directories currently installed.)
Preparing to unpack logstash-6.2.2.deb ...
Unpacking logstash (1:6.2.2-1) ...
Setting up logstash (1:6.2.2-1) ...
Using provided startup.options file: /etc/logstash/startup.options
/usr/share/logstash/vendor/jruby/bin/jruby: line 401: /usr/bin/java: No such file or directory
Unable to install system startup script for Logstash.
chmod: cannot access '/etc/default/logstash': No such file or directory
dpkg: error processing package logstash (--install):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
logstash
this problem and some else basically for java! you can change java path on /etc/logstash/startup.options and run installation command again, it will be ok but some problem will arise!
My Solution:
I have installed java manually in /usr/local/java/.... but logstash by default read /usr/bin/java to use java.
to do it I use this guide to install java and run logstash installation command again. it works well.
wget http://download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/jdk-8u151-linux-i586.tar.gz
sudo mkdir /usr/lib/jvm
cd /usr/lib/jvm
sudo tar -xvzf ~/Downloads/jdk-8u151-linux-x64.tar.gz
vi /etc/environment
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.