我想用redhat设置crate启动,所以我为crate写了一个systemd服务文件:
crate版本:1.1.2
以下是crate.service:
[Unit]
Description=crate daemon
After=network.target
[Service]
Type=forking
ExecStart=/usr/bin/su - hadmin -c '/home/hadmin/aisinofp/crate/bin/crate.sh start'
ExecStop=/usr/bin/su - hadmin -c '/home/hadmin/aisinofp/crate/bin/crate.sh stop'
Restart=always
[Install]
WantedBy=multi-user.target
crate.sh是:
#!/bin/bash
source /home/hadmin/myproject/conf/env.sh
if [ "$1" = "start" ]
then
$CRATE_HOME/bin/crate -d
elif [ "$1" = "stop" ]
then
pid=$(ps -ef|grep io.crate.bootstrap.CrateDB |grep jar |awk '{print $2}')
echo "KILLING cratedb PROCESS "$pid
kill -9 $pid
fi
env.sh是:
#!/bin/bash
# set ulimit
#ulimit -n 655360
export JAVA_HOME=/usr/java/default
export JRE_HOME=/usr/java/default
PATH=$JAVA_HOME/bin:$PATH
# environment for all Projects
export TD_BASE=/home/hadmin
export TD_HOME=$TD_BASE/myproject
export TD_DATA=$TD_BASE/data
# zookeeper environment
export ZOO_HOME=$TD_BASE/zookeeper
export ZOO_LOG_DIR=$ZOO_HOME/logs
PATH=$ZOO_HOME/bin:$PATH
# cratedb environment
export CRATE_HEAP_SIZE=4g
export CRATE_HOME=/home/hadmin/crate
PATH=$CRATE_HOME/bin:$PATH
# activemq environment
export activemq_data=/home/hadmin/data/activemq
export activemq_base=/home/hadmin/activemq
export activemq_conf=$activemq_base/conf
PATH=$activemq_base/bin:$PATH
export PATH
当我写完这些文件后,我开始使用“systemctl start crate.service”,但我在/ var / logs / message中收到了这样的消息:
我可以看到crate守护程序一直在重启,我不知道为什么它会在启动后被杀死
感谢
答案 0 :(得分:1)
Crate已经为使用systemd的Red Hat Linux提供了官方RPM包。无需编写自己的服务文件。