Unable to locate redis.conf file after installing it using snap

Hi,

I am running redis on CentOS Linux release 7.9.2009 (Core) redis-cli 6.2.3 (git:e90e5640)

snap install redis
yum search snapcraft
yum install snapd
systemctl enable --now snapd.socket
ln -s /var/lib/snapd/snap /snap
snap install redis
systemctl status snap.redis.server.service
systemctl restart snap.redis.server.service
systemctl status snap.redis.server.service
cd /snap/redis/
cd snap/
ll /snap/redis/135/usr/bin/redis-server
cd /snap/
#ps aux | grep redis
root 5495 0.2 0.1 52952 10148 ? Rsl May17 2:37 /snap/redis/135/usr/bin/redis-server *:6379
/snap

ls -l

total 4
drwxr-xr-x 2 root root 114 May 17 11:50 bin
drwxr-xr-x 3 root root 32 May 17 11:50 core20
-r–r--r-- 1 root root 590 May 17 11:50 README
drwxr-xr-x 3 root root 32 May 17 11:50 redis
drwxr-xr-x 3 root root 34 May 17 11:50 snapd

I am unable to locate redis.conf to change the default parameters. Please suggest. Thanks in Advance.

Best Regards,

Kaushal

take a look into /var/snap/redis/current or /var/snap/redis/common where system config files are usually stored … you should also rather use snap status... and snap restart ... instead of the systemctl command …

@ogra I have logged into the CentOS Linux release 7.9.2009 (Core)

[root@~]#redis.cli --version
redis-cli 6.2.3 (git:e90e5640)

[root@~]# cd /var/snap/redis/
[root@redis]# ls
135 common current
[root@ redis]# ll
total 0
drwxr-xr-x 2 root root 22 May 18 15:51 135
drwxr-xr-x 2 root root 6 May 17 11:50 common
lrwxrwxrwx 1 root root 3 May 17 11:50 current -> 135
[root@redis]# pwd
/var/snap/redis
[root@ redis]# ls 135/
dump.rdb
[root@redis]# ls common/
[root@redis]# snap restart redis
Restarted.
[root@redis]# ps aux | grep redis
root 29566 3.5 0.1 52952 9896 ? Ssl 15:54 0:00 /snap/redis/135/usr/bin/redis-server *:6379
root 29589 0.0 0.0 112812 976 pts/0 S+ 15:54 0:00 grep --color=auto redis
[root@redis]#snap logs redis
2021-05-18T10:27:40Z redis.server[29851]: 29851:C 18 May 2021 15:57:40.251 # Warning: no config file specified, using the default config. In order to specify a config file use /snap/redis/135/usr/bin/redis-server /path/to/redis.conf
2021-05-18T10:27:40Z redis.server[29851]: 29851:M 18 May 2021 15:57:40.252 * Increased maximum number of open files to 10032 (it was originally set to 1024).
2021-05-18T10:27:40Z redis.server[29851]: 29851:M 18 May 2021 15:57:40.252 * monotonic clock: POSIX clock_gettime
2021-05-18T10:27:40Z redis.server[29851]: 29851:M 18 May 2021 15:57:40.253 * Running mode=standalone, port=6379.
2021-05-18T10:27:40Z redis.server[29851]: 29851:M 18 May 2021 15:57:40.253 # Server initialized
2021-05-18T10:27:40Z redis.server[29851]: 29851:M 18 May 2021 15:57:40.254 * Loading RDB produced by version 6.2.3
2021-05-18T10:27:40Z redis.server[29851]: 29851:M 18 May 2021 15:57:40.254 * RDB age 1 seconds
2021-05-18T10:27:40Z redis.server[29851]: 29851:M 18 May 2021 15:57:40.254 * RDB memory usage when created 0.77 Mb
2021-05-18T10:27:40Z redis.server[29851]: 29851:M 18 May 2021 15:57:40.254 * DB loaded from disk: 0.000 seconds
2021-05-18T10:27:40Z redis.server[29851]: 29851:M 18 May 2021 15:57:40.254 * Ready to accept connections
[root@redis]#

It says Warning: no config file specified, using the default config. In order to specify a config file use. Is there a way to locate the default config file as i could not see it in /var/snap/redis/current or /var/snap/redis/common

Please suggest further. Thanks in Advance.

Best Regards,

Kaushal

This is actually my solution to start the redis-server with my configuration file. I paste that part of my snapcraft.yaml

apps
  # redis service 
  redis-server:
     command: redis-server $SNAP/config/redis/redis.conf
     daemon: simple
     plugs: [network, network-bind]

# building redis 
redis:
   plugin: make
   source: https://github.com/antirez/redis.git
   source-tag: '6.0.5'
build-packages:
  - build-essential
make-install-var: 'PREFIX'

# set the custom redis configuration 
redis-customizations:
   plugin: dump
   source: redis/
 organize:
   config/*: config/redis/

where i’m copying my redis.conf file from a folder ./redis/config present in the project root. So the file is copied into the snapcraft lifecycle and the deamon is launched with the file passed as argument in command ( command: redis-server $SNAP/config/redis/redis.conf ) !!

well, $SNAP is a read-only file-system, if you need to make changes to the config it means you will actually have to re-build the snap and users will not be able to make their own adjustments to the config file at all …

what you should do here instead is to change your command to:

command: redis-server $SNAP_COMMON/redis.conf

and along with that change ship an install hook (in the sources snap/hooks/ directory) like:

#! /bin/sh

# if the file does not exist yet, copy it 
# from the read-only place to a writable one
[ -e "$SNAP_COMMON/redis.conf" ] || cp -a $SNAP/config/redis/redis.conf $SNAP_COMMON/

Good solution, thanks