syncthing的方案及安装记录
项目地址: syncthing
安装 syncthing
选择和自己电脑匹配的版本
1
wget https://github.com/syncthing/syncthing/releases/download/v1.20.3/syncthing-linux-amd64-v1.20.3.tar.gz
解压目录
1
tar -zxf syncthing-linux-amd64-v1.20.3.tar.gz
移动文件到 /usr/bin 下
1
mv syncthing-linux-amd64-v1.20.3/syncthing /usr/bin/syncthing
创建启动用户
1
adduser syncthing
创建 systemd 开机自启动
1
cp syncthing-linux-amd64-v1.20.3/etc/linux-systemd/system/syncthing@.service /etc/systemd/system/syncthing@syncthing.service
允许开机自启
1
systemctl enable syncthing@syncthing.service
开启服务
1
systemctl start syncthing@syncthing.service
配置代理
1
proxy_pass 127.0.0.1:8384;
开放防火墙
22000/tcp
+22000/tcp
安装 discover
由于公共的 discover 服务在国内访问实在问题大大的,因此最好自己搭一个发现服务器 (类似于信令服务)。
下载和服务器匹配的版本
1
wget https://github.com/syncthing/discosrv/releases/download/v1.18.6/stdiscosrv-linux-amd64-v1.18.6.tar.gz
解压文件
1
tar -zxf stdiscosrv-linux-amd64-v1.18.6.tar.gz
将文件移动到 opt 下
1
mv stdiscosrv-linux-amd64-v1.18.6 /opt/stdiscosrv
创建 daemon
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28cat <<eof > /etc/systemd/system/syncdiscover@syncthing.service
[Unit]
Description=Syncthing discover for %I
After=network.target
StartLimitIntervalSec=60
StartLimitBurst=4
[Service]
WorkingDirectory=/opt/stdiscosrv
User=%i
ExecStart=/opt/stdiscosrv/stdiscosrv -debug -listen 0.0.0.0:8101
Restart=on-failure
RestartSec=1
SuccessExitStatus=3 4
RestartForceExitStatus=3 4
# Hardening
ProtectSystem=full
PrivateTmp=true
SystemCallArchitectures=native
MemoryDenyWriteExecute=true
NoNewPrivileges=true
[Install]
WantedBy=multi-user.target
eof运行服务
1
2systemctl enable syncdiscover@syncthing.service &&\
systemctl start syncdiscover@syncthing.service查看服务运行状态
1
systemctl status syncdiscover@syncthing.service
查看服务 id
1
journalctl -u syncdiscover@syncthing.service
结果如下
1
27月 10 20:11:26 longser2 stdiscosrv[19917]: stdiscosrv v1.18.6 "Fermium Flea" (go1.17.6 linux-amd64) teamcity@build.syncthing.net 2021-12-30 12:07:01 UTC [purego]
7月 10 20:11:26 longser2 stdiscosrv[19917]: Server device ID is xxxx-xxxx-xxxx-xxxx-xxxx-xxx在各客户端中修改 全局发现服务器地址
1
https://xxx.xxx.xxx:8101/?id=xxxx-xxxx-xxxx
安装 relay server
relay 服务的使用场景是,当 p2p 失败时,可以借由 relay server 进行数据转发。
下载和服务器匹配的版本
1
wget https://github.com/syncthing/relaysrv/releases/download/v1.18.6/strelaysrv-linux-amd64-v1.18.6.tar.gz
解压文件
1
tar -zxf strelaysrv-linux-amd64-v1.18.6.tar.gz
我目前没有 relay 的需求,待有需求时,再来完善此处。
归属:
- syncthing 安装记录
本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!