Connect to a Redis cluster with Python

To connect to a Redis server with Python, one can use python3-redis module. First verify that python3-redis module is installed. I’m showing the package name in Fedora 39, if you use a different distro, then check for the relevant package name. $ rpm -q python3-redis python3-redis-4.3.3-1.el9.noarch Here is the sample code to connect to a non-cluster Redis server: import redis # Connect to Redis r = redis.Redis(host='10.97.147.175', port=6379) # Set a key-value pair r....

April 3, 2024 · 1 min · 191 words · kenno

How to Run Redis in Podman Container

This is just a quick note on how to run Redis as a container using Podman on Ubuntu 22.04 (i.e. there will be no mention about SELinux.) Create a persistent volume for the Redis container I like storing all data/volume for containers under /srv/data. So I’ll create a sub-directory called redis-data under the same location. # mkdir -p /srv/data/redis-data Pull the Redis image # podman pull docker.io/redis Create and run the Redis container # podman run -d --name redis_server \ -v /srv/data/redis-data:/var/redis/data \ -p 6379:6379 redis Create systemd service for the Redis container I like creating a systemd service to enable/start the container....

February 22, 2023 · 1 min · 189 words · kenno