【数据存储】分布式文件系统SeaweedFS

article/2025/10/14 17:06:39

2021.05.25

初始seaweedFS

安装
1、先去GitHub下载所需版本

linux_amd64.tar.gz

2、然后放到服务器的文档中

/opt/software

3、解压安装

tar -zxvf ./linux_amd64.tar.gz -C /opt/install/seaweed

4、在seaweed安装包下安装seaweedfs文件夹及其下属两个文件夹

mkdir -p ./seaweedfs/data ./seaweedfs/volume

5、用以下命令查看master

 ./weed master -h
Example: weed master -port=9333
Default Usage:-cpuprofile stringcpu profile output file-defaultReplication stringDefault replication type if not specified. (default "000")-disableHttpdisable http requests, only gRPC operations are allowed.-garbageThreshold floatthreshold to vacuum and reclaim spaces (default 0.3)-ip stringmaster <ip>|<server> address, also used as identifier (default "172.19.0.16")
-ip.bind stringip address to bind to-mdir stringdata directory to store meta data (default "/tmp")-memprofile stringmemory profile output file-metrics.address stringPrometheus gateway address <host>:<port>-metrics.intervalSeconds intPrometheus push interval in seconds (default 15)-options stringa file of command line options, each line in optionName=optionValue format-peers stringall master nodes in comma separated ip:port list, example: 127.0.0.1:9093,127.0.0.1:9094,127.0.0.1:9095-port inthttp listen port (default 9333)-resumeStateresume previous state on start master server-volumePreallocatePreallocate disk space for volumes.-volumeSizeLimitMB uintMaster stops directing writes to oversized volumes. (default 30000)-whiteList stringcomma separated Ip addresses having write permission. No limit if empty.
Description:start a master server to provide volume=>location mapping service and sequence number of file idsThe configuration file "security.toml" is read from ".", "$HOME/.seaweedfs/", "/usr/local/etc/seaweedfs/", or "/etc/seaweedfs/", in that order.The example security.toml configuration file can be generated by "weed scaffold -config=security"

6、用以下命令查看volume

./weed volume -h
Example: weed volume -port=8080 -dir=/tmp -max=5 -ip=server_name -mserver=localhost:9333
Default Usage:-compactionMBps intlimit background compaction or copying speed in mega bytes per second-concurrentUploadLimitMB intlimit total concurrent upload size (default 128)-cpuprofile stringcpu profile output file-dataCenter stringcurrent volume server's data center name-dir stringdirectories to store data files. dir[,dir]... (default "/tmp")-dir.idx stringdirectory to store .idx files-disk string[hdd|ssd|<tag>] hard drive or solid state drive or any tag-fileSizeLimitMB intlimit file size to avoid out of memory (default 256)-idleTimeout intconnection idle seconds (default 30)-images.fix.orientationAdjust jpg orientation when uploading.-index stringChoose [memory|leveldb|leveldbMedium|leveldbLarge] mode for memory~performance balance. (default "memory")-ip stringip or server name, also used as identifier (default "172.19.0.16")-ip.bind stringip address to bind to-max stringmaximum numbers of volumes, count[,count]... If set to zero, the limit will be auto configured. (default "8")-memprofile stringmemory profile output file-metricsPort intPrometheus metrics listen port-minFreeSpace stringmin free disk space (value<=100 as percentage like 1, other as human readable bytes, like 10GiB). Low disk space will mark all volumes as ReadOnly.-minFreeSpacePercent stringminimum free disk space (default to 1%). Low disk space will mark all volumes as ReadOnly (deprecated, use minFreeSpace instead). (default "1")-mserver stringcomma-separated master servers (default "localhost:9333")-options stringa file of command line options, each line in optionName=optionValue format-port inthttp listen port (default 8080)-port.public intport opened to public-pprofenable pprof http handlers. precludes --memprofile and --cpuprofile-preStopSeconds intnumber of seconds between stop send heartbeats and stop volume server (default 10)-publicUrl stringPublicly accessible address-rack stringcurrent volume server's rack name-read.redirectRedirect moved or non-local volumes. (default true)-tcp<exprimental> enable tcp port-whiteList stringcomma separated Ip addresses having write permission. No limit if empty.
Description:start a volume server to provide storage spaces

2021.05.26

认识SeaweedFS命令

