feat: add more

This commit is contained in:
Sun-ZhenXing
2025-10-06 21:48:39 +08:00
parent f330e00fa0
commit 3c609b5989
120 changed files with 7698 additions and 59 deletions

View File

@@ -0,0 +1,66 @@
# Valkey Cluster
[English](./README.md) | [中文](./README.zh.md)
This service deploys a Valkey cluster with 6 nodes (3 masters and 3 replicas).
## Services
- `valkey-node-1` to `valkey-node-6`: Six Valkey cluster nodes.
- `valkey-cluster-init`: Initialization service that creates the cluster.
## Environment Variables
| Variable Name | Description | Default Value |
| ------------------- | --------------------------- | ------------- |
| VALKEY_VERSION | Valkey image version | `8.0-alpine` |
| VALKEY_PASSWORD | Password for authentication | `passw0rd` |
| VALKEY_PORT_1-6 | Host ports for nodes | 7001-7006 |
| VALKEY_BUS_PORT_1-6 | Host ports for cluster bus | 17001-17006 |
Please modify the `.env` file as needed for your use case.
## Volumes
- `valkey_data_1` to `valkey_data_6`: Volumes for storing Valkey data for each node.
## Cluster Configuration
The cluster is configured with:
- **6 nodes**: 3 masters and 3 replicas
- **Replication factor**: 1 (each master has 1 replica)
- **Hash slots**: Automatically distributed across masters
- **Automatic failover**: Enabled
## Connection
Connect to the cluster using any Valkey/Redis client with cluster mode enabled:
```bash
# Using valkey-cli
valkey-cli -c -h localhost -p 7001 -a passw0rd
# Using redis-cli (compatible)
redis-cli -c -h localhost -p 7001 -a passw0rd
```
## Notes
- The `valkey-cluster-init` service runs once to create the cluster and then stops.
- If you need to recreate the cluster, remove all volumes and restart.
- For production, consider using at least 6 nodes on different machines.
- The cluster requires all nodes to be reachable from each other.
## Scaling
To add more nodes to the cluster:
1. Add new node services to `docker-compose.yaml`
2. Start the new nodes
3. Use `valkey-cli --cluster add-node` to add them to the cluster
4. Rebalance the hash slots if needed
## License
Valkey is licensed under the BSD 3-Clause License.