您好,欢迎来到思海网络,我们将竭诚为您提供优质的服务! 诚征网络推广 | 网站备案 | 帮助中心 | 软件下载 | 购买流程 | 付款方式 | 联系我们 [ 会员登录/注册 ]
促销推广
客服中心
业务咨询
有事点击这里…  531199185
有事点击这里…  61352289
点击这里给我发消息  81721488
有事点击这里…  376585780
有事点击这里…  872642803
有事点击这里…  459248018
有事点击这里…  61352288
有事点击这里…  380791050
技术支持
有事点击这里…  714236853
有事点击这里…  719304487
有事点击这里…  1208894568
有事点击这里…  61352289
在线客服
有事点击这里…  531199185
有事点击这里…  61352288
有事点击这里…  983054746
有事点击这里…  893984210
当前位置:首页 >> 技术文章 >> 文章浏览
技术文章

CentOS7 增加tomcat 启动、停止

添加时间:2019-5-8 20:19:49  添加: 思海网络 
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]
Deion=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可以配置在多个目录下,互不影响。


关键字:CentOS、tomcat、服务 
分享到:

顶部 】 【 关闭
版权所有:佛山思海电脑网络有限公司 ©1998-2024 All Rights Reserved.
联系电话:(0757)22630313、22633833
中华人民共和国增值电信业务经营许可证: 粤B1.B2-20030321 备案号:粤B2-20030321-1
网站公安备案编号:44060602000007 交互式栏目专项备案编号:200303DD003  
察察 工商 网安 举报有奖  警警  手机打开网站