AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题

问题[daemon](server)

Martin Hope
Rody Oldenhuis
Asked: 2021-03-25 18:14:52 +0800 CST

Docker 守护进程在启动时忽略 daemon.json

  • 4

我的 Docker 守护进程似乎/etc/docker/daemon.json在启动时忽略了。

与这个问题类似,我在告诉 Docker 守护进程它不应该使用默认172.17.*范围时遇到了一些麻烦。该范围已被我们的 VPN 占用,并阻止通过该 VPN 连接的人员连接到运行 Docker 的服务器。

非常烦人的事情是,每次我重新启动服务器时,Docker 都会再次从 VPN 的范围内申请一个 IP,而不管我输入了什么/etc/docker/daemon.json。我必须手动发出

# systemctl restart docker

启动后直接在172.17.*网络上的人可以再次访问服务器之前。

这显然经常被遗忘,并导致许多问题票。

我的/etc/docker/daemon.json样子是这样的:

{
 "default-address-pools": [
   {
      "base": "172.20.0.0/16",
      "size": 24
   }
 ]
}

并获得这样的许可:

-rw-r--r--   1 root root   123 Dec  8 10:43 daemon.json

我什至不知道如何开始诊断这个问题;有任何想法吗?

为了完整性:

  • Ubuntu 18.04.5 LTS
  • Docker 版本 19.03.6,构建 369ce74a3c

编辑:输出systemctl cat docker:

# /lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service containerd.service
Wants=network-online.target
Requires=docker.socket
Wants=containerd.service

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always

# Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
# Both the old, and new location are accepted by systemd 229 and up, so using the old location
# to make them work for either version of systemd.
StartLimitBurst=3

# Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
# Both the old, and new name are accepted by systemd 230 and up, so using the old name to make
# this option work for either version of systemd.
StartLimitInterval=60s

# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity

# Comment TasksMax if your systemd version does not support it.
# Only systemd 226 and above support this option.
TasksMax=infinity

# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes

# kill only the docker process, not all processes in the cgroup
KillMode=process

[Install]
WantedBy=multi-user.target

sudo docker info(之后systemctl restart docker)的输出:

Client:
 Debug Mode: false

Server:
 Containers: 34
  Running: 19
  Paused: 0
  Stopped: 15
 Images: 589
 Server Version: 19.03.6
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 
 runc version: 
 init version: 
 Security Options:
  apparmor
  seccomp
   Profile: default
 Kernel Version: 4.15.0-140-generic
 Operating System: Ubuntu 18.04.5 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 16
 Total Memory: 47.16GiB
 Name: linuxsrv
 ID: <redacted>
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Username: <redacted>
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Registry Mirrors:
  http://172.16.30.33:6000/
 Live Restore Enabled: false

WARNING: No swap limit support
ubuntu boot daemon docker
  • 2 个回答
  • 2025 Views
Martin Hope
Alasdair
Asked: 2021-03-11 14:03:26 +0800 CST

如何在给定 PID 编号的情况下找到进程的 PID 文件?

  • 0

我正在尝试使用 Monit 来监视并在进程停止运行时发送有关进程的电子邮件警报,但我需要该进程的 PID 文件的位置。我可以使用htoporps命令找到 PID 编号,我认为从那里找到 PID 文件非常简单,但是在搜索 Google 和 StackExchange 之后,我没有找到任何可以回答我的问题的东西。

我知道这个线程:How to find the .pid file for a given process但发现它没有帮助。刚才给出的答案提到了 PID 文件的通常位置,它适用于 Redhat/CentOS 风格的系统。我正在使用 Ubuntu,并希望得到更具体的答案。给定PID号,是否没有返回PID文件路径的命令?

谢谢!

ubuntu monitoring process daemon monit
  • 1 个回答
  • 771 Views
Martin Hope
paullb
Asked: 2020-10-31 15:48:21 +0800 CST

设置自动重启 php 守护进程

  • 1

我有一个带有来自 Fuelphp 的环境变量的 php 脚本,我使用类似的命令运行FUEL_ENV=production php oil run task它,但我希望它作为一个守护进程运行,当它退出时会自动重新启动。它存在的主要原因是由于内存使用,任务处理大量数据并缓慢泄漏(正如 PHP 所倾向于的那样)

我试过了,但它使脚本陷入了一个我无法杀死的无限循环(所以甚至没有尝试过 nohup,因为我认为我不能杀死它)

while true; do FUEL_ENV=production php oil run task && break; done &

那么设置一个 PHP 脚本的最佳方法是什么,它会在它存在时自行重启。

php service daemon
  • 1 个回答
  • 305 Views
Martin Hope
Rinkana
Asked: 2020-10-13 10:20:35 +0800 CST

CentOS 8上systemd守护进程内的屏幕

  • 1

所以我想在 systemd 服务中运行 screen,这样我就可以在进程运行时(在守护进程内部)发出命令。请参阅问题末尾的示例,了解我希望能够做什么。

我目前拥有的:
ExecStart=/usr/bin/java -someArguments -jar server.jar一个以-running 作为守护进程 启动的 java 应用程序,其中 user:group 设置为“server”:“server”,以及“ProtectSystem=full”和类似的强化参数。这运行良好,没有问题。

但是,我想要: 与上面相同,但它在屏幕实例中运行。像这样的东西:
ExecStart=/usr/bin/screen -DmS aServer /usr/bin/java -someArguments -jar server.jar

后者拒绝启动,输出journalctl -xe告诉我:“无法执行命令:权限被拒绝”。但是,如果我自己在终端中执行此操作(与 ExecStart 中的命令相同),我可以从同一用户(服务器:服务器)启动屏幕会话。

