侧边栏壁纸
博主头像
极简笔记博主等级

极简笔记,书写你的精彩程序人生!

  • 累计撰写 147 篇文章
  • 累计创建 24 个标签
  • 累计收到 8 条评论

目 录CONTENT

文章目录

CentOS安装Syncthing同步工具

极简笔记
2022-06-14 / 0 评论 / 0 点赞 / 2,273 阅读 / 1,504 字 / 正在检测是否收录...
温馨提示:
本文最后更新于 2022-06-14,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

Syncthing 是一个免费开源的工具,它能在你的各个网络计算机间同步文件 / 文件夹,它的同步数据是直接从一个系统中直接传输到另一个系统的,并且它是安全且私密的。支持多版本控制,同时支持Windows、Mac OS X、Linux等客户端,和Resilio有点类似,但是又略有不同,这篇文章介绍一下Centos安装Syncthing工具的方法。

image-1655193524076

一、下载与安装

Syncthing工具配置非常的简单,小z博客以CentOS X64为例,如果您需要其它版本的客户端请访问:
syncthinghttps://syncthing.net)。
GitHubhttps://github.com/syncthing/syncthing.git)
言归正传,下面就开始分别执行命令:

### 下载客户端
wget https://github.com/syncthing/syncthing/releases/download/v1.20.2/syncthing-linux-amd64-v1.20.2.tar.gz
### 解压
tar -zxvf syncthing-linux-amd64-v1.20.2.tar.gz
### 进入目录
cd syncthing-linux-amd64-v1.20.2/
### 复制到环境变量
cp syncthing /usr/local/bin/

image-1655193805821

接着我们需要先运行一次让Syncthing自动生成初始配置文件,上面已经加入环境变量,直接输入syncthing即可运行,会看到下面的运行结果。

