Ubuntu Server 18.04 配置 rsync(systemctl)

【服务端配置】

  • 系统版本

# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.2 LTS
Release:	18.04
Codename:	bionic
sudo apt install rsync
  • 创建 /etc/rsyncd.conf 文件,添加如下内容:

max connections = 5
log file = /var/log/rsync.log
lock file = /var/lock/rsyncd.lock
timeout = 300
charset = GB18030    # 用于避免中文乱码

[share] # 模块名
comment = Public Share
# path为需要同步的文件夹路径
path = /var/test
hosts allow = 192.168.0.0/16
hosts deny = *
read only = no
list = yes
uid = root
gid = root
# 必须和 rsyncd.secrets中的用户名对应
auth users = walker
secrets file = /etc/rsyncd.secrets
  • 创建 /etc/rsyncd.secrets 文件,添加如下内容:

# 配置用户名和密码,密码可以任意设置
walker:test
  • 修改 rsyncd.secrets 文件权限

sudo chmod 600 /etc/rsyncd.secrets
  • 如果端口未被监听,可尝试重启

# netstat -anop | grep 873
tcp    0    0 0.0.0.0:873    0.0.0.0:*    LISTEN    929/rsync    off (0.00/0/0)
tcp6   0    0 :::873              :::*    LISTEN    929/rsync    off (0.00/0/0)


【客户端测试】

  • 系统版本(Windows 10 x64 1803)

winver
  • 客户端软件版本

cwRsyncServer 4.0.5.0
  • 将服务端文件同步至本地

rsync -cvazu --progress [email protected]::share ./test
# --iconv=locale_charset,remote_charset 用于避免中文乱码
rsync -cvazu --progress --iconv=UTF-8,GB18030 [email protected]::share ./test
  • 若报以下错误,查看服务器端口是否开放(检查防火墙,重启服务器...)

rsync: failed to connect to 218.107.243.2: No route to host (113)
rsync error: error in socket IO (code 10) at clientserver.c(104) [receiver=2.6.9]


【名词解释】

  • xinetd: eXtended InterNET services daemon


【相关阅读】


*** walker *** 


猜你喜欢

转载自blog.51cto.com/walkerqt/2373146
今日推荐