Centos7.9安装Syncthing

Syncthing是一个开源免费的同步程序,可以帮忙单向同步或者双向同步数据。Syncthing是用Go语言所编写的所以具备跨平台的属性,Windows或Linux都可以使用。


1.安装自动补齐命令脚本

yum -y install bash-completion

TIPS:安装完成后需要断开重新连接SSH

2.关闭防火墙

2-1.查看系统防火墙运行状态

systemctl status firewalld.service

2-2.关闭防火墙和禁止开机自启动

systemctl stop firewalld.service && systemctl disable firewalld.service

2-3.查看系统防火墙运行状态(确认是否已关闭)

systemctl status firewalld.service

3.下载Syncthing并解压

3-1.下载Syncthing官网:https://syncthing.net/downloads/

3-2.下载完成后上传到服务器上

3-3.解压下载的压缩包

4.复制到工作目录

4-1.复制主程序到工作目录

cp /root/syncthing/syncthing /usr/bin/

4-2.复制systemd配置文件到工作目录

  • centos7使用syncthing中的etc/linux-systemd/文件。
  • 先切换到syncthing压缩包中的linux-systemd工作目录下
cp -r system/* /etc/systemd/system/
cp -r user/* /etc/systemd/user/

4-3.修改文件名称

cd /etc/systemd/system
mv syncthing@.service syncthing@root.service

5.修改配文件

5-1.首次运行一次,让程序自动生成配置文件

systemctl start syncthing@root.service && systemctl status syncthing@root.service

5-2.停止运行

systemctl stop syncthing@root.service

5-3.修改生成的配置文件

  • 默认策略只允许127.0.0.1:8384访问,需要修改为:0.0.0.0:8384(全部允许访问)
vi /root/.config/syncthing/config.xml

5-4.搜索关键词:127.0.0.1:8384并修改为0.0.0.0:8384

  • /127.0.0.1:8384(VI模式)
  • 按下N按键,继续查询下一个。

6.开启服务

6-1.运行并添加开机自启动服务

systemctl start syncthing@root.service && systemctl enable syncthing@root.service

6-2.查看运行状态

systemctl status syncthing@root.service

6-3.打开浏览器访问网页:IP:8384

6-4.通过网页给给syncthing设定访问账户和密码

6-5.忽略以root用户运行的提示,我TMD就要用ROOT。