0

So, I can get the directory of dump.rdb's location to change by using the dir option in redis.conf when I start it normally (just calling redis-server). If I want redis-server to run all of the time (I do) without needing a terminal window always open, I think I need to daemonize it. However, it doesn't seem this ever persists to the disk automatically and whenever the redis-server process ends (I've been ending it in testing by just running redis-cli shutdown or sometimes just killing the process with kill PID) and starts back up, all database changes are lost, which seems pretty bad if a crash or unexpected shutdown were to happen in the future. In the code that runs the processing of data (either python with redis-py or java with jedis), I can explicitly run bgsave(), but that saves dump.rdb in the directory that the code was run in and not where the dir option specifies in redis.conf

So, is there either another way to run redis-server without requiring a whole terminal window to stay open that allows what I want to do or is there a way to get the data to persist on disk in the proper directory when it's run as redis-server --daemonize yes or similar?

jimmyq
  • 13
  • 5

1 Answers1

0

You could put it on linux "background" using nohup. It does not need a terminal window to stay up and running. I don't know the daemonize option to give you an advice about that, but, see if it works for you:

nohup redis-server &> redis.log&

or

Set daemonize yes in the conf file and run:

redis-server path/to/redis.conf

Roberto Gonçalves
  • 3,186
  • 4
  • 13
  • 27
  • unfortunately this still causes the dump.rdb file to save in the directory where the code is run and not where I specify in redis.conf – jimmyq Aug 02 '17 at 22:35
  • That is interesting. @jimmyq try this: putting the daemonize option and pass the conf file as a parameter to redis-server ./redis-server /etc/redis.conf – Roberto Gonçalves Aug 02 '17 at 22:38
  • So, I had tried that, redis-server would immediately start up and then immediately shut down because it supposedly doesn't have permissions to write to the log file in /var/log/redis/redis.log (I even tried redirecting the logs to the current directory and also tried completely opening up the permissions to the /var/log/redis directory (would rather not open up permissions to the entire /var/log directory)). This does work with sudo priveleges though (fortunately). Would rather have this done normally, but that will work for now if no one else has another solution. Thank you – jimmyq Aug 02 '17 at 22:58
  • You could add your user to the group redis for resolving this sudo issue, if that is the problem. If the question was answered please confirm it. You're welcome ;) – Roberto Gonçalves Aug 02 '17 at 23:00
  • Adding the user isn't a good long-term option unfortunately for other reasons, but it didn't seem to work regardless. Doesn't complain about permissions, but doesn't even output anything and doesn't start the server (without sudo) – jimmyq Aug 02 '17 at 23:23
  • Well...so it is a something about the redis-server installation. Well, hope you solve this in the future. – Roberto Gonçalves Aug 02 '17 at 23:28