我在网上找到了一个解决方案,上面写着:
# Uncomment this to fix screen on RHEL 8
ExecStartPre=+/bin/sh -c 'chmod 777 /run/screen'

但我本能地不喜欢 777 部分,我也不明白为什么每次守护程序启动时都需要运行它。

我基本上要问的是:如何让屏幕在 systemd 守护进程中工作?上述解决方案是个好主意,还是有更好的方法?


我希望能够做的例子:

  1. 有一个 systemd 计时器,ExecStartPre=/screen -p 0 -S -X eval 'stuff "save-all"\\015'其序列中有一个(或类似的)。
  2. ExecStop 期间的一系列命令,如上面的命令。
  3. 当我手动连接到 Linux 服务器(连接到屏幕实例)时,能够与进程交互。
gnu-screen chmod daemon systemd centos8
  • 2 个回答
  • 857 Views
Martin Hope
Bigbohne
Asked: 2020-01-24 05:09:59 +0800 CST

Docker 守护进程似乎忽略了 no_proxy 配置

  • 0

我正在尝试在公司代理(例如http://proxy.domain.name:3128 )后面设置一个 docker 守护进程,并希望守护进程在从本地注册表(例如 registry.domain.name )中提取图像时忽略代理

我有以下配置:

文件:/etc/systemd/system/docker.service.d/proxy.conf

[Service]
Environment="http_proxy=http://proxy.domain.name:3128"
Environment="https_proxy=http://proxy.domain.name:3128"
Environment="no_proxy="localhost,127.0.0.1,::1,*.domain.name"

做了systemctl daemon-reload并且systemctl restart docker

症状:Docker总是使用配置好的代理,忽略no_proxy

proxy daemon docker
  • 1 个回答
  • 1271 Views
Martin Hope
prgrm
Asked: 2017-03-07 05:28:07 +0800 CST

在 Linux 中杀死 Perl 进程

  • -1

我启动了一个运行脚本的 perl 进程,我想结束它,但不想结束其余的 perl 脚本。我如何定位它而不是其余的?

linux perl process daemon
  • 1 个回答
  • 3798 Views
Martin Hope
Shailesh Sutar
Asked: 2017-01-10 11:25:42 +0800 CST

个人服务的正常运行时间

  • 2

我在生产服务器上运行多个独角兽进程。现在我想检查我的服务的单个服务正常运行时间。例如,如果任何独角兽进程自动重启,它应该开始记录其正常运行时间。通过这种方式,我想计算自上次服务以来服务的正常运行时间start/restart/reload 注意:这里我不是在谈论服务器正常运行时间,可以通过使用uptime如下命令知道。

$ uptime
 19:11:25 up 2 days, 21:28,  1 user,  load average: 0.11, 0.09, 0.11

我想知道单个服务的正常运行时间,比如 nginx 的正常运行时间

有可能以某种方式知道吗?

linux ubuntu service daemon uptime
  • 1 个回答
  • 2935 Views
Martin Hope
Jasmine
Asked: 2016-12-20 04:58:10 +0800 CST

Systemd:在启动时运行 Python 脚本(virtualenv)

  • 11

我有一个 python 脚本,我通常使用以下命令运行它:

(environment) python run.py

我想在开始时运行这个脚本。(我正在使用 ubuntu)这是我的服务:

[Unit]
Description=My Script Service
After=multi-user.target

[Service]
Type=idle

ExecStart=/home/user/anaconda3/bin/python /home/user/space/run.py

[Install]
WantedBy=multi-user.target

顺便说一句,我无法运行此脚本,但我可以运行不在环境中的任何脚本。如何在启动时运行 python 脚本(virtualenv)?

sudo systemctl status user_sent
● user_sent.service - Mail Service
Loaded: loaded (/lib/systemd/system/user_sent.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since xxxxx 16:30:20 MSK; 3s ago
Process: 3713 ExecStart=/usr/bin/python run.py (code=exited,   status=200/CHDIR)
Main PID: 3713 (code=exited, status=200/CHDIR)
python daemon systemd virtualenv
  • 1 个回答
  • 31576 Views
Martin Hope
Antoine
Asked: 2016-10-26 07:30:03 +0800 CST

如何启动 let'schat (nodejs app) 作为守护进程?

  • 0

我已经在我的服务器上安装了“让我们聊天”。在文档中,他们说要启动应用程序

npm start

从安装应用程序的目录。

但我无法使用 systemd 启动它。我希望应用程序始终在线。所以如果我手动启动它就可以了

cd /MIDDLE/uow/lets-chat/ && /bin/npm start

但如果我从 systemd 配置 Execstart 中的行,则不会。我尝试使用同一行,我尝试使用 npm,我尝试使用 "node ./apps.js" :

ExecStart=/usr/bin/cd /MIDDLE/uow/lets-chat/ && /usr/local/bin/node /MIDDLE/uow/lets-chat/app.js 

(我尝试使用或不使用命令的绝对路径,但它没有任何改变)。

我不知道如何在我的 centos 中将这个应用程序作为守护进程启动。请问我该怎么办?

谢谢,

一个。

daemon systemd node.js npm
  • 1 个回答
  • 107 Views
Martin Hope
Luke
Asked: 2016-10-03 03:41:01 +0800 CST

将 Systemd 服务配置为以 root 访问权限运行

  • 46

我在 Raspbian Jessie 上使用 Systemd 设置了 node.js 应用程序形式的服务,它使用自己的用户帐户。但是,我发现该服务没有正确运行,因为它没有必要的权限。我安装的其中一个节点模块需要 root 访问权限。如果我使用 sudo 手动运行应用程序,一切正常。

有没有办法告诉 systemd 用 sudo 运行服务?

linux service daemon systemd
  • 4 个回答
  • 144521 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve