树莓派3下seaweedfs docker镜像编译、测试

说明

  • 一直在寻找一个分布式文件存储的开源实现
  • 最好是go编写的 :)
    根据以上的两个条件在网上找到了seaweedfs。跟踪了有段时间了也结识了Chiho Sin,在群里看到他很耐心的解决各位朋友提出的各类问题。也想尝试着自己使用中的东西写出来。由于工作中用到很多第三方商用工具及知识产权问题不适用于开源,所以想通过开源工具尝试复现。正好最近在玩树莓派所以测试环境问题不愁了。顺便将Docker在上面搭建完成以便测试。树莓派3 HypriotOS安装
    测试环境:
  • 硬件:树莓派3
  • 系统:
Linux pi1 4.4.43-hypriotos-v7+ #1 SMP PREEMPT Thu Jan 19 20:54:06 UTC 2017 armv7l GNU/Linux
  • Docker:
Client:
 Version:      1.13.0
 API version:  1.25
 Go version:   go1.7.3
 Git commit:   49bf474
 Built:        Tue Jan 17 10:28:23 2017
 OS/Arch:      linux/arm
Server:
 Version:      1.13.0
 API version:  1.25 (minimum version 1.12)
 Go version:   go1.7.3
 Git commit:   49bf474
 Built:        Tue Jan 17 10:28:23 2017
 OS/Arch:      linux/arm
 Experimental: false

1.克隆seaweedfs源码

git clone https://github.com/chrislusf/seaweedfs

2.编辑Dockerfile文件进行树莓派所需Docker文件的准备

FROM armhf/alpine:3.4
RUN apk add --no-cache --virtual=build-dependencies --update curl wget ca-certificates && \
wget -P /tmp https://github.com/$(curl -s -L https://github.com/chrislusf/seaweedfs/releases/latest | egrep -o '/chrislusf/seaweedfs/releases/download/.*/linux_arm.tar.gz') && \
    tar -C /usr/bin/ -xzvf /tmp/linux_arm.tar.gz && \
    apk del curl wget ca-certificates build-dependencies && \
    rm -rf /tmp/*
EXPOSE 8080
EXPOSE 9333
VOLUME /data
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

3.编译

docker build -t sunsl/seaweedfs .

*这里注意我是直接在克隆chrislusf/seaweedfs代码的docker文件下执行的操作,你也可以先在pc机克隆代码后将docker文件夹拷贝到树莓派下运行。因为我已挂载一个synology的ntfs分区至树莓派所以我不担心存储空间问题:)

Sending build context to Docker daemon  5.12 kB
Step 1/8 : FROM armhf/alpine:3.4
 ---> eaed1e60f73c
Step 2/8 : RUN apk add --no-cache --virtual=build-dependencies --update curl wget ca-certificates &&     wget -P /tmp https://github.com/$(curl -s -L https://github.com/chrislusf/seaweedfs/releases/latest | egrep -o '/chrislusf/seaweedfs/releases/download/.*/linux_arm.tar.gz') &&     tar -C /usr/bin/ -xzvf /tmp/linux_arm.tar.gz &&     apk del curl wget ca-certificates build-dependencies &&     rm -rf /tmp/*
 ---> Running in ae0076cf85b7
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/armhf/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/armhf/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/community/armhf/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/community/armhf/APKINDEX.tar.gz
(1/6) Installing ca-certificates (20161130-r0)
(2/6) Installing libssh2 (1.7.0-r0)
(3/6) Installing libcurl (7.52.1-r0)
(4/6) Installing curl (7.52.1-r0)
(5/6) Installing wget (1.18-r0)
(6/6) Installing build-dependencies (0)
Executing busybox-1.24.2-r13.trigger
Executing ca-certificates-20161130-r0.trigger
OK: 6 MiB in 17 packages
--2017-02-03 15:35:36--  https://github.com//chrislusf/seaweedfs/releases/download/0.74/linux_arm.tar.gz
Resolving github.com... 192.30.253.113, 192.30.253.112
Connecting to github.com|192.30.253.113|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://github-cloud.s3.amazonaws.com/releases/21827146/fa612038-dd62-11e6-861b-964ae5d85e5b.gz?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAISTNZFOVBIJMK3TQ%2F20170203%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20170203T153537Z&X-Amz-Expires=300&X-Amz-Signature=31f794fcdebd158470991bc7bc7c78bcf4f16fcbc6536f8296615630cce823ae&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Dlinux_arm.tar.gz&response-content-type=application%2Foctet-stream [following]
--2017-02-03 15:35:37--  https://github-cloud.s3.amazonaws.com/releases/21827146/fa612038-dd62-11e6-861b-964ae5d85e5b.gz?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAISTNZFOVBIJMK3TQ%2F20170203%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20170203T153537Z&X-Amz-Expires=300&X-Amz-Signature=31f794fcdebd158470991bc7bc7c78bcf4f16fcbc6536f8296615630cce823ae&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Dlinux_arm.tar.gz&response-content-type=application%2Foctet-stream
Resolving github-cloud.s3.amazonaws.com... 54.231.49.64
Connecting to github-cloud.s3.amazonaws.com|54.231.49.64|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5846533 (5.6M) [application/octet-stream]
Saving to: '/tmp/linux_arm.tar.gz'

     0K .......... .......... .......... .......... ..........  0%  121K 47s
    50K .......... .......... .......... .......... ..........  1% 57.4K 72s
   100K .......... .......... .......... .......... ..........  2% 47.2K 87s
                                                               省略一部分下载信息
  5700K .........                                             100% 2.85M=25s