seaweedFS是根据Haystack来实现的,它有两大特性:
1、存储数以亿计的文件
2、访问文件非常快
之所以它能达到这两个特性,是因为所有文件的元数据metadata不存储在master节点,而是分散存储在volume(逻辑卷,存储数据的逻辑结构)中,master节点只保存volume信息

3、查看master服务的参数:

命令类型解释
-cpuprofilestring输出cpu使用的统计信息
-defaultReplicationstring默认的副本类型(默认为000)
-disableHttp关闭http接口,只使用gRPC来访问
-garbageThresholdfloat回收空间的阈值(默认为0.3)
-ipstringmaster服务的ip地址,默认为localhost
-ip.bindstring
-mdirstring存储内存使用的统计信息(默认“/tmp”)
-memprofilestring输出内存使用的统计信息
-metrics.addressstring性能指标统计工具的地址,seaweedFS使用prometheus来存储性能统计信息
-metrics.intervalSecondsint性能统计信息推送的间隔时间
-optionsstring一个命令行选项文件,每一行的格式为optionName=optionValue
-peersstring所有的master节点列表,比如127.0.0.1:9093,127.0.0.1:9094
-portintmaster服务监听的端口,默认为9333
-resumeState在启动服务器上恢复原来的状态
-volumePrellocate为volumes预分配空间
-volumeSizeLimitMB停止向超出大小限制的volume写入数据,默认为3000
-whiteListstringip白名单,只有在白名单中的ip才拥有写入权限

4、查看volume服务参数

命令类型解释
-compactionMBpsint以百万字节每秒为单位限制后台压缩或复制速度
-concurrentUploadLimitMBint限制总并发上传大小(默认128)
-cpuprofilestringCPU配置文件输出
-dataCenterstring当前卷服务器的数据中心名称
-dirstring存放数据文件的目录。dir [dir]…(默认“/ tmp”)
-dir.idxstring存放。idx文件的目录
-diskstring[hdd
-fileSizeLimitMBint限制文件大小以避免内存不足(默认256)
idleTimeoutint连接空闲秒数(默认30秒)
image.fix.orientation上传时调整jpg的方向。
index string 选择[memoryleveldbleveldbMedium
-ipstringIP或服务器名,也用作标识符(默认"172.19.0.16")
-ip.bindstring要绑定的IP地址
-maxstring最大卷数,count [,count]…如果设置为零,将自动配置该限制。(默认“8”)
-memprofilestring内存配置文件输出文件
-metricsPortint普罗米修斯度量监听端口
minFreeSpacestring最小的空闲磁盘空间(值<=100为百分数,如1,其他为人类可读字节,如10GiB)。低磁盘空间将把所有卷标记为只读。
-minFreeSpacePercentstring最小可用磁盘空间(默认为1%)。低磁盘空间将把所有卷标记为只读(已弃用,请使用minFreeSpace代替)。(默认值“1”)
-mserverstring逗号分隔的主服务器(默认"localhost:9333")
-optionsstring一个命令行选项文件,每一行的格式为optionName=optionValue
-portintHTTP监听端口(默认8080)
-port.publicint公开的端口
-pprof启用pprof HTTP处理程序。排除—memprofile和—cpuprofile
preStopSecondsint停止发送心跳和停止音量服务器之间的秒数(默认10)
publicUrlstring公共可访问的地址
-rackstring当前卷服务器的机架名
-read.redirect重定向移动的或非本地卷。(默认正确)
-tcp< experimental >启用TCP端口
-whiteListstring逗号分隔有写权限的Ip地址。如果为空,则没有限制。

2021.05.27

在集群上启动seaweedFS

1、先检查集群上是否已经运行

ps aux | grep weed

结果:
root 17420 0.0 0.0 112728 972 pts/4 S+ 09:40 0:00 grep --color=auto weed

再检查下端口号

netstat -anp |grep 9333

2、分别在三台服务器上建立文件夹

mkdir -p ./seaweedfs/data ./seaweedfs/volume

此处学习一些Linux的命令,放于Linux的笔记中如:nohup、<、&等

2、启动master服务,分别在三台机器上启动

nohup ./weed master -ip=集群ip01 -port=9333 -mdir=./seaweedfs/data -peers=集群ip01:9333,集群ip02:9333,集群ip03:9333 > ./seaweedfs/data/master.log &
nohup ./weed master -ip=集群ip02 -port=9333 -mdir=./seaweedfs/data -peers=集群ip02:9333,集群ip01:9333,集群ip03:9333 > ./seaweedfs/data/master.log &
nohup ./weed master -ip=集群ip03 -port=9333 -mdir=./seaweedfs/data -peers=集群ip03:9333,集群ip01:9333,集群ip02:9333 > ./seaweedfs/data/master.log &

3、启动volume,分别在三台机器上启动

nohup ./weed volume -dataCenter dc1 -rack rack1 -dir ./seaweedfs/volume -ip=集群ip01 -port 9222 -ip.bind 集群ip01 -max 20 -mserver 集群ip01:9333,集群ip02:9333,集群ip03:9333 -publicUrl 集群ip01:9222 > ./seaweedfs/volume/volume.log &
nohup ./weed volume -dataCenter dc1 -rack rack1 -dir ./seaweedfs/volume -ip=集群ip02 -port 9222 -ip.bind 集群ip02 -max 20 -mserver 集群ip01:9333,集群ip02:9333,集群ip03:9333 -publicUrl 集群ip02:9222 > ./seaweedfs/volume/volume.log &
nohup ./weed volume -dataCenter dc1 -rack rack1 -dir ./seaweedfs/volume -ip=集群ip03 -port 9222 -ip.bind 集群ip03 -max 20 -mserver 集群ip01:9333,集群ip02:9333,集群ip03:9333 -publicUrl 集群ip03:9222 > ./seaweedfs/volume/volume.log &

4、打开http://集群ip01:9333/

文件操作

1、文件上传:先请求master,分配一个fid

curl http://集群ip01:9333/dir/assign

返回结果:
{"fid":"1,01da229ee5","url":"172.17.100.30:9222","publicUrl":"172.17.100.30:9222","count":1}

然后把test文件夹里的text文件上传上去,按照分配的fid上传

curl -F file=@./seaweedfs/test/test.txt 集群ip01:9222/1,01da229ee5

得到结果:
{"name":"test.txt","size":71,"eTag":"321d88cf6431a578fc8d586889275ff4","mime":"text/plain"}
2、也可以来操作删除

curl -X DELETE 集群ip01:9222/1,01da229ee5

3、解释说明:文件fid:1,01da229ee5
1代表volume id,volume id 是一个32位无符号整型
01代表file key,file key是一个64位无符号整型
da229ee5代表file cookie,file cookie是一个32位无符号整型,用来防止文件url被解
每个数字都以16进制保存,因此如果要保存成字符串的话,需要8+1+16+8一共33个字节
4、查询,下载都要先查到id

wget 集群ip01:9222/1,01da229ee5

filer

filer是一个在SeaweedFS之上的服务,它保存路径与文件id的映射关系,最终还是使用文件id来访问文件。filer服务和master服务保持一个长连接,获取并保存volume的信息。这样就不用每次请求都去查询volume的信息。

读:

1.从数据库中查询路径的元数据
2.从volume服务中读取文件内容并发送给请求

写:

1.客户端将文件传输给filer
2.filer将文件上传到volume服务,大文件被分成多个块
3.filer将元数据和块的元数据信息写到数据库中

1、先查看filer配置文件

./weed scaffold -config=filer

2、配置文件有一些如存储方式的选择,先选一个,根据红框里的配置式样配置一个,先创建filer文件

cd seaweedfs/
touch filer.toml
ll

创建好后,开始配置

vi filer.toml
[leveldb2]
enabled = true
dir = "."

3、保存退出后,执行启动命令

./weed filer -master="集群ip01:9333" -ip=集群ip01

在这里插入图片描述

已经启动

4、试一下上传文件,不需要再去找分配的fid上传

curl -F file=@/opt/finished/seaweedfs/test/test2.txt http://集群ip01:9333/text/

结果:{"error":"strconv.ParseUint: parsing \"text\": invalid syntax"} 无效的语法

查看启动文件

修改:

curl -F file=@/opt/finished/seaweedfs/test/test2.txt http://172.17.100.30:8888/text/

{"name":"test2.txt","size":71}

以新的名称重命名上传后的文件

curl -F file=@/opt/finished/seaweedfs/test/test2.txt http://172.17.100.30:8888/text/new.txt

查看一下内容

curl "http://172.17.100.30:8888/text/new.txt"

文件内容正确,是我瞎写的一些字母:abcdefgaskldhgkasdjgalsd;gshkdgasd;hgwe;aoityawdgjs;adjgkjsd;ugtaoieutg

挂载

1、先建立一个挂载的文件夹

mkdir -p ./seaweedfs/data/mount

2、指定SeaweedFS挂载到新建的文件夹

./weed mount -filer=172.17.100.30:8888 -dir=./seaweedfs/data/mount -filer.path=/

3、上传文件

curl -F file=@/opt/finished/seaweedfs/test/abc.txt http://172.17.100.30:8888/text/

4、查看文件夹里

在这里插入图片描述


http://chatgpt.dhexx.cn/article/bYAAQPPY.shtml

相关文章

seata

Seata 1 seata概述 1.1 Seata简介 Seata 是一款开源的分布式事务解决方案&#xff0c;致力于提供高性能和简单易用的分布式事务服务。Seata 将为用户提供了 AT、TCC、SAGA 和 XA 事务模式&#xff0c;为用户打造一站式的分布式解决方案。 1.1.1 AT 模式 基于支持本地 ACID…

Selective sweep与Genomic island

最近在阅读文献时遇到了“genomic island”的概念&#xff0c;其概念并不难理解&#xff0c;但是其形成的机制之一“selective sweep”比较难理解。之前在一篇综述&#xff08;Variation of the adaptive substitution rate between species and within genomes&#xff09;中我…

Docker seaweedfs

2019独角兽企业重金招聘Python工程师标准>>> 关于seaweedfs的介绍我就不在此文赘述&#xff0c;本文的主要目的是讲述我在docker中运行seaweedfs遇到的一些问题。 这是我搜集的一些关于SeaWeedFS的资料 ps.不管是在物理机还是docker之中运行seaweedfs&#xff0c;建…

Seaweed-fs

windows–文件服务器weed集群操作&#xff1a; weed master -ip 127.0.0.1 weed volume -max10 -mserver“127.0.0.1:9333” -ip127.0.0.1 -port9331 -dir“C:\data1” weed volume -max10 -mserver“127.0.0.1:9333” -ip127.0.0.1 -port9332 -dir“C:\data2” Linux部署文件…

seaweedfs上传文件为什么要先申请文件号?(/dir/assign)(两种工作模式:Volume模式与Filer模式)(seaweed上传文件)

文章目录 SeaweedFS两种工作模式Volume模式Filer模式总结 SeaweedFS两种工作模式 SeaweedFS是一个分布式文件系统&#xff0c;它有两种模式&#xff1a;Volume模式和Filer模式。 Volume模式 在Volume模式下&#xff0c;需要先申请文件号&#xff0c;因为SeaweedFS会为每个文…

docker部署seaweedf

总的来说需要两个文件&#xff0c;如下&#xff1a; 1、compose.yml 需要注意&#xff1a;network_mode 模式、ip为宿主机ip version: 3.3services:master:network_mode: "host"image: chrislusf/seaweedfs # use a remote imagecommand: "master -ip172.0.1…

浅析 SeaweedFS 与 JuiceFS 架构异同

SeaweedFS 是一款高效的分布式文件存储系统&#xff0c;最早的设计原型参考了 Facebook 的 Haystack&#xff0c;具有快速读写小数据块的能力。本文将通过对比 SeaweedFS 与 JuiceFS 在设计与功能上的差异&#xff0c;以帮助读者进行更适合自己的选择。 SeaweedFS 系统结构 S…

seaweedfs 部署使用

seaweedfs是一个非常优秀的由 golang 开发的分布式存储开源项目。它是用来存储文件的系统 seaweedfs的特点&#xff1a; 1 可以成存储上亿的文件&#xff08;根据你硬盘大小变化&#xff09; 2 速度快 weed-fs自身可以在两种模式下运行&#xff0c;一种是Master&#xff0c;另…

SeaweedFs分布式文件存储实战

背景&#xff1a; 需求重点&#xff1a;大量小文件&#xff0c;读场景多&#xff0c;磁盘存储有限&#xff0c;要能支持fuse挂载&#xff0c;兼容s3接口 公司最近要进行分布式文件服务的选型&#xff0c;起因是因为公司目前有一些设备上报的文件或者日志性能管理文件需要定时…

SEA~~

抹平One-Stage与Two-Stage目标检测之间的差距 ,重新讨论了单阶段和两阶段的检测器蒸馏任务 在这讨论了单阶段和两阶段的检测器蒸馏任务&#xff0c;并提出了一个简单而有效的语义感知框架来填补它们之间的空白。作者通过设计类别Anchor来生成每个类别的代表性模式&#xff0c;…

SeaweedFS容器部署(seaweed部署、seaweedfs部署)(文件块chunks概念)(master节点与volume节点通信原理)(seaweed上传seaweed下载)

官网链接&#xff1a;https://github.com/seaweedfs 文章目录 seaweed简介seaweedfs文件块概念&#xff08;chunks&#xff09;分布式部署时master节点与volume节点通信原理seaweed容器部署方法单个节点部署部署方法&#xff08;mastervolum&#xff09;&#xff08;mastervolu…

seaweedfs服务启动参数及翻译(seaweed参数、seaweed命令、weed参数、weed命令)(在单个容器同时启动master、volume、filer服务)

文章目录 weed命令翻译weed server命令翻译 weed filer命令 docker容器运行示例&#xff08;docker run命令&#xff09;以下是一个在单个容器启动master、volume、filer服务的示例 weed server 容器debug 版本&#xff1a;3.47从官方镜像docker容器里扒下来的&#xff0c;只扒…

Paramiko: Python使用paramiko连接主机报错“Authentication timeout”

问题描述&#xff1a; 在用Python Paramiko库去连接主机时 始终无法连接&#xff0c;exception输出错误仅有 Authentication timeout connection paramiko.SSHClient()connection.set_missing_host_key_policy(paramiko.AutoAddPolicy())try:connection.connect(hostname192.1…

安装paramiko模块

使用Python实现自动化运维巡检网络设备&#xff0c;需要使用到paramiko模块 下载过程&#xff1a; 进入至CMD命令提示符 win r 跳转出 " 运行 " 窗口 打开内输入" cmd " 进入命令提示符 安装paramiko模块 cmd输入&#xff1a;pip install paramiko PS&…

python-paramiko安装

paramiko 安装坑比较多 测试环境&#xff1a; python3.7.9 win10 安装步骤&#xff1a; pip install pep517 pip install cryptography pip install paramiko

Python paramiko 模块详解与SSH主要功能模拟

我们知道&#xff0c;通过SSH服务可以远程连接到Linux服务器&#xff0c;查看上面的日志状态&#xff0c;批量配置远程服务器&#xff0c;文件上传&#xff0c;文件下载等&#xff0c;Python的paramiko模块同样实现了这一功能。 首先我们需要安装这一模块&#xff0c;pycharm环…

paramiko的安装

import paramiko 出错 直接通过下列代码即可&#xff0c;无需安装VS之类的 pip install paramiko 再上一步安装了paramiko之后&#xff0c;若您安装了pycharm &#xff0c;博主安装的是pycharm 2018 community版则可通过File --> setting -->下列方式 步骤1&#xf…

Python模块之paramiko

Paramiko paramiko模块&#xff0c;基于SSH用于连接远程服务器并执行相关操作。 一、安装 1 pip3 install paramiko 二、使用 SSHClient 用于连接远程服务器并执行基本命令 基于用户名密码连接&#xff1a; 1 import paramiko2 3 # 创建SSH对象4 ssh paramiko.SSHCli…

python之paramiko模块

paramiko是一个用于做远程控制的模块&#xff0c;使用该模块可以对远程服务器进行命令或文件操作,paramiko是用python语言写的一个模块&#xff0c;遵循SSH2协议&#xff0c;支持以加密和认证的方式&#xff0c;进行远程服务器的连接。 由于使用的是python这样的能够跨平台运行…

Python--paramiko

Paramiko paramiko模块&#xff0c;基于SSH用于连接远程服务器并执行相关操作。 一、安装 1 pip3 install paramiko 二、使用 SSHClient 用于连接远程服务器并执行基本命令 基于用户名密码连接&#xff1a; import paramiko# 创建SSH对象 ssh paramiko.SSHClient() # 允…