在安装logstash时出现如下报错:“could not find java; set JAVA_HOME or ensure java is in PATH
chmod: cannot access ‘/etc/default/logstash’: No such file or directory
warning: %post(logstash-1:6.6.0-1.noarch) scriptlet failed, exit status 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
warning: %post(logstash-1:6.6.0-1.noarch) scriptlet failed, exit status 1
原以为是jdk没有安装经查是正常的。但启动logstash 的时候也是报错的。
[[email protected] opt]# java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
猜测应该是环境变量的事了。
[[email protected] config]# echo $PATH
/usr/local/jdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
但是发现是有的。
查看整个系统的变量,发现没有,应该就是这个问题了。
[[email protected] preuser-0]# set |grep JAVA_HOME
解决步骤如下:
1、设置变量
[[email protected] opt]# vim ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
PATH=$PATH:$HOME/bin
export JAVA_HOME=/usr/local/jdk
export PATH=$PATH:/usr/local/jdk/bin
[[email protected] opt]# source ~/.bash_profile
2、查看变量值
[[email protected] opt]# set |grep JAVA_HOME
JAVA_HOME=/usr/local/jdk
3、重新安装ok了,问题解决。
[[email protected] opt]# rpm -ivh logstash-6.6.0.rpm
warning: logstash-6.6.0.rpm: Header V4 RSA/SHA512 Signature, key ID d88e42b4: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:logstash-1:6.6.0-1 ################################# [100%]
Using provided startup.options file: /etc/logstash/startup.options
Successfully created system startup script for Logstash
原文地址:https://blog.51cto.com/liqingbiao/2413505
时间: 2024-11-09 12:24:42