绝了,这款P2P全平台的文件同步工具,开源且不依赖中心服务器

简介: 绝了,这款P2P全平台的文件同步工具,开源且不依赖中心服务器

最近在研究一些好玩的开源软件,似乎有些沉迷。

发现这样一款软件可以支持多平台的同步软件,可以在Windows上、各种Linux发行版、MacOS是和Android上,甚至你可以在你的群晖或是OpenWRT甚至树莓派上使用它,可以使多个平台的文件保持一致,非常适合企业或是个人文件的多端同步。

经测试同步时差在10s左右,即一方客户端删除、增加或修改文件,另一端开始产生同步效果的时间,效果极佳!


环境准备


话不多说,开始搭建,首先需要一个docker的环境,我这里依然使用一键脚本。

# CentOS,版本至少大于等于7
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
# Ubuntu
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
# Debian
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

我这里依然使用CentOS7来演示搭建,使用其它Linux发行版或运行有Docker环境的小伙伴操作类似。

# 查看Docker的版本
[root@mx ~]# docker -v
Docker version 20.10.9, build c2ea9bc
[root@mx ~]# 
# 查看Docker运行状态
[root@mx ~]# systemctl status docker


image.png


安装docker-compose

这里搭建需要使用到docker-compose工具,它是docker官方出品的管理软件,能够有效地定义我们容器运行方式,使得管理更加高效。这里使用官方提供的安装脚本。

# 官方
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
# 备用地址
curl -L https://get.daocloud.io/docker/compose/releases/download/1.25.5/docker-compose-`uname -s`-`uname -m`  /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

如果上面的方式下载不了,可以以下地址下载二进制运行文件。

# github地址
# https://github.com/docker/compose/releases/
wget https://github.com/docker/compose/releases/download/v2.0.1/docker-compose-linux-x86_64 
mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose && chmod +x /usr/local/bin/docker-compose

查看docker-compose的版本

[root@mx ~]# docker-compose -v
Docker Compose version v2.0.1
[root@mx ~]#


部署Syncthing


首先创建一个存储数据的目录,并在此目录下创建一个dockerfile的文件。

[root@mx ~]# mkdir -p /opt/docker/syncthing
[root@mx ~]# mkdir -p /opt/docker/syncthing/data
[root@mx ~]# cd /opt/docker/syncthing/ && vim docker-compose.yml

下面是内容,粘贴到docker-compose.yml文件中,保存!我这里把/opt/docker/syncthing/data作为同步目录,大家可自行更改。

---
version: "3"
services:
  syncthing:
    image: syncthing/syncthing
    container_name: syncthing
    hostname: my-syncthing
    environment:
      - PUID=1000
      - PGID=1000
    volumes:
      - /opt/docker/syncthing/data:/var/syncthing
    ports:
      - 8384:8384
      - 22000:22000/tcp
      - 22000:22000/udp
    restart: unless-stopped

执行命令开始部署Syncthing运行环境。

[root@mx syncthing]# docker-compose up
[+] Running 5/5
 ⠿ syncthing Pulled                                                                                                                                               17.2s
   ⠿ a0d0a0d46f8b Pull complete                                                                                                                                    7.1s
   ⠿ c1f268ddb189 Pull complete                                                                                                                                    7.7s
   ⠿ 7135014d6b43 Pull complete                                                                                                                                   11.6s
   ⠿ 1eeaea656424 Pull complete                                                                                                                                   11.8s
[+] Running 2/2
 ⠿ Network syncthing_default  Created                                                                                                                              0.1s
 ⠿ Container syncthing        Created                                                                                                                              0.1s
Attaching to syncthing
syncthing  | [monitor] 12:57:53 INFO: We will skip creation of a default folder on first start
syncthing  | [start] 12:57:53 INFO: syncthing v1.18.3 "Fermium Flea" (go1.17.1 linux-amd64) docker@build.syncthing.net 2021-09-28 06:05:18 UTC [noupgrade]
syncthing  | [start] 12:57:53 INFO: Generating ECDSA key and certificate for syncthing...
syncthing  | [start] 12:57:53 INFO: Default folder created and/or linked to new config
syncthing  | [start] 12:57:53 INFO: Default config saved. Edit /var/syncthing/config/config.xml to taste (with Syncthing stopped) or use the GUI
syncthing  | [start] 12:57:53 INFO: Archiving a copy of old config file format at: /var/syncthing/config/config.xml.v0
syncthing  | [HN32Y] 12:57:53 INFO: My ID: HN32YAU-WLN3D6S-JA65AC6-7VWORO4-O4OOXS3-543CCUQ-FJ3LBX7-SDEU6QY
syncthing  | [HN32Y] 12:57:54 INFO: Single thread SHA256 performance is 164 MB/s using minio/sha256-simd (164 MB/s using crypto/sha256).
syncthing  | [HN32Y] 12:57:55 INFO: Hashing performance is 132.67 MB/s
syncthing  | [HN32Y] 12:57:55 INFO: Running database migration 1...
syncthing  | [HN32Y] 12:57:55 INFO: Running database migration 2...
……

