无法在 Ubuntu 16.04 上启动 Redis 服务器

无法在 Ubuntu 16.04 上启动 Redis 服务器

我无法在 Ubuntu 16.04 上启动 redis 服务器。我通过这个安装的回购

我仔细检查了 systemd redis.service 文件,它看起来很好。它指向二进制文件。

Systemctl 状态

Redis-server.service - Advanced key-value store
   Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
   Active: inactive (dead) (Result: resources) since Fri 2018-05-25 22:08:43 EDT; 1min 3s ago
     Docs: http://redis.io/documentation,
           man:redis-server(1)
  Process: 29520 ExecStopPost=/bin/run-parts --verbose /etc/redis/redis-server.post-down.d (code=exited, status=0/SUCCESS)
  Process: 29515 ExecStop=/bin/kill -s TERM $MAINPID (code=exited, status=0/SUCCESS)
  Process: 29509 ExecStop=/bin/run-parts --verbose /etc/redis/redis-server.pre-down.d (code=exited, status=0/SUCCESS)
  Process: 29505 ExecStartPost=/bin/run-parts --verbose /etc/redis/redis-server.post-up.d (code=exited, status=0/SUCCESS)
  Process: 29500 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exited, status=0/SUCCESS)
  Process: 29496 ExecStartPre=/bin/run-parts --verbose /etc/redis/redis-server.pre-up.d (code=exited, status=0/SUCCESS)
 Main PID: 18177 (code=exited, status=1/FAILURE)

May 25 22:08:43 mysqlwebserv systemd[1]: Failed to start Advanced key-value store.
May 25 22:08:43 mysqlwebserv systemd[1]: redis-server.service: Unit entered failed state.
May 25 22:08:43 mysqlwebserv systemd[1]: redis-server.service: Failed with result 'resources'.
May 25 22:08:43 mysqlwebserv systemd[1]: redis-server.service: Service hold-off time over, scheduling restart.
May 25 22:08:43 mysqlwebserv systemd[1]: Stopped Advanced key-value store.
May 25 22:08:43 mysqlwebserv systemd[1]: redis-server.service: Start request repeated too quickly.
May 25 22:08:43 mysqlwebserv systemd[1]: Failed to start Advanced key-value store.

日志控制:

Subject: Unit redis-server.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit redis-server.service has failed.
--
-- The result is failed.
May 25 21:57:56 mysqlwebserv systemd[1]: redis-server.service: Unit entered failed state.
May 25 21:57:56 mysqlwebserv systemd[1]: redis-server.service: Failed with result 'resources'.
May 25 21:57:56 mysqlwebserv systemd[1]: redis-server.service: Service hold-off time over, scheduling restart.
May 25 21:57:56 mysqlwebserv systemd[1]: Stopped Advanced key-value store.
-- Subject: Unit redis-server.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit redis-server.service has finished shutting down.
May 25 21:57:56 mysqlwebserv systemd[1]: Starting Advanced key-value store...
-- Subject: Unit redis-server.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit redis-server.service has begun starting up.
May 25 21:57:56 mysqlwebserv run-parts[27649]: run-parts: executing /etc/redis/redis-server.pre-up.d/00_example
May 25 21:57:56 mysqlwebserv run-parts[27659]: run-parts: executing /etc/redis/redis-server.post-up.d/00_example
May 25 21:57:56 mysqlwebserv systemd[1]: redis-server.service: PID file /var/run/redis/redis-server.pid not readable (yet?) after start-post: No such file or directory
May 25 21:57:56 mysqlwebserv run-parts[27663]: run-parts: executing /etc/redis/redis-server.pre-down.d/00_example
May 25 21:57:56 mysqlwebserv run-parts[27674]: run-parts: executing /etc/redis/redis-server.post-down.d/00_example
May 25 21:57:56 mysqlwebserv systemd[1]: Failed to start Advanced key-value store.
-- Subject: Unit redis-server.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit redis-server.service has failed.
--
-- The result is failed.
May 25 21:57:56 mysqlwebserv systemd[1]: redis-server.service: Unit entered failed state.
May 25 21:57:56 mysqlwebserv systemd[1]: redis-server.service: Failed with result 'resources'.
May 25 21:57:57 mysqlwebserv systemd[1]: redis-server.service: Service hold-off time over, scheduling restart.
May 25 21:57:57 mysqlwebserv systemd[1]: Stopped Advanced key-value store.
-- Subject: Unit redis-server.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit redis-server.service has finished shutting down.
May 25 21:57:57 mysqlwebserv systemd[1]: redis-server.service: Start request repeated too quickly.
May 25 21:57:57 mysqlwebserv systemd[1]: Failed to start Advanced key-value store.
-- Subject: Unit redis-server.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit redis-server.service has failed.
--
-- The result is failed.
May 25 21:58:01 mysqlwebserv CRON[27696]: pam_unix(cron:session): session opened for user tyler by (uid=0)
May 25 21:58:01 mysqlwebserv CRON[27697]: (tyler) CMD (wget -q --no-check-certificate -O - http://23.226.233.137/gamepanel/startupdates.php >/dev/null 2>&1)
May 25 21:58:18 mysqlwebserv sudo[27730]: wh1t3rose : TTY=pts/3 ; PWD=/usr/local ; USER=root ; COMMAND=/bin/journalctl -xe
May 25 21:58:18 mysqlwebserv sudo[27730]: pam_unix(sudo:session): session opened for user root by wh1t3rose(uid=0)

Redis.service 文件

[Unit]
Description=Advanced key-value store
After=network.target
Documentation=http://redis.io/documentation, man:redis-server(1)

[Service]
Type=forking
ExecStart=/usr/bin/redis-server /etc/redis/redis.conf
PIDFile=/var/run/redis/redis-server.pid
TimeoutStopSec=0
Restart=always
User=redis
Group=redis
RuntimeDirectory=redis
RuntimeDirectoryMode=2755

ExecStartPre=-/bin/run-parts --verbose /etc/redis/redis-server.pre-up.d
ExecStartPost=-/bin/run-parts --verbose /etc/redis/redis-server.post-up.d
ExecStop=-/bin/run-parts --verbose /etc/redis/redis-server.pre-down.d
ExecStop=/bin/kill -s TERM $MAINPID
ExecStopPost=-/bin/run-parts --verbose /etc/redis/redis-server.post-down.d

UMask=007
PrivateTmp=yes
LimitNOFILE=65535
PrivateDevices=yes
ProtectHome=yes
ReadOnlyDirectories=/
ReadWriteDirectories=-/var/lib/redis
ReadWriteDirectories=-/var/log/redis
ReadWriteDirectories=-/var/run/redis
CapabilityBoundingSet=~CAP_SYS_PTRACE

# redis-server can write to its own config file when in cluster mode so we
# permit writing there by default. If you are not using this feature, it is
# recommended that you replace the following lines with "ProtectSystem=full".
ProtectSystem=true
ReadWriteDirectories=-/etc/redis

[Install]
WantedBy=multi-user.target
Alias=redis.service

答案1

  1. 彻底删除 redis-server

    sudo apt-get --purge remove redis-server
    
  2. 确保清理所有剩余的 redis 文件

    sudo rm -rf /etc/redis/dump.rdb
    
  3. 重新启动机器。
  4. 然后重新安装redis-server

    sudo apt-get update
    sudo apt-get install redis-server
    

答案2

在 16.04 中使用以下命令安装 redis

apt update
apt upgrade

最后是 redis 服务器

apt install redis-server

通过 redis 客户端检查你的安装,你应该看到以下内容

# redis-cli
127.0.0.1:6379>

相关内容