CENTOS7 安裝 SYNCTHING


本地電腦需要同步遠程數據,安裝syncthing 測試

1:下載

wget https://github.com/syncthing/syncthing/releases/download/v1.5.0/syncthing-linux-amd64-v1.5.0.tar.gz
Syncthing 默認監聽端口

22000 (TCP) 節點訪問
8384  (TCP) Web管理
21027 (UDP)
44647 (UDP)
37269 (UDP)

2:解壓和復制文件

# tar zxvf syncthing-linux-amd64-v1.5.0.tar.gz

# cp syncthing-linux-amd64-v1.5.0/syncthing /usr/local/bin/

3:運行及生成配置文件

[user@test] /usr/bin/syncthing

生成的默認配置文件路徑 /home/user/.config/syncthing/config.xml

4:編輯配置文件放開web管理

# sed -i 's/127.0.0.1/0.0.0.0/g' '/home/user/.config/syncthing/config.xml'

        <address>127.0.0.1:8384</address> 改為

        <address>0.0.0.0:8384</address>

5:重新啟動syncthing

[user@test] /usr/bin/syncthing 

暫時簡單后台運行 syncthing &

[user@test]nohup syncthing &> /dev/null &

6:web設置

a 加用戶名和密碼

b 如內部使用可關閉 “NAT遍歷”  “全球發現”

c 外部使用一方需要公網ip或域名

d 添加遠程服務端

服務端設備id在 操作〉顯示ID中查看

本地端添加后需要服務端確認

服務端確認

 

遠程端添加成功

e 服務端添加同步目錄(注意ID和路徑)

f 可主動推送共享目錄(注意ID和路徑)

 g 本地端確認共享目錄,可編輯文件夾名稱

h 同步成功

其他:

1:根據情況是否使用版本控制

2:自啟動根據系統情況另行處理

官網介紹:https://docs.syncthing.net/users/autostart.html#using-systemd

支持 systemctl 的發行可以使用官方腳本注冊成為系統服務

A:安裝目錄下有腳本

# syncthing-linux-amd64-v1.5.0/etc/linux-systemd/system/syncthing@.service

B:改名(@后面改為剛才實際運行成功的用戶名)

# mv syncthing@.service syncthing@test.service

C:復制腳本

# cp syncthing@test.service /etc/systemd/system/

D:啟動

# systemctl enable syncthing@test.service

# systemctl start syncthing@test.service

注意:Syncthing 文件的路徑

ExecStart=/usr/bin/syncthing -no-browser -no-restart -logflags=0

# ps -aux | grep syncthing

test      956  0.0  0.2 122516 11796 ?        Ssl  17:38   0:00 /usr/bin/syncthing -no-browser -no-restart -logflags=0
test      965  0.4  0.8 122964 45052 ?        SNl  17:38   0:04 /usr/bin/syncthing -no-browser -no-restart -logflags=0

 

syncthing-illumos-amd64-v1.5.0/etc/linux-systemd/system

使用啟動腳本或supervisord

其他方法官網help:

https://docs.syncthing.net/users/autostart.html#linux

Using Supervisord   

 ************************************************************
Go to /etc/supervisor/conf.d/ and create a new file named syncthing.conf     
with the following content (ensure you replaced <USERNAME> with valid username):    

[program:syncthing]    
autorestart = True    
directory = /home/<USERNAME>/    
user = <USERNAME>    
command = /usr/bin/syncthing -no-browser -home="/home/<USERNAME>/.config/syncthing"    
environment = STNORESTART="1", HOME="/home/<USERNAME>"


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM