【服務端配置】
html
系統版本python
# lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.04.2 LTS Release: 18.04 Codename: bionic
官方文檔:https://rsync.samba.org/documentation.htmlsegmentfault
安裝bash
sudo apt install rsync xinetd
在 /etc/default/rsync 文件內修改或添加服務器
RSYNC_ENABLE=inetd
建立 /etc/xinetd.d/rsync 文件,添加以下內容:socket
service rsync{ disable = no socket_type = stream wait = no user = root server = /usr/bin/rsync server_args = --daemon log_on_failure += 0 # user ID }
建立 /etc/rsyncd.conf 文件,添加以下內容:tcp
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 文件,添加以下內容:ionic
# 配置用戶名和密碼,密碼能夠任意設置 walker:test
修改 rsyncd.secrets 文件權限ide
sudo chmod 600 /etc/rsyncd.secrets
啓動/重啓 xinetd測試
sudo /etc/init.d/xinetd restart
若是端口未被監聽,可嘗試重啓系統
# 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 walker@192.168.136.131::share ./test # --iconv=locale_charset,remote_charset 用於避免中文亂碼 rsync -cvazu --progress --iconv=UTF-8,GB18030 walker@192.168.136.131::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 ***