centos 7中以systemctl的方式来管理服务启动 在centos 7中以systemctl的方式来管理Tomcat启动方式
在/usr/lib/systemd/system/路径下新建一个名称为tomcat.service文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 vim /usr/lib/systemd/system/tomcat.service [Unit] Description=Apache Tomcat Web Application Container After=syslog.target network.target [Service] Type=forking Environment=JAVA_HOME=/data/server/java Environment=CATALINA_PID=/data/server/tomcat/tomcat.pid Environment=CATALINA_HOME=/data/server/tomcat Environment=CATALINE_BASE=/data/server/tomcat Environment='CATALINE_OPTS=-Xms1024M -Xmx2048M -server -XX:+UseParallelGC' Environment='JAVA_OPTS=-Djava.awt.haedless=true -Djava.security.egd=file:/dev/./urandom' ExecStart=/data/server/tomcat/bin/startup.sh ExecStop=/bin/kill -15 $MAINPID User=tomcat Group=tomcat [Install] WantedBy=multi-user.target
centos 7中以systemctl的方式来管理nginx服务
在/usr/lib/systemd/system/路径下新建一个名称为nginx.service文件
1 2 3 4 5 6 7 8 9 10 11 12 13 vim /usr/lib/systemd/system/nginx.service [Unit] Description=nginx - high performance web server After=network.target remote-fs.target nss-lookup.target [Service] Type=forking ExecStart=/data/server/nginx/sbin/nginx -c /data/server/nginx/conf/nginx.conf ExecReload=/data/server/nginx/sbin/nginx -s reload ExecStop=/data/server/nginx/sbin/nginx -s stop [Install] WantedBy=multi-user.target
在centos 7中以systemctl的方式来管理php-fpm服务 1 2 3 4 5 6 7 8 9 10 11 12 [Unit] Description=The PHP 7.1 FastCGI Process Manager After=network.target [Service] Type=simple PIDFile=/data/server/php/var/run/php-fpm.pid ExecStart=/data/server/php/sbin/php-fpm --nodaemonize --fpm-config /data/server/php/etc/php-fpm.conf ExecReload=/bin/kill -USR2 $MAINPID [Install] WantedBy=multi-user.target
在centos 7中以systemctl的方式来管理redis服务 1 2 3 4 5 6 7 8 9 10 [Unit] Description=Redis After=network.target [Service] ExecStart=/data/server/redis/bin/redis-server /data/server/redis/conf/redis.conf --daemonize no ExecStop=/data/server/redis/bin/redis-cli -h 127.0.0.1 -p 6379 shutdown [Install] WantedBy=multi-user.target
在centos 7中以systemctl的方式来管理zookeeper服务 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 [root@prod1-Bprod logs]# cat /usr/lib/systemd/system/zookeeper.service [Unit] Description=zookeeper.service After=network.target [Service] Type=forking Environment=ZOO_LOG_ DIR=/data/server/zookeeper/ Environment=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/data/server/jdk/bin:/root/bin:/data/server/jdk/bin:/data/server/zookeeper/bin ExecStart=/data/server/zookeeper/bin/zkServer.sh start /data/server/zookeeper/conf/zoo.cfg ExecStop=/data/server/zookeeper/bin/zkServer.sh stop /data/server/zookeeper/conf/zoo.cfg ExecReload=/data/server/zookeeper/bin/zkServer.sh restart /data/server/zookeeper/conf/zoo.cfg PIDFile=/data/server/zookeeper/zookeeper_server.pid User=root [Install] WantedBy=multi-user.target