systemd

When should the option RemainAfterExit needs to be set true when creating new systemd services?

南楼画角 提交于 2019-12-04 00:26:33
问题 I am trying to write a few services. Some of them have 'type' option set to oneshot. But i am still confused when the option 'RemainAfterExit' needs to be set true. (not just that service needs to be active even after exiting). 回答1: Use RemainAfterExit=yes for services, which somehow change state of the system. When you want that state reverted, you just stop the service. Then you can start it again, but not without first stopping it. An example would be service which creates a flag in

Tomcat在Centos部署

≯℡__Kan透↙ 提交于 2019-12-03 22:36:52
创建用户 sudo useradd --system --home /opt/tomcat --shell /sbin/nologin --comment "tomcat user" --user-group tomcat 部署tomcat 解压安装包: tar -xvf apache-tomcat-9.0.21.tar.gz 移动解压包: sudo mv apache-tomcat-9.0.21 /opt/tomcat/apache-tomcat-9.0.21 创建软链接: sudo ln -s /opt/tomcat/apache-tomcat-9.0.21 /opt/tomcat/latest 分配目录用户者权限: sudo chown -R tomcat: /opt/tomcat 分配tomcat的bin目录执行权限: sudo sh -c 'chmod +x /opt/tomcat/latest/bin/*.sh' 配置systemd 检查jvm能够使用的最大内存: java -Xms16G -Xmx16G -version 配置systemd配置文件: vi /etc/systemd/system/tomcat.service 内容如下: [Unit] Description=Tomcat 9 servlet container After=network.target

systemd:在service文件中给Exec传入多个参数

有些话、适合烂在心里 提交于 2019-12-03 21:07:13
原问题是 这样 的: 答案是这样的: 此外在使用prometheus监控mongodb时需要安装prometheus-mongodb-exporter,过程中也发现这种用法: 看看service单元文件是怎么写的: cat /lib/systemd/system/prometheus-mongodb-exporter.service 内容如下: [Unit] Description=Prometheus exporter for MongoDB Documentation=https://github.com/dcu/mongodb_exporter [Service] Restart=always User=prometheus EnvironmentFile=/etc/default/prometheus-mongodb-exporter ExecStart=/usr/bin/prometheus-mongodb-exporter $ARGS [Install] WantedBy=multi-user.target 在看看这个 EnvironmentFile : cat /etc/default/prometheus-mongodb-exporter # Set the command-line arguments to pass to the server. ARGS='

zabbix监控ftp

泄露秘密 提交于 2019-12-03 20:08:36
[root@agent ~]# yum -y install vsftpd [root@agent ~]# systemctl start vsftpd [root@agent ~]# systemctl enable vsftpd Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service. 来源: https://www.cnblogs.com/ZCQ123456/p/11806157.html

Docker - Enable Remote HTTP API with SystemD and “daemon.json”

孤街醉人 提交于 2019-12-03 17:22:27
Disclaimer: On a old machine with Ubuntu 14.04 with Upstart as init system I have enabled the HTTP API by defining DOCKER_OPTS on /etc/default/docker . It works. $ docker version Client: Version: 1.11.2 (...) Server: Version: 1.11.2 (...) Problem: This does solution does not work on a recent machine with Ubuntu 16.04 with SystemD. As stated on the top of the recent file installed /etc/default/docker : # Docker Upstart and SysVinit configuration file # # THIS FILE DOES NOT APPLY TO SYSTEMD # # Please see the documentation for "systemd drop-ins": # https://docs.docker.com/engine/articles/systemd

How to get systemd to restart Rails App with Puma

守給你的承諾、 提交于 2019-12-03 16:58:51
问题 I've been struggling with this a week now and really can't seem to find an answer. I've deployed my Rails App with Capistrano. I use Puma as a server. When I deploy, everything works ok. The problem is to get Puma to start at reboot and/or when it crashes. To get the deployment setup, I've used this tutorial. I'm also using RVM. The problem I seem to get is to get the service to start Puma. Here's what I've used (service file): [Unit] Description=Puma HTTP Server After=network.target [Service

