I want to write a script that dumps my database and makes a backup of if. However I've faced a problem. I need to SAVE database and after that I need to copy a file to another location. The thing is, after I run a SAVE command with redis-cli, the file permissions are overwritten and set to -rw-rw----.
How to tell Redis to save the dump.rdb with another permissions?
I've found this answer: Changing default file permission on redis dump, it describes the same problem I'm facing, however setting umask didn't help in my case.
Answering my own question, thanks to the guys at Redis repository at Github.
Here's how I solved it:
sudo systemctl edit redis-server.service
In the editor, type;
[Service]
UMask=0002
And then run systemctl reenable redis-server.service and systemctl restart redis-server.
Related
I'm with this problem when I try to save to redis. Introducing the message below.
MISCONF Redis is configured to save RDB snapshots, but it's currently unable to persist to disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Red
The redis log file displays this:
Background saving started by pid 73
Write error saving DB on disk: Function not implemented
Has anyone ever experienced this?
I found the answer. You need to wsl 2 To find out the version run below command in PowerShell
wsl -l -v
If it is version 1, run the command below and open ubuntu again
wsl --set-version 2
More information: https://learn.microsoft.com/en-us/windows/wsl/install
I've got a Debian server running Redis and I'd like to run a second copy using a different port. There are plenty of guides explaining how to do it on Ubuntu and other flavours of Linux but I'm having a hard time translating those to Debian.
So far I've created a copy of the /etc/redis/redis.conf and have renamed it /etc/redis/redis_6380.conf. In the new file I've changed the name of the PID file, location of the log file, the listening port (to 3680) so that they do not conflict with the existing instance of Redis.
The problem I have is knowing which changes to make so that systemd can start the new instance.
I've made a duplicate of /lib/systemd/system/redis-server.service and called it redis-server-6380.service and have changed the EXECStart and PIDFile lines to point to the new files:
ExecStart=/usr/bin/redis-server /etc/redis/redis_6380.conf
PIDFile=/var/run/redis/redis-server_6380.pid
Doing:
systemctl enable redis-server-6380.service
results in:
Failed to enable unit: File /etc/systemd/system/redis.service already exists and is a symlink to /lib/systemd/system/redis-server.service
How do I fix this ? I'm guessing that I've missed out a vital step but I'm not that familiar with configuring systemd supervised processes on Debian.
The end of the redis-server unit file would say:
[Install]
WantedBy=multi-user.target
Alias=redis.service
Either remove that Alias, or make sure it would be unique.
Also: make sure your Redis instances would have their own database and log files.
I am creating some databases using PostgreSQL but I want to save them on an external hard drive due to lack of memory in my computer.
How can I do this?
You can store the database on another disk by specifying it as the data_directory setting. You need to specify this at startup and it will apply to all databases.
You can put it in postgresql.conf:
data_directory = '/volume/path/'
Or, specify it on the command line when you start PostgreSQL:
postgres -c data_directory='/volume/path/'
Reference: 18.2. File Locations
STEP 1: If postgresql is running, stop it:
sudo systemctl stop postgresql
STEP 2: Get the path to access your hard drive.
(if Linux) Find and mount your hard drive by:
# Retrieve your device's name with:
sudo fdisk -l
# Then mount your device
sudo mount /dev/DEVICE_NAME YOUR_HD_DIR_PATH
STEP 3: Copy the existing database directory to the new location (in your hard drive) with rsync.
sudo rsync -av /var/lib/postgresql YOUR_HD_DIR_PATH
Then rename the previous postgres main dir with .bak extension to prevent conflicts
sudo mv /var/lib/postgresql/11/main /var/lib/postgresql/11/main.bak
Note: my postgres version was 11. Replace in path with your version.
STEP 4: Edit postgres configuration file:
sudo nano /etc/postgresql/11/main/postgresql.conf
Change the data_directory line with:
data_directory = 'YOUR_HD_DIR_PATH/postgresql/11/main'
STEP 5: Restart Postgres & Check everything is working
sudo systemctl start postgresql
pg_lsclusters
Output should shows status as 'online'
Ver Cluster Port Status Owner Data directory Log file
11 main 5432 online postgres YOUR_HD_DIR_PATH/postgresql/11/main /var/log/postgresql/postgresql-11-main.log
Finally your can access your PostgresSQL with:
sudo -u postgres psql
You can try following the walkthrough here. This worked well for me and is similar to #Antiez's answer.
Currently, I am trying to do the same and the only conflict that I'm having at the moment is that it seems there is an issue with PostgreSQL's incremental backup and point-in-time recovery proccesses. I think it has something to do with folder permissions. If I try uploading a ~30MB csv to the postgres db, it will crash and the server will not start again because files cannot be written to the pg_wal directory. The only file in that directory is 000000010000000000000001 and does not move on to 000000010000000000000002 etc. while writing to a new table.
My stackoverflow post looking for a solution to this issue can be found here.
I recently installed Redis on OS X. I did an initial load of some objects, everything in this regard seems to be working perfectly.
I saved the data to dump.rdb and if I launch redis from this directory and don't use a redis.conf file everything goes according to plan.
The problem is that after settling in and setting up a redis.conf file in /etc/redis/ it seems to completely ignore the dbfilename and dir settings.
To be more clear. I created a data directory in: /Library/Redis_Data/.
In the redis.conf I set dbfilename dump.rdb and dir /Library/Redis_Data
If I launch: redis-server /etc/redis/redis.conf it simply refuses to load the dump.rdb.
I've run redis-cli and can read the config parameters get config dbfilename and get config dir and they return the correct values, but no data gets restored.
I also enabled AOF. The file appendonly.aof which resides in the same directory will be recreated if I delete it and start the server again.
Lastly...if I run save from the cli it will completely wipe out and create a new dump.rdb over my data.
Any thoughts?
FYI: redis server v=2.6.9 sha=00000000:0 malloc=libc bits=64
Thanks.
Solved:
Looking back this morning on this issue I managed to discover the problem.
I originally added my data without enabling appendonly mode. After this test load I setup my environment and decided it would be great to enable appendonly.
What I discovered is this. If you have data in the dump.rdb but the appendonly.aof file is empty and appendonly is turned on; Redis will ignore the dump.rdb instead assuming there is nothing to be done because the appendonly.aof transactions don't exist.
What I did: Turned off appendonly in the config file and restarted Redis with the normal directory setup. This then loaded the dump.rdb as per my config file. I then ran the command from redis-cli config set appendonly yes followed by save.
This then created the appendonly.aof file with all the transactions. Set appendonly back to yes in the config and all was right.
Cheers,
damnabit
Now the redis can not background save.
I just want to dump it and restart.
How could I dump the redis? I've always this error :
"Can't re-open the VM
swap file: /tmp/redis.swap. Exiting."
Delete the dump.rdb file. (or simply move it somewhere e.g ~/saved-rdb/., where redis-server won't find it.)
Start redis-server
Note: dump.rdb is your data. By deleting it you are starting fresh (meaning data lost).