root@VM-4-14-centos:/data/soft/syncthing-linux-amd64-v1.20.2# syncthing
[start] 2022/06/14 16:04:29 INFO: syncthing v1.20.2 "Fermium Flea" (go1.18.3 linux-amd64) teamcity@build.syncthing.net 2022-05-31 20:19:44 UTC
[start] 2022/06/14 16:04:29 INFO: Generating ECDSA key and certificate for syncthing...
[start] 2022/06/14 16:04:29 INFO: Default folder created and/or linked to new config
[start] 2022/06/14 16:04:29 INFO: Default config saved. Edit /root/.config/syncthing/config.xml to taste (with Syncthing stopped) or use the GUI
[start] 2022/06/14 16:04:29 INFO: Archiving a copy of old config file format at: /root/.config/syncthing/config.xml.v0
[BWH4O] 2022/06/14 16:04:30 INFO: My ID: BWH4OIX-ZF2ILCQ-AW3NCYW-C3RBTQ3-S35ZOOO-QYMJQAU-XJQZM55-I4WIVQU
[BWH4O] 2022/06/14 16:04:31 INFO: Single thread SHA256 performance is 305 MB/s using minio/sha256-simd (303 MB/s using crypto/sha256).
[BWH4O] 2022/06/14 16:04:32 INFO: Hashing performance is 249.81 MB/s
[BWH4O] 2022/06/14 16:04:32 INFO: Running database migration 1...
[BWH4O] 2022/06/14 16:04:32 INFO: Running database migration 2...
[BWH4O] 2022/06/14 16:04:32 INFO: Running database migration 3...
[BWH4O] 2022/06/14 16:04:32 INFO: Running database migration 5...
[BWH4O] 2022/06/14 16:04:32 INFO: Running database migration 6...
[BWH4O] 2022/06/14 16:04:32 INFO: Running database migration 7...
[BWH4O] 2022/06/14 16:04:32 INFO: Running database migration 9...
[BWH4O] 2022/06/14 16:04:32 INFO: Running database migration 10...
[BWH4O] 2022/06/14 16:04:32 INFO: Running database migration 11...
[BWH4O] 2022/06/14 16:04:32 INFO: Running database migration 13...
[BWH4O] 2022/06/14 16:04:32 INFO: Running database migration 14...
[BWH4O] 2022/06/14 16:04:32 INFO: Running database migration 16...
[BWH4O] 2022/06/14 16:04:32 INFO: Running database migration 17...
[BWH4O] 2022/06/14 16:04:32 INFO: Running database migration 19...
[BWH4O] 2022/06/14 16:04:32 INFO: Compacting database after migration...
[BWH4O] 2022/06/14 16:04:32 INFO: Overall send rate is unlimited, receive rate is unlimited
[BWH4O] 2022/06/14 16:04:32 INFO: No stored folder metadata for "default"; recalculating
[BWH4O] 2022/06/14 16:04:32 INFO: Using discovery mechanism: global discovery server https://discovery.syncthing.net/v2/?noannounce&id=LYXKCHX-VI3NYZR-ALCJBHF-WMZYSPK-QG6QJA3-MPFYMSO-U56GTUK-NA2MIAW
[BWH4O] 2022/06/14 16:04:32 INFO: Using discovery mechanism: global discovery server https://discovery-v4.syncthing.net/v2/?nolookup&id=LYXKCHX-VI3NYZR-ALCJBHF-WMZYSPK-QG6QJA3-MPFYMSO-U56GTUK-NA2MIAW
[BWH4O] 2022/06/14 16:04:32 INFO: Using discovery mechanism: global discovery server https://discovery-v6.syncthing.net/v2/?nolookup&id=LYXKCHX-VI3NYZR-ALCJBHF-WMZYSPK-QG6QJA3-MPFYMSO-U56GTUK-NA2MIAW
[BWH4O] 2022/06/14 16:04:32 INFO: Using discovery mechanism: IPv4 local broadcast discovery on port 21027
[BWH4O] 2022/06/14 16:04:32 INFO: Using discovery mechanism: IPv6 local multicast discovery on address [ff12::8384]:21027
[BWH4O] 2022/06/14 16:04:32 INFO: Relay listener (dynamic+https://relays.syncthing.net/endpoint) starting
[BWH4O] 2022/06/14 16:04:32 INFO: TCP listener ([::]:22000) starting
2022/06/14 16:04:32 failed to sufficiently increase receive buffer size (was: 208 kiB, wanted: 2048 kiB, got: 416 kiB). See https://github.com/lucas-clemente/quic-go/wiki/UDP-Receive-Buffer-Size for details.
[BWH4O] 2022/06/14 16:04:32 INFO: QUIC listener ([::]:22000) starting
[BWH4O] 2022/06/14 16:04:32 INFO: Loading HTTPS certificate: open /root/.config/syncthing/https-cert.pem: no such file or directory
[BWH4O] 2022/06/14 16:04:32 INFO: Creating new HTTPS certificate
[BWH4O] 2022/06/14 16:04:32 INFO: Ready to synchronize "Default Folder" (default) (sendreceive)
[BWH4O] 2022/06/14 16:04:32 INFO: Completed initial scan of sendreceive folder "Default Folder" (default)
[BWH4O] 2022/06/14 16:04:32 INFO: GUI and API listening on 127.0.0.1:8384
[BWH4O] 2022/06/14 16:04:32 INFO: Access the GUI via the following URL: http://127.0.0.1:8384/
[BWH4O] 2022/06/14 16:04:32 INFO: My name is "VM-4-14-centos"
[BWH4O] 2022/06/14 16:04:32 WARNING: Syncthing should not run as a privileged or system user. Please consider using a normal user account.
[BWH4O] 2022/06/14 16:04:42 INFO: Detected 0 NAT services
[BWH4O] 2022/06/14 16:04:51 INFO: quic://0.0.0.0:22000 detected NAT type: Port restricted NAT

二、修改配置文件

上一个步骤输入syncthing已经成功运行,并生成了对应的配置文件,输入Ctrl + C退出客户端。我们需要修改下默认的配置文件:vi ~/.config/syncthing/config.xml大概在22行左右的配置,将127.0.0.1修改为0.0.0.0,如下截图。

image-1655194166580

三、放行端口

syncthing默认监听8384端口,我们需要在iptables放行这个端口,依次输入下面的命令。

### 放行8384端口
/sbin/iptables -I INPUT -p tcp --dport 8384 -j ACCEPT
/etc/init.d/iptables save
service iptables restart 

四、测试访问

再次输入syncthing命令启动Syncthing客户端,然后在浏览器输入:[http://您的服务器IP:8384]进行访问。

image-1655194471008
Syncthing默认支持中文语言,首次登录会让您设置用户名和密码,到这里基本上就完成了,如何添加其它设备和同步文件夹可以自行研究下。

五、其它说明

如果希望Syncthing在后台运行可以使用nohup命令来实现:nohup syncthing &

nohup syncthing > syncthing.log &

六、总结

Syncthing可以在不同设备之间实现同步,前提是已经安装Syncthing客户端,另外还支持历史版本的功能,如果有条件您完整可以利用Syncthing打造自己私有的同步工具。原创文章,转载请注明。


本文转自 https://www.xiaoz.me/archives/7708,如有侵权,请联系删除。

0

评论区