命令ls按文件大小来排序

99封情书 提交于 2019-12-03 15:29:54
有时候我们想按照文件的大小来排序,一直忘记,为此特记下如下操作 按照文件所占的大小从大开始排列 # ls -lS total 64 -rw-r--r-- 1 root root 55895 Nov 5 22:01 all.log -rw-r--r-- 1 root root 6356 Nov 5 22:35 all.tar.gz drwx------. 3 root root 17 Oct 25 16:22 systemd-private-27df22a4d93a4d489d3ac1494f38a459-httpd.service-MZGAp4 drwx------. 3 root root 17 Oct 25 16:07 systemd-private-27df22a4d93a4d489d3ac1494f38a459-mariadb.service-WL8NGJ drwx------ 3 root root 17 Nov 5 08:50 systemd-private-5cba973031874b1cac7c3ed4293a8422-httpd.service-CqimqR drwx------ 3 root root 17 Nov 5 08:50 systemd-private-5cba973031874b1cac7c3ed4293a8422-mariadb.service

DEVOPS技术实践_15:使用Docker作为Jenkins的slave

徘徊边缘 提交于 2019-12-03 15:24:27
前面实验了使用docker搭建一个jenkins,下面实验使用docker作为jenkins的slave节点 1. 环境准备 一个运行Docker的主机或者群集 Jenkins应该能访问互联网,方便安装插件。 Jenkins服务器能够和GitHub通信。 Jenkinss对Java所需要的Git,和Maven配置应该配置好。 一个Jenkins master. 2. 在Docker主机上开启远端的访问API 此处针对Docker 18.03 /etc/docker/daemon.json会被docker.service的配置文件覆盖,直接添加daemon.json不起作用。可以有如下几种设置: 直接编辑配置文件:Centos中docker daemon配置文件在/lib/systemd/system/docker.service,找到以下字段,在后面添加如下,注意,此处不能用”fd://”,否则报错 [Unit] Description=Docker Application Container Engine Documentation=https://docs.docker.com BindsTo=containerd.service After=network-online.target firewalld.service containerd.service Wants

maven构建docker镜像异常

大城市里の小女人 提交于 2019-12-03 14:48:22
由于没有配置ip+2375端口,导致每次跑的时候,都是连接本地的,一直会报错 [ERROR] Failed to execute goal com.spotify:docker-maven-plugin:0.4.5:build (server) on project web-service: Exception caught: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: org.apache.http.conn.HttpHostConnectException: Connect to localhost:2375 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1, localhost/fe80:0:0:0:0:0:0:1%1] failed: Connection refused -> [Help 1] 研究了几个小时,终于解决了。 客户端: 加上 -H tcp://0.0.0.0:2375 [root@topcheer system]# cat docker.service [Unit] Description=Docker Application Container

centos 安装ELK

☆樱花仙子☆ 提交于 2019-12-03 14:42:17
准备安装环境 由于本人的centos是通过虚拟机来进行安装的,为了本地电脑能够访问centos系统中的端口,则需要把防火墙进行关闭,通过以下方式进行关闭防火墙。 # vi /etc/sysconfig/selinux 改变SELINUX的值从enforcing 到disabled, 找到SELINUX改变它的值为disabled,SELINUX=disabled,修改完成进行保存。 保存完之后输入reboot命令进行重启。 接着查看防火墙是否被关闭 [root@localhost ~]# /usr/sbin/sestatus SELinux status: disabled [root@localhost ~]# getenforce Disabled 安装Java Jdk Elasticsearch 要求安装的版本是1.8的版本,下面我们是安装1.8的方式,通过Oracle网站下载Oracle jdk1.8. [root@localhost ~]# wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http:%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "https://download.oracle.com