add multi master option

Chris Lu 2018-06-13 00:49:11 -07:00
parent 44cb9cd602
commit 7aa2d1fa39
3 changed files with 15 additions and 52 deletions

@ -9,6 +9,8 @@ The changes are mostly for a new filer implementation.
3. added directory listing in both Cassandra and Redis
4. “weed mount” can work both read and write, with local caching, chunking
5. improved file listing web UI
6. in multi-master mode, starting master needs to specify full list of peers
7. in multi-master mode, starting filer or volume server needs to specify the full master list
Filer breaking changes:
1. the filer storage will not be compatible with old filer store.

@ -17,22 +17,20 @@ weed server -master.port=9335 -dir=./3 -volume.port=8082 \
-master.peers=localhost:9333,localhost:9334,localhost:9335
```
Or, you can use this "-peers" settings to add master servers one by one.
```bash
> weed server -master.port=9333 -dir=./1 -volume.port=8080
> weed server -master.port=9334 -dir=./2 -volume.port=8081 -master.peers=localhost:9333
> weed server -master.port=9335 -dir=./3 -volume.port=8082 -master.peers=localhost:9334
```
## How it works
The master servers are coordinated by Raft protocol, to elect a leader. The leader took over all the work to manage volumes, assign file ids. All other master servers just simply forward requests to the leader.
The master servers are coordinated by Raft protocol, to elect a leader. The leader takes over all the work to manage volumes, assign file ids. All other master servers just simply forward requests to the leader.
If the leader dies, another leader will be elected. And all the volume servers will send their heartbeat together with their volumes information to the new leader. The new leader will take the full responsibility.
During the transition, there could be moments where the new leader has partial information about all volume servers. This just means those yet-to-heartbeat volume servers will not be writable temporarily.
## Master Identifier
When specifying the peers, the peers are identified by the hostname or IP, and port.
The hostname or IP should be consistent with the value from "-ip" option when starting the master.
## Startup multiple master servers
Now let's start the master and volume servers separately, the usual way.
@ -40,15 +38,13 @@ Now let's start the master and volume servers separately, the usual way.
Usually you would start several (3 or 5) master servers, then start the volume servers:
```bash
weed master -port=9333 -mdir=./1
weed master -port=9334 -mdir=./2 -peers=localhost:9333
weed master -port=9335 -mdir=./3 -peers=localhost:9334
weed master -port=9333 -mdir=./1 -peers=localhost:9333,localhost:9334,localhost:9335
weed master -port=9334 -mdir=./2 -peers=localhost:9333,localhost:9334,localhost:9335
weed master -port=9335 -mdir=./3 -peers=localhost:9333,localhost:9334,localhost:9335
# now start the volume servers, specifying any one of the master server
weed volume -dir=./1 -port=8080
weed volume -dir=./2 -port=8081 -mserver=localhost:9334
weed volume -dir=./3 -port=8082 -mserver=localhost:9335
weed volume -dir=./1 -port=8080 -mserver=localhost:9333,localhost:9334,localhost:9335
weed volume -dir=./2 -port=8081 -mserver=localhost:9333,localhost:9334,localhost:9335
weed volume -dir=./3 -port=8082 -mserver=localhost:9333,localhost:9334,localhost:9335
```
These 6 commands will actually functioning the same as the previous 3 commands from the cheatsheet.
Even though we only specified one peer in "-peers" option to bootstrap, the master server will get to know all the other master servers in the cluster, and store these information in the local directory.

@ -61,41 +61,6 @@ curl "http://localhost:8888/javascript/?pretty=y&lastFileName=new_name.js&limit
```
### Move a directory
This is for embedded filer only.
Rename a folder is an O(1) operation, even for folders with lots of files.
```bash
# Change folder name from /javascript to /assets
> curl "http://localhost:8888/admin/mv?from=/javascript&to=/assets"
# no files under /javascript now
> curl "http://localhost:8888/javascript/?pretty=y"
{
"Directory": "/javascript/",
"Files": null,
"Subdirectories": null
}
# files are moved to /assets folder
> curl "http://localhost:8888/assets/?pretty=y"
{
"Directory": "/assets/",
"Files": [
{
"name": "new_name.js",
"fid": "3,034389657e"
},
{
"name": "report.js",
"fid": "7,0254f1f3fd"
}
],
"Subdirectories": null
}
```
# Delete a file
```bash
> curl -X DELETE "http://localhost:8888/assets/report.js"