关于数据同步的那些事儿

一、前言

我最早接触的数据同步软件是Dropbox,在公司进行的设计文档,自动同步到云端,回家打开笔记本,云端的文件就自动同步到本地,完全不需要人为干预,非常方便快捷。然后…就没有然后了,因为被墙了!Dropbox是基于云端服务的。对于个人而言,去中心化的,开源的、有穿越能力的同步软件,才是未来方向。

最近看到一条新闻,Resilio Sync(就是原来的BitTorrent Sync)国内代理发布了煽情公告与大家告别,维基百科的介绍:Resilio Sync使用P2P协议同步软件。该协议用于在多个设备间传递大文件时非常有效,与µTorrent和BitTorrent使用的协议类似。服务器端不开源,客户端开源。

二、Syncthing(官方网站:https://syncthing.net/)

Syncthing是开源的同步软件,适合个人使用。问题:为啥提示有同步用的Server,不是说好了去中心化吗?

实践1、在Windows下安装使用

1、官网下载对应的版本,比如Windows 64bit,将下载的zip文件解压,比如目录C:\sbin

2、运行syncthing.exe,弹出命令行和浏览器窗口

3、浏览器窗口,点击“Default Folder”,“文件夹路径”是运行Syncthing时建立的,放一个需要同步的测试文件到这个目录中去

4、

实践2、在Android手机上安装使用

1、通过Google Play安装“Syncthing”和ZXingTeam的“条码扫描器”,开启Syncthing

2、在Windows浏览器端,选右上角的“操作”、“显示ID”

3、选设备,点击右上角的“+”,点击设备标识右侧的二维码图标,扫描上步Windows端的二维码

实践3、本地局域网实现同步

实践4、在VPS上安装使用

实践5、公司内网与外网实现同步

公司内网无法访问syncthing官网,Windows 7 64bit下也启动syncthing可以打开浏览器界面(注意把缺省浏览器改为最新版本的chrome!)。
是不是需要首先要解决内网穿透的问题呢?
内网穿透系列——frp (新一代高性能内网穿透工具)| 内网穿透系列——SSH反向隧道 (最简单的内网穿透方案)| 内网穿透系列——ngrok (老牌开源内网穿透工具)

实践6、Syncthing进阶知识

1、(自定义同步目录)笔记本同步到手机

1、Windows端,点“添加文件夹”,设置“文件夹标签”、“文件夹路径”、勾选“共享给”的设备。问题:”文件夹ID”可以自己设置吗?

2、手机端提示“新文件夹”:“asus13想将xxx文件夹共享给您,添加新文件夹?”,点“添加”

3、指定手机本地目录。问题:可以在设置中创建吗?

2、手机照片同步到笔记本上

1、手机端通过左上角的图标,打开“页面管理页面”

2、点击“文件夹”下的“摄像机”,确认“文件夹路径”是“/storage/emulated/0/DCIM”,“文件夹类型”是“仅发送”

3、点击“远程设备”中的对应笔记本,我的是“asus13”,点“选项”、“将指定文件夹共享给设备”、“摄像机”,确认点“保存”,回到“文件夹”下的“摄像机”

4、笔记本提示手机端有共享,设置到笔记本本地的文件夹后,会自动同步。

3、设置同步选项
4、命令行窗口的内容解析

1、关于设备标识:V2UJ7

2、关于服务器: Using discovery server
5、Windows端的设置文件

6、Android端的设置文件
7、VPS端的设置文件(以下是编译好的版本,需补充从源代码编译安装的方法)

1、cd ~

2、wget https://github.com/syncthing/syncthing/releases/download/v0.14.33/syncthing-linux-amd64-v0.14.33.tar.gz #从官网查询的最新版本

3、tar -zxvf syncthing-linux-amd64-v0.14.33.tar.gz

4、cd syncthing-linux-amd64-v0.14.33

5、cp syncthing /usr/local/bin #设置路径的方法好奇怪啊!

6、cd ~

7、syncthing #运行一次,以生成配置文件,然后Ctrl+C退出

8、vi ~/.config/syncthing/config.xml #修改配置文件中的“127.0.0.1:8384”为“0.0.0.0:8384”

9、/sbin/iptables -I INPUT -p tcp –dport 8384 -j ACCEPT #放行防火墙8384端口

10、/etc/init.d/iptables save #找不到,看来Centos 7没有这个文件了!

11、service iptables restart

12、syncthing #再次运行,在浏览器中输入地址“http://www.hisense.tk:8384/” #8384端口被封锁就麻烦了,可以自定义端口吧?
第12行命令,浏览器有两条警告:
1、危险!当前配置允许在不使用密码的情况下远程访问 Syncthing 管理界面。 这会让骇客能够轻而易举地访问及修改您的文件。 请在设置对话框中设置 GUI 验证用户及其密码。

2、提示:Syncthing should not run as a privileged or system user. Please consider using a normal user account.
第11行命令返回的错误:

Redirecting to /bin/systemctl restart iptables.service
Failed to restart iptables.service: Unit not found.
运行iptables -Ln | grep 8384“”返回的错误
iptables: No chain/target/match by that name.
[root@vultr ~]# iptable
-bash: iptable: command not found
[root@vultr ~]# iptables
iptables v1.4.21: no command specified
Try `iptables -h' or 'iptables --help' for more information.
如下是第一次运行syncthing的信息(第7行命令,哪些是敏感信息,需要修改一下呢?)
[monitor] 09:45:52 INFO: Starting syncthing
[start] 09:45:52 INFO: Generating ECDSA key and certificate for syncthing...
[LBLQ4] 09:45:52 INFO: syncthing v0.14.33 "Dysprosium Dragonfly" (go1.8.3 linux-                                                                                        amd64) unknown-user@9b8983e226ea 2017-07-13 06:55:12 UTC
[LBLQ4] 09:45:52 INFO: My ID: LBLQ44J-Q2UCGLM-O4ARCPU-HUSVQPW-OAASHJ5-BTRUNDO-LJ                                                                                        22JOO-6BQLIQX
[LBLQ4] 09:45:53 INFO: Single thread SHA256 performance is 268 MB/s using minio/                                                                                        sha256-simd (259 MB/s using crypto/sha256).
[LBLQ4] 09:45:54 INFO: Hashing performance with weak hash is 215.27 MB/s
[LBLQ4] 09:45:55 INFO: Hashing performance without weak hash is 251.32 MB/s
[LBLQ4] 09:45:55 INFO: Default folder created and/or linked to new config
[LBLQ4] 09:45:55 INFO: Defaults saved. Edit /root/.config/syncthing/config.xml t                                                                                        o taste or use the GUI
[LBLQ4] 09:45:55 INFO: Weak hash enabled, as it has an acceptable performance im                                                                                        pact.
[LBLQ4] 09:45:55 INFO: Ready to synchronize "Default Folder" (default) (readwrit                                                                                        e)
[LBLQ4] 09:45:55 INFO: Send rate is unlimited, receive rate is unlimited
[LBLQ4] 09:45:55 INFO: Rate limits do not apply to LAN connections
[LBLQ4] 09:45:55 INFO: Using discovery server https://discovery-v4-2.syncthing.n                                                                                        et/v2/?id=DVU36WY-H3LVZHW-E6LLFRE-YAFN5EL-HILWRYP-OC2M47J-Z4PE62Y-ADIBDQC
[LBLQ4] 09:45:55 INFO: Using discovery server https://discovery-v4-3.syncthing.n                                                                                        et/v2/?id=VK6HNJ3-VVMM66S-HRVWSCR-IXEHL2H-U4AQ4MW-UCPQBWX-J2L2UBK-NVZRDQZ
[LBLQ4] 09:45:55 INFO: Using discovery server https://discovery-v4-4.syncthing.n                                                                                        et/v2/?id=LYXKCHX-VI3NYZR-ALCJBHF-WMZYSPK-QG6QJA3-MPFYMSO-U56GTUK-NA2MIAW
[LBLQ4] 09:45:55 INFO: Using discovery server https://discovery-v6-2.syncthing.n                                                                                        et/v2/?id=DVU36WY-H3LVZHW-E6LLFRE-YAFN5EL-HILWRYP-OC2M47J-Z4PE62Y-ADIBDQC
[LBLQ4] 09:45:55 INFO: Using discovery server https://discovery-v6-3.syncthing.n                                                                                        et/v2/?id=VK6HNJ3-VVMM66S-HRVWSCR-IXEHL2H-U4AQ4MW-UCPQBWX-J2L2UBK-NVZRDQZ
[LBLQ4] 09:45:55 INFO: Using discovery server https://discovery-v6-4.syncthing.n                                                                                        et/v2/?id=LYXKCHX-VI3NYZR-ALCJBHF-WMZYSPK-QG6QJA3-MPFYMSO-U56GTUK-NA2MIAW
[LBLQ4] 09:45:55 INFO: TCP listener ([::]:22000) starting
[LBLQ4] 09:45:55 INFO: Loading HTTPS certificate: open /root/.config/syncthing/h                                                                                        ttps-cert.pem: no such file or directory
[LBLQ4] 09:45:55 INFO: Creating new HTTPS certificate
[LBLQ4] 09:45:55 INFO: Completed initial scan (rw) of "Default Folder" (default)
[LBLQ4] 09:45:55 INFO: GUI and API listening on 127.0.0.1:8384
[LBLQ4] 09:45:55 INFO: Access the GUI via the following URL: http://127.0.0.1:83                                                                                        84/
[LBLQ4] 09:45:55 INFO: Device LBLQ44J-Q2UCGLM-O4ARCPU-HUSVQPW-OAASHJ5-BTRUNDO-LJ                                                                                        22JOO-6BQLIQX is "vultr.guest" at [dynamic]
[LBLQ4] 09:45:55 WARNING: Syncthing should not run as a privileged or system use                                                                                        r. Please consider using a normal user account.
[LBLQ4] 09:46:05 INFO: Joined relay relay://24.55.153.158:22067
[LBLQ4] 09:46:06 INFO: Detected 0 NAT devices

三、seafile

seafile也是开源软件?可以部署在NAS或VPS上,适合团队使用。

由于文件是分块加密的,会不会出现数据灾难?

四、Nextcloud

参考:

树莓派折腾记:安装和配置Syncthing | Syncthing:高效文件同步工具
「玩物志」Syncthing的安装与使用 | Syncthing免费开源的文件同步工具-带版本控制可用于构建个人云存储
Centos安装Syncthing同步工具

How to Install Seafile with Nginx on CentOS 7 | 如何安装Seafile与Nginx在CentOS 7

VirtualBox & CentOS7 & SSH & Seafile & ngrok 搭建私有云盘