發布時間:2024-01-24閱讀(12)
CentOS7開始,從/etc/init.d腳本改為了systemctl管理服務。今天主要記錄一下怎么把tomcat8加入systemd管理的步驟。
以下基于centos7.3進行測試驗證。
# cd /home/tomcat8090/bin# ls編輯 catalina.sh腳本文件
# vim catalina.sh
添加 CATALINA_PID=”/var/run/tomcat.pid”,如上圖
2、創建tomcat.service文件
# vim /usr/lib/systemd/system/tomcat.service
[Unit]Description=TomcatAfter=syslog.target network.target remote-fs.target nss-lookup.target[Service]Type=forkingEnvironment="JAVA_HOME=/usr/local/jdk"PIDFile=/home/tomcat8090/tomcat.pidExecStart=/home/tomcat8090/bin/startup.shExecReload=/bin/kill -s HUP $MAINPIDExecStop=/bin/kill -s QUIT $MAINPIDPrivateTmp=true[Install]WantedBy=multi-user.target3、設置為開機啟動
# systemctl enable tomcat.service
4.修改tomcat.service文件后需要執行下面命令使其生效:
# systemctl daemon-reload
5、維護命令
啟動tomcat服務
systemctl start tomcat.service設置開機自啟動
systemctl enable tomcat.service停止開機自啟動
systemctl disable tomcat.service查看服務當前狀態
systemctl status tomcat.service重新啟動服務
systemctl restart tomcat.service查看所有已啟動的服務
systemctl list-units --type=service后面會分享更多devops和DBA方面的內容,感興趣的朋友可以關注下~
歡迎分享轉載→http://www.avcorse.com/read-252290.html
Copyright ? 2024 有趣生活 All Rights Reserve吉ICP備19000289號-5 TXT地圖HTML地圖XML地圖