国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > CentOS > 正文

CentOS7 增加tomcat 啟動、停止(使用systemctl進行配置)

2020-07-08 12:52:26
字體:
來源:轉載
供稿:網友
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增加啟動參數
tomcat 需要增加一個pid文件
在tomca/bin 目錄下面,增加 setenv.sh 配置,catalina.sh啟動的時候會調用,同時配置java內存參數。


復制代碼
代碼如下:

#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]配置了服務的描述,規定了在network啟動之后執行。[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在啟動時候,執行start不會啟動兩個tomcat,保證始終只有一個tomcat服務在運行。

多個tomcat可以配置在多個目錄下,互不影響。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 永靖县| 黄龙县| 甘南县| 固阳县| 桂平市| 津市市| 吴桥县| 大英县| 攀枝花市| 大宁县| 女性| 新龙县| 和静县| 建水县| 阿坝县| 晋江市| 栾城县| 云南省| 沙河市| 上高县| 祁连县| 宣武区| 遵化市| 安新县| 清苑县| 保德县| 鄂尔多斯市| 四川省| 临朐县| 济源市| 卢湾区| 平乡县| 大新县| 莱阳市| 申扎县| 黄骅市| 洞口县| 永宁县| 兴安盟| 盖州市| 玛沁县|