像守护进程一样运行 solr
run solr like daemon
我尝试让 solr 在 /etc/init.d/solr 中作为启动脚本运行。
这是我从 How to start Solr automatically?
复制粘贴的脚本
#!/bin/sh
# Prerequisites:
# 1. Solr needs to be installed at /usr/local/solr/example
# 2. daemon needs to be installed
# 3. Script needs to be executed by root
# This script will launch Solr in a mode that will automatically respawn if it
# crashes. Output will be sent to /var/log/solr/solr.log. A PID file will be
# created in the standard location.
# Comments to support chkconfig on Red Hat Linux
# chkconfig: 2345 64 36
# Description: A very fast and reliable search engine.
# processname solr
# Source function library.
. /etc/init.d/functions
start () {
echo -n "Starting solr..."
# start daemon
daemon --chdir='/usr/local/solr/example' --command "java -jar start.jar" --respawn --output=/var/log/solr/solr.log --name=solr --verbose
RETVAL=$?
if [ $RETVAL = 0 ]
then
echo "done."
else
echo "failed. See error code for more information."
fi
return $RETVAL
}
stop () {
# stop daemon
echo -n "Stopping solr..."
daemon --stop --name=solr --verbose
RETVAL=$?
if [ $RETVAL = 0 ]
then
echo "done."
else
echo "failed. See error code for more information."
fi
return $RETVAL
}
restart () {
daemon --restart --name=solr --verbose
}
status () {
# report on the status of the daemon
daemon --running --verbose --name=solr
return $?
}
case "" in
start)
start
;;
status)
status
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $"Usage: solr {start|status|stop|restart}"
exit 3
;;
esac
exit $RETVAL
我按照上面的描述做了所有事情link。但是报错
service solr start
Starting solr.../etc/init.d/solr: Usage: daemon [+/-nicelevel] {program}
failed. See error code for more information.
正在阅读https://blog.hazrulnizam.com/create-init-script-centos-6/不明白为什么daemon写错了
这不起作用,因为 daemon
函数(来自 /etc/init.d/functions
)自 2010 年(发布脚本时)以来发生了变化,不再接受相同的参数。您将需要重写 daemon
行以接受当前支持的参数。
我查看了 CentOS 6 机器上的 daemon
函数,看来您可以替换这一行:
daemon --chdir='/usr/local/solr/example' --command "java -jar start.jar" --respawn --output=/var/log/solr/solr.log --name=solr --verbose
只有这个:
daemon "java -jar /usr/local/solr/example/start.jar"
(假设 solr
安装在 /usr/local/solr/example
)。
我尝试让 solr 在 /etc/init.d/solr 中作为启动脚本运行。 这是我从 How to start Solr automatically?
复制粘贴的脚本#!/bin/sh
# Prerequisites:
# 1. Solr needs to be installed at /usr/local/solr/example
# 2. daemon needs to be installed
# 3. Script needs to be executed by root
# This script will launch Solr in a mode that will automatically respawn if it
# crashes. Output will be sent to /var/log/solr/solr.log. A PID file will be
# created in the standard location.
# Comments to support chkconfig on Red Hat Linux
# chkconfig: 2345 64 36
# Description: A very fast and reliable search engine.
# processname solr
# Source function library.
. /etc/init.d/functions
start () {
echo -n "Starting solr..."
# start daemon
daemon --chdir='/usr/local/solr/example' --command "java -jar start.jar" --respawn --output=/var/log/solr/solr.log --name=solr --verbose
RETVAL=$?
if [ $RETVAL = 0 ]
then
echo "done."
else
echo "failed. See error code for more information."
fi
return $RETVAL
}
stop () {
# stop daemon
echo -n "Stopping solr..."
daemon --stop --name=solr --verbose
RETVAL=$?
if [ $RETVAL = 0 ]
then
echo "done."
else
echo "failed. See error code for more information."
fi
return $RETVAL
}
restart () {
daemon --restart --name=solr --verbose
}
status () {
# report on the status of the daemon
daemon --running --verbose --name=solr
return $?
}
case "" in
start)
start
;;
status)
status
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $"Usage: solr {start|status|stop|restart}"
exit 3
;;
esac
exit $RETVAL
我按照上面的描述做了所有事情link。但是报错
service solr start
Starting solr.../etc/init.d/solr: Usage: daemon [+/-nicelevel] {program}
failed. See error code for more information.
正在阅读https://blog.hazrulnizam.com/create-init-script-centos-6/不明白为什么daemon写错了
这不起作用,因为 daemon
函数(来自 /etc/init.d/functions
)自 2010 年(发布脚本时)以来发生了变化,不再接受相同的参数。您将需要重写 daemon
行以接受当前支持的参数。
我查看了 CentOS 6 机器上的 daemon
函数,看来您可以替换这一行:
daemon --chdir='/usr/local/solr/example' --command "java -jar start.jar" --respawn --output=/var/log/solr/solr.log --name=solr --verbose
只有这个:
daemon "java -jar /usr/local/solr/example/start.jar"
(假设 solr
安装在 /usr/local/solr/example
)。