Setelah upgrade Fedora 40 ke Fedora 41, Fedora mengganti Redis dengan Valkey.

Untuk menjalankan Valkey, gunakan perintah

sudo systemctl start valkey
# output
Job for valkey.service failed because the control process exited with error code.
See "systemctl status valkey.service" and "journalctl -xeu valkey.service" for details.

untuk melihat error yang lebih detail jalankan systemctl status valkey.service

sudo systemctl status valkey
# output
× valkey.service - Valkey persistent key-value database
     Loaded: loaded (/usr/lib/systemd/system/valkey.service; disabled; preset: disabled)
    Drop-In: /usr/lib/systemd/system/service.d
             └─10-timeout-abort.conf, 50-keep-warm.conf
     Active: failed (Result: exit-code) since Sat 2024-11-23 11:27:59 WIB; 8s ago
 Invocation: c0bd4884e31d46648dc5e921f6e02eb3
    Process: 36912 ExecStart=/usr/bin/valkey-server /etc/valkey/valkey.conf --daemonize no --supervised systemd $OPTIONS (code=exited, status=1/FAILURE)
   Main PID: 36912 (code=exited, status=1/FAILURE)
   Mem peak: 2.1M
        CPU: 7ms
 
Nov 23 11:27:59 siding systemd[1]: Starting valkey.service - Valkey persistent key-value database...
Nov 23 11:27:59 siding valkey-server[36912]: *** FATAL CONFIG FILE ERROR (Version 8.0.1) ***
Nov 23 11:27:59 siding valkey-server[36912]: Can't open the log file: Permission denied
Nov 23 11:27:59 siding systemd[1]: valkey.service: Main process exited, code=exited, status=1/FAILURE
Nov 23 11:27:59 siding systemd[1]: valkey.service: Failed with result 'exit-code'.
Nov 23 11:27:59 siding systemd[1]: Failed to start valkey.service - Valkey persistent key-value database.

Bila dilihat dari pesan error tersebut, kita bisa melihat bagian “Can’t open the log file: Permission denied” yang terjadi karena Valkey tidak bisa menulis di direktori log yang sudah disetting.

Proses perpindahan dari Redis ke Valkey menggunakan script /usr/libexec/migrate_redis_to_valkey.sh, untuk versi saat ini script tersebut berisi

#!/usr/bin/sh
if [ -f /etc/redis/redis.conf ]; then
  cp /etc/redis/redis.conf /etc/valkey/valkey.conf
  mv /etc/redis/redis.conf /etc/redis/redis.conf.rpmsave
  chown valkey:root /etc/valkey/valkey.conf
  sed -i 's|^dir\s.*|dir /var/lib/valkey|g' /etc/valkey/valkey.conf
  echo "/etc/redis/redis.conf has been copied to /etc/valkey/valkey.conf.  Manual review of valkey.conf is strongly suggested especially if you had modified redis.conf."
fi
if [ -f /etc/redis/sentinel.conf ]; then
  cp /etc/redis/sentinel.conf /etc/valkey/sentinel.conf
  mv /etc/redis/sentinel.conf /etc/redis/sentinel.conf.rpmsave
  chown valkey:root /etc/valkey/sentinel.conf
  echo "/etc/redis/sentinel.conf has been copied to /etc/valkey/sentinel.conf.  Manual review of sentinel.conf is strongly suggested especially if you had modified sentinel.conf."
fi
if [ -d /var/lib/redis ]; then
  # cp could take a while, and this is a one-way move anyway
  mv /var/lib/redis/* /var/lib/valkey/
  # don't leave garbage behind, plus we check if this dir exists when running this script
  rm -rf /var/lib/redis
  chown -R valkey. /var/lib/valkey
  echo "On-disk redis dumps moved from /var/lib/redis/ to /var/lib/valkey"
fi
 
# TODO
# 1. expand logic to read current redis conf for the dir setting.  same for sentinel conf.  if not stock /var/lib/redis, don't do the mv.  redis and sentinel may be using two different paths.

bug ini terjadi karena script /usr/libexec/migrate_redis_to_valkey.sh tidak merubah lokasi file log untuk valkey file config di copy ke valkey.

Cek user valkey

$ id valkey 
uid=953(valkey) gid=954(valkey) groups=954(valkey)

Cek permission untuk folder log

$ sudo stat -c "%U %G %n" /var/log/{valkey,redis}
valkey valkey /var/log/valkey
redis redis /var/log/redis

Cek lokasi log yang disetting di Valkey

$ sudo grep logfile /etc/valkey/valkey.conf
logfile "/var/log/redis/redis.log"

Dari sini kita sudah menemukan alasan kenapa muncul error tersebut, karena valkey menggunakan lokasi log di /var/log/redis sementara lokasi tersebut hanya bisa diakses oleh user redis, solusinya ganti lokasi logfile menjadi

# dari
logfile "/var/log/redis/redis.log"
# menjadi
logfile "/var/log/valkey/valkey.log"

lalu restart Valkey

sudo systemctl restart valkey
sudo systemctl status valkey
# output
● valkey.service - Valkey persistent key-value database
     Loaded: loaded (/usr/lib/systemd/system/valkey.service; disabled; preset: disabled)
    Drop-In: /usr/lib/systemd/system/service.d
             └─10-timeout-abort.conf, 50-keep-warm.conf
     Active: active (running) since Sat 2024-11-23 11:38:54 WIB; 2s ago
 Invocation: e059330c68a14be1a25b223964b8b024
   Main PID: 41532 (valkey-server)
     Status: "Ready to accept connections"
      Tasks: 6 (limit: 73705)
     Memory: 3.2M (peak: 4.3M)
        CPU: 14ms
     CGroup: /system.slice/valkey.service
             └─41532 "/usr/bin/valkey-server 127.0.0.1:6379"
 
Nov 23 11:38:53 siding systemd[1]: Starting valkey.service - Valkey persistent key-value database...
Nov 23 11:38:54 siding systemd[1]: Started valkey.service - Valkey persistent key-value database.

Leave a comment

Your email address will not be published. Required fields are marked *