Git Product home page Git Product logo

godfs's Introduction

godfs

Build Status go report card

   ____  ____  ____  _________
  / ___\/ __ \/ __ \/ ___/ __/ GoDFS::v2.0.0-dev
 / /_/\  /_/ / /_/ / /__/\ \   A distribute filesystem.
 \____/\____/____./_/______/   github.com/hetianyi/godfs

README | 中文文档

godfs 是一个用go实现的轻量,快速,简单易用的分布式文件存储服务器。

godfs 开箱即用,并对docker支持友好。

你可以在docker hub上下载最新镜像: https://hub.docker.com/r/hehety/godfs/

版本兼容表

特性

  • 快速, 轻量, 开箱即用, 友好的go API
  • 易于扩展,运行稳定
  • 低开销
  • 提供HTTP方式的下载和上传API
  • 支持文件断点下载
  • 跨站点资源保护
  • 支持不同平台下的编译运行: Linux, Windows
  • 更好地支持docker容器
  • 更好的文件迁移解决方案
  • 支持读写和只读文件节点
  • 文件组内自动同步
  • 支持访问令牌

安装

请先安装golang1.11+

以CentOS7为例.

从最新的源码构建:

git clone https://github.com/hetianyi/godfs.git
cd godfs
./make.sh
# Windows下直接点击 make.cmd 开始构建。

构建成功后, 会在bin 目录下生成一个可执行文件:

./bin/godfs

将构建成功的二进制文件安装到目录 /usr/bin:

./install.sh

启动tracker服务:

godfs tracker [options]

启动storage服务:

godfs storage [options]

启动agent服务:

godfs agent [options]

agent为新增节点角色,是storage server的代理,能够代理后端storage服务文件的上传下载,提供给前端服务一个统一的入口点,尤其在http协议下能够屏蔽组内文件同步的延时问题和下载容错问题。

上传文件:

# 已有tracker
godfs client upload /you/upload/file [--trackers <pass>@<host>:<port>[,<pass>@<host>:<port>]]
# 没有tracker服务器,也可以直接上传到指定的storage服务器
godfs client upload /you/upload/file [--storages <pass>@<host>:<port>[,<pass>@<host>:<port>]]

architecture

如果你想上传文件到指定的group,可以在命令行加参数-g <groupID>

你还可以用一个更酷的命令来上传一个文件夹下所有的文件:

godfs client upload * --trackers <trackers>

architecture

也可以使用 curl 来上传文件:

curl -F "file=@/your/file" "http://your.host:http_port/upload"

上传成功之后,服务器会返回一个json字符串:

{
    "accessMode":"public",
    "form":[
        {
            "index":1,
            "type":"file",
            "name":"f",
            "value":"fme_eval.msi",
            "size":1309757440,
            "group":"G01",
            "instanceId":"9de71d97",
            "md5":"71e55b30e36b1b8c3343270f86bb6234",
            "fileId":"CfzJHbO1MS84thD13PWEsLIURCw_ZZ7bIqPgpWFJxZ3Ad1cZFzTSL9AMP1CnCChK3Au9dqQ0ciAmdQ5Oaxgj0g"
        }
    ]
}

其中, form 是post表单中的所有字段的name-value信息,文件已被替换为上传之后的路径地址 如果你想上传文件到指定的group,可以在路径上加参数?group=<groupID>

# 下载文件
godfs client download CfzJHbO1MS84thD13PWEsLIURCw_ZZ7bIqPgpWFJxZ3Ad1cZFzTSL9AMP1CnCChK3Au9dqQ0ciAmdQ5Oaxgj0g --name 123.zip

Token的使用

token能够控制一个私有文件在一定时间内的可访问性。

token需要在后端根据secret自行生成,godfs只需要计算并匹配token,token携带的格式如下:

http://...?tk=&ts=

token计算:

md5(timestamp+filemd5+secret) ==> token

构建docker镜像:

cd godfs/docker
docker build -t godfs:latest .

推荐使用docker来运行godfs,最新的godfs的docker镜像可以在 docker hub 获取:

docker pull hehety/godfs

启动tracker服务器:

