pssh批量执行启动tomcat报错:Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
生活随笔
收集整理的這篇文章主要介紹了
pssh批量执行启动tomcat报错:Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
文章目錄
- 問題描述
- 問題分析
- 解決問題
問題描述
我這邊一共4臺主機(jī),4臺主機(jī)tomca路徑一致。我想想通過pssh命令工具直接將4臺主機(jī)的tomcat啟動,命令如下:
[root@hadoop-master pssh]# pssh -P -h hosts.text /usr/local/tomcat/apache-tomcat-8.5.57/bin/startup.sh異常如下:
異常問題:
hadoop-master: Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At least one of these environment variable is needed to run this program問題分析
首先檢查環(huán)境變量,發(fā)現(xiàn)我們已經(jīng)配置了
[root@hadoop-master ~]# echo $JAVA_HOME /usr/local/jdk/jdk1.8.0_261懷疑是通過pssh方式執(zhí)行命令,不能使用全局的環(huán)境變量
解決問題
如果不能設(shè)置全局環(huán)境變量,那只需要在tomcat啟動的時候設(shè)置環(huán)境變量即可,我們使用一臺主機(jī)hadoop-slave1做測試
首先進(jìn)入tomcat的bin目錄,并且編輯
在文件的第二行添加進(jìn)我們的環(huán)境變量
#!/bin/sh export JAVA_HOME="/usr/local/jdk/jdk1.8.0_261" # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership.然后wq保存退出。再執(zhí)行我們的pssh命令:
[root@hadoop-master pssh]# pssh -P -h hosts.text /usr/local/tomcat/apache-tomcat-8.5.57/bin/startup.sh
發(fā)現(xiàn)執(zhí)行成功了,再登錄hadoop-slave1中驗證:
發(fā)現(xiàn)tomcat已經(jīng)啟動成功了。按照此方式,把其他服務(wù)器的tomcat也做同樣的修改,就可解決問題了。
最終目標(biāo):
總結(jié)
以上是生活随笔為你收集整理的pssh批量执行启动tomcat报错:Neither the JAVA_HOME nor the JRE_HOME environment variable is defined的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Hadoop的基本概念和简单使用
- 下一篇: 使用shell脚本完成自动化部署jar包