[root@www ~]# lsb_release -a
LSB Version: :core-4.0-amd64:core-4.0-ia32:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-ia32:printing-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 5.8 (Final)
Release: 5.8
Codename: Final
正式環境需要修改IPTABLES
http://pan.baidu.com/s/1kT1du7P 下載地址
wget ftp://ftp.samba.org/pub/rsync/rsync-3.1.1.tar.gz
tar zxf rsync-3.1.1.tar.gz
cd rsync-3.1.1
./configure && make && make install
/usr/local/bin/rsync --daemon #或增加--config=/etc/rsyncd.conf
#rsyncd.conf、rsyncd.secrets、rsyncd.motd 默認無此文件,需要要創建,如下
[root@www etc]# cat rsyncd.secrets
rsync:rsync_password
[root@www etc]# cat rsyncd.conf
secrets file = /etc/rsyncd.secrets #認證用戶密碼文件,配置auth users的密碼
motd file = /etc/rsyncd.motd #說明信息
read only = yes #只讀,不能上傳
list = yes #允許查看文件列表
uid = root #運行rsync守護進程用戶
gid = root #運行rsync守護進程的組
use chroot = no #不使用chroot
max connections = 5 #最大連接數是5
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
#ignore errors #忽略無關的IO錯誤
#slp refresh = 300
[rsync]
comment = rsync's directory
path = /data/rsync
auth users = rsync #認證的用戶名
hosts allow = 192.168.2.109 #允許訪問服務的IP
#hosts deny = 0.0.0.0/32 #禁止訪問服務器的IP
[root@www etc]# cat rsyncd.secrets
rsync:rsync_password
[root@www ~]# chmod 600 /etc/rsyncd.secrets
[root@www ~]# cat /etc/rsyncd.motd
Welcome to use the rsync services!
同步服務器配置
[root@www ~]# cat /etc/rsyncd.pass
rsync_password
[root@www ~]# chhmod 600 /etc/rsyncd.pass
[root@www ~]# rsync -vzrtopg --progress --delete --password-file=/etc/rsyncd.pass [email protected]::rsync /data/rsync/
receiving incremental file list
./
lzo-2.08.tar.gz
589,045 100% 33.04MB/s 0:00:00 (xfr#1, to-chk=1/4)
rsync-3.1.1.tar.gz
890,124 100% 24.25MB/s 0:00:00 (xfr#2, to-chk=0/4)
sent 65 bytes received 1,479,974 bytes 72,197.02 bytes/sec
total size is 1,479,182 speedup is 1.00
計劃任務cron使用:
[root@www ~]# crontab -e
*/5 * * * * /usr/local/bin/rsync -vzrtopg --progress --delete --password-file=/etc/rsyncd.pass [email protected]::rsync /data/rsync/
常見報錯:
ERROR: password file must not be other-accessible
rsync error: syntax or usage error (code 1) at authenticate.c(196) [Receiver=3.1.1]
解決:[root@www ~]# chmod 600 /etc/rsyncd.pass
@ERROR: auth failed on module rsync
rsync error: error starting client-server protocol (code 5) at main.c(1635) [Receiver=3.1.1]
解決:服務端未設置用戶rsync