When you start the master server, you can specify the replication strategy using the -defaultReplication flag. This flag defines how data is replicated across the cluster. Here's how you can set it:
- 000: no replication
- 001: replicate once on the same rack
- 010: replicate once on a different rack, but same data center
- 100: replicate once on a different data center
- 200: replicate twice on two different data center
- 110: replicate once on a different rack, and once on a different data center
For example, if you want each file to have two replicas across the three nodes, you would set the replication strategy to 002. Adjust your master command in the Docker Compose file on each node like this:
command: "master -ip=node01 -peers=node01:9333,node02:9333,node03:9333 -defaultReplication=002"
If you need to adjust replication settings after the cluster is up and running, you can either restart the master with new parameters, or use filer
to set replication rules for different buckets or directories.
Here’s how you might specify replication using the filer's REST API or through its directory structure:
- You can define custom replication rules for specific directories by creating or modifying the .buckets file inside a directory managed by SeaweedFS. This allows different directories to have different replication settings.
- The
filer
also supports adjusting replication through its API by specifying replication parameters when you create or modify files.
To apply a custom replication rule for a specific directory after the cluster has started, you might do something like this:
Use the filer to create a directory and specify a custom replication strategy:
curl -X PUT "http://node01:8888/path/to/directory?replication=002"
This sets the directory to replicate data across nodes using the 002 strategy.
https://github.com/seaweedfs/seaweedfs/wiki/SeaweedFS-in-Docker-Swarm