一、存放路径

/etc/systemd/system

二、service配置整理

2.1 zookeeper.service

[Unit]

Description=ZooKeeper Service
After=syslog.target
After=network.target
[Service]
#使用shell脚本启动的要用forking模式
Type=forking
User=zookeeper
Group=zookeeper
#脚本启动
ExecStart=/usr/local/zookeeper/bin/zkServer.sh start /usr/local/zookeeper/conf/zoo.cfg
ExecStop=/usr/local/zookeeper/bin/zkServer.sh stop /usr/local/zookeeper/conf/zoo.cfg
ExecReload=/usr/local/zookeeper/bin/zkServer.sh restart /usr/local/zookeeper/conf/zoo.cfg

#配置工作目录,解决zookeeper.out 权限问题

WorkingDirectory=/usr/local/zookeeper

[Install]
WantedBy=default.target

2.2 nexus.service

[Unit]

Description=nexus service
After=syslog.target
After=network.target
 
[Service]
User=nexus
Group=nexus
#使用shell脚本启动的要用forking模式
Type=forking
LimitNOFILE=65536
#脚本启动
ExecStart=/usr/local/nexus/bin/nexus start
 
[Install]
WantedBy=multi-user.target

2.3 jenkins.service

[Unit]

Description=jenkins
After=syslog.target
After=network.target
[Service]
User=jenkins
Group=jenkins
Type=simple
ExecStart=/usr/bin/java -jar /usr/local/jenkins/jenkins.war --httpPort=9090
Restart=always
#配置环境变量
Environment=JENKINS_HOME=/usr/local/jenkins/jenkins JAVA_ARGS="-Dorg.apache.commons.jelly.tags.fmt.timeZone=Asia/Shanghai"
[Install]
WantedBy=multi-user.target

2.4 dubbo.service

[Unit]
Description=dubbo-admin
After=syslog.target
After=network.target
[Service]
User=dubbo
Group=dubbo
#直接启动用simple方式
Type=simple
#直接启动
ExecStart=/usr/bin/java -jar /usr/local/dubbo/dubbo-admin.jar
[Install]
Wan

tedBy=multi-user.target

2.5 gogs.service

[Unit]

Description=Gogs
After=syslog.target
After=network.target
After=mysqld.service
[Service]
# Modify these two values and uncomment them if you have
# repos with lots of files and get an HTTP error 500 because
# of that
###
#LimitMEMLOCK=infinity
#LimitNOFILE=65535
Type=simple
User=git
Group=git
WorkingDirectory=/home/git/gogs
ExecStart=/home/git/gogs/gogs web
Restart=always
Environment=USER=git HOME=/home/git
# Some distributions may not support these hardening directives. If you cannot start the service due
# to an unknown option, comment out the ones not supported by your version of systemd.
ProtectSystem=full
PrivateDevices=yes
PrivateTmp=yes
NoNewPrivileges=true
[Install]
WantedBy=multi-user.target

三、systemctl 基本操作

systemctl start zookeeper.service #启动服务

systemctl status zookeeper #查看服务状态

systemctl stop zookeeper.service #停止服务

systemctl daemon-reload #修改service文件后要重新加载

systemctl enable zookeeper.service  #加入开机自启动

systemctl disable zookeeper.service #取消开机自启动

systemctl list-unit-files |grep enabled #查看所有开机启动项目

四、启动日志查看

journalctl -u zookeeper.service

更多journalctl 使用方法详见参考文档

五、参考文档

https://blog.csdn.net/zstack_org/article/details/56274966