一、SeaweedFS
1. 搭建过程
1. 在主服务器上启动 master 服务
- 注意:主服务器需要预先开放
9333
端口和 19333
通讯端口。
nohup ./weed master -mdir=/root/seaweedfs/master -defaultReplication=001 &>> master.log &
2. 在主服务器上启动 volume 服务
nohup ./weed volume -dir=/root/seaweedfs/vol1 -max=100 -mserver="192.168.91.128:9333" -port=9444 -dataCenter=dc1 -rack=rack1 &>> volume1.log &
nohup ./weed volume -dir=/root/seaweedfs/vol2 -max=100 -mserver="192.168.91.128:9333" -port=9555 -dataCenter=dc1 -rack=rack1 &>> volume2.log &
3. 在备份服务器上启动 volume 服务
nohup ./weed volume -dir=/root/seaweedfs/vol1 -max=100 -mserver="192.168.91.128:9333" -port=9444 -dataCenter=dc1 -rack=rack1 &>> volume1.log &
nohup ./weed volume -dir=/root/seaweedfs/vol2 -max=100 -mserver="192.168.91.128:9333" -port=9555 -dataCenter=dc1 -rack=rack1 &>> volume2.log &
2. 调用服务
1. 文件上传首先需要请求 master 服务,去分配一个逻辑卷和 fid
curl http://192.168.91.128:9333/dir/assign?dataCenter=dc1
{"fid":"4,01383f079c","url":"192.168.91.128:9555","publicUrl":"192.168.91.128:9555","count":1}
curl http://192.168.91.128:9333/dir/assign?dataCenter=dc1&ttl=3m
2. 上传文件到指定的 volume 服务
curl -F file=@/root/seaweedfs/6.jpg http://192.168.91.128:9555/4,01383f079c
{"name":"6.jpg","size":1419763,"eTag":"82e9466dff7aeaf089f51819a51c99a2"}
curl -F file=@/root/seaweedfs/6.jpg http://192.168.91.128:9444/6,0db9810493
curl -F file=@/root/seaweedfs/8.mp4 http://192.168.91.128:9444/2,117114a811
curl -F file=@/e/app/xunlei/5.jpg http://192.168.91.128:9444/2,12260e077c
curl -F file=@/e/app/xunlei/7.mp4 http://192.168.91.128:9444/3,1388165830
3. 查看下载
http://192.168.91.128:9444/6,0db9810493
http://192.168.91.128:9444/6,0db9810493?width=100&height=20
wget http://192.168.91.128:9444/6,0db9810493
4. 删除指定的文件
curl -X DELETE http://192.168.91.128:9555/4,01383f079c
{"size":1419780}
二、FastDFS