1、创建solr用户
useradd solr
2、设置solr-7.7.2目录拥有者
cd /usr/local/
chown -R solr:solr solr-7.7.2
3、在/etc/init.d/目录创建solr服务
cd /etc/init.d/
vi solr
solr文件内容:
#!/bin/sh # #chkconfig: 345 63 37 SOLR_INSTALL_DIR=/usr/local/solr-7.7.2 case "$1" in start|stop|restart|status) SOLR_CMD="$1" ;; *) echo "Usage: $0 {start|stop|restart|status}" exit esac su - solr -c "$SOLR_INSTALL_DIR/bin/solr $SOLR_CMD"
设置执行权限:
chmod 755 /etc/init.d/solr
服务命令:
service solr start // 启动服务 service solr restart // 重启服务 service solr stop // 关闭服务 service solr status // 查看状态
4、设置(关闭)开机启动
chkconfig solr on // 设置开机启动 chkconfig solr off // 关闭开机启动
补充:
1、消除Please install lsof as this script needs it to determine if Solr is listening on port 8983(否则service solr stop无法执行)
yum install -y lsof