哈喽,大家好,最近在处理solr在linux下安装时,遇到了这么一个问题,我们正常启动进入到solr的bin目录下直接solr start就直接启动了。但如果突然有天centos7服务器重启了,此时solr服务器也需要重启才能使用。
于是H哥在网上查找如何在linux下开机自启动solr服务命令,结果一无所获。于是尝试自己编写shell脚本,并加入开机启动项中。成功解决这一痛处。
言归正传,开始上干货:
首先,创建solr文件
cd /etc/init.d
vim solr
编写shell脚本
#!bin/bash
#chkconfig:2345 55 25
#processname:solr
#description:solr server
prog=/usr/local/solr-7.7.2/bin/solr
start(){
$prog start -p 9090 -force
echo "正在启动服务...."
}
stop(){
$prog stop -all
echo "正在停止服务...."
}
status(){
echo "正在查看状态...."
}
restart(){
stop
start
}
case "$1" in
"start")
start
;;
"stop")