【发布时间】:2020-05-28 10:41:03
【问题描述】:
我正在尝试创建一个可用于在重新启动时自动启动 solr 的 solr 服务脚本。这是我看到推荐的一个脚本:
#!/bin/sh
# Starts, stops, and restarts Apache Solr.
#
# chkconfig: 35 92 08
# description: Starts and stops Apache Solr
SOLR_DIR="/var/www/html/fas/solr/solr-latest"
JAVA_OPTIONS="-Xmx1024m -DSTOP.PORT=8983 -DSTOP.KEY=mustard -jar /var/www/html/fas/solr/solr-latest/server/start.jar"
LOG_FILE="/var/log/solr.log"
JAVA="/bin/java"
case $1 in
start)
echo "Starting Solr"
cd $SOLR_DIR
$JAVA $JAVA_OPTIONS 2> $LOG_FILE &
;;
stop)
echo "Stopping Solr"
cd $SOLR_DIR
$JAVA $JAVA_OPTIONS --stop
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}" >&2
exit 1
;;
esac
我想我已经为脚本中的变量设置了适当的值。但是当我尝试运行脚本时,我得到“连接被拒绝”。
$ service solr stop
Stopping Solr
java.net.ConnectException: Connection refused (Connection refused)
无论我是否以 root 身份运行脚本,我都会得到相同的结果。
不过,我可以通过这种方式停止和启动 solr:
/path/to/my/solr/bin/solr start
所以我也尝试在 /etc/init.d/solr-start 创建这个脚本
#!/bin/sh
# Starts Apache Solr.
#
# chkconfig: 35 92 08
# description: Starts Apache Solr
/var/www/html/fas/solr/solr-latest/bin/solr start
此脚本在命令行下工作,但在重新启动时不起作用。为了让它在重启时运行,我做了......
sudo systemctl enable solr-start
但是重启时 solr 没有启动。
我的版本: RHEL 7,Solr 6.6.6
【问题讨论】: