我无法启用或禁用用户服务:无法执行操作:没有此类文件或目录


18

我想在Eclipse中调试/测试使用Redis服务器的程序,因此我决定将服务器转换为用户服务以具有运行它的特权。让我困扰的是我可以启动或停止该服务,但无法启用/禁用它。

我得到的错误是:

Failed to execute operation: No such file or directory

原始的/ usr / lib / systemd / system:

[Unit]
Description=Advanced key-value store
After=network.target

[Service]
User=arkos
ExecStart=/usr/bin/redis-server /etc/arkos/arkos-redis.conf
ExecStop=/usr/bin/redis-cli shutdown

[Install]
WantedBy=multi-user.target

编辑并移至/ usr / lib / systemd / user:

[Unit]
Description=Advanced key-value store

[Service]
ExecStart=/usr/bin/redis-server /etc/arkos/arkos-redis.conf
ExecStop=/usr/bin/redis-cli shutdown

[Install]
WantedBy=default.target

Systemctl状态:

�� arkos-redis.service - Advanced key-value store
   Loaded: loaded (/usr/lib/systemd/user/arkos-redis.service; disabled; vendor preset: enabled)
   Active: active (running) since Tue 2015-08-25 09:19:25 UTC; 1min 55s ago
  Process: 644 ExecStop=/usr/bin/redis-cli shutdown (code=exited, status=1/FAILURE)
 Main PID: 736 (redis-server)
   CGroup: /user.slice/user-1000.slice/user@1000.service/arkos-redis.service
           ������736 /usr/bin/redis-server *:0                        

Aug 25 09:19:25 arkos-vagrant redis-server[736]: |    `-._`-._        _.-'_.-'    |
Aug 25 09:19:25 arkos-vagrant redis-server[736]: `-._    `-._`-.__.-'_.-'    _.-'
Aug 25 09:19:25 arkos-vagrant redis-server[736]: `-._    `-.__.-'    _.-'
Aug 25 09:19:25 arkos-vagrant redis-server[736]: `-._        _.-'
Aug 25 09:19:25 arkos-vagrant redis-server[736]: `-.__.-'
Aug 25 09:19:25 arkos-vagrant redis-server[736]: 736:M 25 Aug 09:19:25.471 # Server started, Redis version 3.0.3
Aug 25 09:19:25 arkos-vagrant redis-server[736]: 736:M 25 Aug 09:19:25.472 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
Aug 25 09:19:25 arkos-vagrant redis-server[736]: 736:M 25 Aug 09:19:25.472 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
Aug 25 09:19:25 arkos-vagrant redis-server[736]: 736:M 25 Aug 09:19:25.472 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
Aug 25 09:19:25 arkos-vagrant redis-server[736]: 736:M 25 Aug 09:19:25.472 * The server is now ready to accept connections at /tmp/arkos-redis.sock

Journalctl:

Aug 25 09:19:25 arkos-vagrant redis-server[736]: 736:M 25 Aug 09:19:25.470 # You requested maxclients of 10000 requiring at least 10032 max file descrip
Aug 25 09:19:25 arkos-vagrant redis-server[736]: 736:M 25 Aug 09:19:25.470 # Redis can't set maximum open files to 10032 because of OS error: Operation 
Aug 25 09:19:25 arkos-vagrant redis-server[736]: 736:M 25 Aug 09:19:25.470 # Current maximum open files is 4096. maxclients has been reduced to 4064 to 
Aug 25 09:19:25 arkos-vagrant redis-server[736]: _._
Aug 25 09:19:25 arkos-vagrant redis-server[736]: _.-``__ ''-._
Aug 25 09:19:25 arkos-vagrant redis-server[736]: _.-``    `.  `_.  ''-._           Redis 3.0.3 (00000000/0) 64 bit
Aug 25 09:19:25 arkos-vagrant redis-server[736]: .-`` .-```.  ```\/    _.,_ ''-._
Aug 25 09:19:25 arkos-vagrant redis-server[736]: (    '      ,       .-`  | `,    )     Running in standalone mode
Aug 25 09:19:25 arkos-vagrant redis-server[736]: |`-._`-...-` __...-.``-._|'` _.-'|     Port: 0
Aug 25 09:19:25 arkos-vagrant redis-server[736]: |    `-._   `._    /     _.-'    |     PID: 736
Aug 25 09:19:25 arkos-vagrant redis-server[736]: `-._    `-._  `-./  _.-'    _.-'
Aug 25 09:19:25 arkos-vagrant redis-server[736]: |`-._`-._    `-.__.-'    _.-'_.-'|
Aug 25 09:19:25 arkos-vagrant redis-server[736]: |    `-._`-._        _.-'_.-'    |           http://redis.io
Aug 25 09:19:25 arkos-vagrant redis-server[736]: `-._    `-._`-.__.-'_.-'    _.-'
Aug 25 09:19:25 arkos-vagrant redis-server[736]: |`-._`-._    `-.__.-'    _.-'_.-'|
Aug 25 09:19:25 arkos-vagrant redis-server[736]: |    `-._`-._        _.-'_.-'    |
Aug 25 09:19:25 arkos-vagrant redis-server[736]: `-._    `-._`-.__.-'_.-'    _.-'
Aug 25 09:19:25 arkos-vagrant redis-server[736]: `-._    `-.__.-'    _.-'
Aug 25 09:19:25 arkos-vagrant redis-server[736]: `-._        _.-'
Aug 25 09:19:25 arkos-vagrant redis-server[736]: `-.__.-'
Aug 25 09:19:25 arkos-vagrant redis-server[736]: 736:M 25 Aug 09:19:25.471 # Server started, Redis version 3.0.3
Aug 25 09:19:25 arkos-vagrant redis-server[736]: 736:M 25 Aug 09:19:25.472 # WARNING overcommit_memory is set to 0! Background save may fail under low m
Aug 25 09:19:25 arkos-vagrant redis-server[736]: 736:M 25 Aug 09:19:25.472 # WARNING you have Transparent Huge Pages (THP) support enabled in your kerne
Aug 25 09:19:25 arkos-vagrant redis-server[736]: 736:M 25 Aug 09:19:25.472 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sy
Aug 25 09:19:25 arkos-vagrant redis-server[736]: 736:M 25 Aug 09:19:25.472 * The server is now ready to accept connections at /tmp/arkos-redis.sock

systemctl daemon-reload在移动/编辑文件后您跑了吗?
安德烈·伯瑞(AndréBorie)2015年

Answers:


4

就我而言,我是将systemd单元文件直接放在/etc/systemd/system/...文件夹下。将它们移至/lib/systemd/system,使用systemctl enable / disable命令解决了该问题。


2
自从我遇到这个问题已经很长时间了,但是我记得像这样的解决方案。
Folatt

1
在我的情况下,我从lib复制到etc,并起作用了
斯大林·吉诺

21

Symlink问题?

使用符号链接时,我收到了类似的错误消息。

显然systemd不遵循符号链接,解决方案只是复制或移动文件。

用户服务?

我认为您需要将--user以下单位添加到命令行中user/

sudo systemctl --user enable arkos-redis.service

2
这里也是符号链接问题。
cweiske '16

2
有趣。当我start提供服务时,它确实遵循了符号链接,但enable没有这样做
Michael Mrozek

您是对的,符号链接无效。我最终改为使用硬链接。
布莱斯·昆塔

1
好奇。我之所以使用符号链接,是因为它使我可以将服务文件作为项目的一部分进行git-manage,并且可以很好地启动和停止,但不能启用。限制很奇怪。
rosuav

从这里开始讨论为什么允许或禁止符号链接:bugzilla.redhat.com/show_bug.cgi?
id=955379#c14

1

尝试:

  • sudo touch /etc/init.d/arkos-redis

我有同样的问题。如果这样不起作用:

  • sudo strace systemctl enable arkos-redis

查找上次故障发生的位置。


0

我在Fedora 29上遇到过同样的问题。

替换为 After=network.target
Requires=network.target

令人沮丧的是,因为该文件显然位于此处,但似乎什么都不想看到它。systemd分析也没有失败。它只是在下显示为“坏” systemctl --list-unit-files


-1

当单元文件为时,在Redhat上收到此错误

Cannot send after transport endpoint shutdown
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.