如果启动没有问题,可以使用它在后台运行。使用ctrl+c 结束当前进程,并放到后台运行。

[root@mx syncthing]# docker-compose up -d
[root@mx syncthing]# docker ps
CONTAINER ID   IMAGE                 COMMAND                  CREATED         STATUS                            PORTS                                                                                                                                                NAMES
7cafc4c27c08   syncthing/syncthing   "/bin/entrypoint.sh …"   7 minutes ago   Up 2 seconds (health: starting)   0.0.0.0:8384->8384/tcp, :::8384->8384/tcp, 0.0.0.0:22000->22000/tcp, :::22000->22000/tcp, 21027/udp, 0.0.0.0:22000->22000/udp, :::22000->22000/udp   syncthing
[root@mx syncthing]#

开放防火墙端口

firewall-cmd --add-port={8384,22000}/tcp --permanent
firewall-cmd --add-port=22000/udp --permanent
firewall-cmd --reload


访问


使用ip:8384访问,可以看到已经正常地访问到我们的syncthing服务了,但还需要一些设置使我们的服务更加的安全。

image.png

image.png


配置同步

点击添加一个文件夹,并为此文件夹设置好名称等相关属性。


image.png

image.png


使用客户端测试同步


我这里使用Mac的客户端来先做一个测试,下载好运行文件,点击syncthing开始运行。


image.png

image.png

image.png

image.png

相关文章
|
5月前
|
人工智能 API 开发者
FastAPI开发者福音!FastAPI-MCP:将FastAPI秒变MCP服务器的开源神器,无需配置自动转换!
FastAPI-MCP是一款能将FastAPI应用端点自动转换为符合模型上下文协议(MCP)的开源工具,支持零配置自动发现接口并保留完整文档和模式定义。
2956 112
FastAPI开发者福音!FastAPI-MCP:将FastAPI秒变MCP服务器的开源神器,无需配置自动转换!
|
25天前
|
人工智能 自然语言处理 安全
Python构建MCP服务器:从工具封装到AI集成的全流程实践
MCP协议为AI提供标准化工具调用接口,助力模型高效操作现实世界。
292 1
|
4月前
|
运维 Linux 网络安全
国产服务器管理工具对比
本内容以表格形式对比了五款工具(宝塔面板、1Panel、gmSSH、Xterminal)的功能定位、用户界面、核心功能、适用场景等关键维度。涵盖服务器运维、容器化管理、SSH客户端及跨平台支持等方面,帮助用户根据需求选择合适的工具。适合开发者、运维人员及中小企业技术团队参考。
|
5月前
|
存储 人工智能 项目管理
2025年GitHub平台上的十大开源MCP服务器汇总分析
本文深入解析了GitHub上十个代表性MCP(Model Context Protocol)服务器项目,探讨其在连接AI与现实世界中的关键作用。这些服务器实现了AI模型与应用程序、数据库、云存储、项目管理等工具的无缝交互,扩展了AI的应用边界。文中涵盖Airbnb、Supabase、AWS-S3、Kubernetes等领域的MCP实现方案,展示了AI在旅行规划、数据处理、云存储、容器编排等场景中的深度应用。未来,MCP技术将向标准化、安全性及行业定制化方向发展,为AI系统集成提供更强大的支持。
1217 2
2025年GitHub平台上的十大开源MCP服务器汇总分析
|
6月前
|
自然语言处理 安全 开发工具
分享一个纯净无广、原版操作系统、开发人员工具、服务器等资源免费下载的网站
分享一个纯净无广、原版操作系统、开发人员工具、服务器等资源免费下载的网站
274 4
|
6月前
|
运维 安全 开发工具
GitHub 热门开源运维工具 Websoft9:如何实现服务器管理效率翻倍?
Websoft9 提供 200+ 开源应用一键部署,支持容器化隔离、GitOps 自动化和企业级安全防护,助力服务器管理效率提升 80%。
188 1
|
25天前
|
弹性计算 编解码 大数据
性价比最高提升50%!阿里云企业级云服务器上新
阿里云ECS云服务器推出全新升级的u2系列实例,包括基于Intel的u2i实例与首个基于AMD的u2a实例,提供企业级独享算力,综合性价比最高提升50%。u2i实例已开放公测,适用于中小型数据库、企业网站建设等场景。同时发布基于AMD的第九代旗舰实例g9ae,性能提升65%,适用于大数据、视频转码等密集型业务。
141 0
|
1月前
|
弹性计算 运维 安全
阿里云轻量应用服务器是什么?看完你就知道了
阿里云轻量应用服务器是面向网站建设、开发测试等轻量场景的云服务器,按套餐售卖,内置多种应用镜像,支持一键部署,操作简单,适合个人开发者和中小企业使用。
238 0

热门文章

最新文章