CentOS7 增长tomcat 启动,中止,使用systemctl进行配置

1,centos7 使用 systemctl 替换了 service命令html

参考:redhat文档:java

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
centos

查看所有服务命令:
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 能够省略。tomcat

2,tomcat增长启动参数ide

tomcat 须要增长一个pid文件ui

在tomca/bin 目录下面,增长 setenv.sh 配置,catalina.sh启动的时候会调用,同时配置java内存参数。centos7

#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.servicerest

在/usr/lib/systemd/system目录下增长tomcat.service,目录必须是绝对目录。code

[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]配置了使用用户。server

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能够配置在多个目录下,互不影响。

相关文章
相关标签/搜索