# docker_group **Repository Path**: istop/docker_group ## Basic Information - **Project Name**: docker_group - **Description**: 用来创建docker示例 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-06-14 - **Last Updated**: 2026-06-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Redis Cluster Project This project provides a Docker-based Redis cluster deployment solution, along with Python client connection examples. ## Project Overview This is a Redis cluster project that includes: - Redis cluster deployment using Docker Compose - Python Redis client utility class - Distributed lock implementation - Message queue operation examples - Various Redis data operation demonstrations ## Directory Structure ``` redis_group/ ├── cluster/ # Redis cluster configuration │ ├── config/ # Redis configuration files (ports 7000-7005) │ ├── docker-compose.yaml # Docker Compose configuration │ ├── start-cluster.ps1 # Start cluster script │ ├── stop-cluster.ps1 # Stop cluster script │ ├── gen-config.ps1 # Configuration generation script │ └── redis_conn_cluster_s1.py # Python Redis client ├── cluster-linux/ # Linux version cluster configuration │ ├── docker-compose.yaml │ ├── gen-config.sh │ ├── start-cluster.sh │ └── config/ └── cluster/test_redis_demo.py # Redis operation demonstration ``` ## Quick Start ### 1. Start the Redis Cluster **Windows:** ```powershell .\redis_group\cluster\start-cluster.ps1 ``` **Linux:** ```bash cd redis_group/cluster-linux chmod +x start-cluster.sh ./start-cluster.sh ``` ### 2. Stop the Cluster ```powershell .\redis_group\cluster\stop-cluster.ps1 ``` ## Python Usage Examples ### Connect to Redis ```python from redis_conn_cluster_s1 import RedisDB # Initialize connection redis_db = RedisDB() ``` ### Basic Operations ```python # String operations redis_db.set("key", "value") value = redis_db.get("key") # Set operations redis_db.sadd("myset", "member1", "member2") members = redis_db.smembers("myset") # Sorted set redis_db.zadd("myzset", {"score1": 1, "score2": 2}) ``` ### Distributed Lock ```python from redis_conn_cluster_s1 import RedisDistributedLock lock = RedisDistributedLock("lock_key", lock_value="unique_id") if lock.acquire(): try: # Critical section code pass finally: lock.release() ``` ### Message Queue ```python from redis_conn_cluster_s1 import RedisMsg # Consume messages msg = RedisMsg(consumer="consumer1", queue_name="myqueue", group_name="mygroup", msg_id="*", message=None) message = msg.get_message() msg.ack() # Acknowledge processing ``` ### Run Demonstration ```python from test_redis_demo import * demo_string_ops() demo_set_ops() demo_distributed_lock() ``` ## Configuration Details ### Cluster Port Configuration | Node | Port | |------|------| | Redis 1 | 7000 | | Redis 2 | 7001 | | Redis 3 | 7002 | | Redis 4 | 7003 | | Redis 5 | 7004 | | Redis 6 | 7005 | ### Environment Variables - `HOST_IP`: Set the Redis cluster host IP address ## Dependencies - Python 3.10+ - redis-py >= 4.0 - Docker & Docker Compose ## License Please refer to the LICENSE file in the project.