一、存放路径
/etc/systemd/system二、service配置整理
2.1 zookeeper.service
[Unit]
Description=ZooKeeper ServiceAfter=syslog.targetAfter=network.target[Service]#使用shell脚本启动的要用forking模式Type=forkingUser=zookeeperGroup=zookeeper#脚本启动ExecStart=/usr/local/zookeeper/bin/zkServer.sh start /usr/local/zookeeper/conf/zoo.cfgExecStop=/usr/local/zookeeper/bin/zkServer.sh stop /usr/local/zookeeper/conf/zoo.cfgExecReload=/usr/local/zookeeper/bin/zkServer.sh restart /usr/local/zookeeper/conf/zoo.cfg#配置工作目录,解决zookeeper.out 权限问题
WorkingDirectory=/usr/local/zookeeper
[Install]WantedBy=default.target2.2 nexus.service
[Unit]
Description=nexus serviceAfter=syslog.targetAfter=network.target [Service]User=nexusGroup=nexus#使用shell脚本启动的要用forking模式Type=forkingLimitNOFILE=65536#脚本启动ExecStart=/usr/local/nexus/bin/nexus start [Install]WantedBy=multi-user.target2.3 jenkins.service
[Unit]
Description=jenkinsAfter=syslog.targetAfter=network.target[Service]User=jenkinsGroup=jenkinsType=simpleExecStart=/usr/bin/java -jar /usr/local/jenkins/jenkins.war --httpPort=9090Restart=always#配置环境变量Environment=JENKINS_HOME=/usr/local/jenkins/jenkins JAVA_ARGS="-Dorg.apache.commons.jelly.tags.fmt.timeZone=Asia/Shanghai"[Install]WantedBy=multi-user.target2.4 dubbo.service
[Unit]Description=dubbo-adminAfter=syslog.targetAfter=network.target[Service]User=dubboGroup=dubbo#直接启动用simple方式Type=simple#直接启动ExecStart=/usr/bin/java -jar /usr/local/dubbo/dubbo-admin.jar[Install]WantedBy=multi-user.target
2.5 gogs.service
[Unit]
Description=GogsAfter=syslog.targetAfter=network.targetAfter=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=65535Type=simpleUser=gitGroup=gitWorkingDirectory=/home/git/gogsExecStart=/home/git/gogs/gogs webRestart=alwaysEnvironment=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=fullPrivateDevices=yesPrivateTmp=yesNoNewPrivileges=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