2017-02-03 15:36:08 (231 KB/s) - '/tmp/linux_arm.tar.gz' saved [5846533/5846533]

weed
(1/6) Purging build-dependencies (0)
(2/6) Purging curl (7.52.1-r0)
(3/6) Purging wget (1.18-r0)
(4/6) Purging libcurl (7.52.1-r0)
(5/6) Purging ca-certificates (20161130-r0)
Executing ca-certificates-20161130-r0.post-deinstall
(6/6) Purging libssh2 (1.7.0-r0)
Executing busybox-1.24.2-r13.trigger
OK: 4 MiB in 11 packages
 ---> 1ea85f835fca
Removing intermediate container ae0076cf85b7
Step 3/8 : EXPOSE 8080
 ---> Running in 91b81204f681
 ---> 1dfa8d66bf4a
Removing intermediate container 91b81204f681
Step 4/8 : EXPOSE 9333
 ---> Running in 1738b41e8a93
 ---> f2a61620bb5a
Removing intermediate container 1738b41e8a93
Step 5/8 : VOLUME /data
 ---> Running in ae8fcc0c5963
 ---> ef9b037a4a39
Removing intermediate container ae8fcc0c5963
Step 6/8 : COPY entrypoint.sh /entrypoint.sh
 ---> babf644bdcc7
Removing intermediate container e3b81b369c5f
Step 7/8 : RUN chmod +x /entrypoint.sh
 ---> Running in 8b9ab7127e9e
 ---> a98159e1ed14
Removing intermediate container 8b9ab7127e9e
Step 8/8 : ENTRYPOINT /entrypoint.sh
 ---> Running in bcbe517e4315
 ---> ac4cd2752946
Removing intermediate container bcbe517e4315
Successfully built ac4cd2752946
$ docker images
REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
sunsl/seaweedfs             latest              ac4cd2752946        4 minutes ago       21.6 MB
armhf/alpine                3.4                 eaed1e60f73c        2 days ago          3.94 MB

4.测试运行
原封不动的使用克隆下来的 docker-compose文件,改成自己的镜像名称

version: '2'
services:
  master:
    image: sunsl/seaweedfs
    ports:
      - 9333:9333
    command: "master"
    networks:
      default:
        aliases:
          - seaweed_master
  volume:
    image: sunsl/seaweedfs
    ports:
      - 8080:8080
    command: 'volume -max=5 -mserver="master:9333" -port=8080'
    depends_on:
     - master
    networks:
      default:
        aliases:
          - seaweed_volume

运行

$ docker-compose up
Creating network "seaweedfs_default" with the default driver
Creating seaweedfs_master_1
Creating seaweedfs_volume_1
Attaching to seaweedfs_master_1, seaweedfs_volume_1
master_1  | I0203 15:46:16     1 file_util.go:20] Folder /data Permission: -rwxr-xr-x
master_1  | I0203 15:46:16     1 topology.go:81] Using default configurations.
master_1  | I0203 15:46:16     1 master_server.go:67] Volume Size Limit is 30000 MB
master_1  | I0203 15:46:16     1 master.go:88] Start Seaweed Master 0.74 at 0.0.0.0:9333
master_1  | I0203 15:46:16     1 raft_server.go:56] Peers Change: [] => []
master_1  | I0203 15:46:16     1 raft_server.go:98] Initializing new cluster
master_1  | I0203 15:46:17     1 master_server.go:100] [ 172.19.0.2:9333 ] I am the leader!
master_1  | I0203 15:46:27     1 node.go:223] topo adds child DefaultDataCenter
master_1  | I0203 15:46:27     1 node.go:223] topo:DefaultDataCenter adds child DefaultRack
master_1  | I0203 15:46:27     1 node.go:223] topo:DefaultDataCenter:DefaultRack adds child 172.19.0.3:8080
master_1  | I0203 15:46:27     1 master_grpc_server.go:36] added volume server 172.19.0.3:8080
volume_1  | I0203 15:46:26     1 file_util.go:20] Folder /data Permission: -rwxr-xr-x
volume_1  | I0203 15:46:26     1 disk_location.go:97] Store started on dir: /data with 0 volumes max 5
volume_1  | I0203 15:46:26     1 volume_grpc_client.go:17] Volume server bootstraps with master master:9333
volume_1  | I0203 15:46:26     1 volume.go:141] Start Seaweed volume server 0.74 at 0.0.0.0:8080
volume_1  | I0203 15:46:27     1 volume_grpc_client.go:52] Heartbeat to 172.19.0.2:9333

用另一个ssh 登录查看状态

$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                              NAMES
8d1553f83347        sunsl/seaweedfs     "/entrypoint.sh vo..."   3 minutes ago       Up 2 minutes        0.0.0.0:8080->8080/tcp, 9333/tcp   seaweedfs_volume_1
848cc4cfff34        sunsl/seaweedfs     "/entrypoint.sh ma..."   3 minutes ago       Up 3 minutes        8080/tcp, 0.0.0.0:9333->9333/tcp   seaweedfs_master_1

通过网页访问树莓派地址,信息如下:

树莓派3下seaweedfs docker镜像编译、测试_第1张图片

树莓派3下seaweedfs docker镜像编译、测试_第2张图片

你也可以通过 seaweedfs wiki中提到的curl测试方式进行测试

参考

  • seaweedfs 源码
  • SeaweedFS:简单,高可用的分布式文件存储
  • 分布式存储Seaweedfs源码分析
  • SeaweedFS概述
  • Docker Compose 项目

你可能感兴趣的:(树莓派3下seaweedfs docker镜像编译、测试)