赞
踩
Syncthing是一款开源的文件同步客户端与服务器软件,采用Go语言编写。它可以在本地网络上的设备之间或通过Internet在远程设备之间同步文件,使用了其独有的对等自由块交换协议。Syncthing是免费开源的工具,它能在你的各个网络计算机间同步文件/文件夹。
这个软件最大的特点:看着简单一些,支持各种平台,可以完成各种平台间文件的同步。
网址:GitHub - syncthing/syncthing: Open Source Continuous File Synchronization
软件安装包下载地址:Release v1.27.2 · syncthing/syncthing · GitHub
apt install syncthing ,但是版本低,建议直接下载tar.gz包。
如果github官网下不来,可以用镜像:
配置文件:.config/syncthing/config.xml
启动后可以使用127.0.0.1:8384链接登陆进行配置
pkg install syncthing
直接下载安装包
配置文件放置在~/.config/syncthing目录下,主要是config.xml这个文件。一般情况下不用去手工修改这个文件,而是使用web端进行配置。
浏览器里输入:http://127.0.0.1:8384即可进入控制界面,如下图:
可以看到,这是一台Linux设备,它有两个远程设备,分别是一台mac设备和一台FreeBSD设备。这三台设备可以自由的选择共享。一旦选好共享目录之后,后面就不用再管了,Syncthing后台会帮我们搞定文件同步的事情。
官网介绍的方法:
How to set up a system service
Create the user who should run the service, or choose an existing one.
(Skip if your distribution package already installs these files, see above.) From git location copy the
syncthing@.service
file into the load path of the system instance.Enable and start the service. Replace “myuser” with the actual Syncthing user after the
@
:systemctl enable syncthing@myuser.service systemctl start syncthing@myuser.service
也就是执行上面两条命令,把myuser修改成自己的用户名即可。
这个syncthing@.service
文件在ubuntu18放置在/lib/systemd/system目录下。
注意如果不是用的系统默认版本,需要修改syncthing@.service里面的文件指向。比如修改成这样:
- # ExecStart=/usr/bin/syncthing -no-browser -no-restart -logflags=0
-
- ExecStart=/home/eln/github/syncthing-linux-amd64-v1.27.2/syncthing -no-browser -no-restart -logflags=0
关闭的时候使用systemctl stop syncthing@myuser.service 即可。当然如果是普通用户,也可以用syncthing启动,用kill 进程号 关闭。
在ysncthing的安装包里,有/etc/目录,里面有启动需要的配置文件,比如
~/work/syncthing-linux-amd64-v1.27.2/etc/linux-systemd/system目录里就有这两个文件:
syncthing-resume.service syncthing@.service
将这两个文件cp到/lib/systemd/system目录下即可。当然syncthing@.service文件里需要修改bin文件的位置,或者把syncthing这个bin文件cp到/usr/bin这个默认目录里。
ps,启动服务的时候不要忘记用sudo哦!
Syncthing可以满足我们在不同机器同步文件的需求!
Syncthing软件非常简单方便,适合初创企业和个人使用,非常推荐!
- [KKMBN] 16:45:44 INFO: Listen (BEP/tcp): TLS handshake: tls: no cipher suite supported by both client and server
- [KKMBN] 16:45:44 INFO: Listen (BEP/tcp): TLS handshake: tls: no cipher suite supported by both client and server
- [KKMBN] 16:46:03 INFO: Joined relay relay://81.68.192.46:22067
- [KKMBN] 16:46:30 INFO: Restarted folder "Default Folder" (default) (readonly)
- [KKMBN] 16:46:30 INFO: Completed initial scan of readonly folder "Default Folder" (default)
- [KKMBN] 16:46:54 INFO: Listen (BEP/tcp): TLS handshake: tls: no cipher suite supported by both client and server
升级版本后问题解决。
刚开始怀疑可能是mac这边有点问题,回头用FreeBSD测试一下。发现是版本不一致的问题,linux 使用apt安装的版本太老,从网站手工下载1.27.2版本的tar.gz包,解压后执行syncthing,问题解决,且可以互联互通了,文件同步也正常了!
- 979 systemctl enable syncthing@eln.service
- 980 systemctl start syncthing@eln.service
还是版本不一致造成的。因为以前用apt安装的版本较老,后期手工安装到用户目录,而syncthing@eln.service调用的还是老版本。
修改该文件,
# ExecStart=/usr/bin/syncthing -no-browser -no-restart -logflags=0
ExecStart=/home/eln/github/syncthing-linux-amd64-v1.27.2/syncthing -no-browser -no-restart -logflags=0
重启服务
sudo systemctl restart syncthing@elb.service
Warning: The unit file, source configuration file or drop-ins of syncthing@elb.service changed on disk. Run 'systemctl daemon-reload' to reload units.
(base) eln@huanju:/lib/systemd/system$ systemctl daemon-reload
如果上面命令失败,重启系统。
重启系统后,版本更新到1.27,终于能和其它机器互联互通了。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。