docker run -d --net host --name tracker hehety/godfs:2.0.0-dev \
godfs tracker \
--bind-address 0.0.0.0 \
--secret 123123 \
--data-dir /godfs/data

启动storage服务器:

docker run -d --net host --name s1  hehety/godfs:2.0.0-dev \
godfs storage \
--bind-address 0.0.0.0 \
--secret 123123 \
--data-dir /godfs/data \
--log-dir /godfs/logs \
--trackers [email protected]:11706 \
--preferred-network eth0

你可以使用docker的命令-e来覆盖配置文件中的相应配置。

客户端命令:

Usage: godfs [global options] command [command options] [arguments...]

Commands:

     tracker  start as tracker server
     storage  start as storage server
     client   godfs client cli
     help, h  Shows a list of commands or help for one command

Options:

   --version, -v  show version
   --help, -h     show help
说明:

godfs 2.0版本移除了sqlite数据库(在1.x中测试发现,sqlite数据库文件在大并发和大数据量的情况下可能会出现损坏和无法写入情况),使用boltdb来存储配置数据,使用gox包的set来存储文件id,简化的数据存储策略能够大幅提升随机写入性能。

godfs's People

Contributors

chaunceyjiang avatar hetianyi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

godfs's Issues

建议要能可以mount

要能可以mount就好了,就像普通磁盘可以挂载,可以取消,数据能自动同步,分布式

binlog同步时,dataset为什么要修改?

197f44b这个版本,svc/binlog_synchronizer.go文件中, watch方法250行,这里写了Binlog为什么要写dataset呢? 我理解的是,Binlog记录的是文件的元数据, dataset记录的是文件内容本身是否存在, 这里watch的方法的作用是找其他存储服务器同步文件的元数据而非文件内容本身, 文件内容的同步有svc/file_synchronizer.go下229行sync_file来完成, 是否在这里而非svc/binlog_synchronizer.go watch 250行 写dataset会更合理呢?

docker 在这有什么用

我使用docker 安装完, 容器启动 ,可以使用curl 来上传文件
但是怎么下载文件呢??
还是要在容器外在完整的安装一遍??

token问题

没看明白token如何使用,可否详细说明下,如何提交和获取呀

使用curl无法上传文件

curl -v -F "file=@/home/xxxx/tmpfiles/test.bin" "http://192.168.2.58:1024/upload/"

  • Hostname was NOT found in DNS cache
  • Trying 192.168.2.58...
  • Connected to 192.168.2.58 (192.168.2.58) port 1024 (#0)

POST /upload/ HTTP/1.1
User-Agent: curl/7.35.0
Host: 192.168.2.58:1024
Accept: /
Content-Length: 1048776
Expect: 100-continue
Content-Type: multipart/form-data; boundary=------------------------ae65b7cb65f4f67e

  • Recv failure: Connection reset by peer
  • Closing connection 0
    curl: (56) Recv failure: Connection reset by peer

[base_dao.go:58] error prepare db file: open source file failed

no db file。

安装一切都成功了,可是提示没有db file。

[root@localhost godfs]# /usr/local/godfs/bin/tracker -c /usr/local/godfs/conf/tracker.conf
INFO - 2019-10-21 19:31:06,340 [tracker.go:32] using config file: /usr/local/godfs/conf/tracker.conf
INFO - 2019-10-21 19:31:06,341 [base_dao.go:54] no db file found, init db file from template.

请问secret=OASAD834jA97AAQE761==是如何生成的?

你好,我安装并启动服务后,在上传文件的时候,无法通过校验。所以想请问一下secret=OASAD834jA97AAQE761==是如何生成的?是secret的原因吗?期盼回复,非常感谢!
下面是报错信息:
wx20190214-171056

docker部署api获取

docker 部署之后:

  1. tracker容器是-p 1022:1022
  2. storage容器是 -p 1024:1024 -p 80:8001

目前我是在单机,而且只有一个 stroage,为什么每次我上传是通过 stroage上传,下载也是通过 stroage 下载,那么 tracker 有什么作用?

只是做多个 stroage 之间的同步么?

如果是多个 storage 那么我该如何确定到底访问哪一个去上传/下载资源?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.