Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

How to free Redis memory usage

15 views
Skip to first unread message

Roger Xandri Elias

unread,
Apr 17, 2024, 12:16:57 PM4/17/24
to Sentilo
Hi,
We are using ralational agent, so we have whole our data in MySQL.
Our whole data is reaching 15Gb in Redis and increasing.

We would like to free Redis database, because it will be increasing for ever and ever.

I have tried 2 strategies to free Redis database: a simple FlushDB on redis-cli and
several configurations in Redis with maxmemory and maxmemory-policy parameters. Both with the same result: sensors became unrechables for HTTP PUT requests, with the following message:

{"code":404,"message":"Events associated with resources [xxxxxxx] have been rejected. See the error details to know about what went wrong in each case","errorDetails":["Sensor xxxxxxxxx] not found on Sentilo (404.1)."]}

That sensor is still showed on sentilo-catalog-web. You can ask for data with GET HTTP requests with empty response: {"observations":[]}. But shown message while trying to publish new values.

Any suggestion to free Redis memory usage?

Thanks in advance,
Roger

Roger Xandri Elias

unread,
Apr 18, 2024, 6:23:00 AM4/18/24
to Sentilo
I have already solved this situation.
I will write some notes on the process I followed, trying to help anyone else who can belong in similar case.
Most of steps (or main steps) have been taken from this forum.

El dia dimecres, 17 d’abril del 2024 a les 18:16:57 UTC+2, Roger Xandri Elias va escriure:

Roger Xandri Elias

unread,
Apr 18, 2024, 7:09:45 AM4/18/24
to Sentilo
1. Stop Redis and sentilo-server:
systemctl stop redis-server.service
systemctl stop sentilo-server.service

2. Do a backup of Redis BBDD:
cp /var/lib/redis/dump.rdb <your path>/dump.rdb.<current date>

3. Configure Redis propertly at /etc/redis/redis.conf. Set parameters:
maxmemory 8gb
maxmemory-policy volatile-ttl

4. Configure your sentilo.conf:
sentilo.redis.expire.key.seconds=7500000

5. Start Redis and Stop sentilo-server:
systemctl start redis-server.service
systemctl stop sentilo-server.service

6. Set Expiration value for all KEYS:
redis-cli –a <password> KEYS 'sdid:*' | awk '{printf "EXPIRE %s 60\n", $1}' | redis-cli -a <password> > expire.log

7. Use mongosh to syncronize Redis and MongoDB:
db.sensor.updateMany({},{$unset:{synchronized:""}},{multi:true});

8. Reboot server

I hope it helps
El dia dijous, 18 d’abril del 2024 a les 12:23:00 UTC+2, Roger Xandri Elias va escriure:
Reply all
Reply to author
Forward
0 new messages