【问题标题】:systemctl start not returning/exitingsystemctl start 不返回/退出
【发布时间】:2020-08-08 00:21:56
【问题描述】:

我正在尝试为 redis 启动一个服务文件,我已经阅读了很多关于将它作为 systemd 服务运行的帖子,但我不确定为什么会发生这种情况。

当我跑步时 sudo systemctl start redis-server.service 它不会返回/退出 - 只是坐在那里,光标闪烁,直到我 Ctrl-C。我已确认服务器已启动并正在运行,因此服务器似乎工作正常 - 我不确定为什么 systemctl start 永远不会退出。 Redis 旨在与 systemd 一起使用,并且使用参数 --supervised systemd 服务应该是 Type=notify。

我的服务文件是:

[Unit]
Description=Redis

[Service]
Type=notify
User=john
Group=john
ExecStart=/usr/local/bin/redis-server /home/john/redis/redis.conf --supervised systemd --daemonize no
ExecStop=/usr/local/bin/redis-cli shutdown
Restart=on-success
WorkingDirectory=/home/john/redis

[Install]
WantedBy=multi-user.target

redis.conf的内容是:

port              6379
save              60 1
bind              127.0.0.1
tcp-keepalive     300
dbfilename        dump.rdb
dir               ./
logfile           ./redis-server.log

【问题讨论】:

    标签: redis systemd


    【解决方案1】:

    似乎从 redis 版本 6 开始,它需要使用安装在 Ubuntu + Debian 上的 libsystemd-dev 包进行编译。请参阅此 GitHub 问题:https://github.com/redis/redis/issues/7284

    安装这个包并重新编译 redis 解决了这个问题。

    【讨论】:

    • 显然它使用pkg-config 来检查libsystemd 的存在,而我的Ubuntu Server 20.04 安装中没有它,如果您没有安装pkg-config,则在重新编译之前这样做apt install pkg-config .
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-10
    • 2019-11-18
    • 2022-01-09
    • 2015-05-29
    • 2020-01-04
    • 1970-01-01
    相关资源
    最近更新 更多