iT邦幫忙

2024 iThome 鐵人賽

DAY 24
0

先前在開發主機上所安裝的 Redis 雖然手動叫起來了,但是他的服務並未能正常執行。

問題說明

  • 當執行 sudo systemctl status redis-server 去重新啟動 redis server 時 ...
× redis-server.service - Advanced key-value store
     Loaded: loaded (/usr/lib/systemd/system/redis-server.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Tue 2024-10-08 15:48:24 UTC; 9s ago
   Duration: 628us
       Docs: http://redis.io/documentation,
             man:redis-server(1)
   Main PID: 233992 (code=exited, status=1/FAILURE)
        CPU: 36ms

Oct 08 15:48:24 ip-172-31-132-147 systemd[1]: redis-server.service: Scheduled restart job, restart counter is at 835.
Oct 08 15:48:24 ip-172-31-132-147 systemd[1]: redis-server.service: Start request repeated too quickly.
Oct 08 15:48:24 ip-172-31-132-147 systemd[1]: redis-server.service: Failed with result 'exit-code'.
Oct 08 15:48:24 ip-172-31-132-147 systemd[1]: Failed to start redis-server.service - Advanced key-value store.

手動修改項目

  1. 先去改 /etc/redis/redis.conf 在裡面把預設 Pidfile 建立位置,頂層多加上 /var 後,Supervisor 設定為 systemd
  2. /lib/systemd/system/redis-server.service 中,修改 [Service] 段中的 Type=forkingRestartSec=30PIDFile=/var/run/redis/redis-server.pid
  3. 從最上面的錯誤訊息的調查,我們得知 Start request repeated too quickly. 造成 Service 排程異常,於是便在 Service 中去修改重啟等待時間。
  4. 之後記得要 reload service / 你也可以 systemctl disable redis-server 再 systemctl enable redis-server 再 systemctl start redis-server 最後 systemctl status redis-server

結論

  • 理解 Service 也是從 debian package 裡面解壓縮,在安裝時被放進來的。

上一篇
【Day 23】 Build Debian Package - 1 / 套件打包與否?
下一篇
【Day 25】 MySQL on Ubuntu / Update Django settings
系列文
從一萬元開始交易:收割韭菜三十天,量化交易工具製作31
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言