Redis data lost after server restart - linux

I have configured Redis to use RDB persistence method to save data every second if single write (save 1 1) but still after restart I see the key value as nil.

Well I found that the Redis I used to start was with the command: redis-server &
This command is used to start every time with new key in database, so the data stored in snapshot and AOF files was ignored.
I changed the configuration to start the redis server with the correct path to database files and started the server with following command and its working fine now: /etc/init.d/redis_port start

Related

Mongo watch change stream suddenly stopped working

I'm using mongo watch() to subscribe to change stream events. I've noticed that the change stream events automatically stopped without throwing any specific error and become idle. Then have to restart the server to listen to the change stream again.
I'm not able to find out the specific reason for this strange behavior.
We are using Nodejs server. mongoose for db connection and watch.
If any one of you faced the same issue please guide me on that. We have 1 primary node and 2 secondary node cluster and hosted in mongodb atlas.
The collection.watch(...) method has to be called on the collection on every server restart. Common mistake is to call it once upon the creation of the collection. However, the database does not maintain reference to the result of this call as it does for other calls such as the collection.createIndexes(...).
Change streams only notify on data changes that have persisted to a majority of data-bearing members in the replica set. This ensures that notifications are triggered only by majority-committed changes that are durable in failure scenarios.
Change stream events stop working when a node fails in a replica set

Change a redis password without external downtime

I would like to refresh redis server password. The issue is that there are some external services using it so until I propagate this change thing will eventually stop working.
From my research I have only seen the requirepass command + the server restart, but this has downtime.
With other databases like Postgres, I would create new user-password, migrate permissions, change at application level and then invalidate the previous access.
How can I do this process in redis?
You can change the password without downtime by issuing:
redis> CONFIG SET requirepass <your new password>
To persist the changes for next restart, edit your .conf file or issue a CONFIG REWRITE.

Update SQLite database without restarting application

I have an NodeJS application that run on a production server with forever.
That application use a third-party SQLite database which is updated every morning with a script triggered by a cron, who download the db from an external FTP to the server.
I spend some time before realising that I need to restart my server every time the file is rapatriated otherwise there is no change in the data used by my application (I guess it's cached in memory at starting).
// sync_db.sh
wget -l 0 ftp://$REMOTE_DB_PATH --ftp-user=$USER --ftp-password=$PASSWORD \
--directory-prefix=$DIRECTORY -nH
forever restart 0 // <- Here I hope something nicer...
What can I do to refresh the database without restarting the app ?
You must not overwrite a database file that might have some open connection to it (see How To Corrupt An SQLite Database File).
The correct way to overwrite a database is to download to a temporary file, and then copy it to the actual database with the backup API, which takes care of proper transactional behaviour. The simplest way to do this is with the sqlite3 command-line shell:
sqlite3 $DIRECTORY/real.db ".restore $DOWNLOADDIRECTORY/temp.db"
(If your application manually caches data, you still have to tell it to reload it.)

How to update shared MongoDB instance safely?

I'm trying to work out how I can establish what I think needs to be a write-lock on a Mongo database during application startup.
I've got a setup whereby we have several (in this diagram just 2) Node API's that establish a connection to a Mongo replica set. Upon startup I want to be able to run some scripts against Mongo if it's an old version. For example:
MongoDB: v1 schema
Node App: expecting v3 schema
So during startup the Node App will run v2Upgrade.js and v3Upgrade.js or similar. However, I want to ensure that only 1 Node app can run this at any one time. So 2 questions:
Am I thinking about this in the right way?
How would I best create some sort of lock, so only 1 process runs these updates before the database is "ready"?

Problems when trying to start the redis with dump.rdb file

I'm trying to start redis with a dump.rdb file on linux, but I get a core error. However, when I start on Windows with te same file, it runs perfectly. Also, if I try to start on this Linux machine with a smaller file, it seems that it starts.
Could it be a memory problem?
Thanks!
Amparo
i had the similar problem before and the reason is that the user "redis" do not have the write authority in the folder of "dump.rdb".bgsave is the default way to backup data to disk in redis. so i run the code " config set stop-writes-on-bgsave-error no" in redis.cli and the problem be fixed.what's more,you also can change the folder of the "dump.rdb" in redis.conf.

Resources