CentOS7 增加tomcat 啟動、停止(使用systemctl進行配置)
發(fā)布時間:2015-11-02 16:22:29 作者:佚名
我要評論

這篇文章主要介紹了CentOS7 增加tomcat 啟動、停止(使用systemctl進行配置),需要的朋友可以參考下
1,centos7 使用 systemctl 替換了 service命令
參考:redhat文檔:
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/sect-Managing_Services_with_systemd-Services.html#sect-Managing_Services_with_systemd-Services-List
查看全部服務命令:
systemctl list-unit-files --type service
查看服務
systemctl status name.service
啟動服務
systemctl start name.service
停止服務
systemctl stop name.service
重啟服務
systemctl restart name.service增加開機啟動
systemctl enable name.service
刪除開機啟動
systemctl disable name.service
其中.service 可以省略。
2,tomcat增加啟動參數(shù)
tomcat 需要增加一個pid文件
在tomca/bin 目錄下面,增加 setenv.sh 配置,catalina.sh啟動的時候會調(diào)用,同時配置java內(nèi)存參數(shù)。
#add tomcat pid
CATALINA_PID="$CATALINA_BASE/tomcat.pid"
#add java opts
JAVA_OPTS="-server -XX:PermSize=256M -XX:MaxPermSize=1024m -Xms512M -Xmx1024M -XX:MaxNewSize=256m"
3,增加tomcat.service
在/usr/lib/systemd/system目錄下增加tomcat.service,目錄必須是絕對目錄。
[Unit]
Description=Tomcat
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/data/tomcat/tomcat.pid
ExecStart=/data/tomcat/bin/startup.sh
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
[unit]配置了服務的描述,規(guī)定了在network啟動之后執(zhí)行。[service]配置服務的pid,服務的啟動,停止,重啟。[install]配置了使用用戶。
4,使用tomcat.service
配置開機啟動
systemctl enable tomcat
啟動tomcat
systemctl start tomcat
停止tomcat
systemctl stop tomcat
重啟tomcat
systemctl restart tomcat
因為配置pid,在啟動的時候會再tomcat根目錄生成tomcat.pid文件,停止之后刪除。
同時tomcat在啟動時候,執(zhí)行start不會啟動兩個tomcat,保證始終只有一個tomcat服務在運行。
多個tomcat可以配置在多個目錄下,互不影響。
參考:redhat文檔:
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/sect-Managing_Services_with_systemd-Services.html#sect-Managing_Services_with_systemd-Services-List
查看全部服務命令:
systemctl list-unit-files --type service
查看服務
systemctl status name.service
啟動服務
systemctl start name.service
停止服務
systemctl stop name.service
重啟服務
systemctl restart name.service增加開機啟動
systemctl enable name.service
刪除開機啟動
systemctl disable name.service
其中.service 可以省略。
2,tomcat增加啟動參數(shù)
tomcat 需要增加一個pid文件
在tomca/bin 目錄下面,增加 setenv.sh 配置,catalina.sh啟動的時候會調(diào)用,同時配置java內(nèi)存參數(shù)。
復制代碼
代碼如下:#add tomcat pid
CATALINA_PID="$CATALINA_BASE/tomcat.pid"
#add java opts
JAVA_OPTS="-server -XX:PermSize=256M -XX:MaxPermSize=1024m -Xms512M -Xmx1024M -XX:MaxNewSize=256m"
3,增加tomcat.service
在/usr/lib/systemd/system目錄下增加tomcat.service,目錄必須是絕對目錄。
復制代碼
代碼如下:[Unit]
Description=Tomcat
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/data/tomcat/tomcat.pid
ExecStart=/data/tomcat/bin/startup.sh
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
[unit]配置了服務的描述,規(guī)定了在network啟動之后執(zhí)行。[service]配置服務的pid,服務的啟動,停止,重啟。[install]配置了使用用戶。
4,使用tomcat.service
配置開機啟動
systemctl enable tomcat
啟動tomcat
systemctl start tomcat
停止tomcat
systemctl stop tomcat
重啟tomcat
systemctl restart tomcat
因為配置pid,在啟動的時候會再tomcat根目錄生成tomcat.pid文件,停止之后刪除。
同時tomcat在啟動時候,執(zhí)行start不會啟動兩個tomcat,保證始終只有一個tomcat服務在運行。
多個tomcat可以配置在多個目錄下,互不影響。
相關(guān)文章
Win10出現(xiàn)"Shell Infrastructure Host已停止工作"怎么辦?
有用戶在使用win10時就遇上了“Shell Infrastructure Host已停止工作”的提示,這是怎么回事?怎么解決呢?下面就看看解決Win10提示“Shell Infrastructure Host已停止工作2016-02-14Win8什么時候停止服務?Win8.1系統(tǒng)停止服務時間介紹
微軟繼停止winXP系統(tǒng)安全服務后,近日,又有媒體報道微軟將停止win8/win8.1系統(tǒng)安全補丁更新,那么,Win8停止服務時間是什么時候?對此,本文小編就為大家進行解答2016-01-12微軟下周(1月12日)將停止支持Win8 請速升級Win8.1或Win10
微軟宣布1月12日將停止支持IE8、IE9和IE10這三款瀏覽器。微軟也會在當天給這三款瀏覽器放出KB3123303補丁,安裝后用戶會看到升級瀏覽器的提醒。這個補丁將會給運行Windows72016-01-10Win7系統(tǒng)彈出Adobe Flash Player已停止工作窗口的解決方法
最近有用戶反映win7在瀏覽關(guān)于Falsh內(nèi)容的網(wǎng)頁時,經(jīng)常會彈出Adobe Flash Player已停止工作的提示框,或顯示“插件 Adobe Flash 已崩潰”,這是怎么回事呢?這種情況怎么辦2016-01-07Win8.1系統(tǒng)提示“公用外殼DLL已停止工作”的解決方法
最近有網(wǎng)友反映Win8.1系統(tǒng)測試游戲手柄的時候,突然出現(xiàn)提示公用外殼DLL已停止工作,這是什么情況呢?這種情況怎么辦呢?本文將提供Win8.1系統(tǒng)提示“公用外殼DLL已停止工作2015-12-31Win7/Win8.1設(shè)備即將停止銷售 2016年10月31日起實施
每個系統(tǒng)都有維護期,winxp已經(jīng)停止維護了,現(xiàn)在win7/8設(shè)備也即將停止銷售,最近微軟公布了最新的OEM系統(tǒng)生命周期,預裝win7的電腦于2014年10月31日停止銷售。另外,預裝Wi2015-11-03win8.1系統(tǒng)出現(xiàn)GWXUX.exe停止工作的解決辦法
win901電腦最近總是提示GWXUX.exe停止工作,雖然并不影響工作,但是總提示也覺得麻煩,于是找了一下原因,后來的事是因為微軟更新造成的,下面分享解決辦法,需要的朋友可2015-10-27- win8.1安裝CAD2006無法激活提示停止工作怎么辦?win8系統(tǒng)安裝cad2006沒有問題,但是沒辦法激活,總是出現(xiàn)停滯工作,每次進入激活界面時出現(xiàn)、Auto Cad application停止工作2015-10-19
windows主進程rundll32已停止工作的四種解決方法介紹
windows主進程rundll32已停止工作怎么辦?這個問題貌似很難啊,而且我電腦是經(jīng)常出現(xiàn),看來得解決了。 下面小編就為大家介紹四種解決方法,有需要的朋友可以參考一下哦2015-10-12WinXp系統(tǒng)死機/停止響應怎么辦?xp系統(tǒng)死機時自動重啟的方法
WinXp系統(tǒng)死機、停止響應怎么辦?本文將提供讓xp系統(tǒng)死機時自動重啟的方法供大家了解,希望對大家有所幫助2015-10-12