Can't find dump.rdb of redis - redis

I use the command
sudo locate *rdb
and I can see the following files
/snap/core/3440/usr/share/bash-completion/completions/xrdb
/snap/core/3604/usr/share/bash-completion/completions/xrdb
/snap/core/3748/usr/share/bash-completion/completions/xrdb
/usr/bin/xrdb /usr/lib/libreoffice/program/services.rdb
/usr/lib/libreoffice/program/types.rdb
/usr/lib/libreoffice/program/services/pyuno.rdb
/usr/lib/libreoffice/program/services/services.rdb
/usr/lib/libreoffice/program/types/offapi.rdb
/usr/lib/libreoffice/program/types/oovbaapi.rdb
/usr/share/bash-completion/completions/xrdb
/var/lib/docker/image/aufs/layerdb
But I don't have the dump.rdb file. Redis version is 4.0.1

Related

What is the default location for Redis AOF file for Ubuntu?

Background
Yesterday our machine crashed unexpectedly and our AOF file for Redis got corrupted.
Upon trying to start the service with sudo systemctl start redis-server we are greeted with the following logs:
Bad file format reading the append only file: make a backup of your
AOF file, then use ./redis-check-aof --fix
Research
Aparently this looks like a simple error to fix, just execute ./redis-check-aof --fix <filename>.
Except I don't have the smallest idea of where that file is.
I have searched the Github discussions for this issue, but unfortunately none provides me with the location for the file:
https://github.com/antirez/redis/issues/4931
The persistence documentation also doesn't make a mention of the location for this file:
https://redis.io/topics/persistence
Specs
These are the specs of the system where I am running Redis:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.3 LTS
Release: 16.04
Codename: xenial
Question
Where is located this file?
You have two choices:
Find the configure file for Redis, normally, it's named redis.conf. The dir and appendfilename configuration specify the directory and file name of the AOF file.
Connect to Redis with redis-cli, and use the CONFIG GET command to get the dir configuration, i.e. CONFIG GET dir. The AOF file should located under this directory.
The path is typically /var/lib/redis/appendonly.aof you will need to run sudo redis-check-aof --fix /var/lib/redis/appendonly.aof
in case if you use docker and append volume to /data then the path to appendonly.aof will be: /data/appendonly.aof
In my case, I was using docker. I started the redis server without using --appendonly yes, then it started without any issues. And then ran CONFIG GET dir like #for-stack said and got this output:
1) "dir"
2) "/data"
So I checked under the /data path and found the file appendonly.aof
Then I ran /usr/local/bin/redis-check-aof --fix /data/appendonly.aof to fix the issue.
I ran /path/redis-check-aof --fix /data/appendonly.aof to fix this.
Thanks all.

error while restoring dump.rdb

i had a backup from dump.rdb database in my last server and i just copied it with scp command to new server and i restore it like this :
service redis-server stop
cp -r /root/dump.rdb/ /var/lib/redis/
cd /var/lib/redis && chown redis:redis dump.rdb
service redis-server start
but after using the last command i got this error :
Job for redis-server.service failed because a configured resource limit was exceeded. See "systemctl status redis-server.service" and "journalctl -xe" for details.
as i know it maybe from redis version but i dont know what version is my Dump.rdb is for .
do you have any solution for this ?
at least i found this out that my redis version was lower than Database's Saved redis version .
you can load the lower redis databases on high versions but you can't lost higher versions in lower versions .
and when i use sudo apt-get install redis-server it just installs the lower versions of redis which is commited in ubuntu community .
so i installed the new one with the commands :
wget redis-4.0.8.tar.gz
tar -xzf redis-4.0.8.tar.gz
cd redis-4.0.8
make
make install
make test
then i have to edit redis.conf like this :
nano redis.conf
i set the database name like this :
dbfilename dump.rdb
and at least i set the database directory :
dir /var/lib/redis/
then press CTRL + X then Y then ENTER .
then use these commands :
cd src
redis-server
now just close the terminal without anything .
now reconnect and test :
redis-cli get PING
it have to treat like this :
127.0.0.1:6379> "PONG"

How to use redis with gearman for persistence

How can I use Gearman with redis for persistent queue?
I am trying to run it for centos7.
I have Gearman working.
On running
gearmand -h
I can see support for
libsqlite3,
Postgres,
libtokyocabinet and
MySQL.
I've installed hiredis using yum as per various forums although i cant figure out how to run it through terminal.
I downloaded tar file for gearman and tried running this command inside the gearman folder to no avail.
./configure --enable-FEATURE sql
To build gearmand with hiredis persistence queue you have to install libhiredis-devel on CentOS or libhiredis-dev on Debian/Ubuntu package.
Insure ./configure --enable-hiredis output contains
checking hiredis/hiredis.h usability... yes
checking hiredis/hiredis.h presence... yes
checking for hiredis/hiredis.h... yes
checking for main in -lhiredis... yes
To run gearmand with redis as queue type, run:
gearmand --verbose DEBUG --queue-type redis

Upgrade Redis cluster Ubuntu

I have installed redis cluster 3.0.0. But Want to upgrade it to 3.0.7. Can somebody tell me the steps to do it?
I don't want to loose any data. And don't want any downtime either.
Steps I did when upgrading from 2.9.101 to 3.0 release. I hope it will do for upgrading to 3.0.7 too.
Compile 3.0.7 from the source and start several instances with cluster enabled.
Let the 3.0.7 instances replicate the 3.0.0 instances as slave
Connect to each 3.0.7 instance and do a manual failover, then the 3.0.0 masters would become slaves after several seconds.
Wait for your application to connect to the new masters; also check the configuration files, and modify the entries to the new masters on your need
Remove those slaves
UPDATE : Docker approach
As it's probably unable to replacing the binary executable while the process is still alive, you could do it by run some Redis in docker.
First you should install docker on your machine and pull the Redis image, or pull a basic OS image and manually build Redis in it, whatever
Based on this image, you are supposed to
copy your current redis.conf into it
make sure the dir exists in the image (cluster-config-file could be the same for all the containers as they are saved individually in their own fs)
make sure the directory for logfile exists and is not the same as dir (we will later map this directory to the host)
leave port logfile anything you like, as they are specified when a container is started
commit the image as redis-3.0.7
Now launch a containerized Redis. I suppose your logfile is located in /var/log/redis/, this Redis binds :8000, and your config file in the image is /etc/redis/redis.conf
docker run -d --net=host -v /var/log/redis:/var/log/redis \
-p 8000:8000 -t redis-3.0.7 \
/usr/bin/redis-server /etc/redis/redis.conf \
--port 8000 \
--logfile /var/log/redis/redis_8000.log
Now you have a Redis 3.0.7 instance, and are ready to finish the rest steps in the previous part.

Redis "Fatal error, can't open config file 'restart'" after a crash

So after restarting my httpd redis crashed (due to the number of sudden requests sent via httpd and written on redis) and now when I try to restart redis on my centos 6.5 server I get the following error:
[root#host /]# /usr/sbin/redis-server restart
[1705] 17 Apr 00:30:49 # Fatal error, can't open config file 'restart'
I have also tried to login to redis using redis-cli and I get an error stating the connection to the server failed.
What options do I have to safely restart the server?
From the /src directory where you downloaded and unzipped your redis source, run the following. This is for RHEL based systems.
make install
# (OR)
sudo cp src/redis-server /usr/local/bin/
sudo cp src/redis-cli /usr/local/bin/