Problem to install logstash using deb file on ubuntu 16.0.4


(Soheyl Arab) #1

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

What is the problem??


(Magnus Bäck) #2

Does sudo java -version work or does sudo env | grep jAVA_HOME return the expected results?


(Soheyl Arab) #3

This is the Result.

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

(Magnus Bäck) #4

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?


(Soheyl Arab) #5

I have not Internet on the remote server! my connection is over vpn.


(Magnus Bäck) #6

So copy the .deb file(s) over the VPN and install it?


(Soheyl Arab) #7

Yes, I did it. This Problem occurred when I wanted to install Logsatsh with deb file.


(Soheyl Arab) #9

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

Add this line to environment

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/jdk1.8.0_151/bin:/usr/lib/jvm/jdk1.8.0_151/db/bin:/usr/lib/jvm/jdk1.8.0_151/jre/bin"
J2SDKDIR="/usr/lib/jvm/jdk1.8.0_151"
J2REDIR="/usr/lib/jvm/jdk1.8.0_151/jre"
JAVA_HOME="/usr/lib/jvm/jdk1.8.0_151"
DERBY_HOME="/usr/lib/jvm/jdk1.8.0_151/db"

then save it and close. after that run this commands:

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0_151/bin/java" 0 
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.8.0_151/bin/javac" 0 
sudo update-alternatives --set java /usr/lib/jvm/jdk1.8.0_151/bin/java 
sudo update-alternatives --set javac /usr/lib/jvm/jdk1.8.0_151/bin/javac


reboot

(system) #10

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