这是我的 systemd 服务的单元文件:
[Unit]
Description=Tunnel For %i
After=network.target
[Service]
User=autossh
ExecStart=/usr/bin/autossh -M 0 -N -o "ExitOnForwardFailure yes" -o "ConnectTimeout=1" -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -R 40443:installserver:40443 -R 8080:installserver:8080 tunnel@%i
Restart=always
[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)
该单元在 15 天前出现故障并且 systemd 没有重新启动它,尽管“Restart=always”在上面的单元文件中。
这里是这个服务的状态输出:
salt:/srv # systemctl status autossh@eins-work
autossh@eins-work.service - Tunnel For eins-work
Loaded: loaded (/etc/systemd/system/autossh@.service; enabled)
Active: failed (Result: start-limit) since Wed, 2016-02-10 14:33:34 CET; 2 weeks and 1 days ago
Main PID: 17980 (code=exited, status=0/SUCCESS)
CGroup: name=systemd:/system/autossh@.service/eins-work
Feb 10 14:33:34 salt systemd[1]: …Run Code Online (Sandbox Code Playgroud) 我的 inode 快用完了。只有11%可用:
the-foo:~ # df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/mapper/system-home 9830400 8702297 1128103 89% /home
Run Code Online (Sandbox Code Playgroud)
有没有办法在不创建和复制到新分区的情况下解决这个问题?
细节:
the-foo:~ # tune2fs -l /dev/mapper/system-home
tune2fs 1.42.6 (21-Sep-2012)
Filesystem volume name: <none>
Last mounted on: /home
Filesystem UUID: 55899b65-15af-437d-ac56-d323c702f305
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize
Filesystem flags: signed_directory_hash
Default mount options: user_xattr acl
Filesystem state: clean
Errors …Run Code Online (Sandbox Code Playgroud) 我们通过 SaltStack 部署和更改系统服务文件。
例如,如果文件/etc/systemd/system/superfoo.service被更改,则 systemd 会发出以下警告:
Warning: Unit file of superfoo.service changed on disk,
'systemctl --system daemon-reload' recommended.
Run Code Online (Sandbox Code Playgroud)
如何使用 salt-stack 自动执行此操作?
我收到“网关超时”
504:网关没有及时收到上游服务器或应用的响应。
我将 apache 与 mod_wsgi 版本 4.4.8 一起使用。
在 apache 错误日志中,我看到:
Timeout when reading response headers from daemon process 'md':
/home/user/mc/src/mc/mc/mc.wsgi
Run Code Online (Sandbox Code Playgroud)
wsgi 配置:
WSGIDaemonProcess md user=mc group=users threads=1 processes=4
maximum-requests=1000
request-timeout=600
python-home=/localhome/user/mc
WSGIScriptAlias /mc /home/mc/src/mc/mc/mc.wsgi
<Location "/mc/">
WSGIProcessGroup md
WSGIApplicationGroup %{GLOBAL}
Require all granted
</Location>
Run Code Online (Sandbox Code Playgroud)
超时发生在 100 秒后。
根据配置超时为 600 秒。
我不知道为什么会发生这种情况。它是可重复的。该错误是可重复的。对于特定的 URL,它每次都会发生。
第一步对我来说是:更好的错误信息。谁负责此消息“从守护进程读取响应头时超时”?
我收到了这样的公钥,我应该将它添加到 .ssh/authorized_keys:
---- BEGIN SSH2 PUBLIC KEY ----
Comment: "rsa-key-20190107"
AAAAB3NzaC1yc2EAAAABJQAAAQEAucNIPbPoaEqyBAKtk3LTfM/hiZlWomTdQEf7
zUI4LGz91aZYIZNpWGTAUZKuFLdIEsktxQTNwEJNWMe2QocqQWyPGA+xL08ZP7Xk
VEbVOyH0nQ3ZHptgmyH4y4+bbAWXAROL3078h2iwtsCO343VQKg1iSNvemnLafA5
9/RtkcCR8SxH+NEXcc8MwGOE9gLX2pph4bxrFz9R6yyw3oRGVLt4uU9BlD3+LXg1
plUzc2KZXEt8Zr04I0Fd865zyiB8Q+2ZEPvHf7MMaW66FRe4BXCI7LMh/voXi0C8
H4NDIu1GZr7dNxgbEO05ZnASMofpLDU6cq7LFVl0BQG8gt1hOw==
---- END SSH2 PUBLIC KEY ----
Run Code Online (Sandbox Code Playgroud)
我想我可以编辑这个文件vi并创建 .ssh/authorized_keys 所需的相应单行。
这是真的?
AFAIK 这个密钥是根据这个页面创建的:https : //winscp.net/eng/docs/guide_public_key
有没有办法将 PC 与 nextcloud 服务器同步,但无需桌面 GUI?
PC 启动后就会进行同步。即使用户尚未登录。
我知道nextcloudcmd。我可以运行一个 cron 作业并每 N 分钟调用一次“nextcloudcmd”。
但这并不好。
我真的更喜欢立即同步的解决方案(例如通过 inotify)。
这怎么可能做到呢?
我认为封装 nextcloudcmd 的 shell 脚本只是一种解决方法。
如果nextcloud不提供这个,那么我将使用seafile来做到这一点。请参阅:https://manual.seafile.com/deploy/start_seafile_at_system_bootup.html
我个人认为这很奇怪。GUI 可以做到这一点。我只是想要同样的东西,但没有 GUI。是的,我可以在“假”帧缓冲区 X 环境中运行 GUI……但是不行,那太脏了。
有没有办法像 docker 那样在 lxd 容器中进行端口转发?
我听到一些传言说没有简单的方法。
根据 lxd 的主页,这是他们的目标:
直观(简单、清晰的 API 和清晰的命令行体验)
对我来说,端口转发是一个重要的部分。
我不着急。如果计划在未来发布,这将是一个有效的答案。
我尝试为 autossh 创建一个可靠的 systemd 服务。
服务正常工作,但如果主机密钥发生变化,则服务处于正常状态(正在运行)。
如果隧道不起作用,我希望它处于“失败”状态。
这是我当前的 systemd 服务文件:
# Source is in srv/salt/tunnel/autossh\@.service
# which is a git repo.
# Don't edit /etc/systemd/system/autossh\@.service
[Unit]
Description=Tunnel For %i
After=network.target
[Service]
User=autossh
# https://serverfault.com/a/563401/90324
ExecStart=/usr/bin/autossh -M 0 -N -o "ExitOnForwardFailure yes" -o "ConnectTimeout=1" -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -R 40443:installserver:40443 -R 8080:installserver:8080 tunnel@%i
Restart=always
[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)
这是输出 systemctl status autossh@foo-work
salt:/srv # systemctl status autossh@foo-work
autossh@foo-work.service - Tunnel For foo-work
Loaded: loaded (/etc/systemd/system/autossh@.service; enabled)
Active: active (running) since Wed, …Run Code Online (Sandbox Code Playgroud) 我寻找一种可靠导出 journalctl 日志的方法。
我可以使用该--since=...选项,但这有点模糊。
在我的情况下,脚本会journalctl --output=json每十分钟调用一次。
我不想错过任何一行,并且(如果可能)我想避免重复行。
问这个问题几天后,我遇到了 RELP:https : //en.wikipedia.org/wiki/Reliable_Event_Logging_Protocol
如何解决递归目录管理不保留权限的问题?
我想将(本地)中的所有文件复制/monitoring/files/etc到/etc小黄人上。
copy_files_in_etc:
file.recurse:
- source:
- salt://monitoring/files/etc
- name: /etc
- template: jinja
Run Code Online (Sandbox Code Playgroud)
上面的代码片段有效,但我缺少某些文件的可执行位。
例如 /etc/cron.daily 中的脚本应该是可执行的。
解决这个问题最简单的方法是什么?
我搜索一种方法使与此表达式匹配的所有文件都可执行:
/etc/cron.(daily|hourly|monthly|weekly/)
Run Code Online (Sandbox Code Playgroud) systemd ×3
saltstack ×2
ssh ×2
apache2 ×1
chmod ×1
containers ×1
ext4 ×1
filesystems ×1
inode ×1
journalctl ×1
journald ×1
linux ×1
lxc ×1
lxd ×1
mod-wsgi ×1
nextcloud ×1
ssh-tunnel ×1
